vendor: 4,276 bytes, lines 1-10
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/audioFileUploader-CKMpGHaq.js","assets/fundamental-detector-eOE6r6IZ.js","assets/song-scheduler-B44bR_LS.js","assets/instrument-player-NxMImQOz.js","assets/audio-file-player-CaPcbHD5.js","assets/audioFileDownloader-C-2LE-Gt.js"])))=>i.map(i=>d[i]); 2var y$=Object.defineProperty;var v$=(t,e,n)=>e in t?y$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Xt=(t,e,n)=>v$(t,typeof e!="symbol"?e+"":e,n);import{g as Vo,a as Y4,c as jc,F as UI}from"./fundamental-detector-eOE6r6IZ.js";import{m as x$,a as w$,e as k$,g as U2,d as p0,s as f_,b as h_,t as S$,c as V2,f as p_,h as X4,n as Bv,i as H2,j as ua,k as G2,D as Ss,l as Q4,o as C$,p as g1,P as qg,q as _$,S as uu,A as VI,I as HI}from"./song-scheduler-B44bR_LS.js";import{B as ft,a as m0,I as $r,b as Z4,c as J4,d as Sn,e as Du}from"./instrument-player-NxMImQOz.js";import{A as GI}from"./audio-file-player-CaPcbHD5.js";function E$(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var b1={exports:{}},Tp={},y1={exports:{}},Wn={};/** 3 * @license React 4 * react.production.min.js 5 * 6 * Copyright (c) Facebook, Inc. and its affiliates. 7 * 8 * This source code is licensed under the MIT license found in the 9 * LICENSE file in the root directory of this source tree. 10 */var WI;function N$(){if(WI)return Wn;WI=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.iterator;function h(L){return L===null||typeof L!="object"?null:(L=f&&L[f]||L["@@iterator"],typeof L=="function"?L:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,g={};function w(L,$,q){this.props=L,this.context=$,this.refs=g,this.updater=q||m}w.prototype.isReactComponent={},w.prototype.setState=function(L,$){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,$,"setState")},w.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function v(){}v.prototype=w.prototype;function S(L,$,q){this.props=L,this.context=$,this.refs=g,this.updater=q||m}var C=S.prototype=new v;C.constructor=S,y(C,w.prototype),C.isPureReactComponent=!0;var k=Array.isArray,N=Object.prototype.hasOwnProperty,_={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function T(L,$,q){var Z,ie={},ge=null,re=null;if($!=null)for(Z in $.ref!==void 0&&(re=$.ref),$.key!==void 0&&(ge=""+$.key),$)N.call($,Z)&&!j.hasOwnProperty(Z)&&(ie[Z]=$[Z]);var Y=arguments.length-2;if(Y===1)ie.children=q;else if(1<Y){for(var ne=Array(Y),be=0;be<Y;be++)ne[be]=arguments[be+2];ie.children=ne}if(L&&L.defaultProps)for(Z in Y=L.defaultProps,Y)ie[Z]===void 0&&(ie[Z]=Y[Z]);return{$$typeof:t,type:L,key:ge,ref:re,props:ie,_owner:_.current}}function M(L,$){return{$$typeof:t,type:L.type,key:$,ref:L.ref,props:L.props,_owner:L._owner}}
vendor: 10,148 bytes, lines 10-34
10function V(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function H(L){var $={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(q){return $[q]})}var P=/\/+/g;function F(L,$){return typeof L=="object"&&L!==null&&L.key!=null?H(""+L.key):$.toString(36)}function I(L,$,q,Z,ie){var ge=typeof L;(ge==="undefined"||ge==="boolean")&&(L=null);var re=!1;if(L===null)re=!0;else switch(ge){case"string":case"number":re=!0;break;case"object":switch(L.$$typeof){case t:case e:re=!0}}if(re)return re=L,ie=ie(re),L=Z===""?"."+F(re,0):Z,k(ie)?(q="",L!=null&&(q=L.replace(P,"$&/")+"/"),I(ie,$,q,"",function(be){return be})):ie!=null&&(V(ie)&&(ie=M(ie,q+(!ie.key||re&&re.key===ie.key?"":(""+ie.key).replace(P,"$&/")+"/")+L)),$.push(ie)),1;if(re=0,Z=Z===""?".":Z+":",k(L))for(var Y=0;Y<L.length;Y++){ge=L[Y];var ne=Z+F(ge,Y);re+=I(ge,$,q,ne,ie)}else if(ne=h(L),typeof ne=="function")for(L=ne.call(L),Y=0;!(ge=L.next()).done;)ge=ge.value,ne=Z+F(ge,Y++),re+=I(ge,$,q,ne,ie);else if(ge==="object")throw $=String(L),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return re}function R(L,$,q){if(L==null)return L;var Z=[],ie=0;return I(L,Z,"","",function(ge){return $.call(q,ge,ie++)}),Z}function U(L){if(L._status===-1){var $=L._result;$=$(),$.then(function(q){(L._status===0||L._status===-1)&&(L._status=1,L._result=q)},function(q){(L._status===0||L._status===-1)&&(L._status=2,L._result=q)}),L._status===-1&&(L._status=0,L._result=$)}if(L._status===1)return L._result.default;throw L._result}var A={current:null},W={transition:null},D={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:W,ReactCurrentOwner:_};function B(){throw Error("act(...) is not supported in production builds of React.")}return Wn.Children={map:R,forEach:function(L,$,q){R(L,function(){$.apply(this,arguments)},q)},count:function(L){var $=0;return R(L,function(){$++}),$},toArray:function(L){return R(L,function($){return $})||[]},only:function(L){if(!V(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Wn.Component=w,Wn.Fragment=n,Wn.Profiler=i,Wn.PureComponent=S,Wn.StrictMode=r,Wn.Suspense=l,Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,Wn.act=B,Wn.cloneElement=function(L,$,q){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var Z=y({},L.props),ie=L.key,ge=L.ref,re=L._owner;if($!=null){if($.ref!==void 0&&(ge=$.ref,re=_.current),$.key!==void 0&&(ie=""+$.key),L.type&&L.type.defaultProps)var Y=L.type.defaultProps;for(ne in $)N.call($,ne)&&!j.hasOwnProperty(ne)&&(Z[ne]=$[ne]===void 0&&Y!==void 0?Y[ne]:$[ne])}var ne=arguments.length-2;if(ne===1)Z.children=q;else if(1<ne){Y=Array(ne);for(var be=0;be<ne;be++)Y[be]=arguments[be+2];Z.children=Y}return{$$typeof:t,type:L.type,key:ie,ref:ge,props:Z,_owner:re}},Wn.createContext=function(L){return L={$$typeof:o,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:s,_context:L},L.Consumer=L},Wn.createElement=T,Wn.createFactory=function(L){var $=T.bind(null,L);return $.type=L,$},Wn.createRef=function(){return{current:null}},Wn.forwardRef=function(L){return{$$typeof:a,render:L}},Wn.isValidElement=V,Wn.lazy=function(L){return{$$typeof:d,_payload:{_status:-1,_result:L},_init:U}},Wn.memo=function(L,$){return{$$typeof:u,type:L,compare:$===void 0?null:$}},Wn.startTransition=function(L){var $=W.transition;W.transition={};try{L()}finally{W.transition=$}},Wn.unstable_act=B,Wn.useCallback=function(L,$){return A.current.useCallback(L,$)},Wn.useContext=function(L){return A.current.useContext(L)},Wn.useDebugValue=function(){},Wn.useDeferredValue=function(L){return A.current.useDeferredValue(L)},Wn.useEffect=function(L,$){return A.current.useEffect(L,$)},Wn.useId=function(){return A.current.useId()},Wn.useImperativeHandle=function(L,$,q){return A.current.useImperativeHandle(L,$,q)},Wn.useInsertionEffect=function(L,$){return A.current.useInsertionEffect(L,$)},Wn.useLayoutEffect=function(L,$){return A.current.useLayoutEffect(L,$)},Wn.useMemo=function(L,$){return A.current.useMemo(L,$)},Wn.useReducer=function(L,$,q){return A.current.useReducer(L,$,q)},Wn.useRef=function(L){return A.current.useRef(L)},Wn.useState=function(L){return A.current.useState(L)},Wn.useSyncExternalStore=function(L,$,q){return A.current.useSyncExternalStore(L,$,q)},Wn.useTransition=function(){return A.current.useTransition()},Wn.version="18.3.1",Wn}var qI;function Uh(){return qI||(qI=1,y1.exports=N$()),y1.exports}/** 11 * @license React 12 * react-jsx-runtime.production.min.js 13 * 14 * Copyright (c) Facebook, Inc. and its affiliates. 15 * 16 * This source code is licensed under the MIT license found in the 17 * LICENSE file in the root directory of this source tree. 18 */var KI;function I$(){if(KI)return Tp;KI=1;var t=Uh(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(a,l,u){var d,f={},h=null,m=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(m=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:e,type:a,key:h,ref:m,props:f,_owner:i.current}}return Tp.Fragment=n,Tp.jsx=o,Tp.jsxs=o,Tp}var YI;function j$(){return YI||(YI=1,b1.exports=I$()),b1.exports}var c=j$(),x=Uh();const mr=Vo(x),T$=E$({__proto__:null,default:mr},[x]);var Kg={},v1={exports:{}},Ds={},x1={exports:{}},w1={};/** 19 * @license React 20 * scheduler.production.min.js 21 * 22 * Copyright (c) Facebook, Inc. and its affiliates. 23 * 24 * This source code is licensed under the MIT license found in the 25 * LICENSE file in the root directory of this source tree. 26 */var XI;function z$(){return XI||(XI=1,function(t){function e(W,D){var B=W.length;W.push(D);e:for(;0<B;){var L=B-1>>>1,$=W[L];if(0<i($,D))W[L]=D,W[B]=$,B=L;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var D=W[0],B=W.pop();if(B!==D){W[0]=B;e:for(var L=0,$=W.length,q=$>>>1;L<q;){var Z=2*(L+1)-1,ie=W[Z],ge=Z+1,re=W[ge];if(0>i(ie,B))ge<$&&0>i(re,ie)?(W[L]=re,W[ge]=B,L=ge):(W[L]=ie,W[Z]=B,L=Z);else if(ge<$&&0>i(re,B))W[L]=re,W[ge]=B,L=ge;else break e}}return D}function i(W,D){var B=W.sortIndex-D.sortIndex;return B!==0?B:W.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],u=[],d=1,f=null,h=3,m=!1,y=!1,g=!1,w=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(W){for(var D=n(u);D!==null;){if(D.callback===null)r(u);else if(D.startTime<=W)r(u),D.sortIndex=D.expirationTime,e(l,D);else break;D=n(u)}}function k(W){if(g=!1,C(W),!y)if(n(l)!==null)y=!0,U(N);else{var D=n(u);D!==null&&A(k,D.startTime-W)}}function N(W,D){y=!1,g&&(g=!1,v(T),T=-1),m=!0;var B=h;try{for(C(D),f=n(l);f!==null&&(!(f.expirationTime>D)||W&&!H());){var L=f.callback;if(typeof L=="function"){f.callback=null,h=f.priorityLevel;var $=L(f.expirationTime<=D);D=t.unstable_now(),typeof $=="function"?f.callback=$:f===n(l)&&r(l),C(D)}else r(l);f=n(l)}if(f!==null)var q=!0;else{var Z=n(u);Z!==null&&A(k,Z.startTime-D),q=!1}return q}finally{f=null,h=B,m=!1}}var _=!1,j=null,T=-1,M=5,V=-1;function H(){return!(t.unstable_now()-V<M)}function P(){if(j!==null){var W=t.unstable_now();V=W;var D=!0;try{D=j(!0,W)}finally{D?F():(_=!1,j=null)}}else _=!1}var F;if(typeof S=="function")F=function(){S(P)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,R=I.port2;I.port1.onmessage=P,F=function(){R.postMessage(null)}}else F=function(){w(P,0)};function U(W){j=W,_||(_=!0,F())}function A(W,D){T=w(function(){W(t.unstable_now())},D)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(W){W.callback=null},t.unstable_continueExecution=function(){y||m||(y=!0,U(N))},t.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<W?Math.floor(1e3/W):5},t.unstable_getCurrentPriorityLevel=function(){return h},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(W){switch(h){case 1:case 2:case 3:var D=3;break;default:D=h}var B=h;h=D;try{return W()}finally{h=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(W,D){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var B=h;h=W;try{return D()}finally{h=B}},t.unstable_scheduleCallback=function(W,D,B){var L=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?L+B:L):B=L,W){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=B+$,W={id:d++,callback:D,priorityLevel:W,startTime:B,expirationTime:$,sortIndex:-1},B>L?(W.sortIndex=B,e(u,W),n(l)===null&&W===n(u)&&(g?(v(T),T=-1):g=!0,A(k,B-L))):(W.sortIndex=$,e(l,W),y||m||(y=!0,U(N))),W},t.unstable_shouldYield=H,t.unstable_wrapCallback=function(W){var D=h;return function(){var B=h;h=D;try{return W.apply(this,arguments)}finally{h=B}}}}(w1)),w1}var QI;function P$(){return QI||(QI=1,x1.exports=z$()),x1.exports}/** 27 * @license React 28 * react-dom.production.min.js 29 * 30 * Copyright (c) Facebook, Inc. and its affiliates. 31 * 32 * This source code is licensed under the MIT license found in the 33 * LICENSE file in the root directory of this source tree. 34 */var ZI;
vendor: 48,742 bytes, lines 34-39
34function A$(){if(ZI)return Ds;ZI=1;var t=Uh(),e=P$();function n(p){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+p,E=1;E<arguments.length;E++)b+="&args[]="+encodeURIComponent(arguments[E]);return"Minified React error #"+p+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function s(p,b){o(p,b),o(p+"Capture",b)}function o(p,b){for(i[p]=b,p=0;p<b.length;p++)r.add(b[p])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),l=Object.prototype.hasOwnProperty,u=/^[: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]*$/,d={},f={};function h(p){return l.call(f,p)?!0:l.call(d,p)?!1:u.test(p)?f[p]=!0:(d[p]=!0,!1)}function m(p,b,E,z){if(E!==null&&E.type===0)return!1;switch(typeof b){case"function":case"symbol":return!0;case"boolean":return z?!1:E!==null?!E.acceptsBooleans:(p=p.toLowerCase().slice(0,5),p!=="data-"&&p!=="aria-");default:return!1}}function y(p,b,E,z){if(b===null||typeof b>"u"||m(p,b,E,z))return!0;if(z)return!1;if(E!==null)switch(E.type){case 3:return!b;case 4:return b===!1;case 5:return isNaN(b);case 6:return isNaN(b)||1>b}return!1}function g(p,b,E,z,G,X,me){this.acceptsBooleans=b===2||b===3||b===4,this.attributeName=z,this.attributeNamespace=G,this.mustUseProperty=E,this.propertyName=p,this.type=b,this.sanitizeURL=X,this.removeEmptyString=me}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(p){w[p]=new g(p,0,!1,p,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(p){var b=p[0];w[b]=new g(b,1,!1,p[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(p){w[p]=new g(p,2,!1,p.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(p){w[p]=new g(p,2,!1,p,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(p){w[p]=new g(p,3,!1,p.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(p){w[p]=new g(p,3,!0,p,null,!1,!1)}),["capture","download"].forEach(function(p){w[p]=new g(p,4,!1,p,null,!1,!1)}),["cols","rows","size","span"].forEach(function(p){w[p]=new g(p,6,!1,p,null,!1,!1)}),["rowSpan","start"].forEach(function(p){w[p]=new g(p,5,!1,p.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function S(p){return p[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(p){var b=p.replace(v,S);w[b]=new g(b,1,!1,p,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(p){var b=p.replace(v,S);w[b]=new g(b,1,!1,p,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(p){var b=p.replace(v,S);w[b]=new g(b,1,!1,p,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(p){w[p]=new g(p,1,!1,p.toLowerCase(),null,!1,!1)}),w.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(p){w[p]=new g(p,1,!1,p.toLowerCase(),null,!0,!0)});function C(p,b,E,z){var G=w.hasOwnProperty(b)?w[b]:null;(G!==null?G.type!==0:z||!(2<b.length)||b[0]!=="o"&&b[0]!=="O"||b[1]!=="n"&&b[1]!=="N")&&(y(b,E,G,z)&&(E=null),z||G===null?h(b)&&(E===null?p.removeAttribute(b):p.setAttribute(b,""+E)):G.mustUseProperty?p[G.propertyName]=E===null?G.type===3?!1:"":E:(b=G.attributeName,z=G.attributeNamespace,E===null?p.removeAttribute(b):(G=G.type,E=G===3||G===4&&E===!0?"":""+E,z?p.setAttributeNS(z,b,E):p.setAttribute(b,E))))}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,N=Symbol.for("react.element"),_=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),H=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),W=Symbol.iterator;function D(p){return p===null||typeof p!="object"?null:(p=W&&p[W]||p["@@iterator"],typeof p=="function"?p:null)}var B=Object.assign,L;function $(p){if(L===void 0)try{throw Error()}catch(E){var b=E.stack.trim().match(/\n( *(at )?)/);L=b&&b[1]||""}return` 35`+L+p}var q=!1;function Z(p,b){if(!p||q)return"";q=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(b)if(b=function(){throw Error()},Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(lt){var z=lt}Reflect.construct(p,[],b)}else{try{b.call()}catch(lt){z=lt}p.call(b.prototype)}else{try{throw Error()}catch(lt){z=lt}p()}}catch(lt){if(lt&&z&&typeof lt.stack=="string"){for(var G=lt.stack.split(` 36`),X=z.stack.split(` 37`),me=G.length-1,Pe=X.length-1;1<=me&&0<=Pe&&G[me]!==X[Pe];)Pe--;for(;1<=me&&0<=Pe;me--,Pe--)if(G[me]!==X[Pe]){if(me!==1||Pe!==1)do if(me--,Pe--,0>Pe||G[me]!==X[Pe]){var $e=` 38`+G[me].replace(" at new "," at ");return p.displayName&&$e.includes("<anonymous>")&&($e=$e.replace("<anonymous>",p.displayName)),$e}while(1<=me&&0<=Pe);break}}}finally{q=!1,Error.prepareStackTrace=E}return(p=p?p.displayName||p.name:"")?$(p):""}function ie(p){switch(p.tag){case 5:return $(p.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return p=Z(p.type,!1),p;case 11:return p=Z(p.type.render,!1),p;case 1:return p=Z(p.type,!0),p;default:return""}}function ge(p){if(p==null)return null;if(typeof p=="function")return p.displayName||p.name||null;if(typeof p=="string")return p;switch(p){case j:return"Fragment";case _:return"Portal";case M:return"Profiler";case T:return"StrictMode";case F:return"Suspense";case I:return"SuspenseList"}if(typeof p=="object")switch(p.$$typeof){case H:return(p.displayName||"Context")+".Consumer";case V:return(p._context.displayName||"Context")+".Provider";case P:var b=p.render;return p=p.displayName,p||(p=b.displayName||b.name||"",p=p!==""?"ForwardRef("+p+")":"ForwardRef"),p;case R:return b=p.displayName||null,b!==null?b:ge(p.type)||"Memo";case U:b=p._payload,p=p._init;try{return ge(p(b))}catch{}}return null}function re(p){var b=p.type;switch(p.tag){case 24:return"Cache";case 9:return(b.displayName||"Context")+".Consumer";case 10:return(b._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return p=b.render,p=p.displayName||p.name||"",b.displayName||(p!==""?"ForwardRef("+p+")":"ForwardRef");case 7:return"Fragment";case 5:return b;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ge(b);case 8:return b===T?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof b=="function")return b.displayName||b.name||null;if(typeof b=="string")return b}return null}function Y(p){switch(typeof p){case"boolean":case"number":case"string":case"undefined":return p;case"object":return p;default:return""}}function ne(p){var b=p.type;return(p=p.nodeName)&&p.toLowerCase()==="input"&&(b==="checkbox"||b==="radio")}function be(p){var b=ne(p)?"checked":"value",E=Object.getOwnPropertyDescriptor(p.constructor.prototype,b),z=""+p[b];if(!p.hasOwnProperty(b)&&typeof E<"u"&&typeof E.get=="function"&&typeof E.set=="function"){var G=E.get,X=E.set;return Object.defineProperty(p,b,{configurable:!0,get:function(){return G.call(this)},set:function(me){z=""+me,X.call(this,me)}}),Object.defineProperty(p,b,{enumerable:E.enumerable}),{getValue:function(){return z},setValue:function(me){z=""+me},stopTracking:function(){p._valueTracker=null,delete p[b]}}}}function we(p){p._valueTracker||(p._valueTracker=be(p))}function te(p){if(!p)return!1;var b=p._valueTracker;if(!b)return!0;var E=b.getValue(),z="";return p&&(z=ne(p)?p.checked?"true":"false":p.value),p=z,p!==E?(b.setValue(p),!0):!1}function fe(p){if(p=p||(typeof document<"u"?document:void 0),typeof p>"u")return null;try{return p.activeElement||p.body}catch{return p.body}}function O(p,b){var E=b.checked;return B({},b,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:E??p._wrapperState.initialChecked})}function pe(p,b){var E=b.defaultValue==null?"":b.defaultValue,z=b.checked!=null?b.checked:b.defaultChecked;E=Y(b.value!=null?b.value:E),p._wrapperState={initialChecked:z,initialValue:E,controlled:b.type==="checkbox"||b.type==="radio"?b.checked!=null:b.value!=null}}function he(p,b){b=b.checked,b!=null&&C(p,"checked",b,!1)}function le(p,b){he(p,b);var E=Y(b.value),z=b.type;if(E!=null)z==="number"?(E===0&&p.value===""||p.value!=E)&&(p.value=""+E):p.value!==""+E&&(p.value=""+E);else if(z==="submit"||z==="reset"){p.removeAttribute("value");return}b.hasOwnProperty("value")?Q(p,b.type,E):b.hasOwnProperty("defaultValue")&&Q(p,b.type,Y(b.defaultValue)),b.checked==null&&b.defaultChecked!=null&&(p.defaultChecked=!!b.defaultChecked)}function oe(p,b,E){if(b.hasOwnProperty("value")||b.hasOwnProperty("defaultValue")){var z=b.type;if(!(z!=="submit"&&z!=="reset"||b.value!==void 0&&b.value!==null))return;b=""+p._wrapperState.initialValue,E||b===p.value||(p.value=b),p.defaultValue=b}E=p.name,E!==""&&(p.name=""),p.defaultChecked=!!p._wrapperState.initialChecked,E!==""&&(p.name=E)}function Q(p,b,E){(b!=="number"||fe(p.ownerDocument)!==p)&&(E==null?p.defaultValue=""+p._wrapperState.initialValue:p.defaultValue!==""+E&&(p.defaultValue=""+E))}var de=Array.isArray;function Ne(p,b,E,z){if(p=p.options,b){b={};for(var G=0;G<E.length;G++)b["$"+E[G]]=!0;for(E=0;E<p.length;E++)G=b.hasOwnProperty("$"+p[E].value),p[E].selected!==G&&(p[E].selected=G),G&&z&&(p[E].defaultSelected=!0)}else{for(E=""+Y(E),b=null,G=0;G<p.length;G++){if(p[G].value===E){p[G].selected=!0,z&&(p[G].defaultSelected=!0);return}b!==null||p[G].disabled||(b=p[G])}b!==null&&(b.selected=!0)}}function Ce(p,b){if(b.dangerouslySetInnerHTML!=null)throw Error(n(91));return B({},b,{value:void 0,defaultValue:void 0,children:""+p._wrapperState.initialValue})}function Ae(p,b){var E=b.value;if(E==null){if(E=b.children,b=b.defaultValue,E!=null){if(b!=null)throw Error(n(92));if(de(E)){if(1<E.length)throw Error(n(93));E=E[0]}b=E}b==null&&(b=""),E=b}p._wrapperState={initialValue:Y(E)}}function Ue(p,b){var E=Y(b.value),z=Y(b.defaultValue);E!=null&&(E=""+E,E!==p.value&&(p.value=E),b.defaultValue==null&&p.defaultValue!==E&&(p.defaultValue=E)),z!=null&&(p.defaultValue=""+z)}function Se(p){var b=p.textContent;b===p._wrapperState.initialValue&&b!==""&&b!==null&&(p.value=b)}function ve(p){switch(p){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function je(p,b){return p==null||p==="http://www.w3.org/1999/xhtml"?ve(b):p==="http://www.w3.org/2000/svg"&&b==="foreignObject"?"http://www.w3.org/1999/xhtml":p}var Te,ce=function(p){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(b,E,z,G){MSApp.execUnsafeLocalFunction(function(){return p(b,E,z,G)})}:p}(function(p,b){if(p.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in p)p.innerHTML=b;else{for(Te=Te||document.createElement("div"),Te.innerHTML="<svg>"+b.valueOf().toString()+"</svg>",b=Te.firstChild;p.firstChild;)p.removeChild(p.firstChild);for(;b.firstChild;)p.appendChild(b.firstChild)}});function se(p,b){if(b){var E=p.firstChild;if(E&&E===p.lastChild&&E.nodeType===3){E.nodeValue=b;return}}p.textContent=b}var ye={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ke=["Webkit","ms","Moz","O"];Object.keys(ye).forEach(function(p){ke.forEach(function(b){b=b+p.charAt(0).toUpperCase()+p.substring(1),ye[b]=ye[p]})});function ze(p,b,E){return b==null||typeof b=="boolean"||b===""?"":E||typeof b!="number"||b===0||ye.hasOwnProperty(p)&&ye[p]?(""+b).trim():b+"px"}function qe(p,b){p=p.style;for(var E in b)if(b.hasOwnProperty(E)){var z=E.indexOf("--")===0,G=ze(E,b[E],z);E==="float"&&(E="cssFloat"),z?p.setProperty(E,G):p[E]=G}}var ot=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ze(p,b){if(b){if(ot[p]&&(b.children!=null||b.dangerouslySetInnerHTML!=null))throw Error(n(137,p));if(b.dangerouslySetInnerHTML!=null){if(b.children!=null)throw Error(n(60));if(typeof b.dangerouslySetInnerHTML!="object"||!("__html"in b.dangerouslySetInnerHTML))throw Error(n(61))}if(b.style!=null&&typeof b.style!="object")throw Error(n(62))}}function _t(p,b){if(p.indexOf("-")===-1)return typeof b.is=="string";switch(p){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 tt=null;function gt(p){return p=p.target||p.srcElement||window,p.correspondingUseElement&&(p=p.correspondingUseElement),p.nodeType===3?p.parentNode:p}var dt=null,wt=null,Dt=null;function Kt(p){if(p=mp(p)){if(typeof dt!="function")throw Error(n(280));var b=p.stateNode;b&&(b=lg(b),dt(p.stateNode,p.type,b))}}function rn(p){wt?Dt?Dt.push(p):Dt=[p]:wt=p}function pn(){if(wt){var p=wt,b=Dt;if(Dt=wt=null,Kt(p),b)for(p=0;p<b.length;p++)Kt(b[p])}}function cn(p,b){return p(b)}function kt(){}var rt=!1;function Tt(p,b,E){if(rt)return p(b,E);rt=!0;try{return cn(p,b,E)}finally{rt=!1,(wt!==null||Dt!==null)&&(kt(),pn())}}function Mt(p,b){var E=p.stateNode;if(E===null)return null;var z=lg(E);if(z===null)return null;E=z[b];e:switch(b){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(z=!z.disabled)||(p=p.type,z=!(p==="button"||p==="input"||p==="select"||p==="textarea")),p=!z;break e;default:p=!1}if(p)return null;if(E&&typeof E!="function")throw Error(n(231,b,typeof E));return E}var Rt=!1;if(a)try{var Ct={};Object.defineProperty(Ct,"passive",{get:function(){Rt=!0}}),window.addEventListener("test",Ct,Ct),window.removeEventListener("test",Ct,Ct)}catch{Rt=!1}function Gt(p,b,E,z,G,X,me,Pe,$e){var lt=Array.prototype.slice.call(arguments,3);try{b.apply(E,lt)}catch(Pt){this.onError(Pt)}}var Lt=!1,$t=null,Qt=!1,Ye=null,bt={onError:function(p){Lt=!0,$t=p}};function Ie(p,b,E,z,G,X,me,Pe,$e){Lt=!1,$t=null,Gt.apply(bt,arguments)}function it(p,b,E,z,G,X,me,Pe,$e){if(Ie.apply(this,arguments),Lt){if(Lt){var lt=$t;Lt=!1,$t=null}else throw Error(n(198));Qt||(Qt=!0,Ye=lt)}}function ct(p){var b=p,E=p;if(p.alternate)for(;b.return;)b=b.return;else{p=b;do b=p,(b.flags&4098)!==0&&(E=b.return),p=b.return;while(p)}return b.tag===3?E:null}function Ut(p){if(p.tag===13){var b=p.memoizedState;if(b===null&&(p=p.alternate,p!==null&&(b=p.memoizedState)),b!==null)return b.dehydrated}return null}function Et(p){if(ct(p)!==p)throw Error(n(188))}function yn(p){var b=p.alternate;if(!b){if(b=ct(p),b===null)throw Error(n(188));return b!==p?null:p}for(var E=p,z=b;;){var G=E.return;if(G===null)break;var X=G.alternate;if(X===null){if(z=G.return,z!==null){E=z;continue}break}if(G.child===X.child){for(X=G.child;X;){if(X===E)return Et(G),p;if(X===z)return Et(G),b;X=X.sibling}throw Error(n(188))}if(E.return!==z.return)E=G,z=X;else{for(var me=!1,Pe=G.child;Pe;){if(Pe===E){me=!0,E=G,z=X;break}if(Pe===z){me=!0,z=G,E=X;break}Pe=Pe.sibling}if(!me){for(Pe=X.child;Pe;){if(Pe===E){me=!0,E=X,z=G;break}if(Pe===z){me=!0,z=X,E=G;break}Pe=Pe.sibling}if(!me)throw Error(n(189))}}if(E.alternate!==z)throw Error(n(190))}if(E.tag!==3)throw Error(n(188));return E.stateNode.current===E?p:b}function nn(p){return p=yn(p),p!==null?rr(p):null}function rr(p){if(p.tag===5||p.tag===6)return p;for(p=p.child;p!==null;){var b=rr(p);if(b!==null)return b;p=p.sibling}return null}var xn=e.unstable_scheduleCallback,Bn=e.unstable_cancelCallback,dr=e.unstable_shouldYield,gr=e.unstable_requestPaint,on=e.unstable_now,Fn=e.unstable_getCurrentPriorityLevel,Xn=e.unstable_ImmediatePriority,yt=e.unstable_UserBlockingPriority,Wt=e.unstable_NormalPriority,An=e.unstable_LowPriority,Un=e.unstable_IdlePriority,Rr=null,yr=null;function Ps(p){if(yr&&typeof yr.onCommitFiberRoot=="function")try{yr.onCommitFiberRoot(Rr,p,void 0,(p.current.flags&128)===128)}catch{}}var Kr=Math.clz32?Math.clz32:_e,xe=Math.log,Re=Math.LN2;function _e(p){return p>>>=0,p===0?32:31-(xe(p)/Re|0)|0}var Ve=64,Ge=4194304;function Fe(p){switch(p&-p){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: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 p&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return p&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return p}}function pt(p,b){var E=p.pendingLanes;if(E===0)return 0;var z=0,G=p.suspendedLanes,X=p.pingedLanes,me=E&268435455;if(me!==0){var Pe=me&~G;Pe!==0?z=Fe(Pe):(X&=me,X!==0&&(z=Fe(X)))}else me=E&~G,me!==0?z=Fe(me):X!==0&&(z=Fe(X));if(z===0)return 0;if(b!==0&&b!==z&&(b&G)===0&&(G=z&-z,X=b&-b,G>=X||G===16&&(X&4194240)!==0))return b;if((z&4)!==0&&(z|=E&16),b=p.entangledLanes,b!==0)for(p=p.entanglements,b&=z;0<b;)E=31-Kr(b),G=1<<E,z|=p[E],b&=~G;return z}function St(p,b){switch(p){case 1:case 2:case 4:return b+250;case 8:case 16:case 32:case 64: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 b+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function zt(p,b){for(var E=p.suspendedLanes,z=p.pingedLanes,G=p.expirationTimes,X=p.pendingLanes;0<X;){var me=31-Kr(X),Pe=1<<me,$e=G[me];$e===-1?((Pe&E)===0||(Pe&z)!==0)&&(G[me]=St(Pe,b)):$e<=b&&(p.expiredLanes|=Pe),X&=~Pe}}function Nt(p){return p=p.pendingLanes&-1073741825,p!==0?p:p&1073741824?1073741824:0}function At(){var p=Ve;return Ve<<=1,(Ve&4194240)===0&&(Ve=64),p}function Zt(p){for(var b=[],E=0;31>E;E++)b.push(p);return b}function Me(p,b,E){p.pendingLanes|=b,b!==536870912&&(p.suspendedLanes=0,p.pingedLanes=0),p=p.eventTimes,b=31-Kr(b),p[b]=E}function Qe(p,b){var E=p.pendingLanes&~b;p.pendingLanes=b,p.suspendedLanes=0,p.pingedLanes=0,p.expiredLanes&=b,p.mutableReadLanes&=b,p.entangledLanes&=b,b=p.entanglements;var z=p.eventTimes;for(p=p.expirationTimes;0<E;){var G=31-Kr(E),X=1<<G;b[G]=0,z[G]=-1,p[G]=-1,E&=~X}}function ae(p,b){var E=p.entangledLanes|=b;for(p=p.entanglements;E;){var z=31-Kr(E),G=1<<z;G&b|p[z]&b&&(p[z]|=b),E&=~G}}var K=0;function ee(p){return p&=-p,1<p?4<p?(p&268435455)!==0?16:536870912:4:1}var ue,Ee,Je,Ke,Oe,ut=!1,Be=[],De=null,Xe=null,Le=null,He=new Map,mt=new Map,Ht=[],fn="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 submit".split(" ");function Nn(p,b){switch(p){case"focusin":case"focusout":De=null;break;case"dragenter":case"dragleave":Xe=null;break;case"mouseover":case"mouseout":Le=null;break;case"pointerover":case"pointerout":He.delete(b.pointerId);break;case"gotpointercapture":case"lostpointercapture":mt.delete(b.pointerId)}}function sr(p,b,E,z,G,X){return p===null||p.nativeEvent!==X?(p={blockedOn:b,domEventName:E,eventSystemFlags:z,nativeEvent:X,targetContainers:[G]},b!==null&&(b=mp(b),b!==null&&Ee(b)),p):(p.eventSystemFlags|=z,b=p.targetContainers,G!==null&&b.indexOf(G)===-1&&b.push(G),p)}function $n(p,b,E,z,G){switch(b){case"focusin":return De=sr(De,p,b,E,z,G),!0;case"dragenter":return Xe=sr(Xe,p,b,E,z,G),!0;case"mouseover":return Le=sr(Le,p,b,E,z,G),!0;case"pointerover":var X=G.pointerId;return He.set(X,sr(He.get(X)||null,p,b,E,z,G)),!0;case"gotpointercapture":return X=G.pointerId,mt.set(X,sr(mt.get(X)||null,p,b,E,z,G)),!0}return!1}function ri(p){var b=Zc(p.target);if(b!==null){var E=ct(b);if(E!==null){if(b=E.tag,b===13){if(b=Ut(E),b!==null){p.blockedOn=b,Oe(p.priority,function(){Je(E)});return}}else if(b===3&&E.stateNode.current.memoizedState.isDehydrated){p.blockedOn=E.tag===3?E.stateNode.containerInfo:null;return}}}p.blockedOn=null}function wr(p){if(p.blockedOn!==null)return!1;for(var b=p.targetContainers;0<b.length;){var E=Gi(p.domEventName,p.eventSystemFlags,b[0],p.nativeEvent);if(E===null){E=p.nativeEvent;var z=new E.constructor(E.type,E);tt=z,E.target.dispatchEvent(z),tt=null}else return b=mp(E),b!==null&&Ee(b),p.blockedOn=E,!1;b.shift()}return!0}function ns(p,b,E){wr(p)&&E.delete(b)}function rs(){ut=!1,De!==null&&wr(De)&&(De=null),Xe!==null&&wr(Xe)&&(Xe=null),Le!==null&&wr(Le)&&(Le=null),He.forEach(ns),mt.forEach(ns)}function er(p,b){p.blockedOn===b&&(p.blockedOn=null,ut||(ut=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rs)))}function Yr(p){function b(G){return er(G,p)}if(0<Be.length){er(Be[0],p);for(var E=1;E<Be.length;E++){var z=Be[E];z.blockedOn===p&&(z.blockedOn=null)}}for(De!==null&&er(De,p),Xe!==null&&er(Xe,p),Le!==null&&er(Le,p),He.forEach(b),mt.forEach(b),E=0;E<Ht.length;E++)z=Ht[E],z.blockedOn===p&&(z.blockedOn=null);for(;0<Ht.length&&(E=Ht[0],E.blockedOn===null);)ri(E),E.blockedOn===null&&Ht.shift()}var Ai=k.ReactCurrentBatchConfig,ys=!0;function Id(p,b,E,z){var G=K,X=Ai.transition;Ai.transition=null;try{K=1,Na(p,b,E,z)}finally{K=G,Ai.transition=X}}function ul(p,b,E,z){var G=K,X=Ai.transition;Ai.transition=null;try{K=4,Na(p,b,E,z)}finally{K=G,Ai.transition=X}}function Na(p,b,E,z){if(ys){var G=Gi(p,b,E,z);if(G===null)ow(p,b,z,Wo,E),Nn(p,z);else if($n(G,p,b,E,z))z.stopPropagation();else if(Nn(p,z),b&4&&-1<fn.indexOf(p)){for(;G!==null;){var X=mp(G);if(X!==null&&ue(X),X=Gi(p,b,E,z),X===null&&ow(p,b,z,Wo,E),X===G)break;G=X}G!==null&&z.stopPropagation()}else ow(p,b,z,null,E)}}var Wo=null;function Gi(p,b,E,z){if(Wo=null,p=gt(z),p=Zc(p),p!==null)if(b=ct(p),b===null)p=null;else if(E=b.tag,E===13){if(p=Ut(b),p!==null)return p;p=null}else if(E===3){if(b.stateNode.current.memoizedState.isDehydrated)return b.tag===3?b.stateNode.containerInfo:null;p=null}else b!==p&&(p=null);return Wo=p,null}function ql(p){switch(p){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"resize":case"seeked":case"submit":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"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fn()){case Xn:return 1;case yt:return 4;case Wt:case An:return 16;case Un:return 536870912;default:return 16}default:return 16}}var Ni=null,jd=null,Q0=null;function jN(){if(Q0)return Q0;var p,b=jd,E=b.length,z,G="value"in Ni?Ni.value:Ni.textContent,X=G.length;for(p=0;p<E&&b[p]===G[p];p++);var me=E-p;for(z=1;z<=me&&b[E-z]===G[X-z];z++);return Q0=G.slice(p,1<z?1-z:void 0)}function Z0(p){var b=p.keyCode;return"charCode"in p?(p=p.charCode,p===0&&b===13&&(p=13)):p=b,p===10&&(p=13),32<=p||p===13?p:0}function J0(){return!0}function TN(){return!1}function Js(p){function b(E,z,G,X,me){this._reactName=E,this._targetInst=G,this.type=z,this.nativeEvent=X,this.target=me,this.currentTarget=null;for(var Pe in p)p.hasOwnProperty(Pe)&&(E=p[Pe],this[Pe]=E?E(X):X[Pe]);return this.isDefaultPrevented=(X.defaultPrevented!=null?X.defaultPrevented:X.returnValue===!1)?J0:TN,this.isPropagationStopped=TN,this}return B(b.prototype,{preventDefault:function(){this.defaultPrevented=!0;var E=this.nativeEvent;E&&(E.preventDefault?E.preventDefault():typeof E.returnValue!="unknown"&&(E.returnValue=!1),this.isDefaultPrevented=J0)},stopPropagation:function(){var E=this.nativeEvent;E&&(E.stopPropagation?E.stopPropagation():typeof E.cancelBubble!="unknown"&&(E.cancelBubble=!0),this.isPropagationStopped=J0)},persist:function(){},isPersistent:J0}),b}var Td={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(p){return p.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gx=Js(Td),ip=B({},Td,{view:0,detail:0}),G9=Js(ip),Wx,qx,sp,eg=B({},ip,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Yx,button:0,buttons:0,relatedTarget:function(p){return p.relatedTarget===void 0?p.fromElement===p.srcElement?p.toElement:p.fromElement:p.relatedTarget},movementX:function(p){return"movementX"in p?p.movementX:(p!==sp&&(sp&&p.type==="mousemove"?(Wx=p.screenX-sp.screenX,qx=p.screenY-sp.screenY):qx=Wx=0,sp=p),Wx)},movementY:function(p){return"movementY"in p?p.movementY:qx}}),zN=Js(eg),W9=B({},eg,{dataTransfer:0}),q9=Js(W9),K9=B({},ip,{relatedTarget:0}),Kx=Js(K9),Y9=B({},Td,{animationName:0,elapsedTime:0,pseudoElement:0}),X9=Js(Y9),Q9=B({},Td,{clipboardData:function(p){return"clipboardData"in p?p.clipboardData:window.clipboardData}}),Z9=Js(Q9),J9=B({},Td,{data:0}),PN=Js(J9),e7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},t7={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"},n7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function r7(p){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(p):(p=n7[p])?!!b[p]:!1}function Yx(){return r7}var i7=B({},ip,{key:function(p){if(p.key){var b=e7[p.key]||p.key;if(b!=="Unidentified")return b}return p.type==="keypress"?(p=Z0(p),p===13?"Enter":String.fromCharCode(p)):p.type==="keydown"||p.type==="keyup"?t7[p.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Yx,charCode:function(p){return p.type==="keypress"?Z0(p):0},keyCode:function(p){return p.type==="keydown"||p.type==="keyup"?p.keyCode:0},which:function(p){return p.type==="keypress"?Z0(p):p.type==="keydown"||p.type==="keyup"?p.keyCode:0}}),s7=Js(i7),o7=B({},eg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),AN=Js(o7),a7=B({},ip,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Yx}),l7=Js(a7),c7=B({},Td,{propertyName:0,elapsedTime:0,pseudoElement:0}),u7=Js(c7),d7=B({},eg,{deltaX:function(p){return"deltaX"in p?p.deltaX:"wheelDeltaX"in p?-p.wheelDeltaX:0},deltaY:function(p){return"deltaY"in p?p.deltaY:"wheelDeltaY"in p?-p.wheelDeltaY:"wheelDelta"in p?-p.wheelDelta:0},deltaZ:0,deltaMode:0}),f7=Js(d7),h7=[9,13,27,32],Xx=a&&"CompositionEvent"in window,op=null;a&&"documentMode"in document&&(op=document.documentMode);var p7=a&&"TextEvent"in window&&!op,MN=a&&(!Xx||op&&8<op&&11>=op),BN=" ",RN=!1;function ON(p,b){switch(p){case"keyup":return h7.indexOf(b.keyCode)!==-1;case"keydown":return b.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function DN(p){return p=p.detail,typeof p=="object"&&"data"in p?p.data:null}var zd=!1;function m7(p,b){switch(p){case"compositionend":return DN(b);case"keypress":return b.which!==32?null:(RN=!0,BN);case"textInput":return p=b.data,p===BN&&RN?null:p;default:return null}}function g7(p,b){if(zd)return p==="compositionend"||!Xx&&ON(p,b)?(p=jN(),Q0=jd=Ni=null,zd=!1,p):null;switch(p){case"paste":return null;case"keypress":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1<b.char.length)return b.char;if(b.which)return String.fromCharCode(b.which)}return null;case"compositionend":return MN&&b.locale!=="ko"?null:b.data;default:return null}}var b7={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 LN(p){var b=p&&p.nodeName&&p.nodeName.toLowerCase();return b==="input"?!!b7[p.type]:b==="textarea"}function FN(p,b,E,z){rn(z),b=sg(b,"onChange"),0<b.length&&(E=new Gx("onChange","change",null,E,z),p.push({event:E,listeners:b}))}var ap=null,lp=null;function y7(p){i5(p,0)}function tg(p){var b=Rd(p);if(te(b))return p}function v7(p,b){if(p==="change")return b}var $N=!1;if(a){var Qx;if(a){var Zx="oninput"in document;if(!Zx){var UN=document.createElement("div");UN.setAttribute("oninput","return;"),Zx=typeof UN.oninput=="function"}Qx=Zx}else Qx=!1;$N=Qx&&(!document.documentMode||9<document.documentMode)}function VN(){ap&&(ap.detachEvent("onpropertychange",HN),lp=ap=null)}function HN(p){if(p.propertyName==="value"&&tg(lp)){var b=[];FN(b,lp,p,gt(p)),Tt(y7,b)}}function x7(p,b,E){p==="focusin"?(VN(),ap=b,lp=E,ap.attachEvent("onpropertychange",HN)):p==="focusout"&&VN()}function w7(p){if(p==="selectionchange"||p==="keyup"||p==="keydown")return tg(lp)}function k7(p,b){if(p==="click")return tg(b)}function S7(p,b){if(p==="input"||p==="change")return tg(b)}function C7(p,b){return p===b&&(p!==0||1/p===1/b)||p!==p&&b!==b}var qo=typeof Object.is=="function"?Object.is:C7;function cp(p,b){if(qo(p,b))return!0;if(typeof p!="object"||p===null||typeof b!="object"||b===null)return!1;var E=Object.keys(p),z=Object.keys(b);if(E.length!==z.length)return!1;for(z=0;z<E.length;z++){var G=E[z];if(!l.call(b,G)||!qo(p[G],b[G]))return!1}return!0}function GN(p){for(;p&&p.firstChild;)p=p.firstChild;return p}function WN(p,b){var E=GN(p);p=0;for(var z;E;){if(E.nodeType===3){if(z=p+E.textContent.length,p<=b&&z>=b)return{node:E,offset:b-p};p=z}e:{for(;E;){if(E.nextSibling){E=E.nextSibling;break e}E=E.parentNode}E=void 0}E=GN(E)}}function qN(p,b){return p&&b?p===b?!0:p&&p.nodeType===3?!1:b&&b.nodeType===3?qN(p,b.parentNode):"contains"in p?p.contains(b):p.compareDocumentPosition?!!(p.compareDocumentPosition(b)&16):!1:!1}function KN(){for(var p=window,b=fe();b instanceof p.HTMLIFrameElement;){try{var E=typeof b.contentWindow.location.href=="string"}catch{E=!1}if(E)p=b.contentWindow;else break;b=fe(p.document)}return b}function Jx(p){var b=p&&p.nodeName&&p.nodeName.toLowerCase();return b&&(b==="input"&&(p.type==="text"||p.type==="search"||p.type==="tel"||p.type==="url"||p.type==="password")||b==="textarea"||p.contentEditable==="true")}function _7(p){var b=KN(),E=p.focusedElem,z=p.selectionRange;if(b!==E&&E&&E.ownerDocument&&qN(E.ownerDocument.documentElement,E)){if(z!==null&&Jx(E)){if(b=z.start,p=z.end,p===void 0&&(p=b),"selectionStart"in E)E.selectionStart=b,E.selectionEnd=Math.min(p,E.value.length);else if(p=(b=E.ownerDocument||document)&&b.defaultView||window,p.getSelection){p=p.getSelection();var G=E.textContent.length,X=Math.min(z.start,G);z=z.end===void 0?X:Math.min(z.end,G),!p.extend&&X>z&&(G=z,z=X,X=G),G=WN(E,X);var me=WN(E,z);G&&me&&(p.rangeCount!==1||p.anchorNode!==G.node||p.anchorOffset!==G.offset||p.focusNode!==me.node||p.focusOffset!==me.offset)&&(b=b.createRange(),b.setStart(G.node,G.offset),p.removeAllRanges(),X>z?(p.addRange(b),p.extend(me.node,me.offset)):(b.setEnd(me.node,me.offset),p.addRange(b)))}}for(b=[],p=E;p=p.parentNode;)p.nodeType===1&&b.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<b.length;E++)p=b[E],p.element.scrollLeft=p.left,p.element.scrollTop=p.top}}var E7=a&&"documentMode"in document&&11>=document.documentMode,Pd=null,ew=null,up=null,tw=!1;function YN(p,b,E){var z=E.window===E?E.document:E.nodeType===9?E:E.ownerDocument;tw||Pd==null||Pd!==fe(z)||(z=Pd,"selectionStart"in z&&Jx(z)?z={start:z.selectionStart,end:z.selectionEnd}:(z=(z.ownerDocument&&z.ownerDocument.defaultView||window).getSelection(),z={anchorNode:z.anchorNode,anchorOffset:z.anchorOffset,focusNode:z.focusNode,focusOffset:z.focusOffset}),up&&cp(up,z)||(up=z,z=sg(ew,"onSelect"),0<z.length&&(b=new Gx("onSelect","select",null,b,E),p.push({event:b,listeners:z}),b.target=Pd)))}function ng(p,b){var E={};return E[p.toLowerCase()]=b.toLowerCase(),E["Webkit"+p]="webkit"+b,E["Moz"+p]="moz"+b,E}var Ad={animationend:ng("Animation","AnimationEnd"),animationiteration:ng("Animation","AnimationIteration"),animationstart:ng("Animation","AnimationStart"),transitionend:ng("Transition","TransitionEnd")},nw={},XN={};a&&(XN=document.createElement("div").style,"AnimationEvent"in window||(delete Ad.animationend.animation,delete Ad.animationiteration.animation,delete Ad.animationstart.animation),"TransitionEvent"in window||delete Ad.transitionend.transition);function rg(p){if(nw[p])return nw[p];if(!Ad[p])return p;var b=Ad[p],E;for(E in b)if(b.hasOwnProperty(E)&&E in XN)return nw[p]=b[E];return p}var QN=rg("animationend"),ZN=rg("animationiteration"),JN=rg("animationstart"),e5=rg("transitionend"),t5=new Map,n5="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error 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(" ");function Kl(p,b){t5.set(p,b),s(b,[p])}for(var rw=0;rw<n5.length;rw++){var iw=n5[rw],N7=iw.toLowerCase(),I7=iw[0].toUpperCase()+iw.slice(1);Kl(N7,"on"+I7)}Kl(QN,"onAnimationEnd"),Kl(ZN,"onAnimationIteration"),Kl(JN,"onAnimationStart"),Kl("dblclick","onDoubleClick"),Kl("focusin","onFocus"),Kl("focusout","onBlur"),Kl(e5,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var dp="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(" "),j7=new Set("cancel close invalid load scroll toggle".split(" ").concat(dp));function r5(p,b,E){var z=p.type||"unknown-event";p.currentTarget=E,it(z,b,void 0,p),p.currentTarget=null}function i5(p,b){b=(b&4)!==0;for(var E=0;E<p.length;E++){var z=p[E],G=z.event;z=z.listeners;e:{var X=void 0;if(b)for(var me=z.length-1;0<=me;me--){var Pe=z[me],$e=Pe.instance,lt=Pe.currentTarget;if(Pe=Pe.listener,$e!==X&&G.isPropagationStopped())break e;r5(G,Pe,lt),X=$e}else for(me=0;me<z.length;me++){if(Pe=z[me],$e=Pe.instance,lt=Pe.currentTarget,Pe=Pe.listener,$e!==X&&G.isPropagationStopped())break e;r5(G,Pe,lt),X=$e}}}if(Qt)throw p=Ye,Qt=!1,Ye=null,p}function Or(p,b){var E=b[fw];E===void 0&&(E=b[fw]=new Set);var z=p+"__bubble";E.has(z)||(s5(b,p,2,!1),E.add(z))}function sw(p,b,E){var z=0;b&&(z|=4),s5(E,p,z,b)}var ig="_reactListening"+Math.random().toString(36).slice(2);function fp(p){if(!p[ig]){p[ig]=!0,r.forEach(function(E){E!=="selectionchange"&&(j7.has(E)||sw(E,!1,p),sw(E,!0,p))});var b=p.nodeType===9?p:p.ownerDocument;b===null||b[ig]||(b[ig]=!0,sw("selectionchange",!1,b))}}function s5(p,b,E,z){switch(ql(b)){case 1:var G=Id;break;case 4:G=ul;break;default:G=Na}E=G.bind(null,b,E,p),G=void 0,!Rt||b!=="touchstart"&&b!=="touchmove"&&b!=="wheel"||(G=!0),z?G!==void 0?p.addEventListener(b,E,{capture:!0,passive:G}):p.addEventListener(b,E,!0):G!==void 0?p.addEventListener(b,E,{passive:G}):p.addEventListener(b,E,!1)}function ow(p,b,E,z,G){var X=z;if((b&1)===0&&(b&2)===0&&z!==null)e:for(;;){if(z===null)return;var me=z.tag;if(me===3||me===4){var Pe=z.stateNode.containerInfo;if(Pe===G||Pe.nodeType===8&&Pe.parentNode===G)break;if(me===4)for(me=z.return;me!==null;){var $e=me.tag;if(($e===3||$e===4)&&($e=me.stateNode.containerInfo,$e===G||$e.nodeType===8&&$e.parentNode===G))return;me=me.return}for(;Pe!==null;){if(me=Zc(Pe),me===null)return;if($e=me.tag,$e===5||$e===6){z=X=me;continue e}Pe=Pe.parentNode}}z=z.return}Tt(function(){var lt=X,Pt=gt(E),Bt=[];e:{var jt=t5.get(p);if(jt!==void 0){var en=Gx,an=p;switch(p){case"keypress":if(Z0(E)===0)break e;case"keydown":case"keyup":en=s7;break;case"focusin":an="focus",en=Kx;break;case"focusout":an="blur",en=Kx;break;case"beforeblur":case"afterblur":en=Kx;break;case"click":if(E.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":en=zN;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":en=q9;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":en=l7;break;case QN:case ZN:case JN:en=X9;break;case e5:en=u7;break;case"scroll":en=G9;break;case"wheel":en=f7;break;case"copy":case"cut":case"paste":en=Z9;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":en=AN}var un=(b&4)!==0,fi=!un&&p==="scroll",nt=un?jt!==null?jt+"Capture":null:jt;un=[];for(var We=lt,st;We!==null;){st=We;var Vt=st.stateNode;if(st.tag===5&&Vt!==null&&(st=Vt,nt!==null&&(Vt=Mt(We,nt),Vt!=null&&un.push(hp(We,Vt,st)))),fi)break;We=We.return}0<un.length&&(jt=new en(jt,an,null,E,Pt),Bt.push({event:jt,listeners:un}))}}if((b&7)===0){e:{if(jt=p==="mouseover"||p==="pointerover",en=p==="mouseout"||p==="pointerout",jt&&E!==tt&&(an=E.relatedTarget||E.fromElement)&&(Zc(an)||an[dl]))break e;if((en||jt)&&(jt=Pt.window===Pt?Pt:(jt=Pt.ownerDocument)?jt.defaultView||jt.parentWindow:window,en?(an=E.relatedTarget||E.toElement,en=lt,an=an?Zc(an):null,an!==null&&(fi=ct(an),an!==fi||an.tag!==5&&an.tag!==6)&&(an=null)):(en=null,an=lt),en!==an)){if(un=zN,Vt="onMouseLeave",nt="onMouseEnter",We="mouse",(p==="pointerout"||p==="pointerover")&&(un=AN,Vt="onPointerLeave",nt="onPointerEnter",We="pointer"),fi=en==null?jt:Rd(en),st=an==null?jt:Rd(an),jt=new un(Vt,We+"leave",en,E,Pt),jt.target=fi,jt.relatedTarget=st,Vt=null,Zc(Pt)===lt&&(un=new un(nt,We+"enter",an,E,Pt),un.target=st,un.relatedTarget=fi,Vt=un),fi=Vt,en&&an)t:{for(un=en,nt=an,We=0,st=un;st;st=Md(st))We++;for(st=0,Vt=nt;Vt;Vt=Md(Vt))st++;for(;0<We-st;)un=Md(un),We--;for(;0<st-We;)nt=Md(nt),st--;for(;We--;){if(un===nt||nt!==null&&un===nt.alternate)break t;un=Md(un),nt=Md(nt)}un=null}else un=null;en!==null&&o5(Bt,jt,en,un,!1),an!==null&&fi!==null&&o5(Bt,fi,an,un,!0)}}e:{if(jt=lt?Rd(lt):window,en=jt.nodeName&&jt.nodeName.toLowerCase(),en==="select"||en==="input"&&jt.type==="file")var hn=v7;else if(LN(jt))if($N)hn=S7;else{hn=w7;var wn=x7}else(en=jt.nodeName)&&en.toLowerCase()==="input"&&(jt.type==="checkbox"||jt.type==="radio")&&(hn=k7);if(hn&&(hn=hn(p,lt))){FN(Bt,hn,E,Pt);break e}wn&&wn(p,jt,lt),p==="focusout"&&(wn=jt._wrapperState)&&wn.controlled&&jt.type==="number"&&Q(jt,"number",jt.value)}switch(wn=lt?Rd(lt):window,p){case"focusin":(LN(wn)||wn.contentEditable==="true")&&(Pd=wn,ew=lt,up=null);break;case"focusout":up=ew=Pd=null;break;case"mousedown":tw=!0;break;case"contextmenu":case"mouseup":case"dragend":tw=!1,YN(Bt,E,Pt);break;case"selectionchange":if(E7)break;case"keydown":case"keyup":YN(Bt,E,Pt)}var kn;if(Xx)e:{switch(p){case"compositionstart":var In="onCompositionStart";break e;case"compositionend":In="onCompositionEnd";break e;case"compositionupdate":In="onCompositionUpdate";break e}In=void 0}else zd?ON(p,E)&&(In="onCompositionEnd"):p==="keydown"&&E.keyCode===229&&(In="onCompositionStart");In&&(MN&&E.locale!=="ko"&&(zd||In!=="onCompositionStart"?In==="onCompositionEnd"&&zd&&(kn=jN()):(Ni=Pt,jd="value"in Ni?Ni.value:Ni.textContent,zd=!0)),wn=sg(lt,In),0<wn.length&&(In=new PN(In,p,null,E,Pt),Bt.push({event:In,listeners:wn}),kn?In.data=kn:(kn=DN(E),kn!==null&&(In.data=kn)))),(kn=p7?m7(p,E):g7(p,E))&&(lt=sg(lt,"onBeforeInput"),0<lt.length&&(Pt=new PN("onBeforeInput","beforeinput",null,E,Pt),Bt.push({event:Pt,listeners:lt}),Pt.data=kn))}i5(Bt,b)})}function hp(p,b,E){return{instance:p,listener:b,currentTarget:E}}function sg(p,b){for(var E=b+"Capture",z=[];p!==null;){var G=p,X=G.stateNode;G.tag===5&&X!==null&&(G=X,X=Mt(p,E),X!=null&&z.unshift(hp(p,X,G)),X=Mt(p,b),X!=null&&z.push(hp(p,X,G))),p=p.return}return z}function Md(p){if(p===null)return null;do p=p.return;while(p&&p.tag!==5);return p||null}function o5(p,b,E,z,G){for(var X=b._reactName,me=[];E!==null&&E!==z;){var Pe=E,$e=Pe.alternate,lt=Pe.stateNode;if($e!==null&&$e===z)break;Pe.tag===5&<!==null&&(Pe=lt,G?($e=Mt(E,X),$e!=null&&me.unshift(hp(E,$e,Pe))):G||($e=Mt(E,X),$e!=null&&me.push(hp(E,$e,Pe)))),E=E.return}me.length!==0&&p.push({event:b,listeners:me})}var T7=/\r\n?/g,z7=/\u0000|\uFFFD/g;function a5(p){return(typeof p=="string"?p:""+p).replace(T7,` 39`).replace(z7,"")}function og(p,b,E){if(b=a5(b),a5(p)!==b&&E)throw Error(n(425))}function ag(){}var aw=null,lw=null;function cw(p,b){return p==="textarea"||p==="noscript"||typeof b.children=="string"||typeof b.children=="number"||typeof b.dangerouslySetInnerHTML=="object"&&b.dangerouslySetInnerHTML!==null&&b.dangerouslySetInnerHTML.__html!=null}var uw=typeof setTimeout=="function"?setTimeout:void 0,P7=typeof clearTimeout=="function"?clearTimeout:void 0,l5=typeof Promise=="function"?Promise:void 0,A7=typeof queueMicrotask=="function"?queueMicrotask:typeof l5<"u"?function(p){return l5.resolve(null).then(p).catch(M7)}:uw;function M7(p){setTimeout(function(){throw p})}function dw(p,b){var E=b,z=0;do{var G=E.nextSibling;if(p.removeChild(E),G&&G.nodeType===8)if(E=G.data,E==="/$"){if(z===0){p.removeChild(G),Yr(b);return}z--}else E!=="$"&&E!=="$?"&&E!=="$!"||z++;E=G}while(E);Yr(b)}function Yl(p){for(;p!=null;p=p.nextSibling){var b=p.nodeType;if(b===1||b===3)break;if(b===8){if(b=p.data,b==="$"||b==="$!"||b==="$?")break;if(b==="/$")return null}}return p}function c5(p){p=p.previousSibling;for(var b=0;p;){if(p.nodeType===8){var E=p.data;if(E==="$"||E==="$!"||E==="$?"){if(b===0)return p;b--}else E==="/$"&&b++}p=p.previousSibling}return null}var Bd=Math.random().toString(36).slice(2),Ia="__reactFiber$"+Bd,pp="__reactProps$"+Bd,dl="__reactContainer$"+Bd,fw="__reactEvents$"+Bd,B7="__reactListeners$"+Bd,R7="__reactHandles$"+Bd;function Zc(p){var b=p[Ia];if(b)return b;for(var E=p.parentNode;E;){if(b=E[dl]||E[Ia]){if(E=b.alternate,b.child!==null||E!==null&&E.child!==null)for(p=c5(p);p!==null;){if(E=p[Ia])return E;p=c5(p)}return b}p=E,E=p.parentNode}return null}function mp(p){return p=p[Ia]||p[dl],!p||p.tag!==5&&p.tag!==6&&p.tag!==13&&p.tag!==3?null:p}function Rd(p){if(p.tag===5||p.tag===6)return p.stateNode;throw Error(n(33))}function lg(p){return p[pp]||null}var hw=[],Od=-1;function Xl(p){return{current:p}}function Dr(p){0>Od||(p.current=hw[Od],hw[Od]=null,Od--)}function kr(p,b){Od++,hw[Od]=p.current,p.current=b}var Ql={},is=Xl(Ql),As=Xl(!1),Jc=Ql;function Dd(p,b){var E=p.type.contextTypes;if(!E)return Ql;var z=p.stateNode;if(z&&z.__reactInternalMemoizedUnmaskedChildContext===b)return z.__reactInternalMemoizedMaskedChildContext;var G={},X;for(X in E)G[X]=b[X];return z&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=b,p.__reactInternalMemoizedMaskedChildContext=G),G}function Ms(p){return p=p.childContextTypes,p!=null}function cg(){Dr(As),Dr(is)}function u5(p,b,E){if(is.current!==Ql)throw Error(n(168));kr(is,b),kr(As,E)}function d5(p,b,E){var z=p.stateNode;if(b=b.childContextTypes,typeof z.getChildContext!="function")return E;z=z.getChildContext();for(var G in z)if(!(G in b))throw Error(n(108,re(p)||"Unknown",G));return B({},E,z)}function ug(p){return p=(p=p.stateNode)&&p.__reactInternalMemoizedMergedChildContext||Ql,Jc=is.current,kr(is,p),kr(As,As.current),!0}function f5(p,b,E){var z=p.stateNode;if(!z)throw Error(n(169));E?(p=d5(p,b,Jc),z.__reactInternalMemoizedMergedChildContext=p,Dr(As),Dr(is),kr(is,p)):Dr(As),kr(As,E)}var fl=null,dg=!1,pw=!1;function h5(p){fl===null?fl=[p]:fl.push(p)}function O7(p){dg=!0,h5(p)}function Zl(){if(!pw&&fl!==null){pw=!0;var p=0,b=K;try{var E=fl;for(K=1;p<E.length;p++){var z=E[p];do z=z(!0);while(z!==null)}fl=null,dg=!1}catch(G){throw fl!==null&&(fl=fl.slice(p+1)),xn(Xn,Zl),G}finally{K=b,pw=!1}}return null}var Ld=[],Fd=0,fg=null,hg=0,Co=[],_o=0,eu=null,hl=1,pl="";function tu(p,b){Ld[Fd++]=hg,Ld[Fd++]=fg,fg=p,hg=b}function p5(p,b,E){Co[_o++]=hl,Co[_o++]=pl,Co[_o++]=eu,eu=p;var z=hl;p=pl;var G=32-Kr(z)-1;z&=~(1<<G),E+=1;var X=32-Kr(b)+G;if(30<X){var me=G-G%5;X=(z&(1<<me)-1).toString(32),z>>=me,G-=me,hl=1<<32-Kr(b)+G|E<<G|z,pl=X+p}else hl=1<<X|E<<G|z,pl=p}function mw(p){p.return!==null&&(tu(p,1),p5(p,1,0))}function gw(p){for(;p===fg;)fg=Ld[--Fd],Ld[Fd]=null,hg=Ld[--Fd],Ld[Fd]=null;for(;p===eu;)eu=Co[--_o],Co[_o]=null,pl=Co[--_o],Co[_o]=null,hl=Co[--_o],Co[_o]=null}var eo=null,to=null,Hr=!1,Ko=null;function m5(p,b){var E=jo(5,null,null,0);
vendor: 7,528 bytes, line 39
39E.elementType="DELETED",E.stateNode=b,E.return=p,b=p.deletions,b===null?(p.deletions=[E],p.flags|=16):b.push(E)}function g5(p,b){switch(p.tag){case 5:var E=p.type;return b=b.nodeType!==1||E.toLowerCase()!==b.nodeName.toLowerCase()?null:b,b!==null?(p.stateNode=b,eo=p,to=Yl(b.firstChild),!0):!1;case 6:return b=p.pendingProps===""||b.nodeType!==3?null:b,b!==null?(p.stateNode=b,eo=p,to=null,!0):!1;case 13:return b=b.nodeType!==8?null:b,b!==null?(E=eu!==null?{id:hl,overflow:pl}:null,p.memoizedState={dehydrated:b,treeContext:E,retryLane:1073741824},E=jo(18,null,null,0),E.stateNode=b,E.return=p,p.child=E,eo=p,to=null,!0):!1;default:return!1}}function bw(p){return(p.mode&1)!==0&&(p.flags&128)===0}function yw(p){if(Hr){var b=to;if(b){var E=b;if(!g5(p,b)){if(bw(p))throw Error(n(418));b=Yl(E.nextSibling);var z=eo;b&&g5(p,b)?m5(z,E):(p.flags=p.flags&-4097|2,Hr=!1,eo=p)}}else{if(bw(p))throw Error(n(418));p.flags=p.flags&-4097|2,Hr=!1,eo=p}}}function b5(p){for(p=p.return;p!==null&&p.tag!==5&&p.tag!==3&&p.tag!==13;)p=p.return;eo=p}function pg(p){if(p!==eo)return!1;if(!Hr)return b5(p),Hr=!0,!1;var b;if((b=p.tag!==3)&&!(b=p.tag!==5)&&(b=p.type,b=b!=="head"&&b!=="body"&&!cw(p.type,p.memoizedProps)),b&&(b=to)){if(bw(p))throw y5(),Error(n(418));for(;b;)m5(p,b),b=Yl(b.nextSibling)}if(b5(p),p.tag===13){if(p=p.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(n(317));e:{for(p=p.nextSibling,b=0;p;){if(p.nodeType===8){var E=p.data;if(E==="/$"){if(b===0){to=Yl(p.nextSibling);break e}b--}else E!=="$"&&E!=="$!"&&E!=="$?"||b++}p=p.nextSibling}to=null}}else to=eo?Yl(p.stateNode.nextSibling):null;return!0}function y5(){for(var p=to;p;)p=Yl(p.nextSibling)}function $d(){to=eo=null,Hr=!1}function vw(p){Ko===null?Ko=[p]:Ko.push(p)}var D7=k.ReactCurrentBatchConfig;function gp(p,b,E){if(p=E.ref,p!==null&&typeof p!="function"&&typeof p!="object"){if(E._owner){if(E=E._owner,E){if(E.tag!==1)throw Error(n(309));var z=E.stateNode}if(!z)throw Error(n(147,p));var G=z,X=""+p;return b!==null&&b.ref!==null&&typeof b.ref=="function"&&b.ref._stringRef===X?b.ref:(b=function(me){var Pe=G.refs;me===null?delete Pe[X]:Pe[X]=me},b._stringRef=X,b)}if(typeof p!="string")throw Error(n(284));if(!E._owner)throw Error(n(290,p))}return p}function mg(p,b){throw p=Object.prototype.toString.call(b),Error(n(31,p==="[object Object]"?"object with keys {"+Object.keys(b).join(", ")+"}":p))}function v5(p){var b=p._init;return b(p._payload)}function x5(p){function b(nt,We){if(p){var st=nt.deletions;st===null?(nt.deletions=[We],nt.flags|=16):st.push(We)}}function E(nt,We){if(!p)return null;for(;We!==null;)b(nt,We),We=We.sibling;return null}function z(nt,We){for(nt=new Map;We!==null;)We.key!==null?nt.set(We.key,We):nt.set(We.index,We),We=We.sibling;return nt}function G(nt,We){return nt=oc(nt,We),nt.index=0,nt.sibling=null,nt}function X(nt,We,st){return nt.index=st,p?(st=nt.alternate,st!==null?(st=st.index,st<We?(nt.flags|=2,We):st):(nt.flags|=2,We)):(nt.flags|=1048576,We)}function me(nt){return p&&nt.alternate===null&&(nt.flags|=2),nt}function Pe(nt,We,st,Vt){return We===null||We.tag!==6?(We=u1(st,nt.mode,Vt),We.return=nt,We):(We=G(We,st),We.return=nt,We)}function $e(nt,We,st,Vt){var hn=st.type;return hn===j?Pt(nt,We,st.props.children,Vt,st.key):We!==null&&(We.elementType===hn||typeof hn=="object"&&hn!==null&&hn.$$typeof===U&&v5(hn)===We.type)?(Vt=G(We,st.props),Vt.ref=gp(nt,We,st),Vt.return=nt,Vt):(Vt=Lg(st.type,st.key,st.props,null,nt.mode,Vt),Vt.ref=gp(nt,We,st),Vt.return=nt,Vt)}function lt(nt,We,st,Vt){return We===null||We.tag!==4||We.stateNode.containerInfo!==st.containerInfo||We.stateNode.implementation!==st.implementation?(We=d1(st,nt.mode,Vt),We.return=nt,We):(We=G(We,st.children||[]),We.return=nt,We)}function Pt(nt,We,st,Vt,hn){return We===null||We.tag!==7?(We=cu(st,nt.mode,Vt,hn),We.return=nt,We):(We=G(We,st),We.return=nt,We)}function Bt(nt,We,st){if(typeof We=="string"&&We!==""||typeof We=="number")return We=u1(""+We,nt.mode,st),We.return=nt,We;if(typeof We=="object"&&We!==null){switch(We.$$typeof){case N:return st=Lg(We.type,We.key,We.props,null,nt.mode,st),st.ref=gp(nt,null,We),st.return=nt,st;case _:return We=d1(We,nt.mode,st),We.return=nt,We;case U:var Vt=We._init;return Bt(nt,Vt(We._payload),st)}if(de(We)||D(We))return We=cu(We,nt.mode,st,null),We.return=nt,We;mg(nt,We)}return null}function jt(nt,We,st,Vt){var hn=We!==null?We.key:null;if(typeof st=="string"&&st!==""||typeof st=="number")return hn!==null?null:Pe(nt,We,""+st,Vt);if(typeof st=="object"&&st!==null){switch(st.$$typeof){case N:return st.key===hn?$e(nt,We,st,Vt):null;case _:return st.key===hn?lt(nt,We,st,Vt):null;case U:return hn=st._init,jt(nt,We,hn(st._payload),Vt)}if(de(st)||D(st))return hn!==null?null:Pt(nt,We,st,Vt,null);mg(nt,st)}return null}function en(nt,We,st,Vt,hn){if(typeof Vt=="string"&&Vt!==""||typeof Vt=="number")return nt=nt.get(st)||null,Pe(We,nt,""+Vt,hn);if(typeof Vt=="object"&&Vt!==null){switch(Vt.$$typeof){case N:return nt=nt.get(Vt.key===null?st:Vt.key)||null,$e(We,nt,Vt,hn);case _:return nt=nt.get(Vt.key===null?st:Vt.key)||null,lt(We,nt,Vt,hn);case U:var wn=Vt._init;return en(nt,We,st,wn(Vt._payload),hn)}if(de(Vt)||D(Vt))return nt=nt.get(st)||null,Pt(We,nt,Vt,hn,null);mg(We,Vt)}return null}function an(nt,We,st,Vt){for(var hn=null,wn=null,kn=We,In=We=0,Ri=null;kn!==null&&In<st.length;In++){kn.index>In?(Ri=kn,kn=null):Ri=kn.sibling;var or=jt(nt,kn,st[In],Vt);if(or===null){kn===null&&(kn=Ri);break}p&&kn&&or.alternate===null&&b(nt,kn),We=X(or,We,In),wn===null?hn=or:wn.sibling=or,wn=or,kn=Ri}if(In===st.length)return E(nt,kn),Hr&&tu(nt,In),hn;if(kn===null){for(;In<st.length;In++)kn=Bt(nt,st[In],Vt),kn!==null&&(We=X(kn,We,In),wn===null?hn=kn:wn.sibling=kn,wn=kn);return Hr&&tu(nt,In),hn}for(kn=z(nt,kn);In<st.length;In++)Ri=en(kn,nt,In,st[In],Vt),Ri!==null&&(p&&Ri.alternate!==null&&kn.delete(Ri.key===null?In:Ri.key),We=X(Ri,We,In),wn===null?hn=Ri:wn.sibling=Ri,wn=Ri);return p&&kn.forEach(function(ac){return b(nt,ac)}),Hr&&tu(nt,In),hn}function un(nt,We,st,Vt){var hn=D(st);if(typeof hn!="function")throw Error(n(150));if(st=hn.call(st),st==null)throw Error(n(151));for(var wn=hn=null,kn=We,In=We=0,Ri=null,or=st.next();kn!==null&&!or.done;In++,or=st.next()){kn.index>In?(Ri=kn,kn=null):Ri=kn.sibling;var ac=jt(nt,kn,or.value,Vt);if(ac===null){kn===null&&(kn=Ri);break}p&&kn&&ac.alternate===null&&b(nt,kn),We=X(ac,We,In),wn===null?hn=ac:wn.sibling=ac,wn=ac,kn=Ri}if(or.done)return E(nt,kn),Hr&&tu(nt,In),hn;if(kn===null){for(;!or.done;In++,or=st.next())or=Bt(nt,or.value,Vt),or!==null&&(We=X(or,We,In),wn===null?hn=or:wn.sibling=or,wn=or);return Hr&&tu(nt,In),hn}for(kn=z(nt,kn);!or.done;In++,or=st.next())or=en(kn,nt,In,or.value,Vt),or!==null&&(p&&or.alternate!==null&&kn.delete(or.key===null?In:or.key),We=X(or,We,In),wn===null?hn=or:wn.sibling=or,wn=or);return p&&kn.forEach(function(b$){return b(nt,b$)}),Hr&&tu(nt,In),hn}function fi(nt,We,st,Vt){if(typeof st=="object"&&st!==null&&st.type===j&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case N:e:{for(var hn=st.key,wn=We;wn!==null;){if(wn.key===hn){if(hn=st.type,hn===j){if(wn.tag===7){E(nt,wn.sibling),We=G(wn,st.props.children),We.return=nt,nt=We;break e}}else if(wn.elementType===hn||typeof hn=="object"&&hn!==null&&hn.$$typeof===U&&v5(hn)===wn.type){E(nt,wn.sibling),We=G(wn,st.props),We.ref=gp(nt,wn,st),We.return=nt,nt=We;break e}E(nt,wn);break}else b(nt,wn);wn=wn.sibling}st.type===j?(We=cu(st.props.children,nt.mode,Vt,st.key),We.return=nt,nt=We):(Vt=Lg(st.type,st.key,st.props,null,
vendor: 5,286 bytes, line 39
39nt.mode,Vt),Vt.ref=gp(nt,We,st),Vt.return=nt,nt=Vt)}return me(nt);case _:e:{for(wn=st.key;We!==null;){if(We.key===wn)if(We.tag===4&&We.stateNode.containerInfo===st.containerInfo&&We.stateNode.implementation===st.implementation){E(nt,We.sibling),We=G(We,st.children||[]),We.return=nt,nt=We;break e}else{E(nt,We);break}else b(nt,We);We=We.sibling}We=d1(st,nt.mode,Vt),We.return=nt,nt=We}return me(nt);case U:return wn=st._init,fi(nt,We,wn(st._payload),Vt)}if(de(st))return an(nt,We,st,Vt);if(D(st))return un(nt,We,st,Vt);mg(nt,st)}return typeof st=="string"&&st!==""||typeof st=="number"?(st=""+st,We!==null&&We.tag===6?(E(nt,We.sibling),We=G(We,st),We.return=nt,nt=We):(E(nt,We),We=u1(st,nt.mode,Vt),We.return=nt,nt=We),me(nt)):E(nt,We)}return fi}var Ud=x5(!0),w5=x5(!1),gg=Xl(null),bg=null,Vd=null,xw=null;function ww(){xw=Vd=bg=null}function kw(p){var b=gg.current;Dr(gg),p._currentValue=b}function Sw(p,b,E){for(;p!==null;){var z=p.alternate;if((p.childLanes&b)!==b?(p.childLanes|=b,z!==null&&(z.childLanes|=b)):z!==null&&(z.childLanes&b)!==b&&(z.childLanes|=b),p===E)break;p=p.return}}function Hd(p,b){bg=p,xw=Vd=null,p=p.dependencies,p!==null&&p.firstContext!==null&&((p.lanes&b)!==0&&(Bs=!0),p.firstContext=null)}function Eo(p){var b=p._currentValue;if(xw!==p)if(p={context:p,memoizedValue:b,next:null},Vd===null){if(bg===null)throw Error(n(308));Vd=p,bg.dependencies={lanes:0,firstContext:p}}else Vd=Vd.next=p;return b}var nu=null;function Cw(p){nu===null?nu=[p]:nu.push(p)}function k5(p,b,E,z){var G=b.interleaved;return G===null?(E.next=E,Cw(b)):(E.next=G.next,G.next=E),b.interleaved=E,ml(p,z)}function ml(p,b){p.lanes|=b;var E=p.alternate;for(E!==null&&(E.lanes|=b),E=p,p=p.return;p!==null;)p.childLanes|=b,E=p.alternate,E!==null&&(E.childLanes|=b),E=p,p=p.return;return E.tag===3?E.stateNode:null}var Jl=!1;function _w(p){p.updateQueue={baseState:p.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function S5(p,b){p=p.updateQueue,b.updateQueue===p&&(b.updateQueue={baseState:p.baseState,firstBaseUpdate:p.firstBaseUpdate,lastBaseUpdate:p.lastBaseUpdate,shared:p.shared,effects:p.effects})}function gl(p,b){return{eventTime:p,lane:b,tag:0,payload:null,callback:null,next:null}}function ec(p,b,E){var z=p.updateQueue;if(z===null)return null;if(z=z.shared,(ir&2)!==0){var G=z.pending;return G===null?b.next=b:(b.next=G.next,G.next=b),z.pending=b,ml(p,E)}return G=z.interleaved,G===null?(b.next=b,Cw(z)):(b.next=G.next,G.next=b),z.interleaved=b,ml(p,E)}function yg(p,b,E){if(b=b.updateQueue,b!==null&&(b=b.shared,(E&4194240)!==0)){var z=b.lanes;z&=p.pendingLanes,E|=z,b.lanes=E,ae(p,E)}}function C5(p,b){var E=p.updateQueue,z=p.alternate;if(z!==null&&(z=z.updateQueue,E===z)){var G=null,X=null;if(E=E.firstBaseUpdate,E!==null){do{var me={eventTime:E.eventTime,lane:E.lane,tag:E.tag,payload:E.payload,callback:E.callback,next:null};X===null?G=X=me:X=X.next=me,E=E.next}while(E!==null);X===null?G=X=b:X=X.next=b}else G=X=b;E={baseState:z.baseState,firstBaseUpdate:G,lastBaseUpdate:X,shared:z.shared,effects:z.effects},p.updateQueue=E;return}p=E.lastBaseUpdate,p===null?E.firstBaseUpdate=b:p.next=b,E.lastBaseUpdate=b}function vg(p,b,E,z){var G=p.updateQueue;Jl=!1;var X=G.firstBaseUpdate,me=G.lastBaseUpdate,Pe=G.shared.pending;if(Pe!==null){G.shared.pending=null;var $e=Pe,lt=$e.next;$e.next=null,me===null?X=lt:me.next=lt,me=$e;var Pt=p.alternate;Pt!==null&&(Pt=Pt.updateQueue,Pe=Pt.lastBaseUpdate,Pe!==me&&(Pe===null?Pt.firstBaseUpdate=lt:Pe.next=lt,Pt.lastBaseUpdate=$e))}if(X!==null){var Bt=G.baseState;me=0,Pt=lt=$e=null,Pe=X;do{var jt=Pe.lane,en=Pe.eventTime;if((z&jt)===jt){Pt!==null&&(Pt=Pt.next={eventTime:en,lane:0,tag:Pe.tag,payload:Pe.payload,callback:Pe.callback,next:null});e:{var an=p,un=Pe;switch(jt=b,en=E,un.tag){case 1:if(an=un.payload,typeof an=="function"){Bt=an.call(en,Bt,jt);break e}Bt=an;break e;case 3:an.flags=an.flags&-65537|128;case 0:if(an=un.payload,jt=typeof an=="function"?an.call(en,Bt,jt):an,jt==null)break e;Bt=B({},Bt,jt);break e;case 2:Jl=!0}}Pe.callback!==null&&Pe.lane!==0&&(p.flags|=64,jt=G.effects,jt===null?G.effects=[Pe]:jt.push(Pe))}else en={eventTime:en,lane:jt,tag:Pe.tag,payload:Pe.payload,callback:Pe.callback,next:null},Pt===null?(lt=Pt=en,$e=Bt):Pt=Pt.next=en,me|=jt;if(Pe=Pe.next,Pe===null){if(Pe=G.shared.pending,Pe===null)break;jt=Pe,Pe=jt.next,jt.next=null,G.lastBaseUpdate=jt,G.shared.pending=null}}while(!0);if(Pt===null&&($e=Bt),G.baseState=$e,G.firstBaseUpdate=lt,G.lastBaseUpdate=Pt,b=G.shared.interleaved,b!==null){G=b;do me|=G.lane,G=G.next;while(G!==b)}else X===null&&(G.shared.lanes=0);su|=me,p.lanes=me,p.memoizedState=Bt}}function _5(p,b,E){if(p=b.effects,b.effects=null,p!==null)for(b=0;b<p.length;b++){var z=p[b],G=z.callback;if(G!==null){if(z.callback=null,z=E,typeof G!="function")throw Error(n(191,G));G.call(z)}}}var bp={},ja=Xl(bp),yp=Xl(bp),vp=Xl(bp);function ru(p){if(p===bp)throw Error(n(174));return p}function Ew(p,b){switch(kr(vp,b),kr(yp,p),kr(ja,bp),p=b.nodeType,p){case 9:case 11:b=(b=b.documentElement)?b.namespaceURI:je(null,"");break;default:p=p===8?b.parentNode:b,b=p.namespaceURI||null,p=p.tagName,b=je(b,p)}Dr(ja),kr(ja,b)}function Gd(){Dr(ja),Dr(yp),Dr(vp)}function E5(p){ru(vp.current);var b=ru(ja.current),E=je(b,p.type);
vendor: 4,137 bytes, line 39
39b!==E&&(kr(yp,p),kr(ja,E))}function Nw(p){yp.current===p&&(Dr(ja),Dr(yp))}var Xr=Xl(0);function xg(p){for(var b=p;b!==null;){if(b.tag===13){var E=b.memoizedState;if(E!==null&&(E=E.dehydrated,E===null||E.data==="$?"||E.data==="$!"))return b}else if(b.tag===19&&b.memoizedProps.revealOrder!==void 0){if((b.flags&128)!==0)return b}else if(b.child!==null){b.child.return=b,b=b.child;continue}if(b===p)break;for(;b.sibling===null;){if(b.return===null||b.return===p)return null;b=b.return}b.sibling.return=b.return,b=b.sibling}return null}var Iw=[];function jw(){for(var p=0;p<Iw.length;p++)Iw[p]._workInProgressVersionPrimary=null;Iw.length=0}var wg=k.ReactCurrentDispatcher,Tw=k.ReactCurrentBatchConfig,iu=0,Qr=null,Ii=null,Mi=null,kg=!1,xp=!1,wp=0,L7=0;function ss(){throw Error(n(321))}function zw(p,b){if(b===null)return!1;for(var E=0;E<b.length&&E<p.length;E++)if(!qo(p[E],b[E]))return!1;return!0}function Pw(p,b,E,z,G,X){if(iu=X,Qr=b,b.memoizedState=null,b.updateQueue=null,b.lanes=0,wg.current=p===null||p.memoizedState===null?V7:H7,p=E(z,G),xp){X=0;do{if(xp=!1,wp=0,25<=X)throw Error(n(301));X+=1,Mi=Ii=null,b.updateQueue=null,wg.current=G7,p=E(z,G)}while(xp)}if(wg.current=_g,b=Ii!==null&&Ii.next!==null,iu=0,Mi=Ii=Qr=null,kg=!1,b)throw Error(n(300));return p}function Aw(){var p=wp!==0;return wp=0,p}function Ta(){var p={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mi===null?Qr.memoizedState=Mi=p:Mi=Mi.next=p,Mi}function No(){if(Ii===null){var p=Qr.alternate;p=p!==null?p.memoizedState:null}else p=Ii.next;var b=Mi===null?Qr.memoizedState:Mi.next;if(b!==null)Mi=b,Ii=p;else{if(p===null)throw Error(n(310));Ii=p,p={memoizedState:Ii.memoizedState,baseState:Ii.baseState,baseQueue:Ii.baseQueue,queue:Ii.queue,next:null},Mi===null?Qr.memoizedState=Mi=p:Mi=Mi.next=p}return Mi}function kp(p,b){return typeof b=="function"?b(p):b}function Mw(p){var b=No(),E=b.queue;if(E===null)throw Error(n(311));E.lastRenderedReducer=p;var z=Ii,G=z.baseQueue,X=E.pending;if(X!==null){if(G!==null){var me=G.next;G.next=X.next,X.next=me}z.baseQueue=G=X,E.pending=null}if(G!==null){X=G.next,z=z.baseState;var Pe=me=null,$e=null,lt=X;do{var Pt=lt.lane;if((iu&Pt)===Pt)$e!==null&&($e=$e.next={lane:0,action:lt.action,hasEagerState:lt.hasEagerState,eagerState:lt.eagerState,next:null}),z=lt.hasEagerState?lt.eagerState:p(z,lt.action);else{var Bt={lane:Pt,action:lt.action,hasEagerState:lt.hasEagerState,eagerState:lt.eagerState,next:null};$e===null?(Pe=$e=Bt,me=z):$e=$e.next=Bt,Qr.lanes|=Pt,su|=Pt}lt=lt.next}while(lt!==null&<!==X);$e===null?me=z:$e.next=Pe,qo(z,b.memoizedState)||(Bs=!0),b.memoizedState=z,b.baseState=me,b.baseQueue=$e,E.lastRenderedState=z}if(p=E.interleaved,p!==null){G=p;do X=G.lane,Qr.lanes|=X,su|=X,G=G.next;while(G!==p)}else G===null&&(E.lanes=0);return[b.memoizedState,E.dispatch]}function Bw(p){var b=No(),E=b.queue;if(E===null)throw Error(n(311));E.lastRenderedReducer=p;var z=E.dispatch,G=E.pending,X=b.memoizedState;if(G!==null){E.pending=null;var me=G=G.next;do X=p(X,me.action),me=me.next;while(me!==G);qo(X,b.memoizedState)||(Bs=!0),b.memoizedState=X,b.baseQueue===null&&(b.baseState=X),E.lastRenderedState=X}return[X,z]}function N5(){}function I5(p,b){var E=Qr,z=No(),G=b(),X=!qo(z.memoizedState,G);if(X&&(z.memoizedState=G,Bs=!0),z=z.queue,Rw(z5.bind(null,E,z,p),[p]),z.getSnapshot!==b||X||Mi!==null&&Mi.memoizedState.tag&1){if(E.flags|=2048,Sp(9,T5.bind(null,E,z,G,b),void 0,null),Bi===null)throw Error(n(349));(iu&30)!==0||j5(E,b,G)}return G}function j5(p,b,E){p.flags|=16384,p={getSnapshot:b,value:E},b=Qr.updateQueue,b===null?(b={lastEffect:null,stores:null},Qr.updateQueue=b,b.stores=[p]):(E=b.stores,E===null?b.stores=[p]:E.push(p))}function T5(p,b,E,z){b.value=E,b.getSnapshot=z,P5(b)&&A5(p)}function z5(p,b,E){return E(function(){P5(b)&&A5(p)})}function P5(p){var b=p.getSnapshot;p=p.value;try{var E=b();return!qo(p,E)}catch{return!0}}function A5(p){var b=ml(p,1);b!==null&&Zo(b,p,1,-1)}function M5(p){var b=Ta();return typeof p=="function"&&(p=p()),b.memoizedState=b.baseState=p,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:kp,lastRenderedState:p}
vendor: 9,017 bytes, lines 39-41
39,b.queue=p,p=p.dispatch=U7.bind(null,Qr,p),[b.memoizedState,p]}function Sp(p,b,E,z){return p={tag:p,create:b,destroy:E,deps:z,next:null},b=Qr.updateQueue,b===null?(b={lastEffect:null,stores:null},Qr.updateQueue=b,b.lastEffect=p.next=p):(E=b.lastEffect,E===null?b.lastEffect=p.next=p:(z=E.next,E.next=p,p.next=z,b.lastEffect=p)),p}function B5(){return No().memoizedState}function Sg(p,b,E,z){var G=Ta();Qr.flags|=p,G.memoizedState=Sp(1|b,E,void 0,z===void 0?null:z)}function Cg(p,b,E,z){var G=No();z=z===void 0?null:z;var X=void 0;if(Ii!==null){var me=Ii.memoizedState;if(X=me.destroy,z!==null&&zw(z,me.deps)){G.memoizedState=Sp(b,E,X,z);return}}Qr.flags|=p,G.memoizedState=Sp(1|b,E,X,z)}function R5(p,b){return Sg(8390656,8,p,b)}function Rw(p,b){return Cg(2048,8,p,b)}function O5(p,b){return Cg(4,2,p,b)}function D5(p,b){return Cg(4,4,p,b)}function L5(p,b){if(typeof b=="function")return p=p(),b(p),function(){b(null)};if(b!=null)return p=p(),b.current=p,function(){b.current=null}}function F5(p,b,E){return E=E!=null?E.concat([p]):null,Cg(4,4,L5.bind(null,b,p),E)}function Ow(){}function $5(p,b){var E=No();b=b===void 0?null:b;var z=E.memoizedState;return z!==null&&b!==null&&zw(b,z[1])?z[0]:(E.memoizedState=[p,b],p)}function U5(p,b){var E=No();b=b===void 0?null:b;var z=E.memoizedState;return z!==null&&b!==null&&zw(b,z[1])?z[0]:(p=p(),E.memoizedState=[p,b],p)}function V5(p,b,E){return(iu&21)===0?(p.baseState&&(p.baseState=!1,Bs=!0),p.memoizedState=E):(qo(E,b)||(E=At(),Qr.lanes|=E,su|=E,p.baseState=!0),b)}function F7(p,b){var E=K;K=E!==0&&4>E?E:4,p(!0);var z=Tw.transition;Tw.transition={};try{p(!1),b()}finally{K=E,Tw.transition=z}}function H5(){return No().memoizedState}function $7(p,b,E){var z=ic(p);if(E={lane:z,action:E,hasEagerState:!1,eagerState:null,next:null},G5(p))W5(b,E);else if(E=k5(p,b,E,z),E!==null){var G=xs();Zo(E,p,z,G),q5(E,b,z)}}function U7(p,b,E){var z=ic(p),G={lane:z,action:E,hasEagerState:!1,eagerState:null,next:null};if(G5(p))W5(b,G);else{var X=p.alternate;if(p.lanes===0&&(X===null||X.lanes===0)&&(X=b.lastRenderedReducer,X!==null))try{var me=b.lastRenderedState,Pe=X(me,E);if(G.hasEagerState=!0,G.eagerState=Pe,qo(Pe,me)){var $e=b.interleaved;$e===null?(G.next=G,Cw(b)):(G.next=$e.next,$e.next=G),b.interleaved=G;return}}catch{}finally{}E=k5(p,b,G,z),E!==null&&(G=xs(),Zo(E,p,z,G),q5(E,b,z))}}function G5(p){var b=p.alternate;return p===Qr||b!==null&&b===Qr}function W5(p,b){xp=kg=!0;var E=p.pending;E===null?b.next=b:(b.next=E.next,E.next=b),p.pending=b}function q5(p,b,E){if((E&4194240)!==0){var z=b.lanes;z&=p.pendingLanes,E|=z,b.lanes=E,ae(p,E)}}var _g={readContext:Eo,useCallback:ss,useContext:ss,useEffect:ss,useImperativeHandle:ss,useInsertionEffect:ss,useLayoutEffect:ss,useMemo:ss,useReducer:ss,useRef:ss,useState:ss,useDebugValue:ss,useDeferredValue:ss,useTransition:ss,useMutableSource:ss,useSyncExternalStore:ss,useId:ss,unstable_isNewReconciler:!1},V7={readContext:Eo,useCallback:function(p,b){return Ta().memoizedState=[p,b===void 0?null:b],p},useContext:Eo,useEffect:R5,useImperativeHandle:function(p,b,E){return E=E!=null?E.concat([p]):null,Sg(4194308,4,L5.bind(null,b,p),E)},useLayoutEffect:function(p,b){return Sg(4194308,4,p,b)},useInsertionEffect:function(p,b){return Sg(4,2,p,b)},useMemo:function(p,b){var E=Ta();return b=b===void 0?null:b,p=p(),E.memoizedState=[p,b],p},useReducer:function(p,b,E){var z=Ta();return b=E!==void 0?E(b):b,z.memoizedState=z.baseState=b,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:p,lastRenderedState:b},z.queue=p,p=p.dispatch=$7.bind(null,Qr,p),[z.memoizedState,p]},useRef:function(p){var b=Ta();return p={current:p},b.memoizedState=p},useState:M5,useDebugValue:Ow,useDeferredValue:function(p){return Ta().memoizedState=p},useTransition:function(){var p=M5(!1),b=p[0];return p=F7.bind(null,p[1]),Ta().memoizedState=p,[b,p]},useMutableSource:function(){},useSyncExternalStore:function(p,b,E){var z=Qr,G=Ta();if(Hr){if(E===void 0)throw Error(n(407));E=E()}else{if(E=b(),Bi===null)throw Error(n(349));(iu&30)!==0||j5(z,b,E)}G.memoizedState=E;var X={value:E,getSnapshot:b};return G.queue=X,R5(z5.bind(null,z,X,p),[p]),z.flags|=2048,Sp(9,T5.bind(null,z,X,E,b),void 0,null),E},useId:function(){var p=Ta(),b=Bi.identifierPrefix;if(Hr){var E=pl,z=hl;E=(z&~(1<<32-Kr(z)-1)).toString(32)+E,b=":"+b+"R"+E,E=wp++,0<E&&(b+="H"+E.toString(32)),b+=":"}else E=L7++,b=":"+b+"r"+E.toString(32)+":";return p.memoizedState=b},unstable_isNewReconciler:!1},H7={readContext:Eo,useCallback:$5,useContext:Eo,useEffect:Rw,useImperativeHandle:F5,useInsertionEffect:O5,useLayoutEffect:D5,useMemo:U5,useReducer:Mw,useRef:B5,useState:function(){return Mw(kp)},useDebugValue:Ow,useDeferredValue:function(p){var b=No();return V5(b,Ii.memoizedState,p)},useTransition:function(){var p=Mw(kp)[0],b=No().memoizedState;return[p,b]},useMutableSource:N5,useSyncExternalStore:I5,useId:H5,unstable_isNewReconciler:!1},G7={readContext:Eo,useCallback:$5,useContext:Eo,useEffect:Rw,useImperativeHandle:F5,useInsertionEffect:O5,useLayoutEffect:D5,useMemo:U5,useReducer:Bw,useRef:B5,useState:function(){return Bw(kp)},useDebugValue:Ow,useDeferredValue:function(p){var b=No();return Ii===null?b.memoizedState=p:V5(b,Ii.memoizedState,p)},useTransition:function(){var p=Bw(kp)[0],b=No().memoizedState;return[p,b]},useMutableSource:N5,useSyncExternalStore:I5,useId:H5,unstable_isNewReconciler:!1};function Yo(p,b){if(p&&p.defaultProps){b=B({},b),p=p.defaultProps;for(var E in p)b[E]===void 0&&(b[E]=p[E]);return b}return b}function Dw(p,b,E,z){b=p.memoizedState,E=E(z,b),E=E==null?b:B({},b,E),p.memoizedState=E,p.lanes===0&&(p.updateQueue.baseState=E)}var Eg={isMounted:function(p){return(p=p._reactInternals)?ct(p)===p:!1},enqueueSetState:function(p,b,E){p=p._reactInternals;var z=xs(),G=ic(p),X=gl(z,G);X.payload=b,E!=null&&(X.callback=E),b=ec(p,X,G),b!==null&&(Zo(b,p,G,z),yg(b,p,G))},enqueueReplaceState:function(p,b,E){p=p._reactInternals;var z=xs(),G=ic(p),X=gl(z,G);X.tag=1,X.payload=b,E!=null&&(X.callback=E),b=ec(p,X,G),b!==null&&(Zo(b,p,G,z),yg(b,p,G))},enqueueForceUpdate:function(p,b){p=p._reactInternals;var E=xs(),z=ic(p),G=gl(E,z);G.tag=2,b!=null&&(G.callback=b),b=ec(p,G,z),b!==null&&(Zo(b,p,z,E),yg(b,p,z))}};function K5(p,b,E,z,G,X,me){return p=p.stateNode,typeof p.shouldComponentUpdate=="function"?p.shouldComponentUpdate(z,X,me):b.prototype&&b.prototype.isPureReactComponent?!cp(E,z)||!cp(G,X):!0}function Y5(p,b,E){var z=!1,G=Ql,X=b.contextType;return typeof X=="object"&&X!==null?X=Eo(X):(G=Ms(b)?Jc:is.current,z=b.contextTypes,X=(z=z!=null)?Dd(p,G):Ql),b=new b(E,X),p.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=Eg,p.stateNode=b,b._reactInternals=p,z&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=G,p.__reactInternalMemoizedMaskedChildContext=X),b}function X5(p,b,E,z){p=b.state,typeof b.componentWillReceiveProps=="function"&&b.componentWillReceiveProps(E,z),typeof b.UNSAFE_componentWillReceiveProps=="function"&&b.UNSAFE_componentWillReceiveProps(E,z),b.state!==p&&Eg.enqueueReplaceState(b,b.state,null)}function Lw(p,b,E,z){var G=p.stateNode;G.props=E,G.state=p.memoizedState,G.refs={},_w(p);var X=b.contextType;typeof X=="object"&&X!==null?G.context=Eo(X):(X=Ms(b)?Jc:is.current,G.context=Dd(p,X)),G.state=p.memoizedState,X=b.getDerivedStateFromProps,typeof X=="function"&&(Dw(p,b,X,E),G.state=p.memoizedState),typeof b.getDerivedStateFromProps=="function"||typeof G.getSnapshotBeforeUpdate=="function"||typeof G.UNSAFE_componentWillMount!="function"&&typeof G.componentWillMount!="function"||(b=G.state,typeof G.componentWillMount=="function"&&G.componentWillMount(),typeof G.UNSAFE_componentWillMount=="function"&&G.UNSAFE_componentWillMount(),b!==G.state&&Eg.enqueueReplaceState(G,G.state,null),vg(p,E,G,z),G.state=p.memoizedState),typeof G.componentDidMount=="function"&&(p.flags|=4194308)}function Wd(p,b){try{var E="",z=b;do E+=ie(z),z=z.return;while(z);var G=E}catch(X){G=` 40Error generating stack: `+X.message+` 41`+X.stack}return{value:p,source:b,stack:G,digest:null}}function Fw(p,b,E){return{value:p,source:null,stack:E??null,digest:b??null}}function $w(p,b){try{console.error(b.value)}catch(E){setTimeout(function(){throw E})}}var W7=typeof WeakMap=="function"?WeakMap:Map;function Q5(p,b,E){E=gl(-1,E),E.tag=3,E.payload={element:null};var z=b.value;return E.callback=function(){Ag||(Ag=!0,n1=z),$w(p,b)},E}function Z5(p,b,E){E=gl(-1,E),E.tag=3;var z=p.type.getDerivedStateFromError;if(typeof z=="function"){var G=b.value;E.payload=function(){return z(G)},E.callback=function(){$w(p,b)}}var X=p.stateNode;return X!==null&&typeof X.componentDidCatch=="function"&&(E.callback=function(){$w(p,b),typeof z!="function"&&(nc===null?nc=new Set([this]):nc.add(this));var me=b.stack;this.componentDidCatch(b.value,{componentStack:me!==null?me:""})}),E}function J5(p,b,E){var z=p.pingCache;if(z===null){z=p.pingCache=new W7;var G=new Set;z.set(b,G)}else G=z.get(b),G===void 0&&(G=new Set,z.set(b,G));G.has(E)||(G.add(E),p=o$.bind(null,p,b,E),b.then(p,p))}function eI(p){do{var b;
vendor: 43,460 bytes, line 41
41if((b=p.tag===13)&&(b=p.memoizedState,b=b!==null?b.dehydrated!==null:!0),b)return p;p=p.return}while(p!==null);return null}function tI(p,b,E,z,G){return(p.mode&1)===0?(p===b?p.flags|=65536:(p.flags|=128,E.flags|=131072,E.flags&=-52805,E.tag===1&&(E.alternate===null?E.tag=17:(b=gl(-1,1),b.tag=2,ec(E,b,1))),E.lanes|=1),p):(p.flags|=65536,p.lanes=G,p)}var q7=k.ReactCurrentOwner,Bs=!1;function vs(p,b,E,z){b.child=p===null?w5(b,null,E,z):Ud(b,p.child,E,z)}function nI(p,b,E,z,G){E=E.render;var X=b.ref;return Hd(b,G),z=Pw(p,b,E,z,X,G),E=Aw(),p!==null&&!Bs?(b.updateQueue=p.updateQueue,b.flags&=-2053,p.lanes&=~G,bl(p,b,G)):(Hr&&E&&mw(b),b.flags|=1,vs(p,b,z,G),b.child)}function rI(p,b,E,z,G){if(p===null){var X=E.type;return typeof X=="function"&&!c1(X)&&X.defaultProps===void 0&&E.compare===null&&E.defaultProps===void 0?(b.tag=15,b.type=X,iI(p,b,X,z,G)):(p=Lg(E.type,null,z,b,b.mode,G),p.ref=b.ref,p.return=b,b.child=p)}if(X=p.child,(p.lanes&G)===0){var me=X.memoizedProps;if(E=E.compare,E=E!==null?E:cp,E(me,z)&&p.ref===b.ref)return bl(p,b,G)}return b.flags|=1,p=oc(X,z),p.ref=b.ref,p.return=b,b.child=p}function iI(p,b,E,z,G){if(p!==null){var X=p.memoizedProps;if(cp(X,z)&&p.ref===b.ref)if(Bs=!1,b.pendingProps=z=X,(p.lanes&G)!==0)(p.flags&131072)!==0&&(Bs=!0);else return b.lanes=p.lanes,bl(p,b,G)}return Uw(p,b,E,z,G)}function sI(p,b,E){var z=b.pendingProps,G=z.children,X=p!==null?p.memoizedState:null;if(z.mode==="hidden")if((b.mode&1)===0)b.memoizedState={baseLanes:0,cachePool:null,transitions:null},kr(Kd,no),no|=E;else{if((E&1073741824)===0)return p=X!==null?X.baseLanes|E:E,b.lanes=b.childLanes=1073741824,b.memoizedState={baseLanes:p,cachePool:null,transitions:null},b.updateQueue=null,kr(Kd,no),no|=p,null;b.memoizedState={baseLanes:0,cachePool:null,transitions:null},z=X!==null?X.baseLanes:E,kr(Kd,no),no|=z}else X!==null?(z=X.baseLanes|E,b.memoizedState=null):z=E,kr(Kd,no),no|=z;return vs(p,b,G,E),b.child}function oI(p,b){var E=b.ref;(p===null&&E!==null||p!==null&&p.ref!==E)&&(b.flags|=512,b.flags|=2097152)}function Uw(p,b,E,z,G){var X=Ms(E)?Jc:is.current;return X=Dd(b,X),Hd(b,G),E=Pw(p,b,E,z,X,G),z=Aw(),p!==null&&!Bs?(b.updateQueue=p.updateQueue,b.flags&=-2053,p.lanes&=~G,bl(p,b,G)):(Hr&&z&&mw(b),b.flags|=1,vs(p,b,E,G),b.child)}function aI(p,b,E,z,G){if(Ms(E)){var X=!0;ug(b)}else X=!1;if(Hd(b,G),b.stateNode===null)Ig(p,b),Y5(b,E,z),Lw(b,E,z,G),z=!0;else if(p===null){var me=b.stateNode,Pe=b.memoizedProps;me.props=Pe;var $e=me.context,lt=E.contextType;typeof lt=="object"&<!==null?lt=Eo(lt):(lt=Ms(E)?Jc:is.current,lt=Dd(b,lt));var Pt=E.getDerivedStateFromProps,Bt=typeof Pt=="function"||typeof me.getSnapshotBeforeUpdate=="function";Bt||typeof me.UNSAFE_componentWillReceiveProps!="function"&&typeof me.componentWillReceiveProps!="function"||(Pe!==z||$e!==lt)&&X5(b,me,z,lt),Jl=!1;var jt=b.memoizedState;me.state=jt,vg(b,z,me,G),$e=b.memoizedState,Pe!==z||jt!==$e||As.current||Jl?(typeof Pt=="function"&&(Dw(b,E,Pt,z),$e=b.memoizedState),(Pe=Jl||K5(b,E,Pe,z,jt,$e,lt))?(Bt||typeof me.UNSAFE_componentWillMount!="function"&&typeof me.componentWillMount!="function"||(typeof me.componentWillMount=="function"&&me.componentWillMount(),typeof me.UNSAFE_componentWillMount=="function"&&me.UNSAFE_componentWillMount()),typeof me.componentDidMount=="function"&&(b.flags|=4194308)):(typeof me.componentDidMount=="function"&&(b.flags|=4194308),b.memoizedProps=z,b.memoizedState=$e),me.props=z,me.state=$e,me.context=lt,z=Pe):(typeof me.componentDidMount=="function"&&(b.flags|=4194308),z=!1)}else{me=b.stateNode,S5(p,b),Pe=b.memoizedProps,lt=b.type===b.elementType?Pe:Yo(b.type,Pe),me.props=lt,Bt=b.pendingProps,jt=me.context,$e=E.contextType,typeof $e=="object"&&$e!==null?$e=Eo($e):($e=Ms(E)?Jc:is.current,$e=Dd(b,$e));var en=E.getDerivedStateFromProps;(Pt=typeof en=="function"||typeof me.getSnapshotBeforeUpdate=="function")||typeof me.UNSAFE_componentWillReceiveProps!="function"&&typeof me.componentWillReceiveProps!="function"||(Pe!==Bt||jt!==$e)&&X5(b,me,z,$e),Jl=!1,jt=b.memoizedState,me.state=jt,vg(b,z,me,G);var an=b.memoizedState;Pe!==Bt||jt!==an||As.current||Jl?(typeof en=="function"&&(Dw(b,E,en,z),an=b.memoizedState),(lt=Jl||K5(b,E,lt,z,jt,an,$e)||!1)?(Pt||typeof me.UNSAFE_componentWillUpdate!="function"&&typeof me.componentWillUpdate!="function"||(typeof me.componentWillUpdate=="function"&&me.componentWillUpdate(z,an,$e),typeof me.UNSAFE_componentWillUpdate=="function"&&me.UNSAFE_componentWillUpdate(z,an,$e)),typeof me.componentDidUpdate=="function"&&(b.flags|=4),typeof me.getSnapshotBeforeUpdate=="function"&&(b.flags|=1024)):(typeof me.componentDidUpdate!="function"||Pe===p.memoizedProps&&jt===p.memoizedState||(b.flags|=4),typeof me.getSnapshotBeforeUpdate!="function"||Pe===p.memoizedProps&&jt===p.memoizedState||(b.flags|=1024),b.memoizedProps=z,b.memoizedState=an),me.props=z,me.state=an,me.context=$e,z=lt):(typeof me.componentDidUpdate!="function"||Pe===p.memoizedProps&&jt===p.memoizedState||(b.flags|=4),typeof me.getSnapshotBeforeUpdate!="function"||Pe===p.memoizedProps&&jt===p.memoizedState||(b.flags|=1024),z=!1)}return Vw(p,b,E,z,X,G)}function Vw(p,b,E,z,G,X){oI(p,b);var me=(b.flags&128)!==0;if(!z&&!me)return G&&f5(b,E,!1),bl(p,b,X);z=b.stateNode,q7.current=b;var Pe=me&&typeof E.getDerivedStateFromError!="function"?null:z.render();return b.flags|=1,p!==null&&me?(b.child=Ud(b,p.child,null,X),b.child=Ud(b,null,Pe,X)):vs(p,b,Pe,X),b.memoizedState=z.state,G&&f5(b,E,!0),b.child}function lI(p){var b=p.stateNode;b.pendingContext?u5(p,b.pendingContext,b.pendingContext!==b.context):b.context&&u5(p,b.context,!1),Ew(p,b.containerInfo)}function cI(p,b,E,z,G){return $d(),vw(G),b.flags|=256,vs(p,b,E,z),b.child}var Hw={dehydrated:null,treeContext:null,retryLane:0};function Gw(p){return{baseLanes:p,cachePool:null,transitions:null}}function uI(p,b,E){var z=b.pendingProps,G=Xr.current,X=!1,me=(b.flags&128)!==0,Pe;if((Pe=me)||(Pe=p!==null&&p.memoizedState===null?!1:(G&2)!==0),Pe?(X=!0,b.flags&=-129):(p===null||p.memoizedState!==null)&&(G|=1),kr(Xr,G&1),p===null)return yw(b),p=b.memoizedState,p!==null&&(p=p.dehydrated,p!==null)?((b.mode&1)===0?b.lanes=1:p.data==="$!"?b.lanes=8:b.lanes=1073741824,null):(me=z.children,p=z.fallback,X?(z=b.mode,X=b.child,me={mode:"hidden",children:me},(z&1)===0&&X!==null?(X.childLanes=0,X.pendingProps=me):X=Fg(me,z,0,null),p=cu(p,z,E,null),X.return=b,p.return=b,X.sibling=p,b.child=X,b.child.memoizedState=Gw(E),b.memoizedState=Hw,p):Ww(b,me));if(G=p.memoizedState,G!==null&&(Pe=G.dehydrated,Pe!==null))return K7(p,b,me,z,Pe,G,E);if(X){X=z.fallback,me=b.mode,G=p.child,Pe=G.sibling;var $e={mode:"hidden",children:z.children};return(me&1)===0&&b.child!==G?(z=b.child,z.childLanes=0,z.pendingProps=$e,b.deletions=null):(z=oc(G,$e),z.subtreeFlags=G.subtreeFlags&14680064),Pe!==null?X=oc(Pe,X):(X=cu(X,me,E,null),X.flags|=2),X.return=b,z.return=b,z.sibling=X,b.child=z,z=X,X=b.child,me=p.child.memoizedState,me=me===null?Gw(E):{baseLanes:me.baseLanes|E,cachePool:null,transitions:me.transitions},X.memoizedState=me,X.childLanes=p.childLanes&~E,b.memoizedState=Hw,z}return X=p.child,p=X.sibling,z=oc(X,{mode:"visible",children:z.children}),(b.mode&1)===0&&(z.lanes=E),z.return=b,z.sibling=null,p!==null&&(E=b.deletions,E===null?(b.deletions=[p],b.flags|=16):E.push(p)),b.child=z,b.memoizedState=null,z}function Ww(p,b){return b=Fg({mode:"visible",children:b},p.mode,0,null),b.return=p,p.child=b}function Ng(p,b,E,z){return z!==null&&vw(z),Ud(b,p.child,null,E),p=Ww(b,b.pendingProps.children),p.flags|=2,b.memoizedState=null,p}function K7(p,b,E,z,G,X,me){if(E)return b.flags&256?(b.flags&=-257,z=Fw(Error(n(422))),Ng(p,b,me,z)):b.memoizedState!==null?(b.child=p.child,b.flags|=128,null):(X=z.fallback,G=b.mode,z=Fg({mode:"visible",children:z.children},G,0,null),X=cu(X,G,me,null),X.flags|=2,z.return=b,X.return=b,z.sibling=X,b.child=z,(b.mode&1)!==0&&Ud(b,p.child,null,me),b.child.memoizedState=Gw(me),b.memoizedState=Hw,X);if((b.mode&1)===0)return Ng(p,b,me,null);if(G.data==="$!"){if(z=G.nextSibling&&G.nextSibling.dataset,z)var Pe=z.dgst;return z=Pe,X=Error(n(419)),z=Fw(X,z,void 0),Ng(p,b,me,z)}if(Pe=(me&p.childLanes)!==0,Bs||Pe){if(z=Bi,z!==null){switch(me&-me){case 4:G=2;break;case 16:G=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:G=32;break;case 536870912:G=268435456;break;default:G=0}G=(G&(z.suspendedLanes|me))!==0?0:G,G!==0&&G!==X.retryLane&&(X.retryLane=G,ml(p,G),Zo(z,p,G,-1))}return l1(),z=Fw(Error(n(421))),Ng(p,b,me,z)}return G.data==="$?"?(b.flags|=128,b.child=p.child,b=a$.bind(null,p),G._reactRetry=b,null):(p=X.treeContext,to=Yl(G.nextSibling),eo=b,Hr=!0,Ko=null,p!==null&&(Co[_o++]=hl,Co[_o++]=pl,Co[_o++]=eu,hl=p.id,pl=p.overflow,eu=b),b=Ww(b,z.children),b.flags|=4096,b)}function dI(p,b,E){p.lanes|=b;var z=p.alternate;z!==null&&(z.lanes|=b),Sw(p.return,b,E)}function qw(p,b,E,z,G){var X=p.memoizedState;X===null?p.memoizedState={isBackwards:b,rendering:null,renderingStartTime:0,last:z,tail:E,tailMode:G}:(X.isBackwards=b,X.rendering=null,X.renderingStartTime=0,X.last=z,X.tail=E,X.tailMode=G)}function fI(p,b,E){var z=b.pendingProps,G=z.revealOrder,X=z.tail;if(vs(p,b,z.children,E),z=Xr.current,(z&2)!==0)z=z&1|2,b.flags|=128;else{if(p!==null&&(p.flags&128)!==0)e:for(p=b.child;p!==null;){if(p.tag===13)p.memoizedState!==null&&dI(p,E,b);else if(p.tag===19)dI(p,E,b);else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===b)break e;for(;p.sibling===null;){if(p.return===null||p.return===b)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}z&=1}if(kr(Xr,z),(b.mode&1)===0)b.memoizedState=null;else switch(G){case"forwards":for(E=b.child,G=null;E!==null;)p=E.alternate,p!==null&&xg(p)===null&&(G=E),E=E.sibling;E=G,E===null?(G=b.child,b.child=null):(G=E.sibling,E.sibling=null),qw(b,!1,G,E,X);break;case"backwards":for(E=null,G=b.child,b.child=null;G!==null;){if(p=G.alternate,p!==null&&xg(p)===null){b.child=G;break}p=G.sibling,G.sibling=E,E=G,G=p}qw(b,!0,E,null,X);break;case"together":qw(b,!1,null,null,void 0);break;default:b.memoizedState=null}return b.child}function Ig(p,b){(b.mode&1)===0&&p!==null&&(p.alternate=null,b.alternate=null,b.flags|=2)}function bl(p,b,E){if(p!==null&&(b.dependencies=p.dependencies),su|=b.lanes,(E&b.childLanes)===0)return null;if(p!==null&&b.child!==p.child)throw Error(n(153));if(b.child!==null){for(p=b.child,E=oc(p,p.pendingProps),b.child=E,E.return=b;p.sibling!==null;)p=p.sibling,E=E.sibling=oc(p,p.pendingProps),E.return=b;E.sibling=null}return b.child}function Y7(p,b,E){switch(b.tag){case 3:lI(b),$d();break;case 5:E5(b);break;case 1:Ms(b.type)&&ug(b);break;case 4:Ew(b,b.stateNode.containerInfo);break;case 10:var z=b.type._context,G=b.memoizedProps.value;kr(gg,z._currentValue),z._currentValue=G;break;case 13:if(z=b.memoizedState,z!==null)return z.dehydrated!==null?(kr(Xr,Xr.current&1),b.flags|=128,null):(E&b.child.childLanes)!==0?uI(p,b,E):(kr(Xr,Xr.current&1),p=bl(p,b,E),p!==null?p.sibling:null);kr(Xr,Xr.current&1);break;case 19:if(z=(E&b.childLanes)!==0,(p.flags&128)!==0){if(z)return fI(p,b,E);b.flags|=128}if(G=b.memoizedState,G!==null&&(G.rendering=null,G.tail=null,G.lastEffect=null),kr(Xr,Xr.current),z)break;return null;case 22:case 23:return b.lanes=0,sI(p,b,E)}return bl(p,b,E)}var hI,Kw,pI,mI;hI=function(p,b){for(var E=b.child;E!==null;){if(E.tag===5||E.tag===6)p.appendChild(E.stateNode);else if(E.tag!==4&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===b)break;for(;E.sibling===null;){if(E.return===null||E.return===b)return;E=E.return}E.sibling.return=E.return,E=E.sibling}},Kw=function(){},pI=function(p,b,E,z){var G=p.memoizedProps;if(G!==z){p=b.stateNode,ru(ja.current);var X=null;switch(E){case"input":G=O(p,G),z=O(p,z),X=[];break;case"select":G=B({},G,{value:void 0}),z=B({},z,{value:void 0}),X=[];break;case"textarea":G=Ce(p,G),z=Ce(p,z),X=[];break;default:typeof G.onClick!="function"&&typeof z.onClick=="function"&&(p.onclick=ag)}Ze(E,z);var me;E=null;for(lt in G)if(!z.hasOwnProperty(lt)&&G.hasOwnProperty(lt)&&G[lt]!=null)if(lt==="style"){var Pe=G[lt];for(me in Pe)Pe.hasOwnProperty(me)&&(E||(E={}),E[me]="")}else lt!=="dangerouslySetInnerHTML"&<!=="children"&<!=="suppressContentEditableWarning"&<!=="suppressHydrationWarning"&<!=="autoFocus"&&(i.hasOwnProperty(lt)?X||(X=[]):(X=X||[]).push(lt,null));for(lt in z){var $e=z[lt];if(Pe=G!=null?G[lt]:void 0,z.hasOwnProperty(lt)&&$e!==Pe&&($e!=null||Pe!=null))if(lt==="style")if(Pe){for(me in Pe)!Pe.hasOwnProperty(me)||$e&&$e.hasOwnProperty(me)||(E||(E={}),E[me]="");for(me in $e)$e.hasOwnProperty(me)&&Pe[me]!==$e[me]&&(E||(E={}),E[me]=$e[me])}else E||(X||(X=[]),X.push(lt,E)),E=$e;else lt==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,Pe=Pe?Pe.__html:void 0,$e!=null&&Pe!==$e&&(X=X||[]).push(lt,$e)):lt==="children"?typeof $e!="string"&&typeof $e!="number"||(X=X||[]).push(lt,""+$e):lt!=="suppressContentEditableWarning"&<!=="suppressHydrationWarning"&&(i.hasOwnProperty(lt)?($e!=null&<==="onScroll"&&Or("scroll",p),X||Pe===$e||(X=[])):(X=X||[]).push(lt,$e))}E&&(X=X||[]).push("style",E);var lt=X;(b.updateQueue=lt)&&(b.flags|=4)}},mI=function(p,b,E,z){E!==z&&(b.flags|=4)};function Cp(p,b){if(!Hr)switch(p.tailMode){case"hidden":b=p.tail;for(var E=null;b!==null;)b.alternate!==null&&(E=b),b=b.sibling;E===null?p.tail=null:E.sibling=null;break;case"collapsed":E=p.tail;for(var z=null;E!==null;)E.alternate!==null&&(z=E),E=E.sibling;z===null?b||p.tail===null?p.tail=null:p.tail.sibling=null:z.sibling=null}}function os(p){var b=p.alternate!==null&&p.alternate.child===p.child,E=0,z=0;if(b)for(var G=p.child;G!==null;)E|=G.lanes|G.childLanes,z|=G.subtreeFlags&14680064,z|=G.flags&14680064,G.return=p,G=G.sibling;else for(G=p.child;G!==null;)E|=G.lanes|G.childLanes,z|=G.subtreeFlags,z|=G.flags,G.return=p,G=G.sibling;return p.subtreeFlags|=z,p.childLanes=E,b}function X7(p,b,E){var z=b.pendingProps;switch(gw(b),b.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return os(b),null;case 1:return Ms(b.type)&&cg(),os(b),null;case 3:return z=b.stateNode,Gd(),Dr(As),Dr(is),jw(),z.pendingContext&&(z.context=z.pendingContext,z.pendingContext=null),(p===null||p.child===null)&&(pg(b)?b.flags|=4:p===null||p.memoizedState.isDehydrated&&(b.flags&256)===0||(b.flags|=1024,Ko!==null&&(s1(Ko),Ko=null))),Kw(p,b),os(b),null;case 5:Nw(b);var G=ru(vp.current);if(E=b.type,p!==null&&b.stateNode!=null)pI(p,b,E,z,G),p.ref!==b.ref&&(b.flags|=512,b.flags|=2097152);else{if(!z){if(b.stateNode===null)throw Error(n(166));return os(b),null}if(p=ru(ja.current),pg(b)){z=b.stateNode,E=b.type;var X=b.memoizedProps;switch(z[Ia]=b,z[pp]=X,p=(b.mode&1)!==0,E){case"dialog":Or("cancel",z),Or("close",z);break;case"iframe":case"object":case"embed":Or("load",z);break;case"video":case"audio":for(G=0;G<dp.length;G++)Or(dp[G],z);break;case"source":Or("error",z);break;case"img":case"image":case"link":Or("error",z),Or("load",z);break;case"details":Or("toggle",z);break;case"input":pe(z,X),Or("invalid",z);break;case"select":z._wrapperState={wasMultiple:!!X.multiple},Or("invalid",z);break;case"textarea":Ae(z,X),Or("invalid",z)}Ze(E,X),G=null;for(var me in X)if(X.hasOwnProperty(me)){var Pe=X[me];me==="children"?typeof Pe=="string"?z.textContent!==Pe&&(X.suppressHydrationWarning!==!0&&og(z.textContent,Pe,p),G=["children",Pe]):typeof Pe=="number"&&z.textContent!==""+Pe&&(X.suppressHydrationWarning!==!0&&og(z.textContent,Pe,p),G=["children",""+Pe]):i.hasOwnProperty(me)&&Pe!=null&&me==="onScroll"&&Or("scroll",z)}switch(E){case"input":we(z),oe(z,X,!0);break;case"textarea":we(z),Se(z);break;case"select":case"option":break;default:typeof X.onClick=="function"&&(z.onclick=ag)}z=G,b.updateQueue=z,z!==null&&(b.flags|=4)}else{me=G.nodeType===9?G:G.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=ve(E)),p==="http://www.w3.org/1999/xhtml"?E==="script"?(p=me.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof z.is=="string"?p=me.createElement(E,{is:z.is}):(p=me.createElement(E),E==="select"&&(me=p,z.multiple?me.multiple=!0:z.size&&(me.size=z.size))):p=me.createElementNS(p,E),p[Ia]=b,p[pp]=z,hI(p,b,!1,!1),b.stateNode=p;e:{switch(me=_t(E,z),E){case"dialog":Or("cancel",p),Or("close",p),G=z;break;case"iframe":case"object":case"embed":Or("load",p),G=z;break;case"video":case"audio":for(G=0;G<dp.length;G++)Or(dp[G],p);G=z;break;case"source":Or("error",p),G=z;break;case"img":case"image":case"link":Or("error",p),Or("load",p),G=z;break;case"details":Or("toggle",p),G=z;break;case"input":pe(p,z),G=O(p,z),Or("invalid",p);break;case"option":G=z;break;case"select":p._wrapperState={wasMultiple:!!z.multiple},G=B({},z,{value:void 0}),Or("invalid",p);break;case"textarea":Ae(p,z),G=Ce(p,z),Or("invalid",p);break;default:G=z}Ze(E,G),Pe=G;for(X in Pe)if(Pe.hasOwnProperty(X)){var $e=Pe[X];X==="style"?qe(p,$e):X==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,$e!=null&&ce(p,$e)):X==="children"?typeof $e=="string"?(E!=="textarea"||$e!=="")&&se(p,$e):typeof $e=="number"&&se(p,""+$e):X!=="suppressContentEditableWarning"&&X!=="suppressHydrationWarning"&&X!=="autoFocus"&&(i.hasOwnProperty(X)?$e!=null&&X==="onScroll"&&Or("scroll",p):$e!=null&&C(p,X,$e,me))}switch(E){case"input":we(p),oe(p,z,!1);break;case"textarea":we(p),Se(p);break;case"option":z.value!=null&&p.setAttribute("value",""+Y(z.value));break;case"select":p.multiple=!!z.multiple,X=z.value,X!=null?Ne(p,!!z.multiple,X,!1):z.defaultValue!=null&&Ne(p,!!z.multiple,z.defaultValue,!0);break;default:typeof G.onClick=="function"&&(p.onclick=ag)}switch(E){case"button":case"input":case"select":case"textarea":z=!!z.autoFocus;break e;case"img":z=!0;break e;default:z=!1}}z&&(b.flags|=4)}b.ref!==null&&(b.flags|=512,b.flags|=2097152)}return os(b),null;case 6:if(p&&b.stateNode!=null)mI(p,b,p.memoizedProps,z);else{if(typeof z!="string"&&b.stateNode===null)throw Error(n(166));if(E=ru(vp.current),ru(ja.current),pg(b)){if(z=b.stateNode,E=b.memoizedProps,z[Ia]=b,(X=z.nodeValue!==E)&&(p=eo,p!==null))switch(p.tag){case 3:og(z.nodeValue,E,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&og(z.nodeValue,E,(p.mode&1)!==0)}X&&(b.flags|=4)}else z=(E.nodeType===9?E:E.ownerDocument).createTextNode(z),z[Ia]=b,b.stateNode=z}return os(b),null;case 13:if(Dr(Xr),z=b.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(Hr&&to!==null&&(b.mode&1)!==0&&(b.flags&128)===0)y5(),$d(),b.flags|=98560,X=!1;else if(X=pg(b),z!==null&&z.dehydrated!==null){if(p===null){if(!X)throw Error(n(318));if(X=b.memoizedState,X=X!==null?X.dehydrated:null,!X)throw Error(n(317));X[Ia]=b}else $d(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;os(b),X=!1}else Ko!==null&&(s1(Ko),Ko=null),X=!0;if(!X)return b.flags&65536?b:null}return(b.flags&128)!==0?(b.lanes=E,b):(z=z!==null,z!==(p!==null&&p.memoizedState!==null)&&z&&(b.child.flags|=8192,(b.mode&1)!==0&&(p===null||(Xr.current&1)!==0?ji===0&&(ji=3):l1())),b.updateQueue!==null&&(b.flags|=4),os(b),null);case 4:return Gd(),Kw(p,b),p===null&&fp(b.stateNode.containerInfo),os(b),null;case 10:return kw(b.type._context),os(b),null;case 17:return Ms(b.type)&&cg(),os(b),null;case 19:if(Dr(Xr),X=b.memoizedState,X===null)return os(b),null;if(z=(b.flags&128)!==0,me=X.rendering,me===null)if(z)Cp(X,!1);else{if(ji!==0||p!==null&&(p.flags&128)!==0)for(p=b.child;p!==null;){if(me=xg(p),me!==null){for(b.flags|=128,Cp(X,!1),z=me.updateQueue,z!==null&&(b.updateQueue=z,b.flags|=4),b.subtreeFlags=0,z=E,E=b.child;E!==null;)X=E,p=z,X.flags&=14680066,me=X.alternate,me===null?(X.childLanes=0,X.lanes=p,X.child=null,X.subtreeFlags=0,X.memoizedProps=null,X.memoizedState=null,X.updateQueue=null,X.dependencies=null,X.stateNode=null):(X.childLanes=me.childLanes,X.lanes=me.lanes,X.child=me.child,X.subtreeFlags=0,X.deletions=null,X.memoizedProps=me.memoizedProps,X.memoizedState=me.memoizedState,X.updateQueue=me.updateQueue,X.type=me.type,p=me.dependencies,X.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),E=E.sibling;return kr(Xr,Xr.current&1|2),b.child}p=p.sibling}X.tail!==null&&on()>Yd&&(b.flags|=128,z=!0,Cp(X,!1),b.lanes=4194304)}else{if(!z)if(p=xg(me),p!==null){if(b.flags|=128,z=!0,E=p.updateQueue,E!==null&&(b.updateQueue=E,b.flags|=4),Cp(X,!0),X.tail===null&&X.tailMode==="hidden"&&!me.alternate&&!Hr)return os(b),null}else 2*on()-X.renderingStartTime>Yd&&E!==1073741824&&(b.flags|=128,z=!0,Cp(X,!1),b.lanes=4194304);X.isBackwards?(me.sibling=b.child,b.child=me):(E=X.last,E!==null?E.sibling=me:b.child=me,X.last=me)}return X.tail!==null?(b=X.tail,X.rendering=b,X.tail=b.sibling,X.renderingStartTime=on(),b.sibling=null,E=Xr.current,kr(Xr,z?E&1|2:E&1),b):(os(b),null);case 22:case 23:return a1(),z=b.memoizedState!==null,p!==null&&p.memoizedState!==null!==z&&(b.flags|=8192),z&&(b.mode&1)!==0?(no&1073741824)!==0&&(os(b),b.subtreeFlags&6&&(b.flags|=8192)):os(b),null;case 24:return null;case 25:return null}throw Error(n(156,b.tag))}function Q7(p,b){switch(gw(b),b.tag){case 1:return Ms(b.type)&&cg(),p=b.flags,p&65536?(b.flags=p&-65537|128,b):null;case 3:return Gd(),Dr(As),Dr(is),jw(),p=b.flags,(p&65536)!==0&&(p&128)===0?(b.flags=p&-65537|128,b):null;case 5:return Nw(b),null;case 13:if(Dr(Xr),p=b.memoizedState,p!==null&&p.dehydrated!==null){if(b.alternate===null)throw Error(n(340));$d()}return p=b.flags,p&65536?(b.flags=p&-65537|128,b):null;case 19:return Dr(Xr),null;case 4:return Gd(),null;case 10:return kw(b.type._context),null;case 22:case 23:return a1(),null;case 24:return null;default:return null}}var jg=!1,as=!1,Z7=typeof WeakSet=="function"?WeakSet:Set,sn=null;function qd(p,b){var E=p.ref;if(E!==null)if(typeof E=="function")try{E(null)}catch(z){ii(p,b,z)}else E.current=null}function Yw(p,b,E){try{E()}catch(z){ii(p,b,z)}}var gI=!1;function J7(p,b){if(aw=ys,p=KN(),Jx(p)){if("selectionStart"in p)var E={start:p.selectionStart,end:p.selectionEnd};else e:{E=(E=p.ownerDocument)&&E.defaultView||window;var z=E.getSelection&&E.getSelection();if(z&&z.rangeCount!==0){E=z.anchorNode;var G=z.anchorOffset,X=z.focusNode;z=z.focusOffset;try{E.nodeType,X.nodeType}catch{E=null;break e}var me=0,Pe=-1,$e=-1,lt=0,Pt=0,Bt=p,jt=null;t:for(;;){for(var en;Bt!==E||G!==0&&Bt.nodeType!==3||(Pe=me+G),Bt!==X||z!==0&&Bt.nodeType!==3||($e=me+z),Bt.nodeType===3&&(me+=Bt.nodeValue.length),(en=Bt.firstChild)!==null;)jt=Bt,Bt=en;for(;;){if(Bt===p)break t;if(jt===E&&++lt===G&&(Pe=me),jt===X&&++Pt===z&&($e=me),(en=Bt.nextSibling)!==null)break;Bt=jt,jt=Bt.parentNode}Bt=en}E=Pe===-1||$e===-1?null:{start:Pe,end:$e}}else E=null}E=E||{start:0,end:0}}else E=null;for(lw={focusedElem:p,selectionRange:E},ys=!1,sn=b;sn!==null;)if(b=sn,p=b.child,(b.subtreeFlags&1028)!==0&&p!==null)p.return=b,sn=p;else for(;sn!==null;){b=sn;try{var an=b.alternate;if((b.flags&1024)!==0)switch(b.tag){case 0:case 11:case 15:break;case 1:if(an!==null){var un=an.memoizedProps,fi=an.memoizedState,nt=b.stateNode,We=nt.getSnapshotBeforeUpdate(b.elementType===b.type?un:Yo(b.type,un),fi);nt.__reactInternalSnapshotBeforeUpdate=We}break;case 3:var st=b.stateNode.containerInfo;st.nodeType===1?st.textContent="":st.nodeType===9&&st.documentElement&&st.removeChild(st.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Vt){ii(b,b.return,Vt)}if(p=b.sibling,p!==null){p.return=b.return,sn=p;break}sn=b.return}return an=gI,gI=!1,an}function _p(p,b,E){var z=b.updateQueue;if(z=z!==null?z.lastEffect:null,z!==null){var G=z=z.next;do{if((G.tag&p)===p){var X=G.destroy;G.destroy=void 0,X!==void 0&&Yw(b,E,X)}G=G.next}while(G!==z)}}function Tg(p,b){if(b=b.updateQueue,b=b!==null?b.lastEffect:null,b!==null){var E=b=b.next;do{if((E.tag&p)===p){var z=E.create;E.destroy=z()}E=E.next}while(E!==b)}}function Xw(p){var b=p.ref;if(b!==null){var E=p.stateNode;switch(p.tag){case 5:p=E;break;default:p=E}typeof b=="function"?b(p):b.current=p}}function bI(p){var b=p.alternate;b!==null&&(p.alternate=null,bI(b)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(b=p.stateNode,b!==null&&(delete b[Ia],delete b[pp],delete b[fw],delete b[B7],delete b[R7])),p.stateNode=null,p.return=null,p.dependencies=null,p.memoizedProps=null,p.memoizedState=null,p.pendingProps=null,p.stateNode=null,p.updateQueue=null}function yI(p){return p.tag===5||p.tag===3||p.tag===4}function vI(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||yI(p.return))return null;p=p.return}for(p.sibling.return=p.return,p=p.sibling;p.tag!==5&&p.tag!==6&&p.tag!==18;){if(p.flags&2||p.child===null||p.tag===4)continue e;p.child.return=p,p=p.child}if(!(p.flags&2))return p.stateNode}}function Qw(p,b,E){var z=p.tag;if(z===5||z===6)p=p.stateNode,b?E.nodeType===8?E.parentNode.insertBefore(p,b):E.insertBefore(p,b):(E.nodeType===8?(b=E.parentNode,b.insertBefore(p,E)):(b=E,b.appendChild(p)),E=E._reactRootContainer,E!=null||b.onclick!==null||(b.onclick=ag));else if(z!==4&&(p=p.child,p!==null))for(Qw(p,b,E),p=p.sibling;p!==null;)Qw(p,b,E),p=p.sibling}function Zw(p,b,E){var z=p.tag;if(z===5||z===6)p=p.stateNode,b?E.insertBefore(p,b):E.appendChild(p);else if(z!==4&&(p=p.child,p!==null))for(Zw(p,b,E),p=p.sibling;p!==null;)Zw(p,b,E),p=p.sibling}var Wi=null,Xo=!1;function tc(p,b,E){for(E=E.child;E!==null;)xI(p,b,E),E=E.sibling}function xI(p,b,E){if(yr&&typeof yr.onCommitFiberUnmount=="function")try{yr.onCommitFiberUnmount(Rr,E)}catch{}switch(E.tag){case 5:as||qd(E,b);case 6:var z=Wi,G=Xo;Wi=null,tc(p,b,E),Wi=z,Xo=G,Wi!==null&&(Xo?(p=Wi,E=E.stateNode,p.nodeType===8?p.parentNode.removeChild(E):p.removeChild(E)):Wi.removeChild(E.stateNode));break;case 18:Wi!==null&&(Xo?(p=Wi,E=E.stateNode,p.nodeType===8?dw(p.parentNode,E):p.nodeType===1&&dw(p,E),Yr(p)):dw(Wi,E.stateNode));break;case 4:z=Wi,G=Xo,Wi=E.stateNode.containerInfo,Xo=!0,tc(p,b,E),Wi=z,Xo=G;break;case 0:case 11:case 14:case 15:if(!as&&(z=E.updateQueue,z!==null&&(z=z.lastEffect,z!==null))){G=z=z.next;do{var X=G,me=X.destroy;X=X.tag,me!==void 0&&((X&2)!==0||(X&4)!==0)&&Yw(E,b,me),G=G.next}while(G!==z)}tc(p,b,E);break;case 1:if(!as&&(qd(E,b),z=E.stateNode,typeof z.componentWillUnmount=="function"))try{z.props=E.memoizedProps,z.state=E.memoizedState,z.componentWillUnmount()}catch(Pe){ii(E,b,Pe)}tc(p,b,E);break;case 21:tc(p,b,E);break;case 22:E.mode&1?(as=(z=as)||E.memoizedState!==null,tc(p,b,E),as=z):tc(p,b,E);break;default:tc(p,b,E)}}function wI(p){var b=p.updateQueue;if(b!==null){p.updateQueue=null;var E=p.stateNode;E===null&&(E=p.stateNode=new Z7),b.forEach(function(z){var G=l$.bind(null,p,z);E.has(z)||(E.add(z),z.then(G,G))})}}function Qo(p,b){var E=b.deletions;if(E!==null)for(var z=0;z<E.length;z++){var G=E[z];try{var X=p,me=b,Pe=me;e:for(;Pe!==null;){switch(Pe.tag){case 5:Wi=Pe.stateNode,Xo=!1;break e;case 3:Wi=Pe.stateNode.containerInfo,Xo=!0;break e;case 4:Wi=Pe.stateNode.containerInfo,Xo=!0;break e}Pe=Pe.return}if(Wi===null)throw Error(n(160));xI(X,me,G),Wi=null,Xo=!1;var $e=G.alternate;$e!==null&&($e.return=null),G.return=null}catch(lt){ii(G,b,lt)}}if(b.subtreeFlags&12854)for(b=b.child;b!==null;)kI(b,p),b=b.sibling}function kI(p,b){var E=p.alternate,z=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(Qo(b,p),za(p),z&4){try{_p(3,p,p.return),Tg(3,p)}catch(un){ii(p,p.return,un)}try{_p(5,p,p.return)}catch(un){ii(p,p.return,un)}}break;case 1:Qo(b,p),za(p),z&512&&E!==null&&qd(E,E.return);break;case 5:if(Qo(b,p),za(p),z&512&&E!==null&&qd(E,E.return),p.flags&32){var G=p.stateNode;try{se(G,"")}catch(un){ii(p,p.return,un)}}if(z&4&&(G=p.stateNode,G!=null)){var X=p.memoizedProps,me=E!==null?E.memoizedProps:X,Pe=p.type,$e=p.updateQueue;if(p.updateQueue=null,$e!==null)try{Pe==="input"&&X.type==="radio"&&X.name!=null&&he(G,X),_t(Pe,me);var lt=_t(Pe,X);for(me=0;me<$e.length;me+=2){var Pt=$e[me],Bt=$e[me+1];Pt==="style"?qe(G,Bt):Pt==="dangerouslySetInnerHTML"?ce(G,Bt):Pt==="children"?se(G,Bt):C(G,Pt,Bt,lt)}switch(Pe){case"input":le(G,X);break;case"textarea":Ue(G,X);break;case"select":var jt=G._wrapperState.wasMultiple;G._wrapperState.wasMultiple=!!X.multiple;var en=X.value;en!=null?Ne(G,!!X.multiple,en,!1):jt!==!!X.multiple&&(X.defaultValue!=null?Ne(G,!!X.multiple,X.defaultValue,!0):Ne(G,!!X.multiple,X.multiple?[]:"",!1))}G[pp]=X}catch(un){ii(p,p.return,un)}}break;case 6:if(Qo(b,p),za(p),z&4){if(p.stateNode===null)throw Error(n(162));G=p.stateNode,X=p.memoizedProps;try{G.nodeValue=X}catch(un){ii(p,p.return,un)}}break;case 3:if(Qo(b,p),za(p),z&4&&E!==null&&E.memoizedState.isDehydrated)try{Yr(b.containerInfo)}catch(un){ii(p,p.return,un)}break;case 4:Qo(b,p),za(p);break;case 13:Qo(b,p),za(p),G=p.child,G.flags&8192&&(X=G.memoizedState!==null,G.stateNode.isHidden=X,!X||G.alternate!==null&&G.alternate.memoizedState!==null||(t1=on())),z&4&&wI(p);break;case 22:if(Pt=E!==null&&E.memoizedState!==null,p.mode&1?(as=(lt=as)||Pt,Qo(b,p),as=lt):Qo(b,p),za(p),z&8192){if(lt=p.memoizedState!==null,(p.stateNode.isHidden=lt)&&!Pt&&(p.mode&1)!==0)for(sn=p,Pt=p.child;Pt!==null;){for(Bt=sn=Pt;sn!==null;){switch(jt=sn,en=jt.child,jt.tag){case 0:case 11:case 14:case 15:_p(4,jt,jt.return);break;case 1:qd(jt,jt.return);var an=jt.stateNode;if(typeof an.componentWillUnmount=="function"){z=jt,E=jt.return;try{b=z,an.props=b.memoizedProps,an.state=b.memoizedState,an.componentWillUnmount()}catch(un){ii(z,E,un)}}break;case 5:qd(jt,jt.return);break;case 22:if(jt.memoizedState!==null){_I(Bt);continue}}en!==null?(en.return=jt,sn=en):_I(Bt)}Pt=Pt.sibling}e:for(Pt=null,Bt=p;;){if(Bt.tag===5){if(Pt===null){Pt=Bt;try{G=Bt.stateNode,lt?(X=G.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none"):(Pe=Bt.stateNode,$e=Bt.memoizedProps.style,me=$e!=null&&$e.hasOwnProperty("display")?$e.display:null,Pe.style.display=ze("display",me))}catch(un){ii(p,p.return,un)}}}else if(Bt.tag===6){if(Pt===null)try{Bt.stateNode.nodeValue=lt?"":Bt.memoizedProps}catch(un){ii(p,p.return,un)}}else if((Bt.tag!==22&&Bt.tag!==23||Bt.memoizedState===null||Bt===p)&&Bt.child!==null){Bt.child.return=Bt,Bt=Bt.child;continue}if(Bt===p)break e;for(;Bt.sibling===null;){if(Bt.return===null||Bt.return===p)break e;Pt===Bt&&(Pt=null),Bt=Bt.return}Pt===Bt&&(Pt=null),Bt.sibling.return=Bt.return,Bt=Bt.sibling}}break;case 19:Qo(b,p),za(p),z&4&&wI(p);break;case 21:break;default:Qo(b,p),za(p)}}function za(p){var b=p.flags;if(b&2){try{e:{for(var E=p.return;E!==null;){if(yI(E)){var z=E;break e}E=E.return}throw Error(n(160))}switch(z.tag){case 5:var G=z.stateNode;z.flags&32&&(se(G,""),z.flags&=-33);var X=vI(p);Zw(p,X,G);break;case 3:case 4:var me=z.stateNode.containerInfo,Pe=vI(p);Qw(p,Pe,me);break;default:throw Error(n(161))}}catch($e){ii(p,p.return,$e)}p.flags&=-3}b&4096&&(p.flags&=-4097)}function e$(p,b,E){sn=p,SI(p)}function SI(p,b,E){for(var z=(p.mode&1)!==0;sn!==null;){var G=sn,X=G.child;if(G.tag===22&&z){var me=G.memoizedState!==null||jg;if(!me){var Pe=G.alternate,$e=Pe!==null&&Pe.memoizedState!==null||as;Pe=jg;var lt=as;if(jg=me,(as=$e)&&!lt)for(sn=G;sn!==null;)me=sn,$e=me.child,me.tag===22&&me.memoizedState!==null?EI(G):$e!==null?($e.return=me,sn=$e):EI(G);for(;X!==null;)sn=X,SI(X),X=X.sibling;sn=G,jg=Pe,as=lt}CI(p)}else(G.subtreeFlags&8772)!==0&&X!==null?(X.return=G,sn=X):CI(p)}}function CI(p){for(;sn!==null;){var b=sn;if((b.flags&8772)!==0){var E=b.alternate;try{if((b.flags&8772)!==0)switch(b.tag){case 0:case 11:case 15:as||Tg(5,b);break;case 1:var z=b.stateNode;if(b.flags&4&&!as)if(E===null)z.componentDidMount();else{var G=b.elementType===b.type?E.memoizedProps:Yo(b.type,E.memoizedProps);z.componentDidUpdate(G,E.memoizedState,z.__reactInternalSnapshotBeforeUpdate)}var X=b.updateQueue;X!==null&&_5(b,X,z);break;case 3:var me=b.updateQueue;if(me!==null){if(E=null,b.child!==null)switch(b.child.tag){case 5:E=b.child.stateNode;break;case 1:E=b.child.stateNode}_5(b,me,E)}break;case 5:var Pe=b.stateNode;if(E===null&&b.flags&4){E=Pe;var $e=b.memoizedProps;switch(b.type){case"button":case"input":case"select":case"textarea":$e.autoFocus&&E.focus();break;case"img":$e.src&&(E.src=$e.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(b.memoizedState===null){var lt=b.alternate;if(lt!==null){var Pt=lt.memoizedState;if(Pt!==null){var Bt=Pt.dehydrated;Bt!==null&&Yr(Bt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}as||b.flags&512&&Xw(b)}catch(jt){ii(b,b.return,jt)}}if(b===p){sn=null;break}if(E=b.sibling,E!==null){E.return=b.return,sn=E;break}sn=b.return}}function _I(p){for(;sn!==null;){var b=sn;if(b===p){sn=null;break}var E=b.sibling;if(E!==null){E.return=b.return,sn=E;break}sn=b.return}}function EI(p){for(;sn!==null;){var b=sn;try{switch(b.tag){case 0:case 11:case 15:var E=b.return;try{Tg(4,b)}catch($e){ii(b,E,$e)}break;case 1:var z=b.stateNode;if(typeof z.componentDidMount=="function"){var G=b.return;try{z.componentDidMount()}catch($e){ii(b,G,$e)}}var X=b.return;try{Xw(b)}catch($e){ii(b,X,$e)}break;case 5:var me=b.return;try{Xw(b)}catch($e){ii(b,me,$e)}}}catch($e){ii(b,b.return,$e)}if(b===p){sn=null;break}var Pe=b.sibling;if(Pe!==null){Pe.return=b.return,sn=Pe;break}sn=b.return}}var t$=Math.ceil,zg=k.ReactCurrentDispatcher,Jw=k.ReactCurrentOwner,Io=k.ReactCurrentBatchConfig,ir=0,Bi=null,yi=null,qi=0,no=0,Kd=Xl(0),ji=0,Ep=null,su=0,Pg=0,e1=0,Np=null,Rs=null,t1=0,Yd=1/0,yl=null,Ag=!1,n1=null,nc=null,Mg=!1,rc=null,Bg=0,Ip=0,r1=null,Rg=-1,Og=0;function xs(){return(ir&6)!==0?on():Rg!==-1?Rg:Rg=on()}function ic(p){return(p.mode&1)===0?1:(ir&2)!==0&&qi!==0?qi&-qi:D7.transition!==null?(Og===0&&(Og=At()),Og):(p=K,p!==0||(p=window.event,p=p===void 0?16:ql(p.type)),p)}function Zo(p,b,E,z){if(50<Ip)throw Ip=0,r1=null,Error(n(185));Me(p,E,z),((ir&2)===0||p!==Bi)&&(p===Bi&&((ir&2)===0&&(Pg|=E),ji===4&&sc(p,qi)),Os(p,z),E===1&&ir===0&&(b.mode&1)===0&&(Yd=on()+500,dg&&Zl()))}function Os(p,b){var E=p.callbackNode;zt(p,b);var z=pt(p,p===Bi?qi:0);if(z===0)E!==null&&Bn(E),p.callbackNode=null,p.callbackPriority=0;else if(b=z&-z,p.callbackPriority!==b){if(E!=null&&Bn(E),b===1)p.tag===0?O7(II.bind(null,p)):h5(II.bind(null,p)),A7(function(){(ir&6)===0&&Zl()}),E=null;else{switch(ee(z)){case 1:E=Xn;break;case 4:E=yt;break;case 16:E=Wt;break;case 536870912:E=Un;break;default:E=Wt}E=RI(E,NI.bind(null,p))}p.callbackPriority=b,p.callbackNode=E}}function NI(p,b){if(Rg=-1,Og=0,(ir&6)!==0)throw Error(n(327));var E=p.callbackNode;if(Xd()&&p.callbackNode!==E)return null;var z=pt(p,p===Bi?qi:0);if(z===0)return null;if((z&30)!==0||(z&p.expiredLanes)!==0||b)b=Dg(p,z);else{b=z;var G=ir;ir|=2;var X=TI();(Bi!==p||qi!==b)&&(yl=null,Yd=on()+500,au(p,b));do try{i$();break}catch(Pe){jI(p,Pe)}while(!0);ww(),zg.current=X,ir=G,yi!==null?b=0:(Bi=null,qi=0,b=ji)}if(b!==0){if(b===2&&(G=Nt(p),G!==0&&(z=G,b=i1(p,G))),b===1)throw E=Ep,au(p,0),sc(p,z),Os(p,on()),E;if(b===6)sc(p,z);else{if(G=p.current.alternate,(z&30)===0&&!n$(G)&&(b=Dg(p,z),b===2&&(X=Nt(p),X!==0&&(z=X,b=i1(p,X))),b===1))throw E=Ep,au(p,0),sc(p,z),Os(p,on()),E;switch(p.finishedWork=G,p.finishedLanes=z,b){case 0:case 1:throw Error(n(345));case 2:lu(p,Rs,yl);break;case 3:if(sc(p,z),(z&130023424)===z&&(b=t1+500-on(),10<b)){if(pt(p,0)!==0)break;if(G=p.suspendedLanes,(G&z)!==z){xs(),p.pingedLanes|=p.suspendedLanes&G;break}p.timeoutHandle=uw(lu.bind(null,p,Rs,yl),b);break}lu(p,Rs,yl);break;case 4:if(sc(p,z),(z&4194240)===z)break;for(b=p.eventTimes,G=-1;0<z;){var me=31-Kr(z);X=1<<me,me=b[me],me>G&&(G=me),z&=~X}if(z=G,z=on()-z,z=(120>z?120:480>z?480:1080>z?1080:1920>z?1920:3e3>z?3e3:4320>z?4320:1960*t$(z/1960))-z,10<z){p.timeoutHandle=uw(lu.bind(null,p,Rs,yl),z);break}lu(p,Rs,yl);break;case 5:lu(p,Rs,yl);break;default:throw Error(n(329))}}}return Os(p,on()),p.callbackNode===E?NI.bind(null,p):null}function i1(p,b){var E=Np;return p.current.memoizedState.isDehydrated&&(au(p,b).flags|=256),p=Dg(p,b),p!==2&&(b=Rs,Rs=E,b!==null&&s1(b)),p}function s1(p){Rs===null?Rs=p:Rs.push.apply(Rs,p)}function n$(p){for(var b=p;;){if(b.flags&16384){var E=b.updateQueue;if(E!==null&&(E=E.stores,E!==null))for(var z=0;z<E.length;z++){var G=E[z],X=G.getSnapshot;G=G.value;try{if(!qo(X(),G))return!1}catch{return!1}}}if(E=b.child,b.subtreeFlags&16384&&E!==null)E.return=b,b=E;else{if(b===p)break;for(;b.sibling===null;){if(b.return===null||b.return===p)return!0;b=b.return}b.sibling.return=b.return,b=b.sibling}}return!0}function sc(p,b){for(b&=~e1,b&=~Pg,p.suspendedLanes|=b,p.pingedLanes&=~b,p=p.expirationTimes;0<b;){var E=31-Kr(b),z=1<<E;p[E]=-1,b&=~z}}function II(p){if((ir&6)!==0)throw Error(n(327));Xd();var b=pt(p,0);if((b&1)===0)return Os(p,on()),null;var E=Dg(p,b);if(p.tag!==0&&E===2){var z=Nt(p);z!==0&&(b=z,E=i1(p,z))}if(E===1)throw E=Ep,au(p,0),sc(p,b),Os(p,on()),E;if(E===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=b,lu(p,Rs,yl),Os(p,on()),null}function o1(p,b){var E=ir;ir|=1;try{return p(b)}finally{ir=E,ir===0&&(Yd=on()+500,dg&&Zl())}}function ou(p){rc!==null&&rc.tag===0&&(ir&6)===0&&Xd();var b=ir;ir|=1;var E=Io.transition,z=K;try{if(Io.transition=null,K=1,p)return p()}finally{K=z,Io.transition=E,ir=b,(ir&6)===0&&Zl()}}function a1(){no=Kd.current,Dr(Kd)}function au(p,b){p.finishedWork=null,p.finishedLanes=0;var E=p.timeoutHandle;if(E!==-1&&(p.timeoutHandle=-1,P7(E)),yi!==null)for(E=yi.return;E!==null;){var z=E;switch(gw(z),z.tag){case 1:z=z.type.childContextTypes,z!=null&&cg();break;case 3:Gd(),Dr(As),Dr(is),jw();break;case 5:Nw(z);break;case 4:Gd();break;case 13:Dr(Xr);break;case 19:Dr(Xr);break;case 10:kw(z.type._context);break;case 22:case 23:a1()}E=E.return}if(Bi=p,yi=p=oc(p.current,null),qi=no=b,ji=0,Ep=null,e1=Pg=su=0,Rs=Np=null,nu!==null){for(b=0;b<nu.length;b++)if(E=nu[b],z=E.interleaved,z!==null){E.interleaved=null;var G=z.next,X=E.pending;if(X!==null){var me=X.next;X.next=G,z.next=me}E.pending=z}nu=null}return p}function jI(p,b){do{var E=yi;try{if(ww(),wg.current=_g,kg){for(var z=Qr.memoizedState;z!==null;){var G=z.queue;G!==null&&(G.pending=null),z=z.next}kg=!1}if(iu=0,Mi=Ii=Qr=null,xp=!1,wp=0,Jw.current=null,E===null||E.return===null){ji=1,Ep=b,yi=null;break}e:{var X=p,me=E.return,Pe=E,$e=b;if(b=qi,Pe.flags|=32768,$e!==null&&typeof $e=="object"&&typeof $e.then=="function"){var lt=$e,Pt=Pe,Bt=Pt.tag;if((Pt.mode&1)===0&&(Bt===0||Bt===11||Bt===15)){var jt=Pt.alternate;jt?(Pt.updateQueue=jt.updateQueue,Pt.memoizedState=jt.memoizedState,Pt.lanes=jt.lanes):(Pt.updateQueue=null,Pt.memoizedState=null)}var en=eI(me);if(en!==null){en.flags&=-257,tI(en,me,Pe,X,b),en.mode&1&&J5(X,lt,b),b=en,$e=lt;var an=b.updateQueue;if(an===null){var un=new Set;un.add($e),b.updateQueue=un}else an.add($e);break e}else{if((b&1)===0){J5(X,lt,b),l1();break e}$e=Error(n(426))}}else if(Hr&&Pe.mode&1){var fi=eI(me);if(fi!==null){(fi.flags&65536)===0&&(fi.flags|=256),tI(fi,me,Pe,X,b),vw(Wd($e,Pe));break e}}X=$e=Wd($e,Pe),ji!==4&&(ji=2),Np===null?Np=[X]:Np.push(X),X=me;do{switch(X.tag){case 3:X.flags|=65536,b&=-b,X.lanes|=b;var nt=Q5(X,$e,b);C5(X,nt);break e;case 1:Pe=$e;var We=X.type,st=X.stateNode;if((X.flags&128)===0&&(typeof We.getDerivedStateFromError=="function"||st!==null&&typeof st.componentDidCatch=="function"&&(nc===null||!nc.has(st)))){X.flags|=65536,b&=-b,X.lanes|=b;var Vt=Z5(X,Pe,b);C5(X,Vt);break e}}X=X.return}while(X!==null)}PI(E)}catch(hn){b=hn,yi===E&&E!==null&&(yi=E=E.return);continue}break}while(!0)}function TI(){var p=zg.current;return zg.current=_g,p===null?_g:p}function l1(){(ji===0||ji===3||ji===2)&&(ji=4),Bi===null||(su&268435455)===0&&(Pg&268435455)===0||sc(Bi,qi)}function Dg(p,b){var E=ir;ir|=2;var z=TI();(Bi!==p||qi!==b)&&(yl=null,au(p,b));do try{r$();break}catch(G){jI(p,G)}while(!0);if(ww(),ir=E,zg.current=z,yi!==null)throw Error(n(261));return Bi=null,qi=0,ji}function r$(){for(;yi!==null;)zI(yi)}function i$(){for(;yi!==null&&!dr();)zI(yi)}function zI(p){var b=BI(p.alternate,p,no);p.memoizedProps=p.pendingProps,b===null?PI(p):yi=b,Jw.current=null}function PI(p){var b=p;do{var E=b.alternate;if(p=b.return,(b.flags&32768)===0){if(E=X7(E,b,no),E!==null){yi=E;return}}else{if(E=Q7(E,b),E!==null){E.flags&=32767,yi=E;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{ji=6,yi=null;return}}if(b=b.sibling,b!==null){yi=b;return}yi=b=p}while(b!==null);ji===0&&(ji=5)}function lu(p,b,E){var z=K,G=Io.transition;try{Io.transition=null,K=1,s$(p,b,E,z)}finally{Io.transition=G,K=z}return null}function s$(p,b,E,z){do Xd();while(rc!==null);if((ir&6)!==0)throw Error(n(327));E=p.finishedWork;var G=p.finishedLanes;if(E===null)return null;if(p.finishedWork=null,p.finishedLanes=0,E===p.current)throw Error(n(177));p.callbackNode=null,p.callbackPriority=0;var X=E.lanes|E.childLanes;if(Qe(p,X),p===Bi&&(yi=Bi=null,qi=0),(E.subtreeFlags&2064)===0&&(E.flags&2064)===0||Mg||(Mg=!0,RI(Wt,function(){return Xd(),null})),X=(E.flags&15990)!==0,(E.subtreeFlags&15990)!==0||X){X=Io.transition,Io.transition=null;var me=K;K=1;var Pe=ir;ir|=4,Jw.current=null,J7(p,E),kI(E,p),_7(lw),ys=!!aw,lw=aw=null,p.current=E,e$(E),gr(),ir=Pe,K=me,Io.transition=X}else p.current=E;if(Mg&&(Mg=!1,rc=p,Bg=G),X=p.pendingLanes,X===0&&(nc=null),Ps(E.stateNode),Os(p,on()),b!==null)for(z=p.onRecoverableError,E=0;E<b.length;E++)G=b[E],z(G.value,{componentStack:G.stack,digest:G.digest});if(Ag)throw Ag=!1,p=n1,n1=null,p;return(Bg&1)!==0&&p.tag!==0&&Xd(),X=p.pendingLanes,(X&1)!==0?p===r1?Ip++:(Ip=0,r1=p):Ip=0,Zl(),null}function Xd(){if(rc!==null){var p=ee(Bg),b=Io.transition,E=K;try{if(Io.transition=null,K=16>p?16:p,rc===null)var z=!1;else{if(p=rc,rc=null,Bg=0,(ir&6)!==0)throw Error(n(331));var G=ir;for(ir|=4,sn=p.current;sn!==null;){var X=sn,me=X.child;if((sn.flags&16)!==0){var Pe=X.deletions;if(Pe!==null){for(var $e=0;$e<Pe.length;$e++){var lt=Pe[$e];for(sn=lt;sn!==null;){var Pt=sn;switch(Pt.tag){case 0:case 11:case 15:_p(8,Pt,X)}var Bt=Pt.child;if(Bt!==null)Bt.return=Pt,sn=Bt;else for(;sn!==null;){Pt=sn;var jt=Pt.sibling,en=Pt.return;if(bI(Pt),Pt===lt){sn=null;break}if(jt!==null){jt.return=en,sn=jt;break}sn=en}}}var an=X.alternate;if(an!==null){var un=an.child;if(un!==null){an.child=null;do{var fi=un.sibling;un.sibling=null,un=fi}while(un!==null)}}sn=X}}if((X.subtreeFlags&2064)!==0&&me!==null)me.return=X,sn=me;else e:for(;sn!==null;){if(X=sn,(X.flags&2048)!==0)switch(X.tag){case 0:case 11:case 15:_p(9,X,X.return)}var nt=X.sibling;if(nt!==null){nt.return=X.return,sn=nt;break e}sn=X.return}}var We=p.current;for(sn=We;sn!==null;){me=sn;var st=me.child;if((me.subtreeFlags&2064)!==0&&st!==null)st.return=me,sn=st;else e:for(me=We;sn!==null;){if(Pe=sn,(Pe.flags&2048)!==0)try{switch(Pe.tag){case 0:case 11:case 15:Tg(9,Pe)}}catch(hn){ii(Pe,Pe.return,hn)}if(Pe===me){sn=null;break e}var Vt=Pe.sibling;if(Vt!==null){Vt.return=Pe.return,sn=Vt;break e}sn=Pe.return}}if(ir=G,Zl(),yr&&typeof yr.onPostCommitFiberRoot=="function")try{yr.onPostCommitFiberRoot(Rr,p)}catch{}z=!0}return z}finally{K=E,Io.transition=b}}return!1}function AI(p,b,E){b=Wd(E,b),b=Q5(p,b,1),p=ec(p,b,1),b=xs(),p!==null&&(Me(p,1,b),Os(p,b))}function ii(p,b,E){if(p.tag===3)AI(p,p,E);else for(;b!==null;){if(b.tag===3){AI(b,p,E);break}else if(b.tag===1){var z=b.stateNode;if(typeof b.type.getDerivedStateFromError=="function"||typeof z.componentDidCatch=="function"&&(nc===null||!nc.has(z))){p=Wd(E,p),p=Z5(b,p,1),b=ec(b,p,1),p=xs(),b!==null&&(Me(b,1,p),Os(b,p));break}}b=b.return}}function o$(p,b,E){var z=p.pingCache;z!==null&&z.delete(b),b=xs(),p.pingedLanes|=p.suspendedLanes&E,Bi===p&&(qi&E)===E&&(ji===4||ji===3&&(qi&130023424)===qi&&500>on()-t1?au(p,0):e1|=E),Os(p,b)}function MI(p,b){b===0&&((p.mode&1)===0?b=1:(b=Ge,Ge<<=1,(Ge&130023424)===0&&(Ge=4194304)));var E=xs();
vendor: 4,438 bytes, line 41
41p=ml(p,b),p!==null&&(Me(p,b,E),Os(p,E))}function a$(p){var b=p.memoizedState,E=0;b!==null&&(E=b.retryLane),MI(p,E)}function l$(p,b){var E=0;switch(p.tag){case 13:var z=p.stateNode,G=p.memoizedState;G!==null&&(E=G.retryLane);break;case 19:z=p.stateNode;break;default:throw Error(n(314))}z!==null&&z.delete(b),MI(p,E)}var BI;BI=function(p,b,E){if(p!==null)if(p.memoizedProps!==b.pendingProps||As.current)Bs=!0;else{if((p.lanes&E)===0&&(b.flags&128)===0)return Bs=!1,Y7(p,b,E);Bs=(p.flags&131072)!==0}else Bs=!1,Hr&&(b.flags&1048576)!==0&&p5(b,hg,b.index);switch(b.lanes=0,b.tag){case 2:var z=b.type;Ig(p,b),p=b.pendingProps;var G=Dd(b,is.current);Hd(b,E),G=Pw(null,b,z,p,G,E);var X=Aw();return b.flags|=1,typeof G=="object"&&G!==null&&typeof G.render=="function"&&G.$$typeof===void 0?(b.tag=1,b.memoizedState=null,b.updateQueue=null,Ms(z)?(X=!0,ug(b)):X=!1,b.memoizedState=G.state!==null&&G.state!==void 0?G.state:null,_w(b),G.updater=Eg,b.stateNode=G,G._reactInternals=b,Lw(b,z,p,E),b=Vw(null,b,z,!0,X,E)):(b.tag=0,Hr&&X&&mw(b),vs(null,b,G,E),b=b.child),b;case 16:z=b.elementType;e:{switch(Ig(p,b),p=b.pendingProps,G=z._init,z=G(z._payload),b.type=z,G=b.tag=u$(z),p=Yo(z,p),G){case 0:b=Uw(null,b,z,p,E);break e;case 1:b=aI(null,b,z,p,E);break e;case 11:b=nI(null,b,z,p,E);break e;case 14:b=rI(null,b,z,Yo(z.type,p),E);break e}throw Error(n(306,z,""))}return b;case 0:return z=b.type,G=b.pendingProps,G=b.elementType===z?G:Yo(z,G),Uw(p,b,z,G,E);case 1:return z=b.type,G=b.pendingProps,G=b.elementType===z?G:Yo(z,G),aI(p,b,z,G,E);case 3:e:{if(lI(b),p===null)throw Error(n(387));z=b.pendingProps,X=b.memoizedState,G=X.element,S5(p,b),vg(b,z,null,E);var me=b.memoizedState;if(z=me.element,X.isDehydrated)if(X={element:z,isDehydrated:!1,cache:me.cache,pendingSuspenseBoundaries:me.pendingSuspenseBoundaries,transitions:me.transitions},b.updateQueue.baseState=X,b.memoizedState=X,b.flags&256){G=Wd(Error(n(423)),b),b=cI(p,b,z,E,G);break e}else if(z!==G){G=Wd(Error(n(424)),b),b=cI(p,b,z,E,G);break e}else for(to=Yl(b.stateNode.containerInfo.firstChild),eo=b,Hr=!0,Ko=null,E=w5(b,null,z,E),b.child=E;E;)E.flags=E.flags&-3|4096,E=E.sibling;else{if($d(),z===G){b=bl(p,b,E);break e}vs(p,b,z,E)}b=b.child}return b;case 5:return E5(b),p===null&&yw(b),z=b.type,G=b.pendingProps,X=p!==null?p.memoizedProps:null,me=G.children,cw(z,G)?me=null:X!==null&&cw(z,X)&&(b.flags|=32),oI(p,b),vs(p,b,me,E),b.child;case 6:return p===null&&yw(b),null;case 13:return uI(p,b,E);case 4:return Ew(b,b.stateNode.containerInfo),z=b.pendingProps,p===null?b.child=Ud(b,null,z,E):vs(p,b,z,E),b.child;case 11:return z=b.type,G=b.pendingProps,G=b.elementType===z?G:Yo(z,G),nI(p,b,z,G,E);case 7:return vs(p,b,b.pendingProps,E),b.child;case 8:return vs(p,b,b.pendingProps.children,E),b.child;case 12:return vs(p,b,b.pendingProps.children,E),b.child;case 10:e:{if(z=b.type._context,G=b.pendingProps,X=b.memoizedProps,me=G.value,kr(gg,z._currentValue),z._currentValue=me,X!==null)if(qo(X.value,me)){if(X.children===G.children&&!As.current){b=bl(p,b,E);break e}}else for(X=b.child,X!==null&&(X.return=b);X!==null;){var Pe=X.dependencies;if(Pe!==null){me=X.child;for(var $e=Pe.firstContext;$e!==null;){if($e.context===z){if(X.tag===1){$e=gl(-1,E&-E),$e.tag=2;var lt=X.updateQueue;if(lt!==null){lt=lt.shared;var Pt=lt.pending;Pt===null?$e.next=$e:($e.next=Pt.next,Pt.next=$e),lt.pending=$e}}X.lanes|=E,$e=X.alternate,$e!==null&&($e.lanes|=E),Sw(X.return,E,b),Pe.lanes|=E;break}$e=$e.next}}else if(X.tag===10)me=X.type===b.type?null:X.child;else if(X.tag===18){if(me=X.return,me===null)throw Error(n(341));me.lanes|=E,Pe=me.alternate,Pe!==null&&(Pe.lanes|=E),Sw(me,E,b),me=X.sibling}else me=X.child;if(me!==null)me.return=X;else for(me=X;me!==null;){if(me===b){me=null;break}if(X=me.sibling,X!==null){X.return=me.return,me=X;break}me=me.return}X=me}vs(p,b,G.children,E),b=b.child}return b;case 9:return G=b.type,z=b.pendingProps.children,Hd(b,E),G=Eo(G),z=z(G),b.flags|=1,vs(p,b,z,E),b.child;case 14:return z=b.type,G=Yo(z,b.pendingProps),G=Yo(z.type,G),rI(p,b,z,G,E);case 15:return iI(p,b,b.type,b.pendingProps,E);case 17:return z=b.type,G=b.pendingProps,G=b.elementType===z?G:Yo(z,G),Ig(p,b),b.tag=1,Ms(z)?(p=!0,ug(b)):p=!1,Hd(b,E),Y5(b,z,G),Lw(b,z,G,E),Vw(null,b,z,!0,p,E);case 19:return fI(p,b,E);case 22:return sI(p,b,E)}throw Error(n(156,b.tag))};function RI(p,b){return xn(p,b)}function c$(p,b,E,z){this.tag=p,this.key=E,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 5,741 bytes, line 41
41ype=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=b,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=z,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jo(p,b,E,z){return new c$(p,b,E,z)}function c1(p){return p=p.prototype,!(!p||!p.isReactComponent)}function u$(p){if(typeof p=="function")return c1(p)?1:0;if(p!=null){if(p=p.$$typeof,p===P)return 11;if(p===R)return 14}return 2}function oc(p,b){var E=p.alternate;return E===null?(E=jo(p.tag,b,p.key,p.mode),E.elementType=p.elementType,E.type=p.type,E.stateNode=p.stateNode,E.alternate=p,p.alternate=E):(E.pendingProps=b,E.type=p.type,E.flags=0,E.subtreeFlags=0,E.deletions=null),E.flags=p.flags&14680064,E.childLanes=p.childLanes,E.lanes=p.lanes,E.child=p.child,E.memoizedProps=p.memoizedProps,E.memoizedState=p.memoizedState,E.updateQueue=p.updateQueue,b=p.dependencies,E.dependencies=b===null?null:{lanes:b.lanes,firstContext:b.firstContext},E.sibling=p.sibling,E.index=p.index,E.ref=p.ref,E}function Lg(p,b,E,z,G,X){var me=2;if(z=p,typeof p=="function")c1(p)&&(me=1);else if(typeof p=="string")me=5;else e:switch(p){case j:return cu(E.children,G,X,b);case T:me=8,G|=8;break;case M:return p=jo(12,E,b,G|2),p.elementType=M,p.lanes=X,p;case F:return p=jo(13,E,b,G),p.elementType=F,p.lanes=X,p;case I:return p=jo(19,E,b,G),p.elementType=I,p.lanes=X,p;case A:return Fg(E,G,X,b);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case V:me=10;break e;case H:me=9;break e;case P:me=11;break e;case R:me=14;break e;case U:me=16,z=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return b=jo(me,E,b,G),b.elementType=p,b.type=z,b.lanes=X,b}function cu(p,b,E,z){return p=jo(7,p,z,b),p.lanes=E,p}function Fg(p,b,E,z){return p=jo(22,p,z,b),p.elementType=A,p.lanes=E,p.stateNode={isHidden:!1},p}function u1(p,b,E){return p=jo(6,p,null,b),p.lanes=E,p}function d1(p,b,E){return b=jo(4,p.children!==null?p.children:[],p.key,b),b.lanes=E,b.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},b}function d$(p,b,E,z,G){this.tag=b,this.containerInfo=p,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zt(0),this.expirationTimes=Zt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zt(0),this.identifierPrefix=z,this.onRecoverableError=G,this.mutableSourceEagerHydrationData=null}function f1(p,b,E,z,G,X,me,Pe,$e){return p=new d$(p,b,E,Pe,$e),b===1?(b=1,X===!0&&(b|=8)):b=0,X=jo(3,null,null,b),p.current=X,X.stateNode=p,X.memoizedState={element:z,isDehydrated:E,cache:null,transitions:null,pendingSuspenseBoundaries:null},_w(X),p}function f$(p,b,E){var z=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:z==null?null:""+z,children:p,containerInfo:b,implementation:E}}function OI(p){if(!p)return Ql;p=p._reactInternals;e:{if(ct(p)!==p||p.tag!==1)throw Error(n(170));var b=p;do{switch(b.tag){case 3:b=b.stateNode.context;break e;case 1:if(Ms(b.type)){b=b.stateNode.__reactInternalMemoizedMergedChildContext;break e}}b=b.return}while(b!==null);throw Error(n(171))}if(p.tag===1){var E=p.type;if(Ms(E))return d5(p,E,b)}return b}function DI(p,b,E,z,G,X,me,Pe,$e){return p=f1(E,z,!0,p,G,X,me,Pe,$e),p.context=OI(null),E=p.current,z=xs(),G=ic(E),X=gl(z,G),X.callback=b??null,ec(E,X,G),p.current.lanes=G,Me(p,G,z),Os(p,z),p}function $g(p,b,E,z){var G=b.current,X=xs(),me=ic(G);return E=OI(E),b.context===null?b.context=E:b.pendingContext=E,b=gl(X,me),b.payload={element:p},z=z===void 0?null:z,z!==null&&(b.callback=z),p=ec(G,b,me),p!==null&&(Zo(p,G,me,X),yg(p,G,me)),me}function Ug(p){if(p=p.current,!p.child)return null;switch(p.child.tag){case 5:return p.child.stateNode;default:return p.child.stateNode}}function LI(p,b){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var E=p.retryLane;p.retryLane=E!==0&&E<b?E:b}}function h1(p,b){LI(p,b),(p=p.alternate)&&LI(p,b)}function h$(){return null}var FI=typeof reportError=="function"?reportError:function(p){console.error(p)};function p1(p){this._internalRoot=p}Vg.prototype.render=p1.prototype.render=function(p){var b=this._internalRoot;if(b===null)throw Error(n(409));$g(p,b,null,null)},Vg.prototype.unmount=p1.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var b=p.containerInfo;ou(function(){$g(null,p,null,null)}),b[dl]=null}};function Vg(p){this._internalRoot=p}Vg.prototype.unstable_scheduleHydration=function(p){if(p){var b=Ke();p={blockedOn:null,target:p,priority:b};for(var E=0;E<Ht.length&&b!==0&&b<Ht[E].priority;E++);Ht.splice(E,0,p),E===0&&ri(p)}};function m1(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Hg(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function $I(){}function p$(p,b,E,z,G){if(G){if(typeof z=="function"){var X=z;z=function(){var lt=Ug(me);X.call(lt)}}var me=DI(b,z,p,0,null,!1,!1,"",$I);return p._reactRootContainer=me,p[dl]=me.current,fp(p.nodeType===8?p.parentNode:p),ou(),me}for(;G=p.lastChild;)p.removeChild(G);if(typeof z=="function"){var Pe=z;z=function(){var lt=Ug($e);Pe.call(lt)}}var $e=f1(p,0,!1,null,null,!1,!1,"",$I);return p._reactRootContainer=$e,p[dl]=$e.current,fp(p.nodeType===8?p.parentNode:p),ou(function(){$g(b,$e,E,z)}),$e}function Gg(p,b,E,z,G){var X=E._reactRootContainer;if(X){var me=X;if(typeof G=="function"){var Pe=G;G=function(){var $e=Ug(me);Pe.call($e)}}$g(b,me,p,G)}else me=p$(E,b,p,G,z);
41return Ug(me)}ue=function(p){switch(p.tag){case 3:var b=p.stateNode;if(b.current.memoizedState.isDehydrated){var E=Fe(b.pendingLanes);E!==0&&(ae(b,E|1),Os(b,on()),(ir&6)===0&&(Yd=on()+500,Zl()))}break;case 13:ou(function(){var z=ml(p,1);if(z!==null){var G=xs();Zo(z,p,1,G)}}),h1(p,1)}},Ee=function(p){if(p.tag===13){var b=ml(p,134217728);if(b!==null){var E=xs();Zo(b,p,134217728,E)}h1(p,134217728)}},Je=function(p){if(p.tag===13){var b=ic(p),E=ml(p,b);if(E!==null){var z=xs();Zo(E,p,b,z)}h1(p,b)}},Ke=function(){return K},Oe=function(p,b){var E=K;try{return K=p,b()}finally{K=E}},dt=function(p,b,E){switch(b){case"input":if(le(p,E),b=E.name,E.type==="radio"&&b!=null){for(E=p;E.parentNode;)E=E.parentNode;for(E=E.querySelectorAll("input[name="+JSON.stringify(""+b)+'][type="radio"]'),b=0;b<E.length;b++){var z=E[b];if(z!==p&&z.form===p.form){var G=lg(z);if(!G)throw Error(n(90));te(z),le(z,G)}}}break;case"textarea":Ue(p,E);break;case"select":b=E.value,b!=null&&Ne(p,!!E.multiple,b,!1)}},cn=o1,kt=ou;var m$={usingClientEntryPoint:!1,Events:[mp,Rd,lg,rn,pn,o1]},jp={findFiberByHostInstance:Zc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},g$={bundleType:jp.bundleType,version:jp.version,rendererPackageName:jp.rendererPackageName,rendererConfig:jp.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:k.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=nn(p),p===null?null:p.stateNode},findFiberByHostInstance:jp.findFiberByHostInstance||h$,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Wg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Wg.isDisabled&&Wg.supportsFiber)try{Rr=Wg.inject(g$),yr=Wg}catch{}}return Ds.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=m$,Ds.createPortal=function(p,b){var E=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m1(b))throw Error(n(200));return f$(p,b,null,E)},Ds.createRoot=function(p,b){if(!m1(p))throw Error(n(299));var E=!1,z="",G=FI;return b!=null&&(b.unstable_strictMode===!0&&(E=!0),b.identifierPrefix!==void 0&&(z=b.identifierPrefix),b.onRecoverableError!==void 0&&(G=b.onRecoverableError)),b=f1(p,1,!1,null,null,E,!1,z,G),p[dl]=b.current,fp(p.nodeType===8?p.parentNode:p),new p1(b)},Ds.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var b=p._reactInternals;if(b===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=nn(b),p=p===null?null:p.stateNode,p},Ds.flushSync=function(p){return ou(p)},Ds.hydrate=function(p,b,E){if(!Hg(b))throw Error(n(200));return Gg(null,p,b,!0,E)},Ds.hydrateRoot=function(p,b,E){if(!m1(p))throw Error(n(405));var z=E!=null&&E.hydratedSources||null,G=!1,X="",me=FI;if(E!=null&&(E.unstable_strictMode===!0&&(G=!0),E.identifierPrefix!==void 0&&(X=E.identifierPrefix),E.onRecoverableError!==void 0&&(me=E.onRecoverableError)),b=DI(b,null,p,1,E??null,G,!1,X,me),p[dl]=b.current,fp(p),z)for(p=0;p<z.length;p++)E=z[p],G=E._getVersion,G=G(E._source),b.mutableSourceEagerHydrationData==null?b.mutableSourceEagerHydrationData=[E,G]:b.mutableSourceEagerHydrationData.push(E,G);return new Vg(b)},Ds.render=function(p,b,E){if(!Hg(b))throw Error(n(200));return Gg(null,p,b,!1,E)},Ds.unmountComponentAtNode=function(p){if(!Hg(p))throw Error(n(40));return p._reactRootContainer?(ou(function(){Gg(null,null,p,!1,function(){p._reactRootContainer=null,p[dl]=null})}),!0):!1},Ds.unstable_batchedUpdates=o1,Ds.unstable_renderSubtreeIntoContainer=function(p,b,E,z){if(!Hg(E))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return Gg(p,b,E,!1,z)},Ds.version="18.3.1-next-f1338f8080-20240426",Ds}var JI;function eR(){if(JI)return v1.exports;JI=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),v1.exports=A$(),v1.exports}var ej;function M$(){if(ej)return Kg;ej=1;var t=eR();return Kg.createRoot=t.createRoot,Kg.hydrateRoot=t.hydrateRoot,Kg}var B$=M$();const R$=Vo(B$);function Ei(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=Ei(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var O$={value:()=>{}};function Rv(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ny(n)}function ny(t){this._=t}function D$(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ny.prototype=Rv.prototype={constructor:ny,on:function(t,e){var n=this._,r=D$(t+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((i=(t=r[s]).type)&&(i=L$(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(t=r[s]).type)n[i]=tj(n[i],t.name,e);else if(e==null)for(i in n)n[i]=tj(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ny(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,i=s.length;r<i;++r)s[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,s=r.length;i<s;++i)r[i].value.apply(e,n)}};function L$(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function tj(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=O$,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var W2="http://www.w3.org/1999/xhtml";const nj={svg:"http://www.w3.org/2000/svg",xhtml:W2,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ov(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),nj.hasOwnProperty(e)?{space:nj[e],local:t}:t}function F$(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===W2&&e.documentElement.namespaceURI===W2?e.createElement(t):e.createElementNS(n,t)}}function $$(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function tR(t){var e=Ov(t);return(e.local?$$:F$)(e)}function U$(){}function m_(t){return t==null?U$:function(){return this.querySelector(t)}}function V$(t){typeof t!="function"&&(t=m_(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,a=r[i]=new Array(o),l,u,d=0;d<o;++d)(l=s[d])&&(u=t.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),a[d]=u);return new xo(r,this._parents)}function H$(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function G$(){return[]}function nR(t){return t==null?G$:function(){return this.querySelectorAll(t)}}function W$(t){return function(){return H$(t.apply(this,arguments))}}function q$(t){typeof t=="function"?t=W$(t):t=nR(t);for(var e=this._groups,n=e.length,r=[],i=[],s=0;s<n;++s)for(var o=e[s],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(r.push(t.call(l,l.__data__,u,o)),i.push(l));return new xo(r,i)}function rR(t){return function(){return this.matches(t)}}function iR(t){return function(e){return e.matches(t)}}var K$=Array.prototype.find;function Y$(t){return function(){return K$.call(this.children,t)}}
vendor: 6,396 bytes, line 41
41function X$(){return this.firstElementChild}function Q$(t){return this.select(t==null?X$:Y$(typeof t=="function"?t:iR(t)))}var Z$=Array.prototype.filter;function J$(){return Array.from(this.children)}function eU(t){return function(){return Z$.call(this.children,t)}}function tU(t){return this.selectAll(t==null?J$:eU(typeof t=="function"?t:iR(t)))}function nU(t){typeof t!="function"&&(t=rR(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,a=r[i]=[],l,u=0;u<o;++u)(l=s[u])&&t.call(l,l.__data__,u,s)&&a.push(l);return new xo(r,this._parents)}function sR(t){return new Array(t.length)}function rU(){return new xo(this._enter||this._groups.map(sR),this._parents)}function jy(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}jy.prototype={constructor:jy,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function iU(t){return function(){return t}}function sU(t,e,n,r,i,s){for(var o=0,a,l=e.length,u=s.length;o<u;++o)(a=e[o])?(a.__data__=s[o],r[o]=a):n[o]=new jy(t,s[o]);for(;o<l;++o)(a=e[o])&&(i[o]=a)}function oU(t,e,n,r,i,s,o){var a,l,u=new Map,d=e.length,f=s.length,h=new Array(d),m;for(a=0;a<d;++a)(l=e[a])&&(h[a]=m=o.call(l,l.__data__,a,e)+"",u.has(m)?i[a]=l:u.set(m,l));for(a=0;a<f;++a)m=o.call(t,s[a],a,s)+"",(l=u.get(m))?(r[a]=l,l.__data__=s[a],u.delete(m)):n[a]=new jy(t,s[a]);for(a=0;a<d;++a)(l=e[a])&&u.get(h[a])===l&&(i[a]=l)}function aU(t){return t.__data__}function lU(t,e){if(!arguments.length)return Array.from(this,aU);var n=e?oU:sU,r=this._parents,i=this._groups;typeof t!="function"&&(t=iU(t));for(var s=i.length,o=new Array(s),a=new Array(s),l=new Array(s),u=0;u<s;++u){var d=r[u],f=i[u],h=f.length,m=cU(t.call(d,d&&d.__data__,u,r)),y=m.length,g=a[u]=new Array(y),w=o[u]=new Array(y),v=l[u]=new Array(h);n(d,f,g,w,v,m,e);for(var S=0,C=0,k,N;S<y;++S)if(k=g[S]){for(S>=C&&(C=S+1);!(N=w[C])&&++C<y;);k._next=N||null}}return o=new xo(o,r),o._enter=a,o._exit=l,o}function cU(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function uU(){return new xo(this._exit||this._groups.map(sR),this._parents)}function dU(t,e,n){var r=this.enter(),i=this,s=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function fU(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,s=r.length,o=Math.min(i,s),a=new Array(i),l=0;l<o;++l)for(var u=n[l],d=r[l],f=u.length,h=a[l]=new Array(f),m,y=0;y<f;++y)(m=u[y]||d[y])&&(h[y]=m);for(;l<i;++l)a[l]=n[l];return new xo(a,this._parents)}function hU(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,s=r[i],o;--i>=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function pU(t){t||(t=mU);function e(f,h){return f&&h?t(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o=n[s],a=o.length,l=i[s]=new Array(a),u,d=0;d<a;++d)(u=o[d])&&(l[d]=u);l.sort(e)}return new xo(i,this._parents).order()}function mU(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function gU(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function bU(){return Array.from(this)}function yU(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length;i<s;++i){var o=r[i];if(o)return o}return null}function vU(){let t=0;for(const e of this)++t;return t}function xU(){return!this.node()}function wU(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],s=0,o=i.length,a;s<o;++s)(a=i[s])&&t.call(a,a.__data__,s,i);return this}function kU(t){return function(){this.removeAttribute(t)}}function SU(t){return function(){this.removeAttributeNS(t.space,t.local)}}function CU(t,e){return function(){this.setAttribute(t,e)}}function _U(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function EU(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function NU(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function IU(t,e){var n=Ov(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?SU:kU:typeof e=="function"?n.local?NU:EU:n.local?_U:CU)(n,e))}function oR(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function jU(t){return function(){this.style.removeProperty(t)}}function TU(t,e,n){return function(){this.style.setProperty(t,e,n)}}function zU(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function PU(t,e,n){return arguments.length>1?this.each((e==null?jU:typeof e=="function"?zU:TU)(t,e,n??"")):ch(this.node(),t)}function ch(t,e){return t.style.getPropertyValue(e)||oR(t).getComputedStyle(t,null).getPropertyValue(e)}function AU(t){return function(){delete this[t]}}function MU(t,e){return function(){this[t]=e}}function BU(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function RU(t,e){return arguments.length>1?this.each((e==null?AU:typeof e=="function"?BU:MU)(t,e)):this.node()[t]}function aR(t){return t.trim().split(/^|\s+/)}function g_(t){return t.classList||new lR(t)}function lR(t){this._node=t,this._names=aR(t.getAttribute("class")||"")}lR.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function cR(t,e){for(var n=g_(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function uR(t,e){for(var n=g_(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function OU(t){return function(){cR(this,t)}}function DU(t){return function(){uR(this,t)}}function LU(t,e){return function(){(e.apply(this,arguments)?cR:uR)(this,t)}}function FU(t,e){var n=aR(t+"");
vendor: 5,274 bytes, line 41
41if(arguments.length<2){for(var r=g_(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?LU:e?OU:DU)(n,e))}function $U(){this.textContent=""}function UU(t){return function(){this.textContent=t}}function VU(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function HU(t){return arguments.length?this.each(t==null?$U:(typeof t=="function"?VU:UU)(t)):this.node().textContent}function GU(){this.innerHTML=""}function WU(t){return function(){this.innerHTML=t}}function qU(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function KU(t){return arguments.length?this.each(t==null?GU:(typeof t=="function"?qU:WU)(t)):this.node().innerHTML}function YU(){this.nextSibling&&this.parentNode.appendChild(this)}function XU(){return this.each(YU)}function QU(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ZU(){return this.each(QU)}function JU(t){var e=typeof t=="function"?t:tR(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function eV(){return null}function tV(t,e){var n=typeof t=="function"?t:tR(t),r=e==null?eV:typeof e=="function"?e:m_(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function nV(){var t=this.parentNode;t&&t.removeChild(this)}function rV(){return this.each(nV)}function iV(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function sV(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function oV(t){return this.select(t?sV:iV)}function aV(t){return arguments.length?this.property("__data__",t):this.node().__data__}function lV(t){return function(e){t.call(this,e,this.__data__)}}function cV(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function uV(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,s;n<i;++n)s=e[n],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++r]=s;++r?e.length=r:delete this.__on}}}function dV(t,e,n){return function(){var r=this.__on,i,s=lV(e);if(r){for(var o=0,a=r.length;o<a;++o)if((i=r[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=e;return}}this.addEventListener(t.type,s,n),i={type:t.type,name:t.name,value:e,listener:s,options:n},r?r.push(i):this.__on=[i]}}function fV(t,e,n){var r=cV(t+""),i,s=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,d;l<u;++l)for(i=0,d=a[l];i<s;++i)if((o=r[i]).type===d.type&&o.name===d.name)return d.value}return}for(a=e?dV:uV,i=0;i<s;++i)this.each(a(r[i],e,n));return this}function dR(t,e,n){var r=oR(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function hV(t,e){return function(){return dR(this,t,e)}}function pV(t,e){return function(){return dR(this,t,e.apply(this,arguments))}}function mV(t,e){return this.each((typeof e=="function"?pV:hV)(t,e))}function*gV(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length,o;i<s;++i)(o=r[i])&&(yield o)}var fR=[null];function xo(t,e){this._groups=t,this._parents=e}function g0(){return new xo([[document.documentElement]],fR)}function bV(){return this}xo.prototype=g0.prototype={constructor:xo,select:V$,selectAll:q$,selectChild:Q$,selectChildren:tU,filter:nU,data:lU,enter:rU,exit:uU,join:dU,merge:fU,selection:bV,order:hU,sort:pU,call:gU,nodes:bU,node:yU,size:vU,empty:xU,each:wU,attr:IU,style:PU,property:RU,classed:FU,text:HU,html:KU,raise:XU,lower:ZU,append:JU,insert:tV,remove:rV,clone:oV,datum:aV,on:fV,dispatch:mV,[Symbol.iterator]:gV};function co(t){return typeof t=="string"?new xo([[document.querySelector(t)]],[document.documentElement]):new xo([[t]],fR)}function yV(t){let e;for(;e=t.sourceEvent;)t=e;return t}function oa(t,e){if(t=yV(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const vV={passive:!1},Am={capture:!0,passive:!1};function k1(t){t.stopImmediatePropagation()}function qf(t){t.preventDefault(),t.stopImmediatePropagation()}function hR(t){var e=t.document.documentElement,n=co(t).on("dragstart.drag",qf,Am);"onselectstart"in e?n.on("selectstart.drag",qf,Am):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function pR(t,e){var n=t.document.documentElement,r=co(t).on("dragstart.drag",null);e&&(r.on("click.drag",qf,Am),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Yg=t=>()=>t;function q2(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:u,dis
vendor: 17,716 bytes, line 41
41patch:d}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}q2.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function xV(t){return!t.ctrlKey&&!t.button}function wV(){return this.parentNode}function kV(t,e){return e??{x:t.x,y:t.y}}function SV(){return navigator.maxTouchPoints||"ontouchstart"in this}function mR(){var t=xV,e=wV,n=kV,r=SV,i={},s=Rv("start","drag","end"),o=0,a,l,u,d,f=0;function h(k){k.on("mousedown.drag",m).filter(r).on("touchstart.drag",w).on("touchmove.drag",v,vV).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(k,N){if(!(d||!t.call(this,k,N))){var _=C(this,e.call(this,k,N),k,N,"mouse");_&&(co(k.view).on("mousemove.drag",y,Am).on("mouseup.drag",g,Am),hR(k.view),k1(k),u=!1,a=k.clientX,l=k.clientY,_("start",k))}}function y(k){if(qf(k),!u){var N=k.clientX-a,_=k.clientY-l;u=N*N+_*_>f}i.mouse("drag",k)}function g(k){co(k.view).on("mousemove.drag mouseup.drag",null),pR(k.view,u),qf(k),i.mouse("end",k)}function w(k,N){if(t.call(this,k,N)){var _=k.changedTouches,j=e.call(this,k,N),T=_.length,M,V;for(M=0;M<T;++M)(V=C(this,j,k,N,_[M].identifier,_[M]))&&(k1(k),V("start",k,_[M]))}}function v(k){var N=k.changedTouches,_=N.length,j,T;for(j=0;j<_;++j)(T=i[N[j].identifier])&&(qf(k),T("drag",k,N[j]))}function S(k){var N=k.changedTouches,_=N.length,j,T;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),j=0;j<_;++j)(T=i[N[j].identifier])&&(k1(k),T("end",k,N[j]))}function C(k,N,_,j,T,M){var V=s.copy(),H=oa(M||_,N),P,F,I;if((I=n.call(k,new q2("beforestart",{sourceEvent:_,target:h,identifier:T,active:o,x:H[0],y:H[1],dx:0,dy:0,dispatch:V}),j))!=null)return P=I.x-H[0]||0,F=I.y-H[1]||0,function R(U,A,W){var D=H,B;switch(U){case"start":i[T]=R,B=o++;break;case"end":delete i[T],--o;case"drag":H=oa(W||A,N),B=o;break}V.call(U,k,new q2(U,{sourceEvent:A,subject:I,target:h,identifier:T,active:B,x:H[0]+P,y:H[1]+F,dx:H[0]-D[0],dy:H[1]-D[1],dispatch:V}),j)}}return h.filter=function(k){return arguments.length?(t=typeof k=="function"?k:Yg(!!k),h):t},h.container=function(k){return arguments.length?(e=typeof k=="function"?k:Yg(k),h):e},h.subject=function(k){return arguments.length?(n=typeof k=="function"?k:Yg(k),h):n},h.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:Yg(!!k),h):r},h.on=function(){var k=s.on.apply(s,arguments);return k===s?h:k},h.clickDistance=function(k){return arguments.length?(f=(k=+k)*k,h):Math.sqrt(f)},h}function b_(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function gR(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function b0(){}var Mm=.7,Ty=1/Mm,Kf="\\s*([+-]?\\d+)\\s*",Bm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qa="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",CV=/^#([0-9a-f]{3,8})$/,_V=new RegExp(`^rgb\\(${Kf},${Kf},${Kf}\\)$`),EV=new RegExp(`^rgb\\(${qa},${qa},${qa}\\)$`),NV=new RegExp(`^rgba\\(${Kf},${Kf},${Kf},${Bm}\\)$`),IV=new RegExp(`^rgba\\(${qa},${qa},${qa},${Bm}\\)$`),jV=new RegExp(`^hsl\\(${Bm},${qa},${qa}\\)$`),TV=new RegExp(`^hsla\\(${Bm},${qa},${qa},${Bm}\\)$`),rj={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};b_(b0,rd,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ij,formatHex:ij,formatHex8:zV,formatHsl:PV,formatRgb:sj,toString:sj});function ij(){return this.rgb().formatHex()}function zV(){return this.rgb().formatHex8()}function PV(){return bR(this).formatHsl()}function sj(){return this.rgb().formatRgb()}function rd(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=CV.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?oj(e):n===3?new Vs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Xg(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Xg(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=_V.exec(t))?new Vs(e[1],e[2],e[3],1):(e=EV.exec(t))?new Vs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=NV.exec(t))?Xg(e[1],e[2],e[3],e[4]):(e=IV.exec(t))?Xg(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=jV.exec(t))?cj(e[1],e[2]/100,e[3]/100,1):(e=TV.exec(t))?cj(e[1],e[2]/100,e[3]/100,e[4]):rj.hasOwnProperty(t)?oj(rj[t]):t==="transparent"?new Vs(NaN,NaN,NaN,0):null}function oj(t){return new Vs(t>>16&255,t>>8&255,t&255,1)}function Xg(t,e,n,r){return r<=0&&(t=e=n=NaN),new Vs(t,e,n,r)}function AV(t){return t instanceof b0||(t=rd(t)),t?(t=t.rgb(),new Vs(t.r,t.g,t.b,t.opacity)):new Vs}function K2(t,e,n,r){return arguments.length===1?AV(t):new Vs(t,e,n,r??1)}function Vs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}b_(Vs,K2,gR(b0,{brighter(t){return t=t==null?Ty:Math.pow(Ty,t),new Vs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Mm:Math.pow(Mm,t),new Vs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Vs(Zu(this.r),Zu(this.g),Zu(this.b),zy(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:aj,formatHex:aj,formatHex8:MV,formatRgb:lj,toString:lj}));function aj(){return`#${Lu(this.r)}${Lu(this.g)}${Lu(this.b)}`}function MV(){return`#${Lu(this.r)}${Lu(this.g)}${Lu(this.b)}${Lu((isNaN(this.opacity)?1:this.opacity)*255)}`}function lj(){const t=zy(this.opacity);return`${t===1?"rgb(":"rgba("}${Zu(this.r)}, ${Zu(this.g)}, ${Zu(this.b)}${t===1?")":`, ${t})`}`}function zy(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Zu(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Lu(t){return t=Zu(t),(t<16?"0":"")+t.toString(16)}function cj(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new da(t,e,n,r)}function bR(t){if(t instanceof da)return new da(t.h,t.s,t.l,t.opacity);if(t instanceof b0||(t=rd(t)),!t)return new da;if(t instanceof da)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,a=s-i,l=(s+i)/2;return a?(e===s?o=(n-r)/a+(n<r)*6:n===s?o=(r-e)/a+2:o=(e-n)/a+4,a/=l<.5?s+i:2-s-i,o*=60):a=l>0&&l<1?0:o,new da(o,a,l,t.opacity)}function BV(t,e,n,r){return arguments.length===1?bR(t):new da(t,e,n,r??1)}function da(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}b_(da,BV,gR(b0,{brighter(t){return t=t==null?Ty:Math.pow(Ty,t),new da(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Mm:Math.pow(Mm,t),new da(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Vs(S1(t>=240?t-240:t+120,i,r),S1(t,i,r),S1(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new da(uj(this.h),Qg(this.s),Qg(this.l),zy(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=zy(this.opacity);return`${t===1?"hsl(":"hsla("}${uj(this.h)}, ${Qg(this.s)*100}%, ${Qg(this.l)*100}%${t===1?")":`, ${t})`}`}}));function uj(t){return t=(t||0)%360,t<0?t+360:t}function Qg(t){return Math.max(0,Math.min(1,t||0))}function S1(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const y_=t=>()=>t;function RV(t,e){return function(n){return t+n*e}}function OV(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function DV(t){return(t=+t)==1?yR:function(e,n){return n-e?OV(e,n,t):y_(isNaN(e)?n:e)}}function yR(t,e){var n=e-t;return n?RV(t,n):y_(isNaN(t)?e:t)}const Py=function t(e){var n=DV(e);function r(i,s){var o=n((i=K2(i)).r,(s=K2(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),u=yR(i.opacity,s.opacity);return function(d){return i.r=o(d),i.g=a(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=t,r}(1);function LV(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function FV(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function $V(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=fm(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(a){for(o=0;o<r;++o)s[o]=i[o](a);return s}}function UV(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function $a(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function VV(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=fm(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var Y2=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,C1=new RegExp(Y2.source,"g");function HV(t){return function(){return t}}function GV(t){return function(e){return t(e)+""}}function vR(t,e){var n=Y2.lastIndex=C1.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(t=t+"",e=e+"";(r=Y2.exec(t))&&(i=C1.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:$a(r,i)})),n=C1.lastIndex;return n<e.length&&(s=e.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?l[0]?GV(l[0].x):HV(e):(e=l.length,function(u){for(var d=0,f;d<e;++d)a[(f=l[d]).i]=f.x(u);return a.join("")})}function fm(t,e){var n=typeof e,r;return e==null||n==="boolean"?y_(e):(n==="number"?$a:n==="string"?(r=rd(e))?(e=r,Py):vR:e instanceof rd?Py:e instanceof Date?UV:FV(e)?LV:Array.isArray(e)?$V:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?VV:$a)(t,e)}var dj=180/Math.PI,X2={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xR(t,e,n,r,i,s){var o,a,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,t)*dj,skewX:Math.atan(l)*dj,scaleX:o,scaleY:a}}var Zg;function WV(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?X2:xR(e.a,e.b,e.c,e.d,e.e,e.f)}function qV(t){return t==null||(Zg||(Zg=document.createElementNS("http://www.w3.org/2000/svg","g")),Zg.setAttribute("transform",t),!(t=Zg.transform.baseVal.consolidate()))?X2:(t=t.matrix,xR(t.a,t.b,t.c,t.d,t.e,t.f))}function wR(t,e,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,d,f,h,m,y){if(u!==f||d!==h){var g=m.push("translate(",null,e,null,n);y.push({i:g-4,x:$a(u,f)},{i:g-2,x:$a(d,h)})}else(f||h)&&m.push("translate("+f+e+h+n)}function o(u,d,f,h){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(i(f)+"rotate(",null,r)-2,x:$a(u,d)})):d&&f.push(i(f)+"rotate("+d+r)}function a(u,d,f,h){u!==d?h.push({i:f.push(i(f)+"skewX(",null,r)-2,x:$a(u,d)}):d&&f.push(i(f)+"skewX("+d+r)}function l(u,d,f,h,m,y){if(u!==f||d!==h){var g=m.push(i(m)+"scale(",null,",",null,")");y.push({i:g-4,x:$a(u,f)},{i:g-2,x:$a(d,h)})}else(f!==1||h!==1)&&m.push(i(m)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=t(u),d=t(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),o(u.rotate,d.rotate,f,h),a(u.skewX,d.skewX,f,h),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(m){for(var y=-1,g=h.length,w;++y<g;)f[(w=h[y]).i]=w.x(m);return f.join("")}}}var KV=wR(WV,"px, ","px)","deg)"),YV=wR(qV,", ",")",")"),XV=1e-12;function fj(t){return((t=Math.exp(t))+1/t)/2}function QV(t){return((t=Math.exp(t))-1/t)/2}function ZV(t){return((t=Math.exp(2*t))-1)/(t+1)}const ry=function t(e,n,r){function i(s,o){var a=s[0],l=s[1],u=s[2],d=o[0],f=o[1],h=o[2],m=d-a,y=f-l,g=m*m+y*y,w,v;if(g<XV)v=Math.log(h/u)/e,w=function(j){return[a+j*m,l+j*y,u*Math.exp(e*j*v)]};else{var S=Math.sqrt(g),C=(h*h-u*u+r*g)/(2*u*n*S),k=(h*h-u*u-r*g)/(2*h*n*S),N=Math.log(Math.sqrt(C*C+1)-C),_=Math.log(Math.sqrt(k*k+1)-k);v=(_-N)/e,w=function(j){var T=j*v,M=fj(N),V=u/(n*S)*(M*ZV(e*T+N)-QV(N));return[a+V*m,l+V*y,u*M/fj(e*T+N)]}}return w.duration=v*1e3*e/Math.SQRT2,w}return i.rho=function(s){var o=Math.max(.001,+s),a=o*o,l=a*a;return t(o,a,l)},i}(Math.SQRT2,2,4);var uh=0,Qp=0,zp=0,kR=1e3,Ay,Zp,My=0,id=0,Dv=0,Rm=typeof performance=="object"&&performance.now?performance:Date,SR=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function v_(){return id||(SR(JV),id=Rm.now()+Dv)}function JV(){id=0}function By(){this._call=this._time=this._next=null}By.prototype=CR.prototype={constructor:By,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?v_():+n)+(e==null?0:+e),!this._next&&Zp!==this&&(Zp?Zp._next=this:Ay=this,Zp=this),this._call=t,this._time=n,Q2()},stop:function(){this._call&&(this._call=null,this._time=1/0,Q2())}};function CR(t,e,n){var r=new By;return r.restart(t,e,n),r}function eH(){v_(),++uh;for(var t=Ay,e;t;)(e=id-t._time)>=0&&t._call.call(void 0,e),t=t._next;--uh}function hj(){id=(My=Rm.now())+Dv,uh=Qp=0;try{eH()}finally{uh=0,nH(),id=0}}function tH(){var t=Rm.now(),e=t-My;e>kR&&(Dv-=e,My=t)}function nH(){for(var t,e=Ay,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ay=n);Zp=t,Q2(r)}function Q2(t){if(!uh){Qp&&(Qp=clearTimeout(Qp));var e=t-id;e>24?(t<1/0&&(Qp=setTimeout(hj,t-Rm.now()-Dv)),zp&&(zp=clearInterval(zp))):(zp||(My=Rm.now(),zp=setInterval(tH,kR)),uh=1,SR(hj))}}function pj(t,e,n){var r=new By;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var rH=Rv("start","end","cancel","interrupt"),iH=[],_R=0,mj=1,Z2=2,iy=3,gj=4,J2=5,sy=6;function Lv(t,e,n,r,i,s){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;sH(t,n,{name:e,index:r,group:i,on:rH,tween:iH,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:_R})}function x_(t,e){var n=_a(t,e);if(n.state>_R)throw new Error("too late; already scheduled");return n}function rl(t,e){var n=_a(t,e);if(n.state>iy)throw new Error("too late; already running");return n}function _a(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function sH(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=CR(s,0,n.time);function s(u){n.state=mj,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var d,f,h,m;if(n.state!==mj)return l();for(d in r)if(m=r[d],m.name===n.name){if(m.state===iy)return pj(o);m.state===gj?(m.state=sy,m.timer.stop(),m.on.call("interrupt",t,t.__data__,m.index,m.group),delete r[d]):+d<e&&(m.state=sy,m.timer.stop(),m.on.call("cancel",t,t.__data__,m.index,m.group),delete r[d])}if(pj(function(){n.state===iy&&(n.state=gj,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Z2,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Z2){for(n.state=iy,i=new Array(h=n.tween.length),d=0,f=-1;d<h;++d)(m=n.tween[d].value.call(t,t.__data__,n.index,n.group))&&(i[
vendor: 5,494 bytes, line 41
41++f]=m);i.length=f+1}}function a(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=J2,1),f=-1,h=i.length;++f<h;)i[f].call(t,d);n.state===J2&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=sy,n.timer.stop(),delete r[e];for(var u in r)return;delete t.__transition}}function oy(t,e){var n=t.__transition,r,i,s=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((r=n[o]).name!==e){s=!1;continue}i=r.state>Z2&&r.state<J2,r.state=sy,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[o]}s&&delete t.__transition}}function oH(t){return this.each(function(){oy(this,t)})}function aH(t,e){var n,r;return function(){var i=rl(this,t),s=i.tween;if(s!==n){r=n=s;for(var o=0,a=r.length;o<a;++o)if(r[o].name===e){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function lH(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=rl(this,t),o=s.tween;if(o!==r){i=(r=o).slice();for(var a={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=a;break}l===u&&i.push(a)}s.tween=i}}function cH(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=_a(this.node(),n).tween,i=0,s=r.length,o;i<s;++i)if((o=r[i]).name===t)return o.value;return null}return this.each((e==null?aH:lH)(n,t,e))}function w_(t,e,n){var r=t._id;return t.each(function(){var i=rl(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return _a(i,r).value[e]}}function ER(t,e){var n;return(typeof e=="number"?$a:e instanceof rd?Py:(n=rd(e))?(e=n,Py):vR)(t,e)}function uH(t){return function(){this.removeAttribute(t)}}function dH(t){return function(){this.removeAttributeNS(t.space,t.local)}}function fH(t,e,n){var r,i=n+"",s;return function(){var o=this.getAttribute(t);return o===i?null:o===r?s:s=e(r=o,n)}}function hH(t,e,n){var r,i=n+"",s;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===r?s:s=e(r=o,n)}}function pH(t,e,n){var r,i,s;return function(){var o,a=n(this),l;return a==null?void this.removeAttribute(t):(o=this.getAttribute(t),l=a+"",o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,a)))}}function mH(t,e,n){var r,i,s;return function(){var o,a=n(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),l=a+"",o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,a)))}}function gH(t,e){var n=Ov(t),r=n==="transform"?YV:ER;return this.attrTween(t,typeof e=="function"?(n.local?mH:pH)(n,r,w_(this,"attr."+t,e)):e==null?(n.local?dH:uH)(n):(n.local?hH:fH)(n,r,e))}function bH(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function yH(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function vH(t,e){var n,r;function i(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&yH(t,s)),n}return i._value=e,i}function xH(t,e){var n,r;function i(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&bH(t,s)),n}return i._value=e,i}function wH(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Ov(t);return this.tween(n,(r.local?vH:xH)(r,e))}function kH(t,e){return function(){x_(this,t).delay=+e.apply(this,arguments)}}function SH(t,e){return e=+e,function(){x_(this,t).delay=e}}function CH(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?kH:SH)(e,t)):_a(this.node(),e).delay}function _H(t,e){return function(){rl(this,t).duration=+e.apply(this,arguments)}}function EH(t,e){return e=+e,function(){rl(this,t).duration=e}}function NH(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?_H:EH)(e,t)):_a(this.node(),e).duration}function IH(t,e){if(typeof e!="function")throw new Error;return function(){rl(this,t).ease=e}}function jH(t){var e=this._id;return arguments.length?this.each(IH(e,t)):_a(this.node(),e).ease}function TH(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;rl(this,t).ease=n}}function zH(t){if(typeof t!="function")throw new Error;return this.each(TH(this._id,t))}function PH(t){typeof t!="function"&&(t=rR(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,a=r[i]=[],l,u=0;u<o;++u)(l=s[u])&&t.call(l,l.__data__,u,s)&&a.push(l);return new Ll(r,this._parents,this._name,this._id)}function AH(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,s=Math.min(r,i),o=new Array(r),a=0;a<s;++a)for(var l=e[a],u=n[a],d=l.length,f=o[a]=new Array(d),h,m=0;m<d;++m)(h=l[m]||u[m])&&(f[m]=h);for(;a<r;++a)o[a]=e[a];return new Ll(o,this._parents,this._name,this._id)}function MH(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function BH(t,e,n){var r,i,s=MH(e)?x_:rl;return function(){var o=s(this,t),a=o.on;a!==r&&(i=(r=a).copy()).on(e,n),o.on=i}}function RH(t,e){var n=this._id;return arguments.length<2?_a(this.node(),n).on.on(t):this.each(BH(n,t,e))}function OH(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function DH(){return this.on("end.remove",OH(this._id))}function LH(t){var e=this._name,n=this._id;typeof t!="function"&&(t=m_(t));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a=r[o],l=a.length,u=s[o]=new Array(l),d,f,h=0;h<l;++h)(d=a[h])&&(f=t.call(d,d.__data__,h,a))&&("__data__"in d&&(f.__data__=d.__data__),u[h]=f,
vendor: 3,334 bytes, line 41
41Lv(u[h],e,n,h,u,_a(d,n)));return new Ll(s,this._parents,e,n)}function FH(t){var e=this._name,n=this._id;typeof t!="function"&&(t=nR(t));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var l=r[a],u=l.length,d,f=0;f<u;++f)if(d=l[f]){for(var h=t.call(d,d.__data__,f,l),m,y=_a(d,n),g=0,w=h.length;g<w;++g)(m=h[g])&&Lv(m,e,n,g,h,y);s.push(h),o.push(d)}return new Ll(s,o,e,n)}var $H=g0.prototype.constructor;function UH(){return new $H(this._groups,this._parents)}function VH(t,e){var n,r,i;return function(){var s=ch(this,t),o=(this.style.removeProperty(t),ch(this,t));return s===o?null:s===n&&o===r?i:i=e(n=s,r=o)}}function NR(t){return function(){this.style.removeProperty(t)}}function HH(t,e,n){var r,i=n+"",s;return function(){var o=ch(this,t);return o===i?null:o===r?s:s=e(r=o,n)}}function GH(t,e,n){var r,i,s;return function(){var o=ch(this,t),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),ch(this,t))),o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,a))}}function WH(t,e){var n,r,i,s="style."+e,o="end."+s,a;return function(){var l=rl(this,t),u=l.on,d=l.value[s]==null?a||(a=NR(e)):void 0;(u!==n||i!==d)&&(r=(n=u).copy()).on(o,i=d),l.on=r}}function qH(t,e,n){var r=(t+="")=="transform"?KV:ER;return e==null?this.styleTween(t,VH(t,r)).on("end.style."+t,NR(t)):typeof e=="function"?this.styleTween(t,GH(t,r,w_(this,"style."+t,e))).each(WH(this._id,t)):this.styleTween(t,HH(t,r,e),n).on("end.style."+t,null)}function KH(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function YH(t,e,n){var r,i;function s(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&KH(t,o,n)),r}return s._value=e,s}function XH(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,YH(t,e,n??""))}function QH(t){return function(){this.textContent=t}}function ZH(t){return function(){var e=t(this);this.textContent=e??""}}function JH(t){return this.tween("text",typeof t=="function"?ZH(w_(this,"text",t)):QH(t==null?"":t+""))}function eG(t){return function(e){this.textContent=t.call(this,e)}}function tG(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&eG(i)),e}return r._value=t,r}function nG(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,tG(t))}function rG(){for(var t=this._name,e=this._id,n=IR(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var d=_a(l,e);Lv(l,t,n,u,o,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ll(r,this._parents,t,n)}function iG(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var a={value:o},l={value:function(){--i===0&&s()}};n.each(function(){var u=rl(this,r),d=u.on;d!==t&&(e=(t=d).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),i===0&&s()})}var sG=0;function Ll(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function IR(){return++sG}var vl=g0.prototype;Ll.prototype={constructor:Ll,select:LH,selectAll:FH,selectChild:vl.selectChild,selectChildren:vl.selectChildren,filter:PH,merge:AH,selection:UH,transition:rG,call:vl.call,nodes:vl.nodes,node:vl.no
vendor: 11,092 bytes, line 41
41de,size:vl.size,empty:vl.empty,each:vl.each,on:RH,attr:gH,attrTween:wH,style:qH,styleTween:XH,text:JH,textTween:nG,remove:DH,tween:cH,delay:CH,duration:NH,ease:jH,easeVarying:zH,end:iG,[Symbol.iterator]:vl[Symbol.iterator]};function oG(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var aG={time:null,delay:0,duration:250,ease:oG};function lG(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function cG(t){var e,n;t instanceof Ll?(e=t._id,t=t._name):(e=IR(),(n=aG).time=v_(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Lv(l,t,e,u,o,n||lG(l,e));return new Ll(r,this._parents,t,e)}g0.prototype.interrupt=oH;g0.prototype.transition=cG;const Jg=t=>()=>t;function uG(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Il(t,e,n){this.k=t,this.x=e,this.y=n}Il.prototype={constructor:Il,scale:function(t){return t===1?this:new Il(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Il(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Fv=new Il(1,0,0);jR.prototype=Il.prototype;function jR(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Fv;return t.__zoom}function _1(t){t.stopImmediatePropagation()}function Pp(t){t.preventDefault(),t.stopImmediatePropagation()}function dG(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function fG(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function bj(){return this.__zoom||Fv}function hG(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function pG(){return navigator.maxTouchPoints||"ontouchstart"in this}function mG(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function TR(){var t=dG,e=fG,n=mG,r=hG,i=pG,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=ry,u=Rv("start","zoom","end"),d,f,h,m=500,y=150,g=0,w=10;function v(I){I.property("__zoom",bj).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",V).filter(i).on("touchstart.zoom",H).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(I,R,U,A){var W=I.selection?I.selection():I;W.property("__zoom",bj),I!==W?N(I,R,U,A):W.interrupt().each(function(){_(this,arguments).event(A).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},v.scaleBy=function(I,R,U,A){v.scaleTo(I,function(){var W=this.__zoom.k,D=typeof R=="function"?R.apply(this,arguments):R;return W*D},U,A)},v.scaleTo=function(I,R,U,A){v.transform(I,function(){var W=e.apply(this,arguments),D=this.__zoom,B=U==null?k(W):typeof U=="function"?U.apply(this,arguments):U,L=D.invert(B),$=typeof R=="function"?R.apply(this,arguments):R;return n(C(S(D,$),B,L),W,o)},U,A)},v.translateBy=function(I,R,U,A){v.transform(I,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof U=="function"?U.apply(this,arguments):U),e.apply(this,arguments),o)},null,A)},v.translateTo=function(I,R,U,A,W){v.transform(I,function(){var D=e.apply(this,arguments),B=this.__zoom,L=A==null?k(D):typeof A=="function"?A.apply(this,arguments):A;return n(Fv.translate(L[0],L[1]).scale(B.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof U=="function"?-U.apply(this,arguments):-U),D,o)},A,W)};function S(I,R){return R=Math.max(s[0],Math.min(s[1],R)),R===I.k?I:new Il(R,I.x,I.y)}function C(I,R,U){var A=R[0]-U[0]*I.k,W=R[1]-U[1]*I.k;return A===I.x&&W===I.y?I:new Il(I.k,A,W)}function k(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function N(I,R,U,A){I.on("start.zoom",function(){_(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(A).end()}).tween("zoom",function(){var W=this,D=arguments,B=_(W,D).event(A),L=e.apply(W,D),$=U==null?k(L):typeof U=="function"?U.apply(W,D):U,q=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),Z=W.__zoom,ie=typeof R=="function"?R.apply(W,D):R,ge=l(Z.invert($).concat(q/Z.k),ie.invert($).concat(q/ie.k));return function(re){if(re===1)re=ie;else{var Y=ge(re),ne=q/Y[2];re=new Il(ne,$[0]-Y[0]*ne,$[1]-Y[1]*ne)}B.zoom(null,re)}})}function _(I,R,U){return!U&&I.__zooming||new j(I,R)}function j(I,R){this.that=I,this.args=R,this.active=0,this.sourceEvent=null,this.extent=e.apply(I,R),this.taps=0}j.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,R){return this.mouse&&I!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var R=co(this.that).datum();u.call(I,this.that,new uG(I,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),R)}};function T(I,...R){if(!t.apply(this,arguments))return;var U=_(this,R).event(I),A=this.__zoom,W=Math.max(s[0],Math.min(s[1],A.k*Math.pow(2,r.apply(this,arguments)))),D=oa(I);if(U.wheel)(U.mouse[0][0]!==D[0]||U.mouse[0][1]!==D[1])&&(U.mouse[1]=A.invert(U.mouse[0]=D)),clearTimeout(U.wheel);else{if(A.k===W)return;U.mouse=[D,A.invert(D)],oy(this),U.start()}Pp(I),U.wheel=setTimeout(B,y),U.zoom("mouse",n(C(S(A,W),U.mouse[0],U.mouse[1]),U.extent,o));function B(){U.wheel=null,U.end()}}function M(I,...R){if(h||!t.apply(this,arguments))return;var U=I.currentTarget,A=_(this,R,!0).event(I),W=co(I.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",q,!0),D=oa(I,U),B=I.clientX,L=I.clientY;hR(I.view),_1(I),A.mouse=[D,this.__zoom.invert(D)],oy(this),A.start();function $(Z){if(Pp(Z),!A.moved){var ie=Z.clientX-B,ge=Z.clientY-L;A.moved=ie*ie+ge*ge>g}A.event(Z).zoom("mouse",n(C(A.that.__zoom,A.mouse[0]=oa(Z,U),A.mouse[1]),A.extent,o))}function q(Z){W.on("mousemove.zoom mouseup.zoom",null),pR(Z.view,A.moved),Pp(Z),A.event(Z).end()}}function V(I,...R){if(t.apply(this,arguments)){var U=this.__zoom,A=oa(I.changedTouches?I.changedTouches[0]:I,this),W=U.invert(A),D=U.k*(I.shiftKey?.5:2),B=n(C(S(U,D),A,W),e.apply(this,R),o);Pp(I),a>0?co(this).transition().duration(a).call(N,B,A,I):co(this).call(v.transform,B,A,I)}}function H(I,...R){if(t.apply(this,arguments)){var U=I.touches,A=U.length,W=_(this,R,I.changedTouches.length===A).event(I),D,B,L,$;for(_1(I),B=0;B<A;++B)L=U[B],$=oa(L,this),$=[$,this.__zoom.invert($),L.identifier],W.touch0?!W.touch1&&W.touch0[2]!==$[2]&&(W.touch1=$,W.taps=0):(W.touch0=$,D=!0,W.taps=1+!!d);d&&(d=clearTimeout(d)),D&&(W.taps<2&&(f=$[0],d=setTimeout(function(){d=null},m)),oy(this),W.start())}}function P(I,...R){if(this.__zooming){var U=_(this,R).event(I),A=I.changedTouches,W=A.length,D,B,L,$;for(Pp(I),D=0;D<W;++D)B=A[D],L=oa(B,this),U.touch0&&U.touch0[2]===B.identifier?U.touch0[0]=L:U.touch1&&U.touch1[2]===B.identifier&&(U.touch1[0]=L);if(B=U.that.__zoom,U.touch1){var q=U.touch0[0],Z=U.touch0[1],ie=U.touch1[0],ge=U.touch1[1],re=(re=ie[0]-q[0])*re+(re=ie[1]-q[1])*re,Y=(Y=ge[0]-Z[0])*Y+(Y=ge[1]-Z[1])*Y;B=S(B,Math.sqrt(re/Y)),L=[(q[0]+ie[0])/2,(q[1]+ie[1])/2],$=[(Z[0]+ge[0])/2,(Z[1]+ge[1])/2]}else if(U.touch0)L=U.touch0[0],$=U.touch0[1];else return;U.zoom("touch",n(C(B,L,$),U.extent,o))}}function F(I,...R){if(this.__zooming){var U=_(this,R).event(I),A=I.changedTouches,W=A.length,D,B;for(_1(I),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),D=0;D<W;++D)B=A[D],U.touch0&&U.touch0[2]===B.identifier?delete U.touch0:U.touch1&&U.touch1[2]===B.identifier&&delete U.touch1;if(U.touch1&&!U.touch0&&(U.touch0=U.touch1,delete U.touch1),U.touch0)U.touch0[1]=this.__zoom.invert(U.touch0[0]);else if(U.end(),U.taps===2&&(B=oa(B,this),Math.hypot(f[0]-B[0],f[1]-B[1])<w)){var L=co(this).on("dblclick.zoom");L&&L.apply(this,arguments)}}}return v.wheelDelta=function(I){return arguments.length?(r=typeof I=="function"?I:Jg(+I),v):r},v.filter=function(I){return arguments.length?(t=typeof I=="function"?I:Jg(!!I),v):t},v.touchable=function(I){return arguments.length?(i=typeof I=="function"?I:Jg(!!I),v):i},v.extent=function(I){return arguments.length?(e=typeof I=="function"?I:Jg([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),v):e},v.scaleExtent=function(I){return arguments.length?(s[0]=+I[0],s[1]=+I[1],v):[s[0],s[1]]},v.translateExtent=function(I){return arguments.length?(o[0][0]=+I[0][0],o[1][0]=+I[1][0],o[0][1]=+I[0][1],o[1][1]=+I[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(I){return arguments.length?(n=I,v):n},v.duration=function(I){return arguments.length?(a=+I,v):a},v.interpolate=function(I){return arguments.length?(l=I,v):l},v.on=function(){var I=u.on.apply(u,arguments);return I===u?v:I},v.clickDistance=function(I){return arguments.length?(g=(I=+I)*I,v):Math.sqrt(g)},v.tapDistance=function(I){return arguments.length?(w=+I,v):w},v}const el={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>
41`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Om=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zR=["Enter"," ","Escape"],PR={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var dh;(function(t){t.Strict="strict",t.Loose="loose"})(dh||(dh={}));var ba;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ba||(ba={}));var Dm;(function(t){t.Partial="partial",t.Full="full"})(Dm||(Dm={}));const AR={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Ec;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Ec||(Ec={}));var Ry;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Ry||(Ry={}));var Cn;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Cn||(Cn={}));const yj={[Cn.Left]:Cn.Right,[Cn.Right]:Cn.Left,[Cn.Top]:Cn.Bottom,[Cn.Bottom]:Cn.Top};function MR(t){return t===null?null:t?"valid":"invalid"}const BR=t=>"id"in t&&"source"in t&&"target"in t,gG=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),k_=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),y0=(t,e=[0,0])=>{const{width:n,height:r}=Gl(t),i=t.origin??e,s=n*i[0],o=r*i[1];return{x:t.position.x-s,y:t.position.y-o}},bG=(t,e={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,i)=>{const s=typeof i=="string";let o=!e.nodeLookup&&!s?i:void 0;e.nodeLookup&&(o=s?e.nodeLookup.get(i):k_(i)?i:e.nodeLookup.get(i.id));
41const a=o?Oy(o,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return $v(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Uv(n)},v0=(t,e={})=>{if(t.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return t.forEach(r=>{if(e.filter===void 0||e.filter(r)){const i=Oy(r);n=$v(n,i)}}),Uv(n)},S_=(t,e,[n,r,i]=[0,0,1],s=!1,o=!1)=>{const a={...w0(e,[n,r,i]),width:e.width/i,height:e.height/i},l=[];for(const u of t.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(o&&!f||h)continue;const m=d.width??u.width??u.initialWidth??null,y=d.height??u.height??u.initialHeight??null,g=Lm(a,hh(u)),w=(m??0)*(y??0),v=s&&g>0;(!u.internals.handleBounds||v||g>=w||u.dragging)&&l.push(u)}return l},yG=(t,e)=>{const n=new Set;return t.forEach(r=>{n.add(r.id)}),e.filter(r=>n.has(r.source)||n.has(r.target))};function vG(t,e){const n=new Map,r=e!=null&&e.nodes?new Set(e.nodes.map(i=>i.id)):null;return t.forEach(i=>{i.measured.width&&i.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}
41async function xG({nodes:t,width:e,height:n,panZoom:r,minZoom:i,maxZoom:s},o){if(t.size===0)return Promise.resolve(!0);const a=vG(t,o),l=v0(a),u=C_(l,e,n,(o==null?void 0:o.minZoom)??i,(o==null?void 0:o.maxZoom)??s,(o==null?void 0:o.padding)??.1);return await r.setViewport(u,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),Promise.resolve(!0)}function RR({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:s}){const o=n.get(t),a=o.parentId?n.get(o.parentId):void 0,{x:l,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},d=o.origin??r;let f=o.extent||i;if(o.extent==="parent"&&!o.expandParent)if(!a)s==null||s("005",el.error005());else{const m=a.measured.width,y=a.measured.height;m&&y&&(f=[[l,u],[l+m,u+y]])}else a&&ph(o.extent)&&(f=[[o.extent[0][0]+l,o.extent[0][1]+u],[o.extent[1][0]+l,o.extent[1][1]+u]]);const h=ph(f)?sd(e,f,o.measured):e;return(o.measured.width===void 0||o.measured.height===void 0)&&(s==null||s("015",el.error015())),{position:{x:h.x-l+(o.measured.width??0)*d[0],y:h.y-u+(o.measured.height??0)*d[1]},positionAbsolute:h}}async function wG({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:i}){const s=new Set(t.map(h=>h.id)),o=[];for(const h of n){if(h.deletable===!1)continue;const m=s.has(h.id),y=!m&&h.parentId&&o.find(g=>g.id===h.parentId);(m||y)&&o.push(h)}const a=new Set(e.map(h=>h.id)),l=r.filter(h=>h.deletable!==!1),d=yG(o,l);for(const h of l)a.has(h.id)&&!d.find(y=>y.id===h.id)&&d.push(h);if(!i)return{edges:d,nodes:o};const f=await i({nodes:o,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:o}:{edges:[],nodes:[]}:f}const fh=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),sd=(t={x:0,y:0},e,n)=>({x:fh(t.x,e[0][0],e[1][0]-((n==null?void 0:n.width)??0)),y:fh(t.y,e[0][1],e[1][1]-((n==null?void 0:n.height)??0))});function OR(t,e,n){const{width:r,height:i}=Gl(n),{x:s,y:o}=n.internals.positionAbsolute;return sd(t,[[s,o],[s+r,o+i]],e)}const vj=(t,e,n)=>t<e?fh(Math.abs(t-e),1,e)/e:t>n?-fh(Math.abs(t-n),1,e)/e:0,DR=(t,e,n=15,r=40)=>{const i=vj(t.x,r,e.width-r)*n,s=vj(t.y,r,e.height-r)*n;return[i,s]},$v=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),eS=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),Uv=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),hh=(t,e=[0,0])=>{var i,s;const{x:n,y:r}=k_(t)?t.internals.positionAbsolute:y0(t,e);return{x:n,y:r,width:((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0,height:((s=t.measured)==null?void 0:s.height)??t.height??t.initialHeight??0}},Oy=(t,e=[0,0])=>{var i,s;const{x:n,y:r}=k_(t)?t.internals.positionAbsolute:y0(t,e);return{x:n,y:r,x2:n+(((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0),y2:r+(((s=t.measured)==null?void 0:s.height)??t.height??t.initialHeight??0)}},LR=(t,e)=>Uv($v(eS(t),eS(e))),Lm=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},xj=t=>pa(t.width)&&pa(t.height)&&pa(t.x)&&pa(t.y),pa=t=>!isNaN(t)&&isFinite(t),kG=(t,e)=>{},x0=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),w0=({x:t,y:e},[n,r,i],s=!1,o=[1,1])=>{const a={x:(t-n)/i,y:(e-r)/i};return s?x0(a,o):a},Dy=({x:t,y:e},[n,r,i])=>({x:t*i+n,y:e*i+r});function Qd(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function SG(t,e,n){if(typeof t=="string"||typeof t=="number"){const r=Qd(t,n),i=Qd(t,e);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof t=="object"){const r=Qd(t.top??t.y??0,n),i=Qd(t.bottom??t.y??0,n),s=Qd(t.left??t.x??0,e),o=Qd(t.right??t.x??0,e);return{top:r,right:o,bottom:i,left:s,x:s+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function CG(t,e,n,r,i,s){const{x:o,y:a}=Dy(t,[e,n,r]),{x:l,y:u}=Dy({x:t.x+t.width,y:t.y+t.height},[e,n,r]),d=i-l,f=s-u;return{left:Math.floor(o),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(f)}}const C_=(t,e,n,r,i,s)=>{const o=SG(s,e,n),a=(e-o.x)/t.width,l=(n-o.y)/t.height,u=Math.min(a,l),d=fh(u,r,i
41),f=t.x+t.width/2,h=t.y+t.height/2,m=e/2-f*d,y=n/2-h*d,g=CG(t,m,y,d,e,n),w={left:Math.min(g.left-o.left,0),top:Math.min(g.top-o.top,0),right:Math.min(g.right-o.right,0),bottom:Math.min(g.bottom-o.bottom,0)};return{x:m-w.left+w.right,y:y-w.top+w.bottom,zoom:d}},Fm=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function ph(t){return t!=null&&t!=="parent"}function Gl(t){var e,n;return{width:((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function FR(t){var e,n;return(((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function $R(t,e={width:0,height:0},n,r,i){const s={...t},o=r.get(n);if(o){const a=o.origin||i;s.x+=o.internals.positionAbsolute.x-(e.width??0)*a[0],s.y+=o.internals.positionAbsolute.y-(e.height??0)*a[1]}return s}function wj(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function _G(){let t,e;return{promise:new Promise((r,i)=>{t=r,e=i}),resolve:t,reject:e}}function EG(t){return{...PR,...t||{}}}function hm(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:s,y:o}=Ha(t),a=w0({x:s-((i==null?void 0:i.left)??0),y:o-((i==null?void 0:i.top)??0)},r),{x:l,y:u}=n?x0(a,e):a;return{xSnapped:l,ySnapped:u,...a}}const __=t=>({width:t.offsetWidth,height:t.offsetHeight}),UR=t=>{var e;return((e=t==null?void 0:t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},NG=["INPUT","SELECT","TEXTAREA"];function VR(t){var r,i;const e=((i=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:i[0])||t.target;return(e==null?void 0:e.nodeType)!==1?!1:NG.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}const HR=t=>"clientX"in t,Ha=(t,e)=>{var s,o;const n=HR(t),r=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,i=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:i-((e==null?void 0:e.top)??0)}},kj=(t,e,n,r,i)=>{const s=e.querySelectorAll(`.${t}`);return!s||!s.length?null:Array.from(s).map(o=>{const a=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:t,nodeId:i,position:o.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...__(o)}})};function GR({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:o,targetControlY:a}){const l=t*.125+i*.375+o*.375+n*.125,u=e*.125+s*.375+a*.375+r*.125,d=Math.abs(l-t),f=Math.abs(u-e);return[l,u,d,f]}function eb(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function Sj({pos:t,x1:e,y1:n,x2:r,y2:i,c:s}){switch(t){case Cn.Left:return[e-eb(e-r,s),n];case Cn.Right:return[e+eb(r-e,s),n];case Cn.Top:return[e,n-eb(n-i,s)];case Cn.Bottom:return[e,n+eb(i-n,s)]}}function WR({sourceX:t,sourceY:e,sourcePosition:n=Cn.Bottom,targetX:r,targetY:i,targetPosition:s=Cn.Top,curvature:o=.25}){const[a,l]=Sj({pos:n,x1:t,y1:e,x2:r,y2:i,c:o}),[u,d]=Sj({pos:s,x1:r,y1:i,x2:t,y2:e,c:o}),[f,h,m,y]=GR({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${t},${e} C${a},${l} ${u},${d} ${r},${i}`,f,h,m,y]}function qR({sourceX:t,sourceY:e,targetX:n,targetY:r}){const i=Math.abs(n-t)/2,s=n<t?n+i:n-i,o=Math.abs(r-e)/2,a=r<e?r+o:r-o;return[s,a,i,o]}function IG({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r,elevateOnSelect:i=!1}){if(r!==void 0)return r;const s=i&&n?1e3:0,o=Math.max(t.parentId?t.internals.z:0,e.parentId?e.internals.z:0);return s+o}function jG({sourceNode:t,targetNode:e,width:n,height:r,transform:i}){const s=$v(Oy(t),Oy(e));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const o={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return Lm(o,Uv(s))>0}const TG=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,zG=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),PG=(t,e)=>{if(!t.source||!t.target)return e;let n;return BR(t)?n={...t}:n={...t,id:TG(t)},zG(n,e)?e:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,e.concat(n))};function KR({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[i,s,o,a]=qR({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,i,s,o,a]}const Cj={[Cn.Left]:{x:-1,y:0},[Cn.Right]:{x:1,y:0},[Cn.Top]:{x:0,y:-1},[Cn.Bottom]:{x:0,y:1}},AG=({source:t,sourcePosition:e=Cn.Bottom,target:n})=>e===Cn.Left||e===Cn.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},_j=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function MG({source:t,sourcePosition:e=Cn.Bottom,target:n,targetPosition:r=Cn.Top,center:i,offset:s,stepPosition:o}){const a=Cj[e],l=Cj[r],u={x:t.x+a.x*s,y:t.y+a.y*s},d={x:n.x+l.x*s,y:n.y+l.y*s},f=AG({source:u,sourcePosition:e,target:d}),h=f.x!==0?"x":"y",m=f[h];let y=[],g,w;const v={x:0,y:0},S={x:0,y:0}
41,[,,C,k]=qR({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(a[h]*l[h]===-1){h==="x"?(g=i.x??u.x+(d.x-u.x)*o,w=i.y??(u.y+d.y)/2):(g=i.x??(u.x+d.x)/2,w=i.y??u.y+(d.y-u.y)*o);const _=[{x:g,y:u.y},{x:g,y:d.y}],j=[{x:u.x,y:w},{x:d.x,y:w}];a[h]===m?y=h==="x"?_:j:y=h==="x"?j:_}else{const _=[{x:u.x,y:d.y}],j=[{x:d.x,y:u.y}];if(h==="x"?y=a.x===m?j:_:y=a.y===m?_:j,e===r){const P=Math.abs(t[h]-n[h]);if(P<=s){const F=Math.min(s-1,s-P);a[h]===m?v[h]=(u[h]>t[h]?-1:1)*F:S[h]=(d[h]>n[h]?-1:1)*F}}if(e!==r){const P=h==="x"?"y":"x",F=a[h]===l[P],I=u[P]>d[P],R=u[P]<d[P];(a[h]===1&&(!F&&I||F&&R)||a[h]!==1&&(!F&&R||F&&I))&&(y=h==="x"?_:j)}const T={x:u.x+v.x,y:u.y+v.y},M={x:d.x+S.x,y:d.y+S.y},V=Math.max(Math.abs(T.x-y[0].x),Math.abs(M.x-y[0].x)),H=Math.max(Math.abs(T.y-y[0].y),Math.abs(M.y-y[0].y));V>=H?(g=(T.x+M.x)/2,w=y[0].y):(g=y[0].x,w=(T.y+M.y)/2)}return[[t,{x:u.x+v.x,y:u.y+v.y},...y,{x:d.x+S.x,y:d.y+S.y},n],g,w,C,k]}function BG(t,e,n,r){const i=Math.min(_j(t,e)/2,_j(e,n)/2,r),{x:s,y:o}=e;if(t.x===s&&s===n.x||t.y===o&&o===n.y)return`L${s} ${o}`;if(t.y===o){const u=t.x<n.x?-1:1,d=t.y<n.y?1:-1;return`L ${s+i*u},${o}Q ${s},${o} ${s},${o+i*d}`}const a=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${s},${o+i*l}Q ${s},${o} ${s+i*a},${o}`}function tS({sourceX:t,sourceY:e,sourcePosition:n=Cn.Bottom,targetX:r,targetY:i,targetPosition:s=Cn.Top,borderRadius:o=5,centerX:a,centerY:l,offset:u=20,stepPosition:d=.5}){const[f,h,m,y,g]=MG({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:i},targetPosition:s,center:{x:a,y:l},offset:u,stepPosition:d});return[f.reduce((v,S,C)=>{let k="";return C>0&&C<f.length-1?k=BG(f[C-1],S,f[C+1],o):k=`${C===0?"M":"L"}${S.x} ${S.y}`,v+=k,v},""),h,m,y,g]}function Ej(t){var e;return t&&!!(t.internals.handleBounds||(e=t.handles)!=null&&e.length)&&!!(t.measured.width||t.width||t.initialWidth)}function RG(t){var f;const{sourceNode:e,targetNode:n}=t;if(!Ej(e)||!Ej(n))return null;const r=e.internals.handleBounds||Nj(e.handles),i=n.internals.handleBounds||Nj(n.handles),s=Ij((r==null?void 0:r.source)??[],t.sourceHandle),o=Ij(t.connectionMode===dh.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),t.targetHandle);if(!s||!o)return(f=t.onError)==null||f.call(t,"008",el.error008(s?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const a=(s==null?void 0:s.position)||Cn.Bottom,l=(o==null?void 0:o.position)||Cn.Top,u=$m(e,s,a),d=$m(n,o,l);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function Nj(t){if(!t)return null;const e=[],n=[];for(const r of t)r.width=r.width??1,r.height=r.height??1,r.type==="source"?e.push(r):r.type==="target"&&n.push(r);return{source:e,target:n}}function $m(t,e,n=Cn.Left,r=!1){const i=((e==null?void 0:e.x)??0)+t.internals.positionAbsolute.x,s=((e==null?void 0:e.y)??0)+t.internals.positionAbsolute.y,{width:o,height:a}=e??Gl(t);if(r)return{x:i+o/2,y:s+a/2};switch((e==null?void 0:e.position)??n){case Cn.Top:return{x:i+o/2,y:s};case Cn.Right:return{x:i+o,y:s+a/2};case Cn.Bottom:return{x:i+o/2,y:s+a};case Cn.Left:return{x:i,y:s+a/2}}}function Ij(t,e){return t&&(e?t.find(n=>n.id===e):t[0])||null}function nS(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`:""}function OG(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const s=new Set;return t.reduce((o,a)=>([a.markerStart||r,a.markerEnd||i].forEach(l=>{if(l&&typeof l=="object"){const u=nS(l,e);s.has(u)||(o.push({id:u,color:l.color||n,...l}),s.add(u))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))}const E_={nodeOrigin:[0,0],nodeExtent:Om,elevateNodesOnSelect:!0,defaults:{}},DG={...E_,checkEquality:!0};function N_(t,e){const n={...t};for(const r in e)e[r]!==void 0&&(n[r]=e[r]);return n}function LG(t,e,n){const r=N_(E_,n);for(const i of t.values())if(i.parentId)I_(i,t,e,r);else{const s=y0(i,r.nodeOrigin),o=ph(i.extent)?i.extent:r.nodeExtent,a=sd(s,o,Gl(i));i.internals.positionAbsolute=a}}function rS(t,e,n,r){var l,u;const i=N_(DG,r);let s=t.length>0;const o=new Map(e),a=i!=null&&i.elevateNodesOnSelect?1e3:0;e.clear(),n.clear();for(const d of t){let f=o.get(d.id);if(i.checkEquality&&d===(f==null?void 0:f.internals.userNode))e.set(d.id,f);else{const h=y0(d,i.nodeOrigin),m=ph(d.extent)?d.extent:i.nodeExtent,y=sd(h,m,Gl(d));f={...i.defaults,...d,measured:{width:(l=d.measured)==null?void 0:l.width,height:(u=d.measured)==null?void 0:u.height},internals:{positionAbsolute:y,handleBounds:d.measured?f==null?void 0:f.internals.handleBounds:void 0,z:YR(d,a),userNode:d}},e.set(d.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(s=!1),d.parentId&&I_(f,e,n,r)}return s}function FG(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function I_(t,e,n,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:o}=N_(E_,r),a=t.parentId,l=e.get(a);if(!l){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}FG(t,n);const u=i?1e3:0,{x:d,y:f,z:h}=$G(t,l,s,o,u),{positionAbsolute:m}=t.internals,y=d!==m.x||f!==m.y;
41(y||h!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:y?{x:d,y:f}:m,z:h}})}function YR(t,e){return(pa(t.zIndex)?t.zIndex:0)+(t.selected?e:0)}function $G(t,e,n,r,i){const{x:s,y:o}=e.internals.positionAbsolute,a=Gl(t),l=y0(t,n),u=ph(t.extent)?sd(l,t.extent,a):l;let d=sd({x:s+u.x,y:o+u.y},r,a);t.extent==="parent"&&(d=OR(d,a,e));const f=YR(t,i),h=e.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function j_(t,e,n,r=[0,0]){var o;const i=[],s=new Map;for(const a of t){const l=e.get(a.parentId);if(!l)continue;const u=((o=s.get(a.parentId))==null?void 0:o.expandedRect)??hh(l),d=LR(u,a.rect);s.set(a.parentId,{expandedRect:d,parent:l})}return s.size>0&&s.forEach(({expandedRect:a,parent:l},u)=>{var C;const d=l.internals.positionAbsolute,f=Gl(l),h=l.origin??r,m=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,y=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,g=Math.max(f.width,Math.round(a.width)),w=Math.max(f.height,Math.round(a.height)),v=(g-f.width)*h[0],S=(w-f.height)*h[1];(m>0||y>0||v||S)&&(i.push({id:u,type:"position",position:{x:l.position.x-m+v,y:l.position.y-y+S}}),(C=n.get(u))==null||C.forEach(k=>{t.some(N=>N.id===k.id)||i.push({id:k.id,type:"position",position:{x:k.position.x+m,y:k.position.y+y}})})),(f.width<a.width||f.height<a.height||m||y)&&i.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?h[0]*m-v:0),height:w+(y?h[1]*y-S:0)}})}),i}function UG(t,e,n,r,i,s){const o=r==null?void 0:r.querySelector(".xyflow__viewport");let a=!1;if(!o)return{changes:[],updatedInternals:a};const l=[],u=window.getComputedStyle(o),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of t.values()){const m=e.get(h.id);if(!m)continue;if(m.hidden){e.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),a=!0;continue}const y=__(h.nodeElement),g=m.measured.width!==y.width||m.measured.height!==y.height;if(!!(y.width&&y.height&&(g||!m.internals.handleBounds||h.force))){const v=h.nodeElement.getBoundingClientRect(),S=ph(m.extent)?m.extent:s;let{positionAbsolute:C}=m.internals;m.parentId&&m.extent==="parent"?C=OR(C,y,e.get(m.parentId)):S&&(C=sd(C,S,y));const k={...m,measured:y,internals:{...m.internals,positionAbsolute:C,handleBounds:{source:kj("source",h.nodeElement,v,d,m.id),target:kj("target",h.nodeElement,v,d,m.id)}}};e.set(m.id,k),m.parentId&&I_(k,e,n,{nodeOrigin:i}),a=!0,g&&(l.push({id:m.id,type:"dimensions",dimensions:y}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:hh(k,i)}))}}if(f.length>0){const h=j_(f,e,n,i);l.push(...h)}return{changes:l,updatedInternals:a}}async function VG({delta:t,panZoom:e,transform:n,translateExtent:r,width:i,height:s}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);const o=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,s]],r),a=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(a)}function jj(t,e,n,r,i,s){let o=i;const a=r.get(o)||new Map;r.set(o,a.set(n,e)),o=`${i}-${t}`;const l=r.get(o)||new Map;if(r.set(o,l.set(n,e)),s){o=`${i}-${t}-${s}`;const u=r.get(o)||new Map;r.set(o,u.set(n,e))}}function XR(t,e,n){t.clear(),e.clear();for(const r of n){const{source:i,target:s,sourceHandle:o=null,targetHandle:a=null}=r,l={edgeId:r.id,source:i,target:s,sourceHandle:o,targetHandle:a},u=`${i}-${o}--${s}-${a}`,d=`${s}-${a}--${i}-${o}`;jj("source",l,d,t,i,o),jj("target",l,u,t,s,a),e.set(r.id,r)}}function QR(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return n?n.selected?!0:QR(n,e):!1}function Tj(t,e,n){var i;let r=t;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,e))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function HG(t,e,n,r){const i=new Map;for(const[s,o]of t)if((o.selected||o.id===r)&&(!o.parentId||!QR(o,t))&&(o.draggable||e&&typeof o.draggable>"u")){const a=t.get(s);a&&i.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return i}function E1({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){var o,a,l;const i=[];for(const[u,d]of e){const f=(o=n.get(u))==null?void 0:o.internals.userNode;f&&i.push({...f,position:d.position,dragging:r})}if(!t)return[i[0],i];const s=(a=n.get(t))==null?void 0:a.internals.userNode;return[s?{...s,position:((l=e.get(t))==null?void 0:l.position)||s.position,dragging:r}:i[0],i]}function GG({dragItems:t,snapGrid:e,x:n,y:r}){const i=t.values().next().value;if(!i)return null;const s={x:n-i.distance.x,y:r-i.distance.y},o=x0(s,e);return{x:o.x-s.x,y:o.y-s.y}}function WG({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:i}){let s={x:null,y:null},o=0,a=new Map,l=!1,u={x:0,y:0},d=null,f=!1,h=null,m=!1,y=!1,g=null;function w({noDragClassName:S,handleSelector:C,domNode:k,isSelectable:N,nodeId:_,nodeClickDistance:j=0}){h=co(k);function T({x:P,y:F}
41){const{nodeLookup:I,nodeExtent:R,snapGrid:U,snapToGrid:A,nodeOrigin:W,onNodeDrag:D,onSelectionDrag:B,onError:L,updateNodePositions:$}=e();s={x:P,y:F};let q=!1;const Z=a.size>1,ie=Z&&R?eS(v0(a)):null,ge=Z&&A?GG({dragItems:a,snapGrid:U,x:P,y:F}):null;for(const[re,Y]of a){if(!I.has(re))continue;let ne={x:P-Y.distance.x,y:F-Y.distance.y};A&&(ne=ge?{x:Math.round(ne.x+ge.x),y:Math.round(ne.y+ge.y)}:x0(ne,U));let be=null;if(Z&&R&&!Y.extent&&ie){const{positionAbsolute:fe}=Y.internals,O=fe.x-ie.x+R[0][0],pe=fe.x+Y.measured.width-ie.x2+R[1][0],he=fe.y-ie.y+R[0][1],le=fe.y+Y.measured.height-ie.y2+R[1][1];be=[[O,he],[pe,le]]}const{position:we,positionAbsolute:te}=RR({nodeId:re,nextPosition:ne,nodeLookup:I,nodeExtent:be||R,nodeOrigin:W,onError:L});q=q||Y.position.x!==we.x||Y.position.y!==we.y,Y.position=we,Y.internals.positionAbsolute=te}if(y=y||q,!!q&&($(a,!0),g&&(r||D||!_&&B))){const[re,Y]=E1({nodeId:_,dragItems:a,nodeLookup:I});r==null||r(g,a,re,Y),D==null||D(g,re,Y),_||B==null||B(g,Y)}}async function M(){if(!d)return;const{transform:P,panBy:F,autoPanSpeed:I,autoPanOnNodeDrag:R}=e();if(!R){l=!1,cancelAnimationFrame(o);return}const[U,A]=DR(u,d,I);(U!==0||A!==0)&&(s.x=(s.x??0)-U/P[2],s.y=(s.y??0)-A/P[2],await F({x:U,y:A})&&T(s)),o=requestAnimationFrame(M)}function V(P){var Z;const{nodeLookup:F,multiSelectionActive:I,nodesDraggable:R,transform:U,snapGrid:A,snapToGrid:W,selectNodesOnDrag:D,onNodeDragStart:B,onSelectionDragStart:L,unselectNodesAndEdges:$}=e();f=!0,(!D||!N)&&!I&&_&&((Z=F.get(_))!=null&&Z.selected||$()),N&&D&&_&&(t==null||t(_));const q=hm(P.sourceEvent,{transform:U,snapGrid:A,snapToGrid:W,containerBounds:d});if(s=q,a=HG(F,R,q,_),a.size>0&&(n||B||!_&&L)){const[ie,ge]=E1({nodeId:_,dragItems:a,nodeLookup:F});n==null||n(P.sourceEvent,a,ie,ge),B==null||B(P.sourceEvent,ie,ge),_||L==null||L(P.sourceEvent,ge)}}const H=mR().clickDistance(j).on("start",P=>{const{domNode:F,nodeDragThreshold:I,transform:R,snapGrid:U,snapToGri
41d:A}=e();d=(F==null?void 0:F.getBoundingClientRect())||null,m=!1,y=!1,g=P.sourceEvent,I===0&&V(P),s=hm(P.sourceEvent,{transform:R,snapGrid:U,snapToGrid:A,containerBounds:d}),u=Ha(P.sourceEvent,d)}).on("drag",P=>{const{autoPanOnNodeDrag:F,transform:I,snapGrid:R,snapToGrid:U,nodeDragThreshold:A,nodeLookup:W}=e(),D=hm(P.sourceEvent,{transform:I,snapGrid:R,snapToGrid:U,containerBounds:d});if(g=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||_&&!W.has(_))&&(m=!0),!m){if(!l&&F&&f&&(l=!0,M()),!f){const B=D.xSnapped-(s.x??0),L=D.ySnapped-(s.y??0);Math.sqrt(B*B+L*L)>A&&V(P)}(s.x!==D.xSnapped||s.y!==D.ySnapped)&&a&&f&&(u=Ha(P.sourceEvent,d),T(D))}}).on("end",P=>{if(!(!f||m)&&(l=!1,f=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:F,updateNodePositions:I,onNodeDragStop:R,onSelectionDragStop:U}=e();if(y&&(I(a,!1),y=!1),i||R||!_&&U){const[A,W]=E1({nodeId:_,dragItems:a,nodeLookup:F,dragging:!1});i==null||i(P.sourceEvent,a,A,W),R==null||R(P.sourceEvent,A,W),_||U==null||U(P.sourceEvent,W)}}}).filter(P=>{const F=P.target;return!P.button&&(!S||!Tj(F,`.${S}`,k))&&(!C||Tj(F,C,k))});h.call(H)}function v(){h==null||h.on(".drag",null)}return{update:w,destroy:v}}function qG(t,e,n){const r=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const s of e.values())Lm(i,hh(s))>0&&r.push(s);return r}const KG=250;function YG(t,e,n,r){var a,l;let i=[],s=1/0;const o=qG(t,n,e+KG);for(const u of o){const d=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((l=u.internals.handleBounds)==null?void 0:l.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:m}=$m(u,f,f.position,!0),y=Math.sqrt(Math.pow(h-t.x,2)+Math.pow(m-t.y,2));y>e||(y<s?(i=[{...f,x:h,y:m}],s=y):y===s&&i.push({...f,x:h,y:m}))}}if(!i.length)return null;if(i.length>1){const u=r.type==="source"?"target":"source";return i.find(d=>d.type===u)??i[0]}return i[0]}function ZR(t,e,n,r,i,s=!1){var u,d,f;
41const o=r.get(t);if(!o)return null;const a=i==="strict"?(u=o.internals.handleBounds)==null?void 0:u[e]:[...((d=o.internals.handleBounds)==null?void 0:d.source)??[],...((f=o.internals.handleBounds)==null?void 0:f.target)??[]],l=(n?a==null?void 0:a.find(h=>h.id===n):a==null?void 0:a[0])??null;return l&&s?{...l,...$m(o,l,l.position,!0)}:l}function JR(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function XG(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}const e3=()=>!0;function QG(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:s,isTarget:o,domNode:a,nodeLookup:l,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:m,onConnectStart:y,onConnect:g,onConnectEnd:w,isValidConnection:v=e3,onReconnectEnd:S,updateConnection:C,getTransform:k,getFromHandle:N,autoPanSpeed:_,dragThreshold:j=1,handleDomNode:T}){const M=UR(t.target);let V=0,H;const{x:P,y:F}=Ha(t),I=JR(s,T),R=a==null?void 0:a.getBoundingClientRect();let U=!1;if(!R||!I)return;const A=ZR(i,I,r,l,e);if(!A)return;let W=Ha(t,R),D=!1,B=null,L=!1,$=null;function q(){if(!d||!R)return;const[we,te]=DR(W,R,_);h({x:we,y:te}),V=requestAnimationFrame(q)}const Z={...A,nodeId:i,type:I,position:A.position},ie=l.get(i);let re={inProgress:!0,isValid:null,from:$m(ie,Z,Cn.Left,!0),fromHandle:Z,fromPosition:Z.position,fromNode:ie,to:W,toHandle:null,toPosition:yj[Z.position],toNode:null};function Y(){U=!0,C(re),y==null||y(t,{nodeId:i,handleId:r,handleType:I})}j===0&&Y();function ne(we){if(!U){const{x:pe,y:he}=Ha(we),le=pe-P,oe=he-F;if(!(le*le+oe*oe>j*j))return;Y()}if(!N()||!Z){be(we);return}const te=k();W=Ha(we,R),H=YG(w0(W,te,!1,[1,1]),n,l,Z),D||(q(),D=!0);const fe=t3(we,{handle:H,connectionMode:e,fromNodeId:i,fromHandleId:r,fromType:o?"target":"source",isValidConnection:v,doc:M,lib:u,flowId:f,nodeLookup:l});$=fe.handleDomNode,B=fe.connection,L=XG(!!H,fe.isValid);const O={...re,isValid:L,to:fe.toHandle&&L?Dy({x:fe.toHandle.x,y:fe.toHandle.y},te):W,toHandle:fe.toHandle,toPosition:L&&fe.toHandle?fe.toHandle.position:yj[Z.position],toNode:fe.toHandle?l.get(fe.toHandle.nodeId):null};L&&H&&re.toHandle&&O.toHandle&&re.toHandle.type===O.toHandle.type&&re.toHandle.nodeId===O.toHandle.nodeId&&re.toHandle.id===O.toHandle.id&&re.to.x===O.to.x&&re.to.y===O.to.y||(C(O),re=O)}function be(we){if(U){(H||$)&&B&&L&&(g==null||g(B));const{inProgress:te,...fe}=re,O={...fe,toPosition:re.toHandle?re.toPosition:null};w==null||w(we,O),s&&(S==null||S(we,O))}m(),cancelAnimationFrame(V),D=!1,L=!1,B=null,$=null,M.removeEventListener("mousemove",ne),M.removeEventListener("mouseup",be),M.removeEventListener("touchmove",ne),M.removeEventListener("touchend",be)}M.addEventListener("mousemove",ne),M.addEventListener("mouseup",be),M.addEventListener("touchmove",ne),M.addEventListener("touchend",be)}function t3(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:s,doc:o,lib:a,flowId:l,isValidConnection:u=e3,nodeLookup:d}){const f=s==="target",h=e?o.querySelector(`.${a}-flow__handle[data-id="${l}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:m,y}=Ha(t),g=o.elementFromPoint(m,y),w=g!=null&&g.classList.contains(`${a}-flow__handle`)?g:h,v={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const S=JR(void 0,w),C=w.getAttribute("data-nodeid"),k=w.getAttribute("data-handleid"),N=w.classList.contains("connectable"),_=w.classList.contains("connectableend");if(!C||!S)return v;const j={source:f?C:r,sourceHandle:f?k:i,target:f?r:C,targetHandle:f?i:k};v.connection=j;const M=N&&_&&(n===dh.Strict?f&&S==="source"||!f&&S==="target":C!==r||k!==i);v.isValid=M&&u(j),v.toHandle=ZR(C,S,k,d,n,!0)}return v}const iS={onPointerDown:QG,isValid:t3};function ZG({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){const i=co(t);function s({translateExtent:a,width:l,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:m=!1}){const y=C=>{if(C.sourceEvent.type!=="wheel"||!e)return;const k=n(),N=C.sourceEvent.ctrlKey&&Fm()?10:1,_=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?
411:.002)*d,j=k[2]*Math.pow(2,_*N);e.scaleTo(j)};let g=[0,0];const w=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(g=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},v=C=>{const k=n();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!e)return;const N=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],_=[N[0]-g[0],N[1]-g[1]];g=N;const j=r()*Math.max(k[2],Math.log(k[2]))*(m?-1:1),T={x:k[0]-_[0]*j,y:k[1]-_[1]*j},M=[[0,0],[l,u]];e.setViewportConstrained({x:T.x,y:T.y,zoom:k[2]},M,a)},S=TR().on("start",w).on("zoom",f?v:null).on("zoom.wheel",h?y:null);i.call(S,{})}function o(){i.on("zoom",null)}return{update:s,destroy:o,pointer:oa}}const JG=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,Vv=t=>({x:t.x,y:t.y,zoom:t.k}),N1=({x:t,y:e,zoom:n})=>Fv.translate(t,e).scale(n),Af=(t,e)=>t.target.closest(`.${e}`),n3=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),eW=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,I1=(t,e=0,n=eW,r=()=>{})=>{const i=typeof e=="number"&&e>0;return i||r(),i?t.transition().duration(e).ease(n).on("end",r):t},r3=t=>{const e=t.ctrlKey&&Fm()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};function tW({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(Af(d,e))return!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&o){const w=oa(d),v=r3(d),S=f*Math.pow(2,v);r.scaleTo(n,S,w,d);return}const h=d.deltaMode===1?20:1;let m=i===ba.Vertical?0:d.deltaX*h,y=i===ba.Horizontal?0:d.deltaY*h;!Fm()&&d.shiftKey&&i!==ba.Vertical&&(m=d.deltaY*h,y=0),r.translateBy(n,-(m/f)*s,-(y/f)*s,{internal:!0});const g=Vv(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling||(t.isPanScrolling=!0,a==null||a(d,g)),t.isPanScrolling&&(l==null||l(d,g),t.panScrollTimeout=setTimeout(()=>{u==null||u(d,g),t.isPanScrolling=!1},150))}}function nW({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,i){const s=r.type==="wheel",o=!e&&s&&!r.ctrlKey,a=Af(r,t);if(r.ctrlKey&&s&&a&&r.preventDefault(),o||a)return null;r.preventDefault(),n.call(this,r,i)}}function rW({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{var s,o,a;if((s=r.sourceEvent)!=null&&s.internal)return;const i=Vv(r.transform);t.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=i,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&e(!0),n&&(n==null||n(r.sourceEvent,i))}}function iW({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return s=>{var o,a;t.usedRightMouseButton=!!(n&&n3(e,t.mouseButton??0)),(o=s.sourceEvent)!=null&&o.sync||r([s.transform.x,s.transform.y,s.transform.k]),i&&!((a=s.sourceEvent)!=null&&a.internal)&&(i==null||i(s.sourceEvent,Vv(s.transform)))}}function sW({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:s}){return o=>{var a;if(!((a=o.sourceEvent)!=null&&a.internal)&&(t.isZoomingOrPanning=!1,s&&n3(e,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&s(o.sourceEvent),t.usedRightMouseButton=!1,r(!1),i&&JG(t.prevViewport,o.transform))){const l=Vv(o.transform);t.prevViewport=l,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i==null||i(o.sourceEvent,l)},n?150:0)}}}function oW({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:o,noWheelClassName:a,noPanClassName:l,lib:u}){return d=>{var y;const f=t||e,h=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Af(d,`${u}-flow__node`)||Af(d,`${u}-flow__edge`)))return!0;if(!r&&!f&&!i&&!s&&!n||o||Af(d,a)&&d.type==="wheel"||Af(d,l)&&(d.type!=="wheel"||i&&d.type==="wheel"&&!t)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((y=d.touches)==null?void 0:y.length)>1)return d.preventDefault(),!1;if(!f&&!i&&!h&&d.type==="wheel"||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const m=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||d.type==="wheel")&&m}}function aW({domNode:t,minZoom:e,maxZoom:n,paneClickDistance:r,translateExtent:i,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=t.getBoundingClientRect(),h=TR().clickDistance(!pa(r)||r<0?0:r).scaleExtent([e,n]).translateExtent(i),m=co(t).call(h);C({x:s.x,y:s.y,zoom:fh(s.zoom,e,n)},[[0,0],[f.width,f.height]],i);const y=m.on("wheel.zoom"),g=m.on("dblclick.zoom");h.wheelDelta(r3);function w(P,F){return m?new Promise(I=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?fm:ry).transform(I1(m,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>I(!0)),P)}):Promise.resolve(!1)}function v({noWheelClassName:P,noPanClassName:F,onPaneContextMenu:I,userSelectionActive:R,panOnScroll:U,panOnDrag:A,panOnScrollMode:W,panOnScrollSpeed:D,preventScrolling:B,zoomOnPinch:L,zoomOnScroll:$,zoomOnDoubleClick:q,zoomActivationKeyPressed:Z,lib:ie,onTransformChange:ge}
41){R&&!d.isZoomingOrPanning&&S();const Y=U&&!Z&&!R?tW({zoomPanValues:d,noWheelClassName:P,d3Selection:m,d3Zoom:h,panOnScrollMode:W,panOnScrollSpeed:D,zoomOnPinch:L,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):nW({noWheelClassName:P,preventScrolling:B,d3ZoomHandler:y});if(m.on("wheel.zoom",Y,{passive:!1}),!R){const be=rW({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});h.on("start",be);const we=iW({zoomPanValues:d,panOnDrag:A,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:ge});h.on("zoom",we);const te=sW({zoomPanValues:d,panOnDrag:A,panOnScroll:U,onPaneContextMenu:I,onPanZoomEnd:l,onDraggingChange:u});h.on("end",te)}const ne=oW({zoomActivationKeyPressed:Z,panOnDrag:A,zoomOnScroll:$,panOnScroll:U,zoomOnDoubleClick:q,zoomOnPinch:L,userSelectionActive:R,noPanClassName:F,noWheelClassName:P,lib:ie});h.filter(ne),q?m.on("dblclick.zoom",g):m.on("dblclick.zoom",null)}function S(){h.on("zoom",null)}async function C(P,F,I){const R=N1(P),U=h==null?void 0:h.constrain()(R,F,I);return U&&await w(U),new Promise(A=>A(U))}async function k(P,F){const I=N1(P);return await w(I,F),new Promise(R=>R(I))}function N(P){if(m){const F=N1(P),I=m.property("__zoom");(I.k!==P.zoom||I.x!==P.x||I.y!==P.y)&&(h==null||h.transform(m,F,null,{sync:!0}))}}function _(){const P=m?jR(m.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function j(P,F){return m?new Promise(I=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?fm:ry).scaleTo(I1(m,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>I(!0)),P)}):Promise.resolve(!1)}function T(P,F){return m?new Promise(I=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?fm:ry).scaleBy(I1(m,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>I(!0)),P)}):Promise.resolve(!1)}function M(P){h==null||h.scaleExtent(P)}function V(P){h==null||h.translateExtent(P)}function H(P){const F=!pa(P)||P<0?0:P;h==null||h.clickDistance(F)}return{update:v,destroy:S,setViewport:k,setViewportConstrained:C,getViewport:_,scaleTo:j,scaleBy:T,setScaleExtent:M,setTranslateExtent:V,syncViewport:N,setClickDistance:H}}var mh;(function(t){t.Line="line",t.Handle="handle"})(mh||(mh={}));function lW({width:t,prevWidth:e,height:n,prevHeight:r,affectsX:i,affectsY:s}){const o=t-e,a=n-r,l=[o>0?1:o<0?-1:0,a>0?1:a<0?-1:0];return o&&i&&(l[0]=l[0]*-1),a&&s&&(l[1]=l[1]*-1),l}function cW(t){const e=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),r=t.includes("left"),i=t.includes("top");return{isHorizontal:e,isVertical:n,affectsX:r,affectsY:i}}function lc(t,e){return Math.max(0,e-t)}function cc(t,e){return Math.max(0,t-e)}function tb(t,e,n){return Math.max(0,e-t,t-n)}function zj(t,e){return t?!e:e}function uW(t,e,n,r,i,s,o,a){let{affectsX:l,affectsY:u}=e;const{isHorizontal:d,isVertical:f}=e,h=d&&f,{xSnapped:m,ySnapped:y}=n,{minWidth:g,maxWidth:w,minHeight:v,maxHeight:S}=r,{x:C,y:k,width:N,height:_,aspectRatio:j}=t;let T=Math.floor(d?m-t.pointerX:0),M=Math.floor(f?y-t.pointerY:0);const V=N+(l?-T:T),H=_+(u?-M:M),P=-s[0]*N,F=-s[1]*_;let I=tb(V,g,w),R=tb(H,v,S);if(o){let W=0,D=0;l&&T<0?W=lc(C+T+P,o[0][0]):!l&&T>0&&(W=cc(C+V+P,o[1][0])),u&&M<0?D=lc(k+M+F,o[0][1]):!u&&M>0&&(D=cc(k+H+F,o[1][1])),I=Math.max(I,W),R=Math.max(R,D)}if(a){let W=0,D=0;l&&T>0?W=cc(C+T,a[0][0]):!l&&T<0&&(W=lc(C+V,a[1][0])),u&&M>0?D=cc(k+M,a[0][1]):!u&&M<0&&(D=lc(k+H,a[1][1])),I=Math.max(I,W),R=Math.max(R,D)}if(i){if(d){const W=tb(V/j,v,S)*j;if(I=Math.max(I,W),o){let D=0;!l&&!u||l&&!u&&h?D=cc(k+F+V/j,o[1][1])*j:D=lc(k+F+(l?T:-T)/j,o[0][1])*j,I=Math.max(I,D)}if(a){let D=0;!l&&!u||l&&!u&&h?D=lc(k+V/j,a[1][1])*j:D=cc(k+(l?T:-T)/j,a[0][1])*j,I=Math.max(I,D)}}if(f){const W=tb(H*j,g,w)/j;if(R=Math.max(R,W),o){let D=0;!l&&!u||u&&!l&&h?D=cc(C+H*j+P,o[1][0])/j:D=lc(C+(u?M:-M)*j+P,o[0][0])/j,R=Math.max(R,D)}if(a){let D=0;!l&&!u||u&&!l&&h?D=lc(C+H*j,a[1][0])/j:D=cc(C+(u?M:-M)*j,a[0][0])/j,R=Math.max(R,D)}}}M=M+(M<0?R:-R),T=T+(T<0?I:-I),i&&(h?V>H*j?M=(zj(l,u)?-T:T)/j:T=(zj(l,u)?-M:M)*j:d?(M=T/j,u=l):(T=M*j,l=u));const U=l?C+T:C,A=u?k+M:k;return{width:N+(l?-T:T),height:_+(u?-M:M),x:s[0]*T*(l?-1:1)+U,y:s[1]*M*(u?-1:1)+A}}const i3={width:0,height:0,x:0,y:0},dW={...i3,pointerX:0,pointerY:0,aspectRatio:1};function fW(t){return[[0,0],[t.measured.width,t.measured.height]]}function hW(t,e,n){const r=e.position.x+t.position.x,i=e.position.y+t.position.y,s=t.measured.width??0,o=t.measured.height??0,a=n[0]*s,l=n[1]*o;return[[r-a,i-l],[r+s-a,i+o-l]]}function pW({domNode:t,nodeId:e,getStoreItems:n,onChange:r,onEnd:i}){const s=co(t);function o({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:m,onResizeEnd:y,shouldResize:g}){let w={...i3},v={...dW};const S=cW(l);let C,k=null,N=[],_,j,T;const M=mR().on("start",V=>
41{const{nodeLookup:H,transform:P,snapGrid:F,snapToGrid:I,nodeOrigin:R,paneDomNode:U}=n();if(C=H.get(e),!C)return;k=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:W}=hm(V.sourceEvent,{transform:P,snapGrid:F,snapToGrid:I,containerBounds:k});w={width:C.measured.width??0,height:C.measured.height??0,x:C.position.x??0,y:C.position.y??0},v={...w,pointerX:A,pointerY:W,aspectRatio:w.width/w.height},_=void 0,C.parentId&&(C.extent==="parent"||C.expandParent)&&(_=H.get(C.parentId),j=_&&C.extent==="parent"?fW(_):void 0),N=[],T=void 0;for(const[D,B]of H)if(B.parentId===e&&(N.push({id:D,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=hW(B,C,B.origin??R);T?T=[[Math.min(L[0][0],T[0][0]),Math.min(L[0][1],T[0][1])],[Math.max(L[1][0],T[1][0]),Math.max(L[1][1],T[1][1])]]:T=L}h==null||h(V,{...w})}).on("drag",V=>{const{transform:H,snapGrid:P,snapToGrid:F,nodeOrigin:I}=n(),R=hm(V.sourceEvent,{transform:H,snapGrid:P,snapToGrid:F,containerBounds:k}),U=[];if(!C)return;const{x:A,y:W,width:D,height:B}=w,L={},$=C.origin??I,{width:q,height:Z,x:ie,y:ge}=uW(v,S,R,u,d,$,j,T),re=q!==D,Y=Z!==B,ne=ie!==A&&re,be=ge!==W&&Y;if(!ne&&!be&&!re&&!Y)return;if((ne||be||$[0]===1||$[1]===1)&&(L.x=ne?ie:w.x,L.y=be?ge:w.y,w.x=L.x,w.y=L.y,N.length>0)){const O=ie-A,pe=ge-W;for(const he of N)he.position={x:he.position.x-O+$[0]*(q-D),y:he.position.y-pe+$[1]*(Z-B)},U.push(he)}if((re||Y)&&(L.width=re&&(!f||f==="horizontal")?q:w.width,L.height=Y&&(!f||f==="vertical")?Z:w.height,w.width=L.width,w.height=L.height),_&&C.expandParent){const O=$[0]*(L.width??0);L.x&&L.x<O&&(w.x=O,v.x=v.x-(L.x-O));const pe=$[1]*(L.height??0);L.y&&L.y<pe&&(w.y=pe,v.y=v.y-(L.y-pe))}const we=lW({width:w.width,prevWidth:D,height:w.height,prevHeight:B,affectsX:S.affectsX,affectsY:S.affectsY}),te={...w,direction:we};(g==null?void 0:g(V,te))!==!1&&(m==null||m(V,te),r(L,U))}).on("end",V=>{y==null||y(V,{...w}),i==null||i({...w})});s.call(M)}function a(){s.on(".drag",null)}return{update:o,destroy:a}}var j1={exports:{}},T1={},z1={exports:{}},P1={};/** 42 * @license React 43 * use-sync-external-store-shim.production.js 44 * 45 * Copyright (c) Meta Platforms, Inc. and affiliates. 46 * 47 * This source code is licensed under the MIT license found in the 48 * LICENSE file in the root directory of this source tree. 49 */var Pj;function mW(){if(Pj)return P1;Pj=1;var t=Uh();function e(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function a(f,h){var m=h(),y=r({inst:{value:m,getSnapshot:h}}),g=y[0].inst,w=y[1];return s(function(){g.value=m,g.getSnapshot=h,l(g)&&w({inst:g})},[f,m,h]),i(function(){return l(g)&&w({inst:g}),f(function(){l(g)&&w({inst:g})})},[f]),o(m),m}function l(f){var h=f.getSnapshot;f=f.value;try{var m=h();return!n(f,m)}catch{return!0}}function u(f,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return P1.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,P1}var Aj;function gW(){return Aj||(Aj=1,z1.exports=mW()),z1.exports}/** 50 * @license React 51 * use-sync-external-store-shim/with-selector.production.js 52 * 53 * Copyright (c) Meta Platforms, Inc. and affiliates. 54 * 55 * This source code is licensed under the MIT license found in the 56 * LICENSE file in the root directory of this source tree. 57 */var Mj;function bW(){if(Mj)return T1;Mj=1;var t=Uh(),e=gW();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,o=t.useEffect,a=t.useMemo,l=t.useDebugValue;return T1.useSyncExternalStoreWithSelector=function(u,d,f,h,m){var y=s(null);if(y.current===null){var g={hasValue:!1,value:null};y.current=g}else g=y.current;y=a(function(){function v(_){if(!S){if(S=!0,C=_,_=h(_),m!==void 0&&g.hasValue){var j=g.value;if(m(j,_))return k=j}return k=_}if(j=k,r(C,_))return j;var T=h(_);return m!==void 0&&m(j,T)?(C=_,j):(C=_,k=T)}var S=!1,C,k,N=f===void 0?null:f;
57return[function(){return v(d())},N===null?void 0:function(){return v(N())}]},[d,f,h,m]);var w=i(u,y[0],y[1]);return o(function(){g.hasValue=!0,g.value=w},[w]),l(w),w},T1}var Bj;function yW(){return Bj||(Bj=1,j1.exports=bW()),j1.exports}var vW=yW();const s3=Vo(vW),xW={},Rj=t=>{let e;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(e):d;if(!Object.is(h,e)){const m=e;e=f??(typeof h!="object"||h===null)?h:Object.assign({},e,h),n.forEach(y=>y(e,m))}},i=()=>e,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(xW?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=e=t(r,i,l);return l},o3=t=>t?Rj(t):Rj,{useDebugValue:wW}=mr,{useSyncExternalStoreWithSelector:kW}=s3,SW=t=>t;function a3(t,e=SW,n){const r=kW(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return wW(r),r}const Oj=(t,e)=>{const n=o3(t),r=(i,s=e)=>a3(n,i,s);return Object.assign(r,n),r},CW=(t,e)=>t?Oj(t,e):Oj;function ni(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,i]of t)if(!Object.is(i,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var Vh=eR();const _W=Vo(Vh),Hv=x.createContext(null),EW=Hv.Provider,l3=el.error001();function Kn(t,e){const n=x.useContext(Hv);if(n===null)throw new Error(l3);return a3(n,t,e)}function qr(){const t=x.useContext(Hv);if(t===null)throw new Error(l3);return x.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Dj={display:"none"},NW={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},c3="react-flow__node-desc",u3="react-flow__edge-desc",IW="react-flow__aria-live",jW=t=>t.ariaLiveMessage,TW=t=>t.ariaLabelConfig;function zW({rfId:t}){const e=Kn(jW);return c.jsx("div",{id:`${IW}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:NW,children:e})}function PW({rfId:t,disableKeyboardA11y:e}){const n=Kn(TW);return c.jsxs(c.Fragment,{children:[c.jsx("div",{id:`${c3}-${t}`,style:Dj,children:e?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),c.jsx("div",{id:`${u3}-${t}`,style:Dj,children:n["edge.a11yDescription.default"]}),!e&&c.jsx(zW,{rfId:t})]})}const Gv=x.forwardRef(({position:t="top-left",children:e,className:n,style:r,...i},s)=>{const o=`${t}`.split("-");return c.jsx("div",{className:Ei(["react-flow__panel",n,...o]),style:r,ref:s,...i,children:e})});Gv.displayName="Panel";function AW({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:c.jsx(Gv,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:c.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const MW=t=>{const e=[],n=[];for(const[,r]of t.nodeLookup)r.selected&&e.push(r.internals.userNode);for(const[,r]of t.edgeLookup)r.selected&&n.push(r);return{selectedNodes:e,selectedEdges:n}},nb=t=>t.id;function BW(t,e){return ni(t.selectedNodes.map(nb),e.selectedNodes.map(nb))&&ni(t.selectedEdges.map(nb),e.selectedEdges.map(nb))}function RW({onSelectionChange:t}){const e=qr(),{selectedNodes:n,selectedEdges:r}=Kn(MW,BW);return x.useEffect(()=>{const i={nodes:n,edges:r};t==null||t(i),e.getState().onSelectionChangeHandlers.forEach(s=>s(i))},[n,r,t]),null}const OW=t=>!!t.onSelectionChangeHandlers;function DW({onSelectionChange:t}){const e=Kn(OW);return t||e?c.jsx(RW,{onSelectionChange:t}):null}const d3=[0,0],LW={x:0,y:0,zoom:1},FW=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGri
57d","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","paneClickDistance","ariaLabelConfig"],Lj=[...FW,"rfId"],$W=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setPaneClickDistance:t.setPaneClickDistance}),Fj={translateExtent:Om,nodeOrigin:d3,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function UW(t){const{setNodes:e,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:s,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:l,setPaneClickDistance:u}=Kn($W,ni),d=qr();x.useEffect(()=>(l(t.defaultNodes,t.defaultEdges),()=>{f.current=Fj,a()}),[]);const f=x.useRef(Fj);return x.useEffect(()=>{for(const h of Lj){const m=t[h],y=f.current[h];m!==y&&(typeof t[h]>"u"||(h==="nodes"?e(m):h==="edges"?n(m):h==="minZoom"?r(m):h==="maxZoom"?i(m):h==="translateExtent"?s(m):h==="nodeExtent"?o(m):h==="paneClickDistance"?u(m):h==="ariaLabelConfig"?d.setState({ariaLabelConfig:EG(m)}):h==="fitView"?d.setState({fitViewQueued:m}):h==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[h]:m})))}f.current=t},Lj.map(h=>t[h])),null}function $j(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function VW(t){var r;const[e,n]=x.useState(t==="system"?null:t);return x.useEffect(()=>{if(t!=="system"){n(t);return}const i=$j(),s=()=>n(i!=null&&i.matches?"dark":"light");return s(),i==null||i.addEventListener("change",s),()=>{i==null||i.removeEventListener("change",s)}},[t]),e!==null?e:(r=$j())!=null&&r.matches?"dark":"light"}const Uj=typeof document<"u"?document:null;function Um(t=null,e={target:Uj,actInsideInputWithModifier:!0}){const[n,r]=x.useState(!1),i=x.useRef(!1),s=x.useRef(new Set([])),[o,a]=x.useMemo(()=>{if(t!==null){const u=(Array.isArray(t)?t:[t]).filter(f=>typeof f=="string").map(f=>f.replace("+",` 58`).replace(` 59 60`,` 61+`).split(` 62`)),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[t]);return x.useEffect(()=>{const l=(e==null?void 0:e.target)??Uj,u=(e==null?void 0:e.actInsideInputWithModifier)??!0;if(t!==null){const d=m=>{var w,v;if(i.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!i.current||i.current&&!u)&&VR(m))return!1;const g=Hj(m.code,a);if(s.current.add(m[g]),Vj(o,s.current,!1)){const S=((v=(w=m.composedPath)==null?void 0:w.call(m))==null?void 0:v[0])||m.target,C=(S==null?void 0:S.nodeName)==="BUTTON"||(S==null?void 0:S.nodeName)==="A";e.preventDefault!==!1&&(i.current||!C)&&m.preventDefault(),r(!0)}},f=m=>{const y=Hj(m.code,a);Vj(o,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(m[y]),m.key==="Meta"&&s.current.clear(),i.current=!1},h=()=>{s.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",d),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{l==null||l.removeEventListener("keydown",d),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[t,r]),n}function Vj(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(i=>e.has(i)))}function Hj(t,e){return e.includes(t)?"code":"key"}const HW=()=>{const t=qr();return x.useMemo(()=>({zoomIn:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomOut:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomTo:(e,n)=>{const{panZoom:r}=t.getState();return r?r.scaleTo(e,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,n)=>{const{transform:[r,i,s],panZoom:o}=t.getState();return o?(await o.setViewport({x:e.x??r,y:e.y??i,zoom:e.zoom??s},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},setCenter:async(e,n,r)=>t.getState().setCenter(e,n,r),fitBounds:async(e,n)=>
62{const{width:r,height:i,minZoom:s,maxZoom:o,panZoom:a}=t.getState(),l=C_(e,r,i,s,o,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,n={})=>{const{transform:r,snapGrid:i,snapToGrid:s,domNode:o}=t.getState();if(!o)return e;const{x:a,y:l}=o.getBoundingClientRect(),u={x:e.x-a,y:e.y-l},d=n.snapGrid??i,f=n.snapToGrid??s;return w0(u,r,f,d)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:i,y:s}=r.getBoundingClientRect(),o=Dy(e,n);return{x:o.x+i,y:o.y+s}}}),[])};function f3(t,e){const n=[],r=new Map,i=[];for(const s of t)if(s.type==="add"){i.push(s);continue}else if(s.type==="remove"||s.type==="replace")r.set(s.id,[s]);else{const o=r.get(s.id);o?o.push(s):r.set(s.id,[s])}for(const s of e){const o=r.get(s.id);if(!o){n.push(s);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const a={...s};for(const l of o)GW(l,a);n.push(a)}return i.length&&i.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function GW(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured??(e.measured={}),e.measured.width=t.dimensions.width,e.measured.height=t.dimensions.height,t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function WW(t,e){return f3(t,e)}function qW(t,e){return f3(t,e)}function Eu(t,e){return{id:t,type:"select",selected:e}}function Mf(t,e=new Set,n=!1){const r=[];for(const[i,s]of t){const o=e.has(i);!(s.selected===void 0&&!o)&&s.selected!==o&&(n&&(s.selected=o),r.push(Eu(s.id,o)))}return r}function Gj({items:t=[],lookup:e}){var i;const n=[],r=new Map(t.map(s=>[s.id,s]));for(const[s,o]of t.entries()){const a=e.get(o.id),l=((i=a==null?void 0:a.internals)==null?void 0:i.userNode)??a;l!==void 0&&l!==o&&n.push({id:o.id,item:o,type:"replace"}),l===void 0&&n.push({item:o,type:"add",index:s})}for(const[s]of e)r.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function Wj(t){return{id:t.id,type:"remove"}}const qj=t=>gG(t),KW=t=>BR(t);function h3(t){return x.forwardRef(t)}const YW=typeof window<"u"?x.useLayoutEffect:x.useEffect;function Kj(t){const[e,n]=x.useState(BigInt(0)),[r]=x.useState(()=>XW(()=>n(i=>i+BigInt(1))));return YW(()=>{const i=r.get();i.length&&(t(i),r.reset())},[e]),r}function XW(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:n=>{e.push(n),t()}}}const p3=x.createContext(null);function QW({children:t}){const e=qr(),n=x.useCallback(a=>{const{nodes:l=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:h,fitViewQueued:m}=e.getState();let y=l;for(const w of a)y=typeof w=="function"?w(y):w;const g=Gj({items:y,lookup:h});d&&u(y),g.length>0?f==null||f(g):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:v,setNodes:S}=e.getState();w&&S(v)})},[]),r=Kj(n),i=x.useCallback(a=>{const{edges:l=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:h}=e.getState();let m=l;for(const y of a)m=typeof y=="function"?y(m):y;d?u(m):f&&f(Gj({items:m,lookup:h}))},[]),s=Kj(i),o=x.useMemo(()=>({nodeQueue:r,edgeQueue:s}),[]);return c.jsx(p3.Provider,{value:o,children:t})}function ZW(){const t=x.useContext(p3);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const JW=t=>!!t.panZoom;function k0(){const t=HW(),e=qr(),n=ZW(),r=Kn(JW),i=x.useMemo(()=>{const s=f=>e.getState().nodeLookup.get(f),o=f=>{n.nodeQueue.push(f)},a=f=>{n.edgeQueue.push(f)},l=f=>{var v,S;const{nodeLookup:h,nodeOrigin:m}=e.getState(),y=qj(f)?f:h.get(f.id),g=y.parentId?$R(y.position,y.measured,y.parentId,h,m):y.position,w={...y,position:g,width:((v=y.measured)==null?void 0:v.width)??y.width,height:((S=y.measured)==null?void 0:S.height)??y.height};return hh(w)},u=(f,h,m={replace:!1})=>{o(y=>y.map(g=>
62{if(g.id===f){const w=typeof h=="function"?h(g):h;return m.replace&&qj(w)?w:{...g,...w}}return g}))},d=(f,h,m={replace:!1})=>{a(y=>y.map(g=>{if(g.id===f){const w=typeof h=="function"?h(g):h;return m.replace&&KW(w)?w:{...g,...w}}return g}))};return{getNodes:()=>e.getState().nodes.map(f=>({...f})),getNode:f=>{var h;return(h=s(f))==null?void 0:h.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:f=[]}=e.getState();return f.map(h=>({...h}))},getEdge:f=>e.getState().edgeLookup.get(f),setNodes:o,setEdges:a,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(m=>[...m,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:m}=e.getState(),[y,g,w]=m;return{nodes:f.map(v=>({...v})),edges:h.map(v=>({...v})),viewport:{x:y,y:g,zoom:w}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:m,edges:y,onNodesDelete:g,onEdgesDelete:w,triggerNodeChanges:v,triggerEdgeChanges:S,onDelete:C,onBeforeDelete:k}=e.getState(),{nodes:N,edges:_}=await wG({nodesToRemove:f,edgesToRemove:h,nodes:m,edges:y,onBeforeDelete:k}),j=_.length>0,T=N.length>0;if(j){const M=_.map(Wj);w==null||w(_),S(M)}if(T){const M=N.map(Wj);g==null||g(N),v(M)}return(T||j)&&(C==null||C({nodes:N,edges:_})),{deletedNodes:N,deletedEdges:_}},getIntersectingNodes:(f,h=!0,m)=>{const y=xj(f),g=y?f:l(f),w=m!==void 0;return g?(m||e.getState().nodes).filter(v=>{const S=e.getState().nodeLookup.get(v.id);if(S&&!y&&(v.id===f.id||!S.internals.positionAbsolute))return!1;const C=hh(w?v:S),k=Lm(C,g);return h&&k>0||k>=C.width*C.height||k>=g.width*g.height}):[]},isNodeIntersecting:(f,h,m=!0)=>{const g=xj(f)?f:l(f);if(!g)return!1;const w=Lm(g,h);return m&&w>0||w>=g.width*g.height},updateNode:u,updateNodeData:(f,h,m={replace:!1})=>{u(f,y=>{const g=typeof h=="function"?h(y):h;return m.replace?{...y,data:g}:{...y,data:{...y.data,...g}}},m)},updateEdge:d,updateEdgeData:(f,h,m={replace:!1})=>{d(f,y=>{const g=typeof h=="function"?h(y):h;return m.replace?{...y,data:g}:{...y,data:{...y.data,...g}}},m)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:m}=e.getState();return bG(f,{nodeLookup:h,nodeOrigin:m})},getHandleConnections:({type:f,id:h,nodeId:m})=>{var y;return Array.from(((y=e.getState().connectionLookup.get(`${m}-${f}${h?`-${h}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:h,nodeId:m})=>{var y;return Array.from(((y=e.getState().connectionLookup.get(`${m}${f?h?`-${f}-${h}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const h=e.getState().fitViewResolver??_G();return e.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return x.useMemo(()=>({...i,...t,viewportInitialized:r}),[r])}const Yj=t=>t.selected,eq=typeof window<"u"?window:void 0;function tq({deleteKeyCode:t,multiSelectionKeyCode:e}){const n=qr(),{deleteElements:r}=k0(),i=Um(t,{actInsideInputWithModifier:!1}),s=Um(e,{target:eq});x.useEffect(()=>{if(i){const{edges:o,nodes:a}=n.getState();r({nodes:a.filter(Yj),edges:o.filter(Yj)}),n.setState({nodesSelectionActive:!1})}},[i]),x.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function nq(t){const e=qr();x.useEffect(()=>{const n=()=>{var i,s;if(!t.current)return!1;const r=__(t.current);(r.height===0||r.width===0)&&((s=(i=e.getState()).onError)==null||s.call(i,"004",el.error004())),e.setState({width:r.width||500,height:r.height||500})};if(t.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(t.current),()=>{window.removeEventListener("resize",n),r&&t.current&&r.unobserve(t.current)}}},[])}const Wv={position:"absolute",width:"100%",height:"100%",top:0,left:0},rq=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib});function iq({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:s=ba.Free,zoomOnDoubleClick:o=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:m=!0,children:y,noWheelClassName:g,noPanClassName:w,onViewportChange:v,isControlledViewport:S,paneClickDistance:C}){const k=qr(),N=x.useRef(null),{userSelectionActive:_,lib:j}=Kn(rq,ni),T=Um(h),M=x.useRef();nq(N);const V=x.useCallback(H=>{v==null||v({x:H[0],y:H[1],zoom:H[2]}),S||k.setState({transform:H})},[v,S]);return x.useEffect(()=>{if(N.current){M.current=aW({domNode:N.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,paneClickDistance:C,onDraggingChange:I=>k.setState({paneDragging:I}),onPanZoomStart:(I,R)=>{const{onViewportChangeStart:U,onMoveStart:A}=k.getState();A==null||A(I,R),U==null||U(R)},onPanZoom:(I,R)=>{const{onViewportChange:U,onMove:A}=k.getState();A==null||A(I,R),U==null||U(R)},onPanZoomEnd:(I,R)=>{const{onViewportChangeEnd:U,onMoveEnd:A}=k.getState();A==null||A(I,R),U==null||U(R)}});const{x:H,y:P,zoom:F}=M.current.getViewport();
62return k.setState({panZoom:M.current,transform:[H,P,F],domNode:N.current.closest(".react-flow")}),()=>{var I;(I=M.current)==null||I.destroy()}}},[]),x.useEffect(()=>{var H;(H=M.current)==null||H.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:T,preventScrolling:m,noPanClassName:w,userSelectionActive:_,noWheelClassName:g,lib:j,onTransformChange:V})},[t,e,n,r,i,s,o,a,T,m,w,_,g,j,V]),c.jsx("div",{className:"react-flow__renderer",ref:N,style:Wv,children:y})}const sq=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function oq(){const{userSelectionActive:t,userSelectionRect:e}=Kn(sq,ni);return t&&e?c.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}const A1=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},aq=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});function lq({isSelecting:t,selectionKeyPressed:e,selectionMode:n=Dm.Full,panOnDrag:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:a,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:h,children:m}){const y=qr(),{userSelectionActive:g,elementsSelectable:w,dragging:v,connectionInProgress:S}=Kn(aq,ni),C=w&&(t||g),k=x.useRef(null),N=x.useRef(),_=x.useRef(new Set),j=x.useRef(new Set),T=x.useRef(!1),M=x.useRef(!1),V=A=>{if(T.current||S){T.current=!1;return}a==null||a(A),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},H=A=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){A.preventDefault();return}l==null||l(A)},P=u?A=>u(A):void 0,F=A=>{var $,q;const{resetSelectedElements:W,domNode:D}=y.getState();if(N.current=D==null?void 0:D.getBoundingClientRect(),!w||!t||A.button!==0||A.target!==k.current||!N.current)return;(q=($=A.target)==null?void 0:$.setPointerCapture)==null||q.call($,A.pointerId),M.current=!0,T.current=!1;const{x:B,y:L}=Ha(A.nativeEvent,N.current);W(),y.setState({userSelectionRect:{width:0,height:0,startX:B,startY:L,x:B,y:L}}),s==null||s(A)},I=A=>{const{userSelectionRect:W,transform:D,nodeLookup:B,edgeLookup:L,connectionLookup:$,triggerNodeChanges:q,triggerEdgeChanges:Z,defaultEdgeOptions:ie}=y.getState();if(!N.current||!W)return;T.current=!0;const{x:ge,y:re}=Ha(A.nativeEvent,N.current),{startX:Y,startY:ne}=W,be={startX:Y,startY:ne,x:ge<Y?ge:Y,y:re<ne?re:ne,width:Math.abs(ge-Y),height:Math.abs(re-ne)},we=_.current,te=j.current;_.current=new Set(S_(B,be,D,n===Dm.Partial,!0).map(O=>O.id)),j.current=new Set;const fe=(ie==null?void 0:ie.selectable)??!0;for(const O of _.current){const pe=$.get(O);if(pe)for(const{edgeId:he}of pe.values()){const le=L.get(he);le&&(le.selectable??fe)&&j.current.add(he)}}if(!wj(we,_.current)){const O=Mf(B,_.current,!0);q(O)}if(!wj(te,j.current)){const O=Mf(L,j.current);Z(O)}y.setState({userSelectionRect:be,userSelectionActive:!0,nodesSelectionActive:!1})},R=A=>{var D,B;if(A.button!==0||!M.current)return;(B=(D=A.target)==null?void 0:D.releasePointerCapture)==null||B.call(D,A.pointerId);const{userSelectionRect:W}=y.getState();!g&&W&&A.target===k.current&&(V==null||V(A)),y.setState({userSelectionActive:!1,userSelectionRect:null,nodesSelectionActive:_.current.size>0}),o==null||o(A),(e||i)&&(T.current=!1),M.current=!1},U=r===!0||Array.isArray(r)&&r.includes(0);return c.jsxs("div",{className:Ei(["react-flow__pane",{draggable:U,dragging:v,selection:t}]),onClick:C?void 0:A1(V,k),onContextMenu:A1(H,k),onWheel:A1(P,k),onPointerEnter:C?void 0:d,onPointerDown:C?F:f,onPointerMove:C?I:f,onPointerUp:C?R:void 0,onPointerLeave:h,ref:k,style:Wv,children:[m,c.jsx(oq,{})]})}function sS({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:s,multiSelectionActive:o,nodeLookup:a,onError:l}=e.getState(),u=a.get(t);if(!u){l==null||l("012",el.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):i([t])}
62function m3({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:s,nodeClickDistance:o}){const a=qr(),[l,u]=x.useState(!1),d=x.useRef();return x.useEffect(()=>{d.current=WG({getStoreItems:()=>a.getState(),onNodeMouseDown:f=>{sS({id:f,store:a,nodeRef:t})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),x.useEffect(()=>{var f,h;if(e)(f=d.current)==null||f.destroy();else if(t.current)return(h=d.current)==null||h.update({noDragClassName:n,handleSelector:r,domNode:t.current,isSelectable:s,nodeId:i,nodeClickDistance:o}),()=>{var m;(m=d.current)==null||m.destroy()}},[n,r,e,s,t,i]),l}const cq=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");function g3(){const t=qr();return x.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:s,nodesDraggable:o,onError:a,updateNodePositions:l,nodeLookup:u,nodeOrigin:d}=t.getState(),f=new Map,h=cq(o),m=i?s[0]:5,y=i?s[1]:5,g=n.direction.x*m*n.factor,w=n.direction.y*y*n.factor;for(const[,v]of u){if(!h(v))continue;let S={x:v.internals.positionAbsolute.x+g,y:v.internals.positionAbsolute.y+w};i&&(S=x0(S,s));const{position:C,positionAbsolute:k}=RR({nodeId:v.id,nextPosition:S,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:a});v.position=C,v.internals.positionAbsolute=k,f.set(v.id,v)}l(f)},[])}const T_=x.createContext(null),uq=T_.Provider;T_.Consumer;const b3=()=>x.useContext(T_),dq=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),fq=(t,e,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:s,connection:o}=r,{fromHandle:a,toHandle:l,isValid:u}=o,d=(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===e&&(l==null?void 0:l.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===e&&(a==null?void 0:a.type)===n,connectingTo:d,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.id)===e&&(i==null?void 0:i.type)===n,isPossibleEndHandle:s===dh.Strict?(a==null?void 0:a.type)!==n:t!==(a==null?void 0:a.nodeId)||e!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!i,valid:d&&u}};function hq({type:t="source",position:e=Cn.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:s=!0,id:o,onConnect:a,children:l,className:u,onMouseDown:d,onTouchStart:f,...h},m){var R,U;const y=o||null,g=t==="target",w=qr(),v=b3(),{connectOnClick:S,noPanClassName:C,rfId:k}=Kn(dq,ni),{connectingFrom:N,connectingTo:_,clickConnecting:j,isPossibleEndHandle:T,connectionInProcess:M,clickConnectionInProcess:V,valid:H}=Kn(fq(v,y,t),ni);v||(U=(R=w.getState()).onError)==null||U.call(R,"010",el.error010());const P=A=>{const{defaultEdgeOptions:W,onConnect:D,hasDefaultEdges:B}=w.getState(),L={...W,...A};if(B){const{edges:$,setEdges:q}=w.getState();q(PG(L,$))}D==null||D(L),a==null||a(L)},F=A=>{if(!v)return;const W=HR(A.nativeEvent);if(i&&(W&&A.button===0||!W)){const D=w.getState();iS.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:g,handleId:y,nodeId:v,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:D.onConnectEnd,updateConnection:D.updateConnection,onConnect:P,isValidConnection:n||D.isValidConnection,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}W?d==null||d(A):f==null||f(A)},I=A=>{const{onClickConnectStart:W,onClickConnectEnd:D,connectionClickStartHandle:B,connectionMode:L,isValidConnection:$,lib:q,rfId:Z,nodeLookup:ie,connection:ge}=w.getState();if(!v||!B&&!i)return;if(!B){W==null||W(A.nativeEvent,{nodeId:v,handleId:y,handleType:t}),w.setState({connectionClickStartHandle:{nodeId:v,type:t,id:y}});return}const re=UR(A.target),Y=n||$,{connection:ne,isValid:be}=iS.isValid(A.nativeEvent,{handle:{nodeId:v,id:y,type:t},connectionMode:L,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:Y,flowId:Z,doc:re,lib:q,nodeLookup:ie});be&&ne&&P(ne);const we=structuredClone(ge);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,D==null||D(A,we),w.setState({connectionClickStartHandle:null})};return c.jsx("div",{"data-handleid":y,"data-nodeid":v,"data-handlepos":e,"data-id":`${k}-${v}-${y}-${t}`,className:Ei(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",C,u,{source:!g,target:g,connectable:r,connectablestart:i,connectableend:s,clickconnecting:j,
62connectingfrom:N,connectingto:_,valid:H,connectionindicator:r&&(!M||T)&&(M||V?s:i)}]),onMouseDown:F,onTouchStart:F,onClick:S?I:void 0,ref:m,...h,children:l})}const Ly=x.memo(h3(hq));function pq({data:t,isConnectable:e,sourcePosition:n=Cn.Bottom}){return c.jsxs(c.Fragment,{children:[t==null?void 0:t.label,c.jsx(Ly,{type:"source",position:n,isConnectable:e})]})}function mq({data:t,isConnectable:e,targetPosition:n=Cn.Top,sourcePosition:r=Cn.Bottom}){return c.jsxs(c.Fragment,{children:[c.jsx(Ly,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,c.jsx(Ly,{type:"source",position:r,isConnectable:e})]})}function gq(){return null}function bq({data:t,isConnectable:e,targetPosition:n=Cn.Top}){return c.jsxs(c.Fragment,{children:[c.jsx(Ly,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label]})}const Fy={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Xj={input:pq,default:mq,output:bq,group:gq};function yq(t){var e,n,r,i;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((e=t.style)==null?void 0:e.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((r=t.style)==null?void 0:r.width),height:t.height??((i=t.style)==null?void 0:i.height)}}const vq=t=>{const{width:e,height:n,x:r,y:i}=v0(t.nodeLookup,{filter:s=>!!s.selected});return{width:pa(e)?e:null,height:pa(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${r}px,${i}px)`}};function xq({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=qr(),{width:i,height:s,transformString:o,userSelectionActive:a}=Kn(vq,ni),l=g3(),u=x.useRef(null);if(x.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]),m3({nodeRef:u}),a||!i||!s)return null;const d=t?h=>{const m=r.getState().nodes.filter(y=>y.selected);t(h,m)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Fy,h.key)&&(h.preventDefault(),l({direction:Fy[h.key],factor:h.shiftKey?4:1}))};return c.jsx("div",{className:Ei(["react-flow__nodesselection","react-flow__container",e]),style:{transform:o},children:c.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:i,height:s}})})}const Qj=typeof window<"u"?window:void 0,wq=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function y3({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:g,zoomActivationKeyCode:w,elementsSelectable:v,zoomOnScroll:S,zoomOnPinch:C,panOnScroll:k,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:j,panOnDrag:T,defaultViewport:M,translateExtent:V,minZoom:H,maxZoom:P,preventScrolling:F,onSelectionContextMenu:I,noWheelClassName:R,noPanClassName:U,disableKeyboardA11y:A,onViewportChange:W,isControlledViewport:D}){const{nodesSelectionActive:B,userSelectionActive:L}=Kn(wq),$=Um(u,{target:Qj}),q=Um(g,{target:Qj}),Z=q||T,ie=q||k,ge=d&&Z!==!0,re=$||L||ge;return tq({deleteKeyCode:l,multiSelectionKeyCode:y}),c.jsx(iq,{onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:S,zoomOnPinch:C,panOnScroll:ie,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:j,panOnDrag:!$&&Z,defaultViewport:M,translateExtent:V,minZoom:H,maxZoom:P,zoomActivationKeyCode:w,preventScrolling:F,noWheelClassName:R,noPanClassName:U,onViewportChange:W,isControlledViewport:D,paneClickDistance:a,children:c.jsxs(lq,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:o,panOnDrag:Z,isSelecting:!!re,selectionMode:f,selectionKeyPressed:$,selectionOnDrag:ge,children:[t,B&&c.jsx(xq,{onSelectionContextMenu:I,noPanClassName:U,disableKeyboardA11y:A})]})})}y3.displayName="FlowRenderer";const kq=x.memo(y3),Sq=t=>e=>t?S_(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(n=>n.id):Array.from(e.nodeLookup.keys());function Cq(t){return Kn(x.useCallback(Sq(t),[t]),ni)}const _q=t=>t.updateNodeInternals;function Eq(){const t=Kn(_q),[e]=x.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;
62n.forEach(i=>{const s=i.target.getAttribute("data-id");r.set(s,{id:s,nodeElement:i.target,force:!0})}),t(r)}));return x.useEffect(()=>()=>{e==null||e.disconnect()},[e]),e}function Nq({node:t,nodeType:e,hasDimensions:n,resizeObserver:r}){const i=qr(),s=x.useRef(null),o=x.useRef(null),a=x.useRef(t.sourcePosition),l=x.useRef(t.targetPosition),u=x.useRef(e),d=n&&!!t.internals.handleBounds;return x.useEffect(()=>{s.current&&!t.hidden&&(!d||o.current!==s.current)&&(o.current&&(r==null||r.unobserve(o.current)),r==null||r.observe(s.current),o.current=s.current)},[d,t.hidden]),x.useEffect(()=>()=>{o.current&&(r==null||r.unobserve(o.current),o.current=null)},[]),x.useEffect(()=>{if(s.current){const f=u.current!==e,h=a.current!==t.sourcePosition,m=l.current!==t.targetPosition;(f||h||m)&&(u.current=e,a.current=t.sourcePosition,l.current=t.targetPosition,i.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:s.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),s}function Iq({id:t,onClick:e,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:s,onDoubleClick:o,nodesDraggable:a,elementsSelectable:l,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:h,noPanClassName:m,disableKeyboardA11y:y,rfId:g,nodeTypes:w,nodeClickDistance:v,onError:S}){const{node:C,internals:k,isParent:N}=Kn(Y=>{const ne=Y.nodeLookup.get(t),be=Y.parentLookup.has(t);return{node:ne,internals:ne.internals,isParent:be}},ni);let _=C.type||"default",j=(w==null?void 0:w[_])||Xj[_];j===void 0&&(S==null||S("003",el.error003(_)),_="default",j=(w==null?void 0:w.default)||Xj.default);const T=!!(C.draggable||a&&typeof C.draggable>"u"),M=!!(C.selectable||l&&typeof C.selectable>"u"),V=!!(C.connectable||u&&typeof C.connectable>"u"),H=!!(C.focusable||d&&typeof C.focusable>"u"),P=qr(),F=FR(C),I=Nq({node:C,nodeType:_,hasDimensions:F,resizeObserver:f}),R=m3({nodeRef:I,disabled:C.hidden||!T,noDragClassName:h,handleSelector:C.dragHandle,nodeId:t,isSelectable:M,nodeClickDistance:v}),U=g3();if(C.hidden)return null;const A=Gl(C),W=yq(C),D=M||T||e||n||r||i,B=n?Y=>n(Y,{...k.userNode}):void 0,L=r?Y=>r(Y,{...k.userNode}):void 0,$=i?Y=>i(Y,{...k.userNode}):void 0,q=s?Y=>s(Y,{...k.userNode}):void 0,Z=o?Y=>o(Y,{...k.userNode}):void 0,ie=Y=>{const{selectNodesOnDrag:ne,nodeDragThreshold:be}=P.getState();M&&(!ne||!T||be>0)&&sS({id:t,store:P,nodeRef:I}),e&&e(Y,{...k.userNode})},ge=Y=>{if(!(VR(Y.nativeEvent)||y)){if(zR.includes(Y.key)&&M){const ne=Y.key==="Escape";sS({id:t,store:P,unselect:ne,nodeRef:I})}else if(T&&C.selected&&Object.prototype.hasOwnProperty.call(Fy,Y.key)){Y.preventDefault();const{ariaLabelConfig:ne}=P.getState();P.setState({ariaLiveMessage:ne["node.a11yDescription.ariaLiveMessage"]({direction:Y.key.replace("Arrow","").toLowerCase(),x:~~k.positionAbsolute.x,y:~~k.positionAbsolute.y})}),U({direction:Fy[Y.key],factor:Y.shiftKey?4:1})}}},re=()=>{var O;if(y||!((O=I.current)!=null&&O.matches(":focus-visible")))return;const{transform:Y,width:ne,height:be,autoPanOnNodeFocus:we,setCenter:te}=P.getState();if(!we)return;S_(new Map([[t,C]]),{x:0,y:0,width:ne,height:be},Y,!0).length>0||te(C.position.x+A.width/2,C.position.y+A.height/2,{zoom:Y[2]})};return c.jsx("div",{className:Ei(["react-flow__node",`react-flow__node-${_}`,{[m]:T},C.className,{selected:C.selected,selectable:M,parent:N,draggable:T,dragging:R}]),ref:I,style:{zIndex:k.z,transform:`translate(${k.positionAbsolute.x}px,${k.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:F?"visible":"hidden",...C.style,...W},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:L,onMouseLeave:$,onContextMenu:q,onClick:ie,onDoubleClick:Z,onKeyDown:H?ge:void 0,tabIndex:H?0:void 0,onFocus:H?re:void 0,role:C.ariaRole??(H?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${c3}-${g}`,"aria-label":C.ariaLabel,...C.domAttributes,children:c.jsx(uq,{value:t,children:c.jsx(j,{id:t,data:C.data,t
62ype:_,positionAbsoluteX:k.positionAbsolute.x,positionAbsoluteY:k.positionAbsolute.y,selected:C.selected??!1,selectable:M,draggable:T,deletable:C.deletable??!0,isConnectable:V,sourcePosition:C.sourcePosition,targetPosition:C.targetPosition,dragging:R,dragHandle:C.dragHandle,zIndex:k.z,parentId:C.parentId,...A})})})}const jq=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function v3(t){const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:s}=Kn(jq,ni),o=Cq(t.onlyRenderVisibleElements),a=Eq();return c.jsx("div",{className:"react-flow__nodes",style:Wv,children:o.map(l=>c.jsx(Iq,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:a,nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:t.nodeClickDistance,onError:s},l))})}v3.displayName="NodeRenderer";const Tq=x.memo(v3);function zq(t){return Kn(x.useCallback(n=>{if(!t)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const s=n.nodeLookup.get(i.source),o=n.nodeLookup.get(i.target);s&&o&&jG({sourceNode:s,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[t]),ni)}const Pq=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t}};return c.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Aq=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t,fill:t}};return c.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zj={[Ry.Arrow]:Pq,[Ry.ArrowClosed]:Aq};function Mq(t){const e=qr();return x.useMemo(()=>{var i,s;return Object.prototype.hasOwnProperty.call(Zj,t)?Zj[t]:((s=(i=e.getState()).onError)==null||s.call(i,"009",el.error009(t)),null)},[t])}const Bq=({id:t,type:e,color:n,width:r=12.5,height:i=12.5,markerUnits:s="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const l=Mq(e);return l?c.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:c.jsx(l,{color:n,strokeWidth:o})}):null},x3=({defaultColor:t,rfId:e})=>{const n=Kn(s=>s.edges),r=Kn(s=>s.defaultEdgeOptions),i=x.useMemo(()=>OG(n,{id:e,defaultColor:t,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,e,t]);return i.length?c.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:c.jsx("defs",{children:i.map(s=>c.jsx(Bq,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};x3.displayName="MarkerDefinitions";var Rq=x.memo(x3);function w3({x:t,y:e,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:s,labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:l,className:u,...d}){const[f,h]=x.useState({x:1,y:0,width:0,height:0}),m=Ei(["react-flow__edge-textwrapper",u]),y=x.useRef(null);return x.useEffect(()=>{if(y.current){const g=y.current.getBBox();h({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),n?c.jsxs("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:m,visibility:f.width?"visible":"hidden",...d,children:[i&&c.jsx("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),c.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:r,children:n}),l]}):null}w3.displayName="EdgeText";const Oq=x.memo(w3);function qv({path:t,labelX:e,labelY:n,label:r,labelStyle:i,labelShowBg:s,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:u=20,...d}){return c.jsxs(c.Fragment,{children:[c.jsx("path",{...d,d:t,fill:"none",className:Ei(["react-flow__edge-path",d.className])}),u?c.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&pa(e)&&pa(n)?c.jsx(Oq,{x:e,y:n,label:r,labelStyle:i,labelShowBg:s,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function Jj({pos:t,x1:e,y1:n,x2:r,y2:i}){return t===Cn.Left||t===Cn.Right?[.5*(e+r),n]:[e,.5*(n+i)]}function k3({sourceX:t,sourceY:e,sourcePosition:n=Cn.Bottom,targetX:r,targetY:i,targetPosition:s=Cn.Top}){const[o,a]=Jj({pos:n,x1:t,y1:e,x2:r,y2:i}),[l,u]=Jj({pos:s,x1:r,y1:i,x2:t,y2:e}),[d,f,h,m]=GR({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:o,sourceControlY:a,targetControlX:l,targetControlY:u});return[`M${t},${e} C${o},${a} ${l},${u} ${r},${i}`,d,f,h,m]}function S3(t){return x.memo(({id:e,sourceX:n,sourceY:r,targetX:i,targetY:s,sourcePosition:o,targetPosition:a,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:g,markerStart:w,interactionWidth:v})=>
62{const[S,C,k]=k3({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:s,targetPosition:a}),N=t.isInternal?void 0:e;return c.jsx(qv,{id:N,path:S,labelX:C,labelY:k,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:g,markerStart:w,interactionWidth:v})})}const Dq=S3({isInternal:!1}),C3=S3({isInternal:!0});Dq.displayName="SimpleBezierEdge";C3.displayName="SimpleBezierEdgeInternal";function _3(t){return x.memo(({id:e,sourceX:n,sourceY:r,targetX:i,targetY:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,sourcePosition:m=Cn.Bottom,targetPosition:y=Cn.Top,markerEnd:g,markerStart:w,pathOptions:v,interactionWidth:S})=>{const[C,k,N]=tS({sourceX:n,sourceY:r,sourcePosition:m,targetX:i,targetY:s,targetPosition:y,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),_=t.isInternal?void 0:e;return c.jsx(qv,{id:_,path:C,labelX:k,labelY:N,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:g,markerStart:w,interactionWidth:S})})}const E3=_3({isInternal:!1}),N3=_3({isInternal:!0});E3.displayName="SmoothStepEdge";N3.displayName="SmoothStepEdgeInternal";function I3(t){return x.memo(({id:e,...n})=>{var i;const r=t.isInternal?void 0:e;return c.jsx(E3,{...n,id:r,pathOptions:x.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const Lq=I3({isInternal:!1}),j3=I3({isInternal:!0});Lq.displayName="StepEdge";j3.displayName="StepEdgeInternal";function T3(t){return x.memo(({id:e,sourceX:n,sourceY:r,targetX:i,targetY:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:y,interactionWidth:g})=>{const[w,v,S]=KR({sourceX:n,sourceY:r,targetX:i,targetY:s}),C=t.isInternal?void 0:e;return c.jsx(qv,{id:C,path:w,labelX:v,labelY:S,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:y,interactionWidth:g})})}const Fq=T3({isInternal:!1}),z3=T3({isInternal:!0});Fq.displayName="StraightEdge";z3.displayName="StraightEdgeInternal";function P3(t){return x.memo(({id:e,sourceX:n,sourceY:r,targetX:i,targetY:s,sourcePosition:o=Cn.Bottom,targetPosition:a=Cn.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:g,markerStart:w,pathOptions:v,interactionWidth:S})=>{const[C,k,N]=WR({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:s,targetPosition:a,curvature:v==null?void 0:v.curvature}),_=t.isInternal?void 0:e;return c.jsx(qv,{id:_,path:C,labelX:k,labelY:N,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:g,markerStart:w,interactionWidth:S})})}const $q=P3({isInternal:!1}),A3=P3({isInternal:!0});$q.displayName="BezierEdge";A3.displayName="BezierEdgeInternal";const eT={default:A3,straight:z3,step:j3,smoothstep:N3,simplebezier:C3},tT={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Uq=(t,e,n)=>n===Cn.Left?t-e:n===Cn.Right?t+e:t,Vq=(t,e,n)=>n===Cn.Top?t-e:n===Cn.Bottom?t+e:t,nT="react-flow__edgeupdater";function rT({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:s,onMouseOut:o,type:a}){return c.jsx("circle",{onMouseDown:i,onMouseEnter:s,onMouseOut:o,className:Ei([nT,`${nT}-${a}`]),cx:Uq(e,r,t),cy:Vq(n,r,t),r,stroke:"transparent",fill:"transparent"})}function Hq({isReconnectable:t,reconnectRadius:e,edge:n,sourceX:r,sourceY:i,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:h,setUpdateHover:m}){const y=qr(),g=(k,N)=>{if(k.button!==0)return;const{autoPanOnConnect:_,domNode:j,isValidConnection:T,connectionMode:M,connectionRadius:V,lib:H,onConnectStart:P,onConnectEnd:F,cancelConnection:I,nodeLookup:R,rfId:U,panBy:A,updateConnection:W}=y.getState(),D=N.type==="target",B=(q,Z)=>{h(!1),f==null||f(q,n,N.type,Z)},L=q=>u==null?void 0:u(n,q),$=(q,Z)=>{h(!0),d==null||d(k,n,N.type),P==null||P(q,Z)};iS.onPointerDown(k.nativeEvent,{autoPanOnConnect:_,connectionMode:M,connectionRadius:V,domNode:j,handleId:N.id,nodeId:N.nodeId,nodeLookup:R,isTarget:D,edgeUpdaterType:N.type,lib:H,flowId:U,cancelConnection:I,panBy:A,isValidConnection:T,onConnect:L,onConnectStart:$,onConnectEnd:F,onReconnectEnd:B,updateConnection:W,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNo
62de:k.currentTarget})},w=k=>g(k,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=k=>g(k,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>m(!0),C=()=>m(!1);return c.jsxs(c.Fragment,{children:[(t===!0||t==="source")&&c.jsx(rT,{position:a,centerX:r,centerY:i,radius:e,onMouseDown:w,onMouseEnter:S,onMouseOut:C,type:"source"}),(t===!0||t==="target")&&c.jsx(rT,{position:l,centerX:s,centerY:o,radius:e,onMouseDown:v,onMouseEnter:S,onMouseOut:C,type:"target"})]})}function Gq({id:t,edgesFocusable:e,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:s,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:m,rfId:y,edgeTypes:g,noPanClassName:w,onError:v,disableKeyboardA11y:S}){let C=Kn(te=>te.edgeLookup.get(t));const k=Kn(te=>te.defaultEdgeOptions);C=k?{...k,...C}:C;let N=C.type||"default",_=(g==null?void 0:g[N])||eT[N];_===void 0&&(v==null||v("011",el.error011(N)),N="default",_=(g==null?void 0:g.default)||eT.default);const j=!!(C.focusable||e&&typeof C.focusable>"u"),T=typeof f<"u"&&(C.reconnectable||n&&typeof C.reconnectable>"u"),M=!!(C.selectable||r&&typeof C.selectable>"u"),V=x.useRef(null),[H,P]=x.useState(!1),[F,I]=x.useState(!1),R=qr(),{zIndex:U,sourceX:A,sourceY:W,targetX:D,targetY:B,sourcePosition:L,targetPosition:$}=Kn(x.useCallback(te=>{const fe=te.nodeLookup.get(C.source),O=te.nodeLookup.get(C.target);if(!fe||!O)return{zIndex:C.zIndex,...tT};const pe=RG({id:t,sourceNode:fe,targetNode:O,sourceHandle:C.sourceHandle||null,targetHandle:C.targetHandle||null,connectionMode:te.connectionMode,onError:v});return{zIndex:IG({selected:C.selected,zIndex:C.zIndex,sourceNode:fe,targetNode:O,elevateOnSelect:te.elevateEdgesOnSelect}),...pe||tT}},[C.source,C.target,C.sourceHandle,C.targetHandle,C.selected,C.zIndex]),ni),q=x.useMemo(()=>C.markerStart?`url('#${nS(C.markerStart,y)}')`:void 0,[C.markerStart,y]),Z=x.useMemo(()=>C.markerEnd?`url('#${nS(C.markerEnd,y)}')`:void 0,[C.markerEnd,y]);if(C.hidden||A===null||W===null||D===null||B===null)return null;const ie=te=>{var he;const{addSelectedEdges:fe,unselectNodesAndEdges:O,multiSelectionActive:pe}=R.getState();M&&(R.setState({nodesSelectionActive:!1}),C.selected&&pe?(O({nodes:[],edges:[C]}),(he=V.current)==null||he.blur()):fe([t])),i&&i(te,C)},ge=s?te=>{s(te,{...C})}:void 0,re=o?te=>{o(te,{...C})}:void 0,Y=a?te=>{a(te,{...C})}:void 0,ne=l?te=>{l(te,{...C})}:void 0,be=u?te=>{u(te,{...C})}:void 0,we=te=>{var fe;if(!S&&zR.includes(te.key)&&M){const{unselectNodesAndEdges:O,addSelectedEdges:pe}=R.getState();te.key==="Escape"?((fe=V.current)==null||fe.blur(),O({edges:[C]})):pe([t])}};return c.jsx("svg",{style:{zIndex:U},children:c.jsxs("g",{className:Ei(["react-flow__edge",`react-flow__edge-${N}`,C.className,w,{selected:C.selected,animated:C.animated,inactive:!M&&!i,updating:H,selectable:M}]),onClick:ie,onDoubleClick:ge,onContextMenu:re,onMouseEnter:Y,onMouseMove:ne,onMouseLeave:be,onKeyDown:j?we:void 0,tabIndex:j?0:void 0,role:C.ariaRole??(j?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":C.ariaLabel===null?void 0:C.ariaLabel||`Edge from ${C.source} to ${C.target}`,"aria-describedby":j?`${u3}-${y}`:void 0,ref:V,...C.domAttributes,children:[!F&&c.jsx(_,{id:t,source:C.source,target:C.target,type:C.type,selected:C.selected,animated:C.animated,selectable:M,deletable:C.deletable??!0,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,sourceX:A,sourceY:W,targetX:D,targetY:B,sourcePosition:L,targetPosition:$,data:C.data,style:C.style,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerStart:q,markerEnd:Z,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth}),T&&c.jsx(Hq,{edge:C,isReconnectable:T,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:m,sourceX:A,sourceY:W,targetX:D,targetY:B,sourcePosition:L,targetPosition:$,setUpdateHover:P,setReconnecting:I})]})})}const Wq=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function M3({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:s,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:h,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:g}){const{edgesFocusable:w,edgesReconnectable:v,elementsSelectable:S,onError:C}=Kn(Wq,ni),k=zq(e);return c.jsxs("div",{className:"react-flow__edges",children:[c.jsx(Rq,{defaultColor:t,rfId:n}),k.map(N=>c.jsx(Gq,{id:N,edgesFocusable:w,edgesReconnectable:v,elementsSelectable:S,noPanClassName:i,onReconnect:s,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:C,edgeTypes:r,disableKeyboardA11y:g},N))]})}M3.displayName="EdgeRenderer";const qq=x.memo(M3),Kq=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function Yq({children:t}){const e=Kn(Kq);return c.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function Xq(t){const e=k0(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)}
62,[t,e.viewportInitialized])}const Qq=t=>{var e;return(e=t.panZoom)==null?void 0:e.syncViewport};function Zq(t){const e=Kn(Qq),n=qr();return x.useEffect(()=>{t&&(e==null||e(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function Jq(t){return t.connection.inProgress?{...t.connection,to:w0(t.connection.to,t.transform)}:{...t.connection}}function eK(t){return Jq}function tK(t){const e=eK();return Kn(e,ni)}const nK=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function rK({containerStyle:t,style:e,type:n,component:r}){const{nodesConnectable:i,width:s,height:o,isValid:a,inProgress:l}=Kn(nK,ni);return!(s&&i&&l)?null:c.jsx("svg",{style:t,width:s,height:o,className:"react-flow__connectionline react-flow__container",children:c.jsx("g",{className:Ei(["react-flow__connection",MR(a)]),children:c.jsx(B3,{style:e,type:n,CustomComponent:r,isValid:a})})})}const B3=({style:t,type:e=Ec.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:s,fromNode:o,fromHandle:a,fromPosition:l,to:u,toNode:d,toHandle:f,toPosition:h}=tK();if(!i)return;if(n)return c.jsx(n,{connectionLineType:e,connectionLineStyle:t,fromNode:o,fromHandle:a,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:l,toPosition:h,connectionStatus:MR(r),toNode:d,toHandle:f});let m="";const y={sourceX:s.x,sourceY:s.y,sourcePosition:l,targetX:u.x,targetY:u.y,targetPosition:h};switch(e){case Ec.Bezier:[m]=WR(y);break;case Ec.SimpleBezier:[m]=k3(y);break;case Ec.Step:[m]=tS({...y,borderRadius:0});break;case Ec.SmoothStep:[m]=tS(y);break;default:[m]=KR(y)}return c.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:t})};B3.displayName="ConnectionLine";const iK={};function iT(t=iK){x.useRef(t),qr(),x.useEffect(()=>{},[t])}function sK(){qr(),x.useRef(!1),x.useEffect(()=>{},[])}function R3({nodeTypes:t,edgeTypes:e,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:s,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:h,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:g,connectionLineComponent:w,connectionLineContainerStyle:v,selectionKeyCode:S,selectionOnDrag:C,selectionMode:k,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:j,deleteKeyCode:T,onlyRenderVisibleElements:M,elementsSelectable:V,defaultViewport:H,translateExtent:P,minZoom:F,maxZoom:I,preventScrolling:R,defaultMarkerColor:U,zoomOnScroll:A,zoomOnPinch:W,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:L,zoomOnDoubleClick:$,panOnDrag:q,onPaneClick:Z,onPaneMouseEnter:ie,onPaneMouseMove:ge,onPaneMouseLeave:re,onPaneScroll:Y,onPaneContextMenu:ne,paneClickDistance:be,nodeClickDistance:we,onEdgeContextMenu:te,onEdgeMouseEnter:fe,onEdgeMouseMove:O,onEdgeMouseLeave:pe,reconnectRadius:he,onReconnect:le,onReconnectStart:oe,onReconnectEnd:Q,noDragClassName:de,noWheelClassName:Ne,noPanClassName:Ce,disableKeyboardA11y:Ae,nodeExtent:Ue,rfId:Se,viewport:ve,onViewportChange:je}){return iT(t),iT(e),sK(),Xq(n),Zq(ve),c.jsx(kq,{onPaneClick:Z,onPaneMouseEnter:ie,onPaneMouseMove:ge,onPaneMouseLeave:re,onPaneContextMenu:ne,onPaneScroll:Y,paneClickDistance:be,deleteKeyCode:T,selectionKeyCode:S,selectionOnDrag:C,selectionMode:k,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:j,elementsSelectable:V,zoomOnScroll:A,zoomOnPinch:W,zoomOnDoubleClick:$,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:L,panOnDrag:q,defaultViewport:H,translateExtent:P,minZoom:F,maxZoom:I,onSelectionContextMenu:f,preventScrolling:R,noDragClassName:de,noWheelClassName:Ne,noPanClassName:Ce,disableKeyboardA11y:Ae,onViewportChange:je,isControlledViewport:!!ve,children:c.jsxs(Yq,{children:[c.jsx(qq,{edgeTypes:e,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:le,onReconnectStart:oe,onReconnectEnd:Q,onlyRenderVisibleElements:M,onEdgeContextMenu:te,onEdgeMouseEnter:fe,onEdgeMouseMove:O,onEdgeMouseLeave:pe,reconnectRadius:he,defaultMarkerColor:U,noPanClassName:Ce,disableKeyboardA11y:Ae,rfId:Se}),c.jsx(rK,{style:g,type:y,component:w,containerStyle:v}),c.jsx("div",{className:"react-flow__edgelabel-renderer"}),c.jsx(Tq,{nodeTypes:t,onNodeClick:r,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:we,onlyRenderVisibleElements:M,noPanClassName:Ce,noDragClassName:de,disableKeyboardA11y:Ae,nodeExtent:Ue,rfId:Se}),c.jsx("div",{className:"react-flow__viewport-portal"})]})})}
62R3.displayName="GraphView";const oK=x.memo(R3),sT=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:i,height:s,fitView:o,fitViewOptions:a,minZoom:l=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f}={})=>{const h=new Map,m=new Map,y=new Map,g=new Map,w=r??e??[],v=n??t??[],S=d??[0,0],C=f??Om;XR(y,g,w);const k=rS(v,h,m,{nodeOrigin:S,nodeExtent:C,elevateNodesOnSelect:!1});let N=[0,0,1];if(o&&i&&s){const _=v0(h,{filter:V=>!!((V.width||V.initialWidth)&&(V.height||V.initialHeight))}),{x:j,y:T,zoom:M}=C_(_,i,s,l,u,(a==null?void 0:a.padding)??.1);N=[j,T,M]}return{rfId:"1",width:0,height:0,transform:N,nodes:v,nodesInitialized:k,nodeLookup:h,parentLookup:m,edges:w,edgeLookup:g,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:u,translateExtent:Om,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:dh.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:a,fitViewResolver:null,connection:{...AR},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:kG,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:PR}},aK=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:i,height:s,fitView:o,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f})=>CW((h,m)=>{async function y(){const{nodeLookup:g,panZoom:w,fitViewOptions:v,fitViewResolver:S,width:C,height:k,minZoom:N,maxZoom:_}=m();w&&(await xG({nodes:g,width:C,height:k,panZoom:w,minZoom:N,maxZoom:_},v),S==null||S.resolve(!0),h({fitViewResolver:null}))}return{...sT({nodes:t,edges:e,width:i,height:s,fitView:o,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r}),setNodes:g=>{const{nodeLookup:w,parentLookup:v,nodeOrigin:S,elevateNodesOnSelect:C,fitViewQueued:k}=m(),N=rS(g,w,v,{nodeOrigin:S,nodeExtent:f,elevateNodesOnSelect:C,checkEquality:!0});k&&N?(y(),h({nodes:g,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:g,nodesInitialized:N})},setEdges:g=>{const{connectionLookup:w,edgeLookup:v}=m();XR(w,v,g),h({edges:g})},setDefaultNodesAndEdges:(g,w)=>{if(g){const{setNodes:v}=m();v(g),h({hasDefaultNodes:!0})}if(w){const{setEdges:v}=m();v(w),h({hasDefaultEdges:!0})}},updateNodeInternals:g=>{const{triggerNodeChanges:w,nodeLookup:v,parentLookup:S,domNode:C,nodeOrigin:k,nodeExtent:N,debug:_,fitViewQueued:j}=m(),{changes:T,updatedInternals:M}=UG(g,v,S,C,k,N);M&&(LG(v,S,{nodeOrigin:k,nodeExtent:N}),j?(y(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(T==null?void 0:T.length)>0&&(_&&console.log("React Flow: trigger node changes",T),w==null||w(T)))},updateNodePositions:(g,w=!1)=>{const v=[],S=[],{nodeLookup:C,triggerNodeChanges:k}=m();for(const[N,_]of g){const j=C.get(N),T=!!(j!=null&&j.expandParent&&(j!=null&&j.parentId)&&(_!=null&&_.position)),M={id:N,type:"position",position:T?{x:Math.max(0,_.position.x),y:Math.max(0,_.position.y)}:_.position,dragging:w};T&&j.parentId&&v.push({id:N,parentId:j.parentId,rect:{..._.internals.positionAbsolute,width:_.measured.width??0,height:_.measured.height??0}}),S.push(M)}if(v.length>0){const{parentLookup:N,nodeOrigin:_}=m(),j=j_(v,C,N,_);S.push(...j)}k(S)},triggerNodeChanges:g=>{const{onNodesChange:w,setNodes:v,nodes:S,hasDefaultNodes:C,debug:k}=m();if(g!=null&&g.length){if(C){const N=WW(g,S);v(N)}k&&console.log("React Flow: trigger node changes",g),w==null||w(g)}},triggerEdgeChanges:g=>{const{onEdgesChange:w,setEdges:v,edges:S,hasDefaultEdges:C,debug:k}=m();if(g!=null&&g.length){if(C){const N=qW(g,S);v(N)}k&&console.log("React Flow: trigger edge changes",g),w==null||w(g)}},addSelectedNodes:g=>{const{multiSelectionActive:w,edgeLookup:v,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:k}=m();if(w){const N=g.map(_=>Eu(_,!0));C(N);return}C(Mf(S,new Set([...g]),!0)),k(Mf(v))},addSelectedEdges:g=>{const{multiSelectionActive:w,edgeLookup:v,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:k}=m();if(w){const N=g.map(_=>Eu(_,!0));k(N);return}k(Mf(v,new Set([...g]))),C(Mf(S,new Set,!0))},unselectNodesAndEdges:({nodes:g,edges:w}={})=>{const{edges:v,nodes:S,nodeLookup:C,triggerNodeChanges:k,triggerEdgeChanges:N}=m(),_=g||S,j=w||v,T=_.map(V=>{const H=C.get(V.id);return H&&(H.selected=!1),Eu(V.id,!1)}),M=j.map(V=>Eu(V.id,!1));k(T),N(M)},setMinZoom:g=>
62{const{panZoom:w,maxZoom:v}=m();w==null||w.setScaleExtent([g,v]),h({minZoom:g})},setMaxZoom:g=>{const{panZoom:w,minZoom:v}=m();w==null||w.setScaleExtent([v,g]),h({maxZoom:g})},setTranslateExtent:g=>{var w;(w=m().panZoom)==null||w.setTranslateExtent(g),h({translateExtent:g})},setPaneClickDistance:g=>{var w;(w=m().panZoom)==null||w.setClickDistance(g)},resetSelectedElements:()=>{const{edges:g,nodes:w,triggerNodeChanges:v,triggerEdgeChanges:S,elementsSelectable:C}=m();if(!C)return;const k=w.reduce((_,j)=>j.selected?[..._,Eu(j.id,!1)]:_,[]),N=g.reduce((_,j)=>j.selected?[..._,Eu(j.id,!1)]:_,[]);v(k),S(N)},setNodeExtent:g=>{const{nodes:w,nodeLookup:v,parentLookup:S,nodeOrigin:C,elevateNodesOnSelect:k,nodeExtent:N}=m();g[0][0]===N[0][0]&&g[0][1]===N[0][1]&&g[1][0]===N[1][0]&&g[1][1]===N[1][1]||(rS(w,v,S,{nodeOrigin:C,nodeExtent:g,elevateNodesOnSelect:k,checkEquality:!1}),h({nodeExtent:g}))},panBy:g=>{const{transform:w,width:v,height:S,panZoom:C,translateExtent:k}=m();return VG({delta:g,panZoom:C,transform:w,translateExtent:k,width:v,height:S})},setCenter:async(g,w,v)=>{const{width:S,height:C,maxZoom:k,panZoom:N}=m();if(!N)return Promise.resolve(!1);const _=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:k;return await N.setViewport({x:S/2-g*_,y:C/2-w*_,zoom:_},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...AR}})},updateConnection:g=>{h({connection:g})},reset:()=>h({...sT()})}},Object.is);function Kv({initialNodes:t,initialEdges:e,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:s,initialMinZoom:o,initialMaxZoom:a,initialFitViewOptions:l,fitView:u,nodeOrigin:d,nodeExtent:f,children:h}){const[m]=x.useState(()=>aK({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:i,height:s,fitView:u,minZoom:o,maxZoom:a,fitViewOptions:l,nodeOrigin:d,nodeExtent:f}));return c.jsx(EW,{value:m,children:c.jsx(QW,{children:h})})}function lK({children:t,nodes:e,edges:n,defaultNodes:r,defaultEdges:i,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:h}){return x.useContext(Hv)?c.jsx(c.Fragment,{children:t}):c.jsx(Kv,{initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:s,initialHeight:o,fitView:a,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:h,children:t})}const cK={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function uK({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:s,edgeTypes:o,onNodeClick:a,onEdgeClick:l,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:m,onConnectStart:y,onConnectEnd:g,onClickConnectStart:w,onClickConnectEnd:v,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:k,onNodeContextMenu:N,onNodeDoubleClick:_,onNodeDragStart:j,onNodeDrag:T,onNodeDragStop:M,onNodesDelete:V,onEdgesDelete:H,onDelete:P,onSelectionChange:F,onSelectionDragStart:I,onSelectionDrag:R,onSelectionDragStop:U,onSelectionContextMenu:A,onSelectionStart:W,onSelectionEnd:D,onBeforeDelete:B,connectionMode:L,connectionLineType:$=Ec.Bezier,connectionLineStyle:q,connectionLineComponent:Z,connectionLineContainerStyle:ie,deleteKeyCode:ge="Backspace",selectionKeyCode:re="Shift",selectionOnDrag:Y=!1,selectionMode:ne=Dm.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:we=Fm()?"Meta":"Control",zoomActivationKeyCode:te=Fm()?"Meta":"Control",snapToGrid:fe,snapGrid:O,onlyRenderVisibleElements:pe=!1,selectNodesOnDrag:he,nodesDraggable:le,autoPanOnNodeFocus:oe,nodesConnectable:Q,nodesFocusable:de,nodeOrigin:Ne=d3,edgesFocusable:Ce,edgesReconnectable:Ae,elementsSelectable:Ue=!0,defaultViewport:Se=LW,minZoom:ve=.5,maxZoom:je=2,translateExtent:Te=Om,preventScrolling:ce=!0,nodeExtent:se,defaultMarkerColor:ye="#b1b1b7",zoomOnScroll:ke=!0,zoomOnPinch:ze=!0,panOnScroll:qe=!1,panOnScrollSpeed:ot=.5,panOnScrollMode:Ze=ba.Free,zoomOnDoubleClick:_t=!0,panOnDrag:tt=!0,onPaneClick:gt,onPaneMouseEnter:dt,onPaneMouseMove:wt,onPaneMouseLeave:Dt,onPaneScroll:Kt,onPaneContextMenu:rn,paneClickDistance:pn=0,nodeClickDistance:cn=0,children:kt,onReconnect:rt,onReconnectStart:Tt,onReconnectEnd:Mt,onEdgeContextMenu:Rt,onEdgeDoubleClick:Ct,onEdgeMouseEnter:Gt,onEdgeMouseMove:Lt,onEdgeMouseLeave:$t,reconnectRadius:Qt=10,onNodesChange:Ye,onEdgesChange:bt,noDragClassName:Ie="nodrag",noWheelClassName:it="nowheel",noPanClassName:ct="nopan",fitView:Ut,fitViewOptions:Et,connectOnClick:yn,attributionPosition:nn,proOptions:rr,defaultEdgeOptions:xn,elevateNodesOnSelect:Bn,elevateEdgesOnSelect:dr,disableKeyboardA11y:gr=!1,autoPanOnConnect:on,autoPanOnNodeDrag:Fn,autoPanSpeed:Xn,connectionRadius:yt,isValidConnection:Wt,onError:An,style:Un,id:Rr,nodeDragThreshold:yr,connectionDragThreshold:Ps,viewport:Kr,onViewportChange:xe,width:Re,height:_e,colorMode:Ve="light",debug:Ge,onScroll:Fe,ariaLabelConfig:pt,...St},zt){const Nt=Rr||"1",At=VW(Ve),Zt=x.useCallback(Me=>{Me.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Fe==null||Fe(Me)},[Fe]);return c.jsx("div",{"data-testid":"rf__wrapper",...St,onScroll:Zt,style:{...Un,...cK},ref:zt,className:Ei(["react-flow",i,At]),id:Rr,role:"application",children:c.jsxs(lK,{nodes:t,edges:e,width:Re,height:_e,fitView:Ut,fitViewOptions:Et,minZoom:ve,maxZoom:je,nodeOrigin:Ne,nodeExtent:se,children:[c.jsx(oK,{onInit:u,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:k,onNodeContextMenu:N,onNodeDoubleClick:_,nodeTypes:s,edgeTypes:o,connectionLineType:$,connectionLineStyle:q,connectionLineComponent:Z,connectionLineContainerStyle:ie,selectionKeyCode:re,selectionOnDrag:Y,selectionMode:ne,deleteKeyCode:ge,multiSelectionKeyCode:we,panActivationKeyCode:be,zoomActivationKeyCode:te,onlyRenderVisibleElements:pe,defaultViewport:Se,translateExtent:Te,minZoom:ve,maxZoom:je,preventScrolling:ce,zoomOnScroll:ke,zoomOnPinch:ze,zoomOnDoubleClick:_t,panOnScroll:qe,panOnScrollSpeed:ot,panOnScrollMode:Ze,panOnDrag:tt,onPaneClick:gt,onPaneMouseEnter:dt,onPaneMouseMove:wt,onPaneMouseLeave:Dt,onPaneScroll:Kt,onPaneContextMenu:rn,paneClickDistance:pn,nodeClickDistance:cn,onSelectionContextMenu:A,onSelectionStart:W,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Tt,onReconnectEnd:Mt,onEdgeContextMenu:Rt,onEdgeDoubleClick:Ct,onEdgeMouseEnter:Gt,onEdgeMouseMove:Lt,onEdgeMouseLeave:$t,reconnectRadius:Qt,defaultMarkerColor:ye,noDragClassName:Ie,noWheelClassName:it,noPanClassName:ct,rfId:Nt,disableKeyboardA11y:gr,nodeExtent:se,viewport:Kr,onViewportChange:xe}),c.jsx(UW,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:y,onConnectEnd:g,onClickConnectStart:w,onClickConnectEnd:v,nodesDraggable:le,autoPanOnNodeFocus:oe,nodesConnectable:Q,nodesFocusable:de,edgesFocusable:Ce,edgesReconnectable:Ae,elementsSelectable:Ue,elevateNodesOnSelect:Bn,elevateEdgesOnSelect:dr,minZoom:ve,maxZoom:je,nodeExtent:se,onNodesChange:Ye,onEdgesChange:bt,snapToGri
62d:fe,snapGrid:O,connectionMode:L,translateExtent:Te,connectOnClick:yn,defaultEdgeOptions:xn,fitView:Ut,fitViewOptions:Et,onNodesDelete:V,onEdgesDelete:H,onDelete:P,onNodeDragStart:j,onNodeDrag:T,onNodeDragStop:M,onSelectionDrag:R,onSelectionDragStart:I,onSelectionDragStop:U,onMove:d,onMoveStart:f,onMoveEnd:h,noPanClassName:ct,nodeOrigin:Ne,rfId:Nt,autoPanOnConnect:on,autoPanOnNodeDrag:Fn,autoPanSpeed:Xn,onError:An,connectionRadius:yt,isValidConnection:Wt,selectNodesOnDrag:he,nodeDragThreshold:yr,connectionDragThreshold:Ps,onBeforeDelete:B,paneClickDistance:pn,debug:Ge,ariaLabelConfig:pt}),c.jsx(DW,{onSelectionChange:F}),kt,c.jsx(AW,{proOptions:rr,position:nn}),c.jsx(PW,{rfId:Nt,disableKeyboardA11y:gr})]})})}var z_=h3(uK);const dK=t=>{var e;return(e=t.domNode)==null?void 0:e.querySelector(".react-flow__viewport-portal")};function O3({children:t}){const e=Kn(dK);return e?Vh.createPortal(t,e):null}function fK({dimensions:t,lineWidth:e,variant:n,className:r}){return c.jsx("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Ei(["react-flow__background-pattern",n,r])})}function hK({radius:t,className:e}){return c.jsx("circle",{cx:t,cy:t,r:t,className:Ei(["react-flow__background-pattern","dots",e])})}var Al;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Al||(Al={}));const pK={[Al.Dots]:1,[Al.Lines]:1,[Al.Cross]:6},mK=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function D3({id:t,variant:e=Al.Dots,gap:n=20,size:r,lineWidth:i=1,offset:s=0,color:o,bgColor:a,style:l,className:u,patternClassName:d}){const f=x.useRef(null),{transform:h,patternId:m}=Kn(mK,ni),y=r||pK[e],g=e===Al.Dots,w=e===Al.Cross,v=Array.isArray(n)?n:[n,n],S=[v[0]*h[2]||1,v[1]*h[2]||1],C=y*h[2],k=Array.isArray(s)?s:[s,s],N=w?[C,C]:S,_=[k[0]*h[2]||1+N[0]/2,k[1]*h[2]||1+N[1]/2],j=`${m}${t||""}`;return c.jsxs("svg",{className:Ei(["react-flow__background",u]),style:{...l,...Wv,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:f,"data-testid":"rf__background",children:[c.jsx("pattern",{id:j,x:h[0]%S[0],y:h[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:g?c.jsx(hK,{radius:C/2,className:d}):c.jsx(fK,{dimensions:N,lineWidth:i,variant:e,className:d})}),c.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}D3.displayName="Background";const gK=x.memo(D3);function bK(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:c.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function yK(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:c.jsx("path",{d:"M0 0h32v4.2H0z"})})}function vK(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:c.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function xK(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:c.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function wK(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:c.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function rb({children:t,className:e,...n}){return c.jsx("button",{type:"button",className:Ei(["react-flow__controls-button",e]),...n,children:t})}const kK=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function L3({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:o,onFitView:a,onInteractiveChange:l,className:u,children:d,position:f="bottom-left",orientation:h="vertical","aria-label":m}){const y=qr(),{isInteractive:g,minZoomReached:w,maxZoomReached:v,ariaLabelConfig:S}=Kn(kK,ni),{zoomIn:C,zoomOut:k,fitView:N}=k0(),_=()=>{C(),s==null||s()},j=()=>{k(),o==null||o()},T=()=>{N(i),a==null||a()},M=()=>{y.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),l==null||l(!g)},V=h==="horizontal"?"horizontal":"vertical";return c.jsxs(Gv,{className:Ei(["react-flow__controls",V,u]),position:f,style:t,"data-testid":"rf__controls","aria-label":m??S["controls.ariaLabel"],children:[e&&c.jsxs(c.Fragment,{children:[c.jsx(rb,{onClick:_,className:"react-flow__controls-zoomin",title:S["controls.zoomIn.ariaLabel"],"aria-label":S["controls.zoomIn.ariaLabel"],disabled:v,children:c.jsx(bK,{})}),c.jsx(rb,{onClick:j,className:"react-flow__controls-zoomout",title:S["controls.zoomOut.ariaLabel"],"aria-label":S["controls.zoomOut.ariaLabel"],disabled:w,children:c.jsx(yK,{})})]}),n&&c.jsx(rb,{className:"react-flow__controls-fitview",onClick:T,title:S["controls.fitView.ariaLabel"],"aria-label":S["controls.fitView.ariaLabel"],children:c.jsx(vK,{})}),r&&c.jsx(rb,{className:"react-flow__controls-interactive",onClick:M,title:S["controls.interactive.ariaLabel"],"aria-label":S["controls.interactive.ariaLabel"],children:g?c.jsx(wK,{}):c.jsx(xK,{})}),d]})}L3.displayName="Controls";x.memo(L3);function SK({id:t,x:e,y:n,width:r,height:i,style:s,color:o,strokeColor:a,strokeWidth:l,className:u,borderRadius:d,shapeRendering:f,selected:h,onClick:m}){const{background:y,backgroundColor:g}=s||{},w=o||y||g;return c.jsx("rect",{className:Ei(["react-flow__minimap-node",{selected:h},u]),x:e,y:n,rx:d,ry:d,width:r,height:i,style:{fill:w,stroke:a,strokeWidth:l},shapeRendering:f,onClick:m?v=>m(v,t):void 0})}const CK=x.memo(SK),_K=t=>t.nodes.map(e=>e.id),M1=t=>t instanceof Function?t:()=>t;function EK({nodeStrokeColor:t,nodeColor:e,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:s=CK,onClick:o}){const a=Kn(_K,ni),l=M1(e),u=M1(t),d=M1(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return c.jsx(c.Fragment,{children:a.map(h=>c.jsx(IK,{id:h,nodeColorFunc:l,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:s,onClick:o,shapeRendering:f},h))})}function NK({id:t,nodeColorFunc:e,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:s,shapeRendering:o,NodeComponent:a,onClick:l}){const{node:u,x:d,y:f,width:h,height:m}=Kn(y=>{const{internals:g}=y.nodeLookup.get(t),w=g.userNode,{x:v,y:S}=g.positionAbsolute,{width:C,height:k}=Gl(w);return{node:w,x:v,y:S,width:C,height:k}},ni);return!u||u.hidden||!FR(u)?null:c.jsx(a,{x:d,y:f,width:h,height:m,style:u.style,selected:!!u.selected,className:r(u),color:e(u),borderRadius:i,strokeColor:n(u),strokeWidth:s,shapeRendering:o,onClick:l,id:u.id})}const IK=x.memo(NK);var jK=x.memo(EK);const TK=200,zK=150,PK=t=>!t.hidden,AK=t=>{const e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?LR(v0(t.nodeLookup,{filter:PK}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},MK="react-flow__minimap-desc";function F3({style:t,className:e,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:l,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:h="bottom-right",onClick:m,onNodeClick:y,pannable:g=!1,zoomable:w=!1,ariaLabel:v,inversePan:S,zoomStep:C=1,offsetScale:k=5}){const N=qr(),_=x.useRef(null),{boundingRect:j,viewBB:T,rfId:M,panZoom:V,translateExtent:H,flowWidth:P,flowHeight:F,ariaLabelConfig:I}=Kn(AK,ni),R=(t==null?void 0:t.width)??TK,U=(t==null?void 0:t.height)??zK,A=j.width/R,W=j.height/U,D=Math.max(A,W),B=D*R,L=D*U,$=k*D,q=j.x-(B-j.width)/2-$,Z=j.y-(L-j.height)/2-$,ie=B+$*2,ge=L+$*2,re=`${MK}-${M}`,Y=x.useRef(0),ne=x.useRef();Y.current=D,x.useEffect(()=>{if(_.current&&V)return ne.current=ZG({domNode:_.current,panZoom:V,getTransform:()=>N.getState().transform,getViewScale:()=>Y.current}),()=>{var fe;
62(fe=ne.current)==null||fe.destroy()}},[V]),x.useEffect(()=>{var fe;(fe=ne.current)==null||fe.update({translateExtent:H,width:P,height:F,inversePan:S,pannable:g,zoomStep:C,zoomable:w})},[g,w,S,C,H,P,F]);const be=m?fe=>{var he;const[O,pe]=((he=ne.current)==null?void 0:he.pointer(fe))||[0,0];m(fe,{x:O,y:pe})}:void 0,we=y?x.useCallback((fe,O)=>{const pe=N.getState().nodeLookup.get(O).internals.userNode;y(fe,pe)},[]):void 0,te=v??I["minimap.ariaLabel"];return c.jsx(Gv,{position:h,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*D:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:Ei(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:c.jsxs("svg",{width:R,height:U,viewBox:`${q} ${Z} ${ie} ${ge}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":re,ref:_,onClick:be,children:[te&&c.jsx("title",{id:re,children:te}),c.jsx(jK,{onClick:we,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:a}),c.jsx("path",{className:"react-flow__minimap-mask",d:`M${q-$},${Z-$}h${ie+$*2}v${ge+$*2}h${-ie-$*2}z 63 M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}F3.displayName="MiniMap";const BK=x.memo(F3),RK=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,OK={[mh.Line]:"right",[mh.Handle]:"bottom-right"};function DK({nodeId:t,position:e,variant:n=mh.Handle,className:r,style:i=void 0,children:s,color:o,minWidth:a=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:m=!0,shouldResize:y,onResizeStart:g,onResize:w,onResizeEnd:v}){const S=b3(),C=typeof t=="string"?t:S,k=qr(),N=x.useRef(null),_=n===mh.Handle,j=Kn(x.useCallback(RK(_&&m),[_,m]),ni),T=x.useRef(null),M=e??OK[n];x.useEffect(()=>{if(!(!N.current||!C))return T.current||(T.current=pW({domNode:N.current,nodeId:C,getStoreItems:()=>{const{nodeLookup:H,transform:P,snapGrid:F,snapToGrid:I,nodeOrigin:R,domNode:U}=k.getState();return{nodeLookup:H,transform:P,snapGrid:F,snapToGrid:I,nodeOrigin:R,paneDomNode:U}},onChange:(H,P)=>{const{triggerNodeChanges:F,nodeLookup:I,parentLookup:R,nodeOrigin:U}=k.getState(),A=[],W={x:H.x,y:H.y},D=I.get(C);if(D&&D.expandParent&&D.parentId){const B=D.origin??U,L=H.width??D.measured.width??0,$=H.height??D.measured.height??0,q={id:D.id,parentId:D.parentId,rect:{width:L,height:$,...$R({x:H.x??D.position.x,y:H.y??D.position.y},{width:L,height:$},D.parentId,I,B)}},Z=j_([q],I,R,U);A.push(...Z),W.x=H.x?Math.max(B[0]*L,H.x):void 0,W.y=H.y?Math.max(B[1]*$,H.y):void 0}if(W.x!==void 0&&W.y!==void 0){const B={id:C,type:"position",position:{...W}};A.push(B)}if(H.width!==void 0&&H.height!==void 0){const L={id:C,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:H.width,height:H.height}};A.push(L)}for(const B of P){const L={...B,type:"position"};A.push(L)}F(A)},onEnd:({width:H,height:P})=>{const F={id:C,type:"dimensions",resizing:!1,dimensions:{width:H,height:P}};k.getState().triggerNodeChanges([F])}})),T.current.update({controlPosition:M,boundaries:{minWidth:a,minHeight:l,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:h,onResizeStart:g,onResize:w,onResizeEnd:v,shouldResize:y}),()=>{var H;(H=T.current)==null||H.destroy()}},[M,a,l,u,d,f,g,w,v,y]);const V=M.split("-");return c.jsx("div",{className:Ei(["react-flow__resize-control","nodrag",...V,n,r]),ref:N,style:{...i,scale:j,...o&&{[_?"backgroundColor":"borderColor"]:o}},children:s})}x.memo(DK);var J=(t=>(t.Bloob="Bloob",t.Song="Song",t.Note="Note",t.Track="Track",t.TextNode="TextNode",t.EmbeddingNode="EmbeddingNode",t.VisualMediaNode="VisualMediaNode",t.AudioFile="AudioFile",t))(J||{}),Us=(t=>(t.Midi="Midi",t.Audio="Audio",t))(Us||{});const ln=t=>t.bloobType==="Midi",En=t=>t.bloobType==="Audio";var so=(t=>(t.LEAD_MELODY="Lead Melody",t.COUNTER_MELODY="Counter Melody",t.HARMONIC_FILL="Harmonic Fill",t.BASSLINE="Bassline",t.OSTINATO="Ostinato",t.TEXTURAL_FILL="Textural Fill",t.PERCUSSION="Percussion",t.NONE="None",t))(so||{});const oT={eq:{enabled:!1,lowGain:0,midGain:0,highGain:0},compressor:{enabled:!1,threshold:-24,ratio:4,attack:.003,release:.25},reverb:{enabled:!1,send:0}};var B1={},R1={},ib={exports:{}},aT;function LK(){if(aT)return ib.exports;aT=1;var t=String,e=function(){return{isColorSupported:!1,reset:t,bold:t,dim:t,italic:t,underline:t,inverse:t,hidden:t,strikethrough:t,black:t,red:t,green:t,yellow:t,blue:t,magenta:t,cyan:t,white:t,gray:t,bgBlack:t,bgRed:t,bgGreen:t,bgYellow:t,bgBlue:t,bgMagenta:t,bgCyan:t,bgWhite:t,blackBright:t,redBright:t,greenBright:t,yellowBright:t,blueBright:t,magentaBright:t,cyanBright:t,whiteBright:t,bgBlackBright:t,bgRedBright:t,bgGreen
63Bright:t,bgYellowBright:t,bgBlueBright:t,bgMagentaBright:t,bgCyanBright:t,bgWhiteBright:t}};return ib.exports=e(),ib.exports.createColors=e,ib.exports}var lT;function FK(){return lT||(lT=1,function(t){var e={};Object.defineProperty(t,"__esModule",{value:!0});function n(u,d){for(var f in d)Object.defineProperty(u,f,{enumerable:!0,get:d[f]})}n(t,{dim:function(){return a},default:function(){return l}});const r=i(LK());function i(u){return u&&u.__esModule?u:{default:u}}let s=new Set;function o(u,d,f){typeof process<"u"&&e.JEST_WORKER_ID||f&&s.has(f)||(f&&s.add(f),console.warn(""),d.forEach(h=>console.warn(u,"-",h)))}function a(u){return r.default.dim(u)}const l={info(u,d){o(r.default.bold(r.default.cyan("info")),...Array.isArray(u)?[u]:[d,u])},warn(u,d){o(r.default.bold(r.default.yellow("warn")),...Array.isArray(u)?[u]:[d,u])},risk(u,d){o(r.default.bold(r.default.magenta("risk")),...Array.isArray(u)?[u]:[d,u])}}}(R1)),R1}var cT;function $K(){return cT||(cT=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});const e=n(FK());function n(s){return s&&s.__esModule?s:{default:s}}function r({version:s,from:o,to:a}){e.default.warn(`${o}-color-renamed`,[`As of Tailwind CSS ${s}, \`${o}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const i={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}}(B1)),B1}var O1,uT;function UK(){if(uT)return O1;uT=1;let t=$K();
63return O1=(t.__esModule?t:{default:t}).default,O1}var VK=UK();const It=Vo(VK);function $3(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e<t.length;e++)t[e]&&(n=$3(t[e]))&&(r&&(r+=" "),r+=n);else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function U3(){for(var t,e,n=0,r="";n<arguments.length;)(t=arguments[n++])&&(e=$3(t))&&(r&&(r+=" "),r+=e);return r}function HK(){for(var t=0,e,n,r="";t<arguments.length;)(e=arguments[t++])&&(n=V3(e))&&(r&&(r+=" "),r+=n);return r}function V3(t){if(typeof t=="string")return t;for(var e,n="",r=0;r<t.length;r++)t[r]&&(e=V3(t[r]))&&(n&&(n+=" "),n+=e);return n}var P_="-";function GK(t){var e=qK(t),n=t.conflictingClassGroups,r=t.conflictingClassGroupModifiers,i=r===void 0?{}:r;function s(a){var l=a.split(P_);return l[0]===""&&l.length!==1&&l.shift(),H3(l,e)||WK(a)}function o(a,l){var u=n[a]||[];return l&&i[a]?[].concat(u,i[a]):u}return{getClassGroupId:s,getConflictingClassGroupIds:o}}function H3(t,e){var o;if(t.length===0)return e.classGroupId;var n=t[0],r=e.nextPart.get(n),i=r?H3(t.slice(1),r):void 0;if(i)return i;if(e.validators.length!==0){var s=t.join(P_);return(o=e.validators.find(function(a){var l=a.validator;return l(s)}))==null?void 0:o.classGroupId}}var dT=/^\[(.+)\]$/;function WK(t){if(dT.test(t)){var e=dT.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}}function qK(t){var e=t.theme,n=t.prefix,r={nextPart:new Map,validators:[]},i=YK(Object.entries(t.classGroups),n);return i.forEach(function(s){var o=s[0],a=s[1];oS(a,r,o,e)}),r}function oS(t,e,n,r){t.forEach(function(i){if(typeof i=="string"){var s=i===""?e:fT(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(KK(i)){oS(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(function(o){var a=o[0],l=o[1];oS(l,fT(e,a),n,r)})})}function fT(t,e){var n=t;return e.split(P_).forEach(function(r){n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n}function KK(t){return t.isThemeGetter}function YK(t,e){return e?t.map(function(n){var r=n[0],i=n[1],s=i.map(function(o){return typeof o=="string"?e+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(function(a){var l=a[0],u=a[1];return[e+l,u]})):o});return[r,s]}):t}function XK(t){if(t<1)return{get:function(){},set:function(){}};var e=0,n=new Map,r=new Map;function i(s,o){n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)}return{get:function(o){var a=n.get(o);if(a!==void 0)return a;if((a=r.get(o))!==void 0)return i(o,a),a},set:function(o,a){n.has(o)?n.set(o,a):i(o,a)}}}var G3="!";function QK(t){var e=t.separator||":",n=e.length===1,r=e[0],i=e.length;return function(o){for(var a=[],l=0,u=0,d,f=0;f<o.length;f++){var h=o[f];if(l===0){if(h===r&&(n||o.slice(f,f+i)===e)){a.push(o.slice(u,f)),u=f+i;continue}if(h==="/"){d=f;continue}}h==="["?l++:h==="]"&&l--}var m=a.length===0?o:o.substring(u),y=m.startsWith(G3),g=y?m.substring(1):m,w=d&&d>u?d-u:void 0;return{modifiers:a,hasImportantModifier:y,baseClassName:g,maybePostfixModifierPosition:w}}}function ZK(t){if(t.length<=1)return t;var e=[],n=[];return t.forEach(function(r){var i=r[0]==="[";i?(e.push.apply(e,n.sort().concat([r])),n=[]):n.push(r)}),e.push.apply(e,n.sort()),e}function JK(t){return{cache:XK(t.cacheSize),splitModifiers:QK(t),...GK(t)}}var eY=/\s+/;function tY(t,e){var n=e.splitModifiers,r=e.getClassGroupId,i=e.getConflictingClassGroupIds,s=new Set;return t.trim().split(eY).map(function(o){var a=n(o),l=a.modifiers,u=a.hasImportantModifier,d=a.baseClassName,f=a.maybePostfixModifierPosition,h=r(f?d.substring(0,f):d),m=!!f;if(!h){if(!f)return{isTailwindClass:!1,originalClassName:o};if(h=r(d),!h)return{isTailwindClass:!1,originalClassName:o};m=!1}var y=ZK(l).join(":"),g=u?y+G3:y;return{isTailwindClass:!0,modifierId:g,classGroupId:h,originalClassName:o,hasPostfixModifier:m}}).reverse().filter(function(o){if(!o.isTailwindClass)return!0;var a=o.modifierId,l=o.classGroupId,u=o.hasPostfixModifier,d=a+l;return s.has(d)?!1:(s.add(d),i(l,u).forEach(function(f){return s.add(a+f)}),!0)}).reverse().map(function(o){return o.originalClassName}).join(" ")}function nY(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r,i,s,o=a;function a(u){var d=e[0],f=e.slice(1),h=f.reduce(function(m,y){return y(m)},d());
vendor: 4,363 bytes, line 63
63return r=JK(h),i=r.cache.get,s=r.cache.set,o=l,l(u)}function l(u){var d=i(u);if(d)return d;var f=tY(u,r);return s(u,f),f}return function(){return o(HK.apply(null,arguments))}}function Lr(t){var e=function(r){return r[t]||[]};return e.isThemeGetter=!0,e}var W3=/^\[(?:([a-z-]+):)?(.+)\]$/i,rY=/^\d+\/\d+$/,iY=new Set(["px","full","screen"]),sY=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oY=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,aY=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;function Jo(t){return Fu(t)||iY.has(t)||rY.test(t)||aS(t)}function aS(t){return yd(t,"length",hY)}function lY(t){return yd(t,"size",q3)}function cY(t){return yd(t,"position",q3)}function uY(t){return yd(t,"url",pY)}function sb(t){return yd(t,"number",Fu)}function Fu(t){return!Number.isNaN(Number(t))}function dY(t){return t.endsWith("%")&&Fu(t.slice(0,-1))}function Ap(t){return hT(t)||yd(t,"number",hT)}function Qn(t){return W3.test(t)}function Mp(){return!0}function uc(t){return sY.test(t)}function fY(t){return yd(t,"",mY)}function yd(t,e,n){var r=W3.exec(t);return r?r[1]?r[1]===e:n(r[2]):!1}function hY(t){return oY.test(t)}function q3(){return!1}function pY(t){return t.startsWith("url(")}function hT(t){return Number.isInteger(Number(t))}function mY(t){return aY.test(t)}function gY(){var t=Lr("colors"),e=Lr("spacing"),n=Lr("blur"),r=Lr("brightness"),i=Lr("borderColor"),s=Lr("borderRadius"),o=Lr("borderSpacing"),a=Lr("borderWidth"),l=Lr("contrast"),u=Lr("grayscale"),d=Lr("hueRotate"),f=Lr("invert"),h=Lr("gap"),m=Lr("gradientColorStops"),y=Lr("gradientColorStopPositions"),g=Lr("inset"),w=Lr("margin"),v=Lr("opacity"),S=Lr("padding"),C=Lr("saturate"),k=Lr("scale"),N=Lr("sepia"),_=Lr("skew"),j=Lr("space"),T=Lr("translate"),M=function(){return["auto","contain","none"]},V=function(){return["auto","hidden","clip","visible","scroll"]},H=function(){return["auto",Qn,e]},P=function(){return[Qn,e]},F=function(){return["",Jo]},I=function(){return["auto",Fu,Qn]},R=function(){return["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]},U=function(){return["solid","dashed","dotted","double","none"]},A=function(){return["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"]},W=function(){return["start","end","center","between","around","evenly","stretch"]},D=function(){return["","0",Qn]},B=function(){return["auto","avoid","all","avoid-page","page","left","right","column"]},L=function(){return[Fu,sb]},$=function(){return[Fu,Qn]};return{cacheSize:500,theme:{colors:[Mp],spacing:[Jo],blur:["none","",uc,Qn],brightness:L(),borderColor:[t],borderRadius:["none","","full",uc,Qn],borderSpacing:P(),borderWidth:F(),contrast:L(),grayscale:D(),hueRotate:$(),invert:D(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[dY,aS],inset:H(),margin:H(),opacity:L(),padding:P(),saturate:L(),scale:L(),sepia:D(),skew:$(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Qn]}],container:["container"],columns:[{columns:[uc]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none"]}],clear:[{clear:["left","right","both","none"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[].concat(R(),[Qn])}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}
vendor: 4,615 bytes, line 63
63],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ap]}],basis:[{basis:H()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Qn]}],grow:[{grow:D()}],shrink:[{shrink:D()}],order:[{order:["first","last","none",Ap]}],"grid-cols":[{"grid-cols":[Mp]}],"col-start-end":[{col:["auto",{span:["full",Ap]},Qn]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[Mp]}],"row-start-end":[{row:["auto",{span:[Ap]},Qn]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Qn]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Qn]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal"].concat(W())}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal"].concat(W(),["baseline"])}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[].concat(W(),["baseline"])}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[j]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[j]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit",Qn,e]}],"min-w":[{"min-w":["min","max","fit",Qn,Jo]}],"max-w":[{"max-w":["0","none","full","min","max","fit","prose",{screen:[uc]},uc,Qn]}],h:[{h:[Qn,e,"auto","min","max","fit"]}],"min-h":[{"min-h":["min","max","fit",Qn,Jo]}],"max-h":[{"max-h":[Qn,e,"min","max","fit"]}],"font-size":[{text:["base",uc,aS]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",sb]}],"font-family":[{font:[Mp]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Qn]}],"line-clamp":[{"line-clamp":["none",Fu,sb]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Qn,Jo]}],"list-image":[{"list-image":["none",Qn]}],"list-style-type":[{list:["none","disc","decimal",Qn]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[].concat(U(),["wavy"])}],"text-decoration-thickness":[{decoration:["auto","from-font",Jo]}],"underline-offset":[{"underline-offset":["auto",Qn,Jo]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Qn]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Qn]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[].concat(R(),[cY])}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",lY]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},uY]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[y]}
vendor: 5,070 bytes, line 63
63],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[].concat(U(),["hidden"])}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:U()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:[""].concat(U())}],"outline-offset":[{"outline-offset":[Qn,Jo]}],"outline-w":[{outline:[Jo]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Jo]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",uc,fY]}],"shadow-color":[{shadow:[Mp]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":A()}],"bg-blend":[{"bg-blend":A()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",uc,Qn]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[f]}],saturate:[{saturate:[C]}],sepia:[{sepia:[N]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[N]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Qn]}],duration:[{duration:$()}],ease:[{ease:["linear","in","out","in-out",Qn]}],delay:[{delay:$()}],animate:[{animate:["none","spin","ping","pulse","bounce",Qn]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Ap,Qn]}],"translate-x":[{"translate-x":[T]}],"translate-y":[{"translate-y":[T]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Qn]}],accent:[{accent:["auto",t]}],appearance:["appearance-none"],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Qn]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}
63],touch:[{touch:["auto","none","pinch-zoom","manipulation",{pan:["x","left","right","y","up","down"]}]}],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Qn]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Jo,sb]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var K3=nY(gY);const bY=1.25,A_=20,dn=A_*1.5,bn=A_*2,fo=bn,Is=bn*.5,Qi=dn,M_=dn*6,B_=bn*5,R_=dn*6,O_=bn*5,D_=dn*6,L_=bn*5,pT={bars:5e3,tracks:5e3},yY=(t,e)=>{const n={x:e.x-t.canvasPosition.x-Qi,y:e.y-t.canvasPosition.y-Is-fo};return{bar:Math.floor(n.x/dn),track:Math.floor(n.y/bn)}},mT=(t,e)=>({x:e.bar*dn+t.canvasPosition.x+Qi,y:e.track*bn+t.canvasPosition.y+Is+fo}),ob=(t,e)=>{for(const n of e)if(n.songId===t.id&&(n.songPosition.track<0||n.songPosition.bar+n.bars>t.bars||n.songPosition.track+1>t.tracks||n.songPosition.bar<0))return!1;return!0},Ro=t=>({x:t.x+30,y:t.y+30});function $y(t,e=500){if(!t||t.length===0)return[];const n=t[0].length,r=Math.floor(n/e),i=[];for(let o=0;o<e;o++){let a=0;for(let l=0;l<r;l++){let u=0;for(let f=0;f<t.length;f++)u+=Math.abs(t[f][o*r+l]);const d=u/t.length;d>a&&(a=d)}i.push(a)}const s=Math.max(...i);return s>0?i.map(o=>o/s):i}function vY(...t){return K3(U3(t))}const ab=1e-6;function F_(t,e,n){const r=e.startBar*n,i=e.endBar*n,s=Math.max(14,n*.35),o=Math.abs(t-r),a=Math.abs(t-i);return o<=s&&a<=s?o<=a?"left":"right":o<=s?"left":a<=s?"right":null}function Ua(t,e){return{x:t.x+e.x,y:t.y+e.y}}function lb(t,e){return!(t.canvasPosition.x+t.width<=e.canvasPosition.x||e.canvasPosition.x+e.width<=t.canvasPosition.x||t.canvasPosition.y+t.height<=e.canvasPosition.y||e.canvasPosition.y+e.height<=t.canvasPosition.y)}function Yv(t){return t*dn+Qi*2}function $_(t){return t*bn+Is*2+fo}var Y3=Symbol.for("immer-nothing"),gT=Symbol.for("immer-draftable"),hr=Symbol.for("immer-state");function Bo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var gh=Object.getPrototypeOf;function bh(t){return!!t&&!!t[hr]}function Fl(t){var e;return t?X3(t)||Array.isArray(t)||!!t[gT]||!!((e=t.constructor)!=null&&e[gT])||Qv(t)||Zv(t):!1}var xY=Object.prototype.constructor.toString();function X3(t){if(!t||typeof t!="object")return!1;const e=gh(t);if(e===null)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===xY}function Vm(t,e){Xv(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}function Xv(t){const e=t[hr];return e?e.type_:Array.isArray(t)?1:Qv(t)?2:Zv(t)?3:0}function lS(t,e){return Xv(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Q3(t,e,n){const r=Xv(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function wY(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Qv(t){return t instanceof Map}function Zv(t){return t instanceof Set}function Di(t){return t.copy_||t.base_}function cS(t,e){if(Qv(t))return new Map(t);if(Zv(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=X3(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[hr];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:t[o]})}return Object.create(gh(t),r)}else{const r=gh(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function U_(t,e=!1){return Jv(t)||bh(t)||!Fl(t)||(Xv(t)>1&&(t.set=t.add=t.clear=t.delete=kY),Object.freeze(t),e&&Object.entries(t).forEach(([n,r])=>U_(r,!0))),t}function kY(){Bo(2)}function Jv(t){return Object.isFrozen(t)}var uS={};function od(t){const e=uS[t];return e||Bo(0,t),e}function SY(t,e){uS[t]||(uS[t]=e)}var Hm;function Uy(){return Hm}
63function CY(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function bT(t,e){e&&(od("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function dS(t){fS(t),t.drafts_.forEach(_Y),t.drafts_=null}function fS(t){t===Hm&&(Hm=t.parent_)}function yT(t){return Hm=CY(Hm,t)}function _Y(t){const e=t[hr];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function vT(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[hr].modified_&&(dS(e),Bo(4)),Fl(t)&&(t=Vy(e,t),e.parent_||Hy(e,t)),e.patches_&&od("Patches").generateReplacementPatches_(n[hr].base_,t,e.patches_,e.inversePatches_)):t=Vy(e,n,[]),dS(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Y3?t:void 0}function Vy(t,e,n){if(Jv(e))return e;const r=e[hr];if(!r)return Vm(e,(i,s)=>xT(t,r,e,i,s,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return Hy(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let s=i,o=!1;r.type_===3&&(s=new Set(i),i.clear(),o=!0),Vm(s,(a,l)=>xT(t,r,i,a,l,n,o)),Hy(t,i,!1),n&&t.patches_&&od("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function xT(t,e,n,r,i,s,o){if(bh(i)){const a=s&&e&&e.type_!==3&&!lS(e.assigned_,r)?s.concat(r):void 0,l=Vy(t,i,a);if(Q3(n,r,l),bh(l))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Fl(i)&&!Jv(i)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Vy(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Hy(t,i)}}function Hy(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&U_(e,n)}function EY(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Uy(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=V_;n&&(i=[r],s=Gm);const{revoke:o,proxy:a}=Proxy.revocable(i,s);return r.draft_=a,r.revoke_=o,a}var V_={get(t,e){if(e===hr)return t;const n=Di(t);if(!lS(n,e))return NY(t,n,e);const r=n[e];return t.finalized_||!Fl(r)?r:r===D1(t.base_,e)?(L1(t),t.copy_[e]=Wm(r,t)):r},has(t,e){return e in Di(t)},ownKeys(t){return Reflect.ownKeys(Di(t))},set(t,e,n){const r=Z3(Di(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=D1(Di(t),e),s=i==null?void 0:i[hr];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(wY(n,i)&&(n!==void 0||lS(t.base_,e)))return!0;L1(t),_l(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return D1(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,L1(t),_l(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Di(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Bo(11)},getPrototypeOf(t){return gh(t.base_)},setPrototypeOf(){Bo(12)}},Gm={};Vm(V_,(t,e)=>{Gm[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});Gm.deleteProperty=function(t,e){return Gm.set.call(this,t,e,void 0)};Gm.set=function(t,e,n){return V_.set.call(this,t[0],e,n,t[0])};function D1(t,e){const n=t[hr];return(n?Di(n):t)[e]}function NY(t,e,n){var i;const r=Z3(e,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(t.draft_):void 0}function Z3(t,e){if(!(e in t))return;let n=gh(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=gh(n)}}function _l(t){t.modified_||(t.modified_=!0,t.parent_&&_l(t.parent_))}function L1(t){t.copy_||(t.copy_=cS(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var IY=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const s=n;n=e;const o=this;return function(l=s,...u){return o.produce(l,d=>n.call(this,d,...u))}}typeof n!="function"&&Bo(6),r!==void 0&&typeof r!="function"&&Bo(7);let i;if(Fl(e)){const s=yT(this),o=Wm(e,void 0);let a=!0;try{i=n(o),a=!1}finally{a?dS(s):fS(s)}return bT(s,r),vT(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===Y3&&(i=void 0),this.autoFreeze_&&U_(i,!0),r){const s=[],o=[];od("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Bo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...a)=>this.produceWithPatches(o,l=>e(l,...a));let r,i;return[this.produce(e,n,(o,a)=>{r=o,i=a}),r,i]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){Fl(t)||Bo(8),bh(t)&&(t=jY(t));const e=yT(this),n=Wm(t,void 0);return n[hr].isManual_=!0,fS(e),n}finishDraft(t,e){const n=t&&t[hr];(!n||!n.isManual_)&&Bo(9);const{scope_:r}=n;return bT(r,e),vT(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];
63if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=od("Patches").applyPatches_;return bh(t)?r(t,e):this.produce(t,i=>r(i,e))}};function Wm(t,e){const n=Qv(t)?od("MapSet").proxyMap_(t,e):Zv(t)?od("MapSet").proxySet_(t,e):EY(t,e);return(e?e.scope_:Uy()).drafts_.push(n),n}function jY(t){return bh(t)||Bo(10,t),J3(t)}function J3(t){if(!Fl(t)||Jv(t))return t;const e=t[hr];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=cS(t,e.scope_.immer_.useStrictShallowCopy_)}else n=cS(t,!0);return Vm(n,(r,i)=>{Q3(n,r,J3(i))}),e&&(e.finalized_=!1),n}function TY(){class t extends Map{constructor(l,u){super(),this[hr]={type_:2,parent_:u,scope_:u?u.scope_:Uy(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:l,draft_:this,isManual_:!1,revoked_:!1}}get size(){return Di(this[hr]).size}has(l){return Di(this[hr]).has(l)}set(l,u){const d=this[hr];return o(d),(!Di(d).has(l)||Di(d).get(l)!==u)&&(n(d),_l(d),d.assigned_.set(l,!0),d.copy_.set(l,u),d.assigned_.set(l,!0)),this}delete(l){if(!this.has(l))return!1;const u=this[hr];return o(u),n(u),_l(u),u.base_.has(l)?u.assigned_.set(l,!1):u.assigned_.delete(l),u.copy_.delete(l),!0}clear(){const l=this[hr];o(l),Di(l).size&&(n(l),_l(l),l.assigned_=new Map,Vm(l.base_,u=>{l.assigned_.set(u,!1)}),l.copy_.clear())}forEach(l,u){const d=this[hr];Di(d).forEach((f,h,m)=>{l.call(u,this.get(h),h,this)})}get(l){const u=this[hr];o(u);const d=Di(u).get(l);if(u.finalized_||!Fl(d)||d!==u.base_.get(l))return d;const f=Wm(d,u);return n(u),u.copy_.set(l,f),f}keys(){return Di(this[hr]).keys()}values(){const l=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{const u=l.next();return u.done?u:{done:!1,value:this.get(u.value)}}}}entries(){const l=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{const u=l.next();if(u.done)return u;const d=this.get(u.value);return{done:!1,value:[u.value,d]}}}}[Symbol.iterator](){return this.entries()}}function e(a,l){return new t(a,l)}function n(a){a.copy_||(a.assigned_=new Map,a.copy_=new Map(a.base_))}class r extends Set{constructor(l,u){super(),this[hr]={type_:3,parent_:u,scope_:u?u.scope_:Uy(),modified_:!1,finalized_:!1,copy_:void 0,base_:l,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return Di(this[hr]).size}has(l){const u=this[hr];return o(u),u.copy_?!!(u.copy_.has(l)||u.drafts_.has(l)&&u.copy_.has(u.drafts_.get(l))):u.base_.has(l)}add(l){const u=this[hr];return o(u),this.has(l)||(s(u),_l(u),u.copy_.add(l)),this}delete(l){if(!this.has(l))return!1;const u=this[hr];return o(u),s(u),_l(u),u.copy_.delete(l)||(u.drafts_.has(l)?u.copy_.delete(u.drafts_.get(l)):!1)}clear(){const l=this[hr];o(l),Di(l).size&&(s(l),_l(l),l.copy_.clear())}values(){const l=this[hr];return o(l),s(l),l.copy_.values()}entries(){const l=this[hr];return o(l),s(l),l.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(l,u){const d=this.values();let f=d.next();for(;!f.done;)l.call(u,f.value,f.value,this),f=d.next()}}function i(a,l){return new r(a,l)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(l=>{if(Fl(l)){const u=Wm(l,a);a.drafts_.set(l,u),a.copy_.add(u)}else a.copy_.add(l)}))}function o(a){a.revoked_&&Bo(3,JSON.stringify(Di(a)))}SY("MapSet",{proxyMap_:e,proxySet_:i})}var wo=new IY,Nu=wo.produce;wo.produceWithPatches.bind(wo);wo.setAutoFreeze.bind(wo);wo.setUseStrictShallowCopy.bind(wo);wo.applyPatches.bind(wo);wo.createDraft.bind(wo);wo.finishDraft.bind(wo);const eO={},{useDebugValue:zY}=mr,{useSyncExternalStoreWithSelector:PY}=s3;let wT=!1;const AY=t=>t;function MY(t,e=AY,n){(eO?"production":void 0)!=="production"&&n&&!wT&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),wT=!0);const r=PY(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return zY(r),r}const BY=t=>{(eO?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { use
63Store } from 'zustand'`.");const e=typeof t=="function"?o3(t):t,n=(r,i)=>MY(e,r,i);return Object.assign(n,e),n},tO=t=>BY,RY="modulepreload",OY=function(t){return"/"+t},kT={},ai=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(u=>{if(u=OY(u),u in kT)return;kT[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":RY,d||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((m,y)=>{h.addEventListener("load",m),h.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})},ci=t=>Z4[t]!==void 0?$r.BuiltInInstrument:J4[t]!==void 0?$r.BuiltInDrumMachine:at.getState().instrumentExists(t)?$r.GeneratedInstrument:$r.UnknownInstrument,Bf=t=>ci(t)===$r.BuiltInInstrument||ci(t)===$r.BuiltInDrumMachine||ci(t)===$r.GeneratedInstrument,DY=t=>ci(t)===$r.GeneratedInstrument,$u=t=>{switch(ci(t)){case $r.BuiltInInstrument:return Z4[t];case $r.BuiltInDrumMachine:return J4[t];case $r.GeneratedInstrument:return at.getState().getInstrumentId(t);case $r.UnknownInstrument:return-1}},$l=t=>{switch(ci(t)){case $r.BuiltInInstrument:return t.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase());case $r.BuiltInDrumMachine:return t+" (Drums)";default:return t}},yh=()=>[...Object.values(ft),...Object.values(m0)],nO=t=>yh().filter(e=>Bc(e)===t),Bc=t=>{const e=ci(t);if(e===$r.BuiltInDrumMachine)return Sn.Drums;if(e===$r.BuiltInInstrument)switch(t){case ft.AcousticGrandPiano:case ft.BrightAcousticPiano:case ft.ElectricGrandPiano:case ft.HonkyTonkPiano:case ft.ElectricPiano1:case ft.ElectricPiano2:case ft.Harpsichord:case ft.Clavinet:return Sn.Piano;case ft.Celesta:case ft.Glockenspiel:case ft.MusicBox:case ft.Vibraphone:case ft.Marimba:case ft.Xylophone:case ft.TubularBells:case ft.Dulcimer:return Sn.ChromaticPercussion;case ft.DrawbarOrgan:case ft.PercussiveOrgan:case ft.RockOrgan:case ft.ChurchOrgan:case ft.ReedOrgan:case ft.Accordion:case ft.Harmonica:case ft.TangoAccordion:return Sn.Organ;case ft.AcousticGuitarNylon:case ft.AcousticGuitarSteel:case ft.ElectricGuitarJazz:case ft.ElectricGuitarClean:case ft.ElectricGuitarMuted:case ft.OverdrivenGuitar:case ft.DistortionGuitar:case ft.GuitarHarmonics:return Sn.Guitar;case ft.AcousticBass:case ft.ElectricBassFinger:case ft.ElectricBassPick:case ft.FretlessBass:case ft.SlapBass1:case ft.SlapBass2:case ft.SynthBass1:case ft.SynthBass2:return Sn.Bass;case ft.Violin:case ft.Viola:case ft.Cello:case ft.Contrabass:case ft.TremoloStrings:case ft.PizzicatoStrings:case ft.OrchestralHarp:case ft.Timpani:return Sn.Strings;case ft.StringEnsemble1:case ft.StringEnsemble2:case ft.SynthStrings1:case ft.SynthStrings2:case ft.ChoirAahs:case ft.VoiceOohs:case ft.SynthChoir:case ft.OrchestraHit:return Sn.Ensemble;case ft.Trumpet:case ft.Trombone:case ft.Tuba:case ft.MutedTrumpet:case ft.FrenchHorn:case ft.BrassSection:case ft.SynthBrass1:case ft.SynthBrass2:return Sn.Brass;case ft.SopranoSax:case ft.AltoSax:case ft.TenorSax:case ft.BaritoneSax:case ft.Oboe:case ft.EnglishHorn:case ft.Bassoon:case ft.Clarinet:return Sn.Reed;case ft.Piccolo:case ft.Flute:case ft.Recorder:case ft.PanFlute:case ft.BlownBottle:case ft.Shakuhachi:case ft.Whistle:case ft.Ocarina:return Sn.Pipe;case ft.Lead1Square:case ft.Lead2Sawtooth:case ft.Lead3Calliope:case ft.Lead4Chiff:case ft.Lead5Charang:case ft.Lead6Voice:case ft.Lead7Fifths:case ft.Lead8BassLead:return Sn.SynthLead;case ft.Pad1NewAge:case ft.Pad2Warm:case ft.Pad3Polysynth:case ft.Pad4Choir:case ft.Pad5Bowed:case ft.Pad6Metallic:case ft.Pad7Halo:case ft.Pad8Sweep:return Sn.SynthPad;case ft.Fx1Rain:case ft.Fx2Soundtrack:case ft.Fx3Crystal:case ft.Fx4Atmosphere:case ft.Fx5Brightness:case ft.Fx6Goblins:case ft.Fx7Echoes:case ft.Fx8Scifi:return Sn.SynthEffects;case ft.Sitar:case ft.Banjo:case ft.Shamisen:case ft.Koto:case ft.Kalimba:case ft.Bagpipe:case ft.Fiddle:case ft.Shanai:return Sn.Ethnic;case ft.TinkleBell:case ft.Agogo:case ft.SteelDrums:case ft.Woodblock:case ft.TaikoDrum:case ft.MelodicTom:case ft.SynthDrum:case ft.ReverseCymbal:case ft.GuitarFretNoise:case ft.BreathNoise:case ft.Seashore:case ft.BirdTweet:case ft.TelephoneRing:case ft.Helicopter:case ft.Applause:case ft.Gunshot:return Sn.Percussive}else return null},rO=["Strings","Violin","Viola","Cello","Contrabass","Double Bass","Upright Bass","String Ensemble","Orchestra Strings","Chamber Strings","String Section","Guitar","Electric Guitar","Acoustic Guitar","Classical Guitar","Nylon Guitar","Steel Guitar","Bass Guitar","Bass","Electric Bass","Acoustic Bass","Rhythm Guitar","Lead Guitar","Clean Guitar","Distorted Guitar","Piano","Grand Piano","Electric Piano","Rhodes","Wurlitzer","Keyboard","Keys","Synth","Synthesizer","Organ","Hammond Organ","Church Organ","Drums","Drum","Drumkit","Drum Kit","Kick","Snare","Hihat","Hi Hat","Cymbal","Tom","Percussion","Congas","Bongos","Tambourine","Shaker","Clap","Claps","Cowbell","Triangle","Woodblock","Timbales","Brass","Trumpet","Trombone","French Horn","Tuba","Brass Section","Horn Section","Horns","Flugelhorn","Cornet","Woodwinds","Flute","Clarinet","Saxophone","Sax","Alto Sax","Tenor Sax","Soprano Sax","Baritone Sax","Oboe","Bassoon","Piccolo","Recorder","Banjo","Mandolin","Ukulele","Sitar","Harp","Harmonica","Accordion","Bagpipe","Didgeridoo","Kalimba","Marimba","Vibraphone","Xylophone","Glockenspiel","Bells","Chimes","Vocals","Voice","Choir","Strings Pad","Pad","Lead","Pluck","Arp","Arpeggiated","Sequence"].sort((t,e)=>e.length-t.length),qm="Unknown Instrument";let iO="";const Iu=t=>{iO=(t==null?void 0:t.trim().toLowerCase())??""},Ra=(t,e)=>{const n=Date.now(),r=Math.floor(Math.random()*1e3),s=aO(`${t}:${iO??""}`),o=(r+s%1e3)%1e3;return n*1e3+o},sO=t=>{if(t.length===0)return{};if(!t.every(e=>e.songId===t[0].songId))throw new Error("cannot group bloobs in different songs by track");return t.reduce((e,n)=>{const r=n.songPosition.track;return e[r]||(e[r]=[]),e[r].push(n),e},{})},oO=(t,e,n,r)=>t.track!==n.track?!1:t.bar<n.bar+r&&n.bar<t.bar+e,Gr={muted:{blue:"#6
63B88CC",deepBlue:"#5A75B0",lightBlue:"#90A8DC",green:"#7DC383",deepGreen:"#5FA865",lightGreen:"#9CD1A1",peach:"#F8C291",deepPeach:"#E5AD7D",purple:"#704BA8",lightPurple:"#8A68C1",teal:"#2B6A6E",rose:"#B45F69",lightRose:"#C67F88",brown:"#A0805E",lightBrown:"#B5987B",gray:"#7A7A7A"}},Ls={[Sn.Piano]:Gr.muted.blue,[Sn.Organ]:Gr.muted.deepBlue,[Sn.ChromaticPercussion]:Gr.muted.lightBlue,[Sn.Guitar]:Gr.muted.peach,[Sn.Strings]:Gr.muted.deepPeach,[Sn.Ensemble]:Gr.muted.lightBrown,[Sn.Bass]:Gr.muted.purple,[Sn.Brass]:Gr.muted.brown,[Sn.Reed]:Gr.muted.lightBrown,[Sn.Pipe]:Gr.muted.deepPeach,[Sn.SynthLead]:Gr.muted.rose,[Sn.SynthPad]:Gr.muted.lightRose,[Sn.SynthEffects]:Gr.muted.lightPurple,[Sn.Drums]:Gr.muted.green,[Sn.Percussive]:Gr.muted.deepGreen,[Sn.Ethnic]:Gr.muted.lightGreen,[Sn.SoundEffects]:Gr.muted.gray},ST=[Gr.muted.blue,Gr.muted.green,Gr.muted.peach,Gr.muted.brown,Gr.muted.purple,Gr.muted.teal,Gr.muted.rose];function aO(t){let e=5381,n=t.length;for(;n;)e=e*33^t.charCodeAt(--n);return e>>>0}const oi=t=>{const e=ci(t);if([$r.BuiltInInstrument,$r.BuiltInDrumMachine].includes(e)){const a=Bc(t);if(a)return Ls[a]}const n=t.toLowerCase();if(n.includes("drum")||n.includes("percussion")||n.includes("kit")||n.includes("beat"))return Ls.drums;const r=Object.values(ft).map(a=>a.toLowerCase()),i=Object.values(m0).map(a=>a.toLowerCase());if(r.includes(n)||i.includes(n))return Ls[Bc(t)];if(Object.values(Sn).map(a=>a.toLowerCase()).includes(n))return Ls[n];for(const[a,l]of Object.entries(Ls)){const u=a.toLowerCase().split(" ");for(const d of u)if(n.includes(d))return l}if(n.includes("piano"))return Ls.piano;if(n.includes("guitar"))return Ls.guitar;if(n.includes("bass"))return Ls.bass;if(n.includes("string")||n.includes("violin")||n.includes("cello")||n.includes("viola"))return Ls.strings;if(n.includes("brass")||n.includes("trumpet")||n.includes("trombone"))return Ls.brass;if(n.includes("synth"))return Ls["synth lead"];if(n.includes("pad"))return Ls["synth pad"];if(n.includes("organ"))return Ls.organ;if(n.includes("flute")||n.includes("sax")||n.includes("clarinet"))return Ls.reed;const o=aO(t);return ST[o%ST.length]},Hh=t=>{const e=t.match(/([A-G][b#]{0,2})(\d+)/);if(!e)throw new Error(`Invalid pitch format: ${t}`);const n=e[1],r=parseInt(e[2]);return{chroma:n,octave:r}},Oo=t=>x$(t),Km=t=>{const e=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],n=Math.floor(t/12)-1,r=t%12;return`${e[r]}${n}`},lO=t=>Oo(t),H_=t=>lO(t),cO=(t,e,n)=>{let r=p0(e,n);return f_(r)>=7&&(r=h_(r,"8P")),S$(t,r)},hS=(t,e)=>{const n=w$(e).scale,r=t,i=k$(r);return n.some(o=>U2(o).pc===U2(i).pc)?i:r},Jp=(t,e)=>e?t/e:1,Gh=t=>En(t)?!1:t.noteIds.size===0,uO=(t,e)=>t.id===e.id&&t.type===e.type,em=6*dn,tm=5*bn,vc=7*dn,Cf=4*bn,nm=6*dn,rm=4*bn,LY=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_EMBEDDING_NODE_HEIGHT:Cf,DEFAULT_EMBEDDING_NODE_WIDTH:vc,DEFAULT_TEXT_NODE_HEIGHT:tm,DEFAULT_TEXT_NODE_WIDTH:em,DEFAULT_VISUAL_MEDIA_NODE_HEIGHT:rm,DEFAULT_VISUAL_MEDIA_NODE_WIDTH:nm,doSongPositionsOverlap:oO,equalsCaiObject:uO,generateIntegerUUID:Ra,getBloobColor:oi,getBloobsByTrack:sO,getEnharmonicEquivalentInKey:hS,getPartsOfPitch:Hh,getPitchFromPitchInt:Km,getPitchIntOfPitch:Oo,getPlaybackRate:Jp,isBloobEmpty:Gh,parseMidi:H_,parsePitchToMidiNumber:lO,setIdGenerationUserEmail:Iu,transposePitch:cO},Symbol.toStringTag,{value:"Module"}));function FY(t,e,n,r){var s,o,a,l,u,d,f,h;const i=n&&typeof n=="object"?n:void 0;switch(t){case J.Song:return{domain_type:"song",domain_id:e};case J.Bloob:{const m=(i==null?void 0:i.songId)??((o=(s=r.bloobs)==null?void 0:s[e])==null?void 0:o.songId);return m!=null?{domain_type:"song",domain_id:m}:void 0}case J.Note:{const m=(i==null?void 0:i.bloobId)??((l=(a=r.notes)==null?void 0:a[e])==null?void 0:l.bloobId);if(m!=null){const y=(d=(u=r.bloobs)==null?void 0:u[m])==null?void 0:d.songId;if(y!=null)return{domain_type:"song",domain_id:y}}return}case J.Track:{const m=(i==null?void 0:i.songId)??((h=(f=r.tracks)==null?void 0:f[e])==null?void 0:h.songId);return m!=null?{domain_type:"song",domain_id:m}:void 0}case"NoteDetails":return;case J.AudioFile:return{domain_type:"song",domain_id:0};case J.TextNode:return{domain_type:"text",domain_id:e};case J.EmbeddingNode:return{domain_type:"embedding",domain_id:e};case J.VisualMediaNode:return{domain_type:"visual",domain_id:e};default:return}}const _c=class _c{constructor(e){Xt(this,"pendingOperations",[]);Xt(this,"previousStateCache",new Map);Xt(this,"clientId");Xt(this,"syncManager");Xt(this,"skipTrackingForRemoteOps",!1);Xt(this,"stateGetter");this.clientId=e}setStateGetter(e){this.stateGetter=e}static getInstance(e){if(!_c.instance){if(!e)throw new Error("ClientId is required for first initialization");_c.instance=new _c(e)}return _c.instance}static resetInstance(){_c.instance=null}setSyncManager(e){this.syncManager=e}addPendingOperation(e){var i;let n={...e};if(n.domain_type==null||n.domain_id==null){const s=(i=this.stateGetter)==null?void 0:i.call(this);if(s){const o=FY(n.cai_object_type,n.cai_object_id,n.value,s);o&&(n={...n,domain_type:o.domain_type,domain_id:o.domain_id})}}const r={...n,id:this.generateOperationId(),timestamp:Date.now(),client_id:this.clientId,operation_set_id:""};this.pendingOperations.push(r)}getPendingOperations(){return[...this.pendingOperations]}clearPendingOperations(){this.pendingOperations=[]}getPendingOperationsCount(){return this.pendingOperations.length}createOperationSetFromPending(e){if(this.pendingOperations.length===0)return null;const n=this.generateOperationSetId(),r=Date.now(),i=this.pendingOperations.map((o,a)=>{const l={...o,operation_set_id:n};if(o.operation_type==="delete"&&o.cai_object_type==="Bloob"&&(l.value==null||typeof l.value!="object")){const u=this.previousStateCache.get(String(a));u&&typeof u=="object"&&(l.value={bloobType:u.bloobType??"midi",...u.audioFileId!=null&&{audioFileId:u.audioFileId}})}return l}),s={id:n,operations:i,timestamp:r,client_id:this.clientId,description:e||`Batch of ${this.pendingOperations.length} operations`};return this.pendingOperations=[],s}flushPendingOperations(e){const n=this.createOperationSetFromPending(e);return n?(this.addPendingOperationSet(n),n):null}getCapturedStateMap(){return new Map(this.previousStateCache)}clearCapturedState(){this.previousStateCache.clear()}convertSetsToLists(e){if(typeof e!="object"||e===null)return e;if(e instanceof Set)return Array.from(e);if(Array.isArray(e))return e.map(n=>this.convertSetsToLists(n));if(e.constructor===Object){const n={};for(const[r,i]of Object.entries(e))n[r]=this.convertSetsToLists(i);return n}return e}createOperationSet(e){const n=this.generateOperationSetId(),r=Date.now();return new $Y(n,r,this.clientId,e)}addPendingOperationSet(e){const n={...e,operations:e.operations.map(r=>({...r,value:this.convertSetsToLists(r.value)}))};this.syncManager&&this.syncManager.dispatchOperationSet(n)}generateOperationSetId(){return`opset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}generateOperationId(){return`op_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}setSkipTrackingForRemoteOps(e){this.skipTrackingForRemoteOps=e}trackAddOperation(e,n,r,i){this.skipTrackingForRemoteOps||this.addPendingOperation({operation_type:"add",cai_object_type:e,cai_object_id:n,value:r,...i&&{domain_type:i.domain_type,domain_id:i.domain_id}})}trackUpdateOperation(e,n,r,i){if(this.skipTrackingForRemoteOps)return;const s=this.pendingOperations.length;if(i!==void 0){const o=`${s}`;this.previousStateCache.set(o,i)}this.addPendingOperation({operation_type:"update",cai_object_type:e,cai_object_id:n,value:r})}trackDeleteOperation(e,n,r,i){if(this.skipTrackingForRemoteOps)return;const s=this.pendingOperations.length;if(r!==void 0){const o=`${s}`;this.previousStateCache.set(o,r)}this.addPendingOperation({operation_type:"delete",cai_object_type:e,cai_object_id:n,...i&&{domain_type:i.domain_type,domain_id:i.domain_id}})}trackIncrementOperation(e,n){this.skipTrackingForRemoteOps||this.addPendingOperation({operation_type:"increment",cai_object_type:"NoteDetails",cai_object_id:0,value:{hash:e},domain_type:"song",domain_id:n})}trackDecrementOperation(e,n){this.skipTrackingForRemoteOps||this.addPendingOperation({operation_type:"decrement",cai_object_type:"NoteDetails",cai_object_id:0,value:{hash:e},domain_type:"song",domain_id:n})}updateConfig(e){e.clientId&&(this.clientId=e.clientId)}};Xt(_c,"instance",null);let pS=_c;class $Y{constructor(e,n,r,i){Xt(this,"operationSetId");
63Xt(this,"timestamp");Xt(this,"clientId");Xt(this,"description");Xt(this,"operations",[]);this.operationSetId=e,this.timestamp=n,this.clientId=r,this.description=i}addOperation(e){const n={...e,id:this.generateOperationId(),operation_set_id:this.operationSetId,timestamp:this.timestamp,client_id:this.clientId};return this.operations.push(n),this}build(){return{id:this.operationSetId,operations:this.operations,timestamp:this.timestamp,client_id:this.clientId,description:this.description}}generateOperationId(){return`op_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}const vh=t=>pS.getInstance(t);class UY{constructor(){Xt(this,"pendingUpdates",{});Xt(this,"syncManager",null);Xt(this,"syncDebounceTimer",null);Xt(this,"SYNC_DEBOUNCE_TIME",2e3)}setSyncManager(e){this.syncManager=e}addPendingUpdate(e){this.pendingUpdates={...this.pendingUpdates,...e},this.syncManager&&this.syncManager.triggerSettingsSync&&this.debouncedSync()}debouncedSync(){this.syncDebounceTimer&&clearTimeout(this.syncDebounceTimer),this.syncDebounceTimer=setTimeout(()=>{this.syncManager&&this.syncManager.triggerSettingsSync&&this.syncManager.triggerSettingsSync(),this.syncDebounceTimer=null},this.SYNC_DEBOUNCE_TIME)}getPendingUpdates(){return{...this.pendingUpdates}}hasPendingUpdates(){return Object.keys(this.pendingUpdates).length>0}clearPendingUpdates(){this.pendingUpdates={}}clearDebounceTimer(){this.syncDebounceTimer&&(clearTimeout(this.syncDebounceTimer),this.syncDebounceTimer=null)}reset(){this.clearPendingUpdates(),this.clearDebounceTimer()}}const Ou=class Ou{constructor(){Xt(this,"syncManager")}static getInstance(){return Ou.instance||(Ou.instance=new Ou),Ou.instance}setSyncManager(e){this.syncManager=e}trackOperation(e,n,r){const i={operation_type:e,thread_id:n,value:r,timestamp:Date.now()};this.syncManager&&this.syncManager.dispatchChatOp(i)}};Xt(Ou,"instance",null);let Gy=Ou;function dO(t,e){return function(){return t.apply(e,arguments)}}const{toString:VY}=Object.prototype,{getPrototypeOf:G_}=Object,ex=(t=>e=>{const n=VY.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ea=t=>(t=t.toLowerCase(),e=>ex(e)===t),tx=t=>e=>typeof e===t,{isArray:Wh}=Array,Ym=tx("undefined");function HY(t){return t!==null&&!Ym(t)&&t.constructor!==null&&!Ym(t.constructor)&&mo(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const fO=Ea("ArrayBuffer");function GY(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&fO(t.buffer),e}const WY=tx("string"),mo=tx("function"),hO=tx("number"),nx=t=>t!==null&&typeof t=="object",qY=t=>t===!0||t===!1,ay=t=>{if(ex(t)!=="object")return!1;const e=G_(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},KY=Ea("Date"),YY=Ea("File"),XY=Ea("Blob"),QY=Ea("FileList"),ZY=t=>nx(t)&&mo(t.pipe),JY=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||mo(t.append)&&((e=ex(t))==="formdata"||e==="object"&&mo(t.toString)&&t.toString()==="[object FormData]"))},eX=Ea("URLSearchParams"),[tX,nX,rX,iX]=["ReadableStream","Request","Response","Headers"].map(Ea),sX=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function S0(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,i;if(typeof t!="object"&&(t=[t]),Wh(t))for(r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else{const s=n?Object.getOwnPropertyNames(t):Object.keys(t),o=s.length;let a;for(r=0;r<o;r++)a=s[r],e.call(null,t[a],a,t)}}function pO(t,e){e=e.toLowerCase();const n=Object.keys(t);let r=n.length,i;for(;r-- >0;)if(i=n[r],e===i.toLowerCase())return i;return null}const Uu=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,mO=t=>!Ym(t)&&t!==Uu;function mS(){const{caseless:t}=mO(this)&&this||{},e={},n=(r,i)=>{const s=t&&pO(e,i)||i;ay(e[s])&&ay(r)?e[s]=mS(e[s],r):ay(r)?e[s]=mS({},r):Wh(r)?e[s]=r.slice():e[s]=r};for(let r=0,i=arguments.length;r<i;r++)arguments[r]&&S0(arguments[r],n);return e}const oX=(t,e,n,{allOwnKeys:r}={})=>(S0(e,(i,s)=>{n&&mo(i)?t[s]=dO(i,n):t[s]=i},{allOwnKeys:r}),t),aX=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),lX=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},cX=(t,e,n,r)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;
vendor: 5,168 bytes, line 63
63)o=i[s],(!r||r(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=n!==!1&&G_(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},uX=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},dX=t=>{if(!t)return null;if(Wh(t))return t;let e=t.length;if(!hO(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},fX=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&G_(Uint8Array)),hX=(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=r.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},pX=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},mX=Ea("HTMLFormElement"),gX=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),CT=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),bX=Ea("RegExp"),gO=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};S0(n,(i,s)=>{let o;(o=e(i,s,t))!==!1&&(r[s]=o||i)}),Object.defineProperties(t,r)},yX=t=>{gO(t,(e,n)=>{if(mo(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(mo(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},vX=(t,e)=>{const n={},r=i=>{i.forEach(s=>{n[s]=!0})};return Wh(t)?r(t):r(String(t).split(e)),n},xX=()=>{},wX=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function kX(t){return!!(t&&mo(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const SX=t=>{const e=new Array(10),n=(r,i)=>{if(nx(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[i]=r;const s=Wh(r)?[]:{};return S0(r,(o,a)=>{const l=n(o,i+1);!Ym(l)&&(s[a]=l)}),e[i]=void 0,s}}return r};return n(t,0)},CX=Ea("AsyncFunction"),_X=t=>t&&(nx(t)||mo(t))&&mo(t.then)&&mo(t.catch),bO=((t,e)=>t?setImmediate:e?((n,r)=>(Uu.addEventListener("message",({source:i,data:s})=>{i===Uu&&s===n&&r.length&&r.shift()()},!1),i=>{r.push(i),Uu.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",mo(Uu.postMessage)),EX=typeof queueMicrotask<"u"?queueMicrotask.bind(Uu):typeof process<"u"&&process.nextTick||bO,ht={isArray:Wh,isArrayBuffer:fO,isBuffer:HY,isFormData:JY,isArrayBufferView:GY,isString:WY,isNumber:hO,isBoolean:qY,isObject:nx,isPlainObject:ay,isReadableStream:tX,isRequest:nX,isResponse:rX,isHeaders:iX,isUndefined:Ym,isDate:KY,isFile:YY,isBlob:XY,isRegExp:bX,isFunction:mo,isStream:ZY,isURLSearchParams:eX,isTypedArray:fX,isFileList:QY,forEach:S0,merge:mS,extend:oX,trim:sX,stripBOM:aX,inherits:lX,toFlatObject:cX,kindOf:ex,kindOfTest:Ea,endsWith:uX,toArray:dX,forEachEntry:hX,matchAll:pX,isHTMLForm:mX,hasOwnProperty:CT,hasOwnProp:CT,reduceDescriptors:gO,freezeMethods:yX,toObjectSet:vX,toCamelCase:gX,noop:xX,toFiniteNumber:wX,findKey:pO,global:Uu,isContextDefined:mO,isSpecCompliantForm:kX,toJSONObject:SX,isAsyncFn:CX,isThenable:_X,setImmediate:bO,asap:EX};function Dn(t,e,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}ht.inherits(Dn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ht.toJSONObject(this.config),code:this.code,status:this.status}}});const yO=Dn.prototype,vO={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{vO[t]={value:t}});Object.defineProperties(Dn,vO);Object.defineProperty(yO,"isAxiosError",{value:!0});Dn.from=(t,e,n,r,i,s)=>{const o=Object.create(yO);return ht.toFlatObject(t,o,function(l){return l!==Error.prototype},a=>a!=="isAxiosError"),Dn.call(o,t.message,e,n,r,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};const NX=null;function gS(t){return ht.isPlainObject(t)||ht.isArray(t)}function xO(t){return ht.endsWith(t,"[]")?t.slice(0,-2):t}function _T(t,e,n){return t?t.concat(e).map(function(i,s){return i=xO(i),!n&&s?"["+i+"]":i}).join(n?".":""):e}function IX(t){return ht.isArray(t)&&!t.some(gS)}const jX=ht.toFlatObject(ht,{},null,function(e){return/^is[A-Z]/.test(e)});function rx(t,e,n){if(!ht.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=ht.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,w){return!ht.isUndefined(w[g])});const r=n.metaTokens,i=n.visitor||d,s=n.dots,o=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&ht.isSpecCompliantForm(e);if(!ht.isFunction(i))throw new TypeError("visitor must be a function");function u(y){if(y===null)return"";if(ht.isDate(y))return y.toISOString();if(!l&&ht.isBlob(y))throw new Dn("Blob is not supported. Use a Buffer instead.");return ht.isArrayBuffer(y)||ht.isTypedArray(y)?l&&typeof Blob=="function"?new Blob([y]):Buffer.from(y):y}function d(y,g,w){let v=y;if(y&&!w&&typeof y=="object"){if(ht.endsWith(g,"{}
vendor: 3,990 bytes, line 63
63"))g=r?g:g.slice(0,-2),y=JSON.stringify(y);else if(ht.isArray(y)&&IX(y)||(ht.isFileList(y)||ht.endsWith(g,"[]"))&&(v=ht.toArray(y)))return g=xO(g),v.forEach(function(C,k){!(ht.isUndefined(C)||C===null)&&e.append(o===!0?_T([g],k,s):o===null?g:g+"[]",u(C))}),!1}return gS(y)?!0:(e.append(_T(w,g,s),u(y)),!1)}const f=[],h=Object.assign(jX,{defaultVisitor:d,convertValue:u,isVisitable:gS});function m(y,g){if(!ht.isUndefined(y)){if(f.indexOf(y)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(y),ht.forEach(y,function(v,S){(!(ht.isUndefined(v)||v===null)&&i.call(e,v,ht.isString(S)?S.trim():S,g,h))===!0&&m(v,g?g.concat(S):[S])}),f.pop()}}if(!ht.isObject(t))throw new TypeError("data must be an object");return m(t),e}function ET(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function W_(t,e){this._pairs=[],t&&rx(t,this,e)}const wO=W_.prototype;wO.append=function(e,n){this._pairs.push([e,n])};wO.toString=function(e){const n=e?function(r){return e.call(this,r,ET)}:ET;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function TX(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function kO(t,e,n){if(!e)return t;const r=n&&n.encode||TX;ht.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(i?s=i(e,n):s=ht.isURLSearchParams(e)?e.toString():new W_(e,n).toString(r),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class NT{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ht.forEach(this.handlers,function(r){r!==null&&e(r)})}}const SO={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zX=typeof URLSearchParams<"u"?URLSearchParams:W_,PX=typeof FormData<"u"?FormData:null,AX=typeof Blob<"u"?Blob:null,MX={isBrowser:!0,classes:{URLSearchParams:zX,FormData:PX,Blob:AX},protocols:["http","https","file","blob","url","data"]},q_=typeof window<"u"&&typeof document<"u",bS=typeof navigator=="object"&&navigator||void 0,BX=q_&&(!bS||["ReactNative","NativeScript","NS"].indexOf(bS.product)<0),RX=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",OX=q_&&window.location.href||"http://localhost",DX=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:q_,hasStandardBrowserEnv:BX,hasStandardBrowserWebWorkerEnv:RX,navigator:bS,origin:OX},Symbol.toStringTag,{value:"Module"})),fs={...DX,...MX};function LX(t,e){return rx(t,new fs.classes.URLSearchParams,Object.assign({visitor:function(n,r,i,s){return fs.isNode&&ht.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function FX(t){return ht.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function $X(t){const e={},n=Object.keys(t);let r;const i=n.length;let s;for(r=0;r<i;r++)s=n[r],e[s]=t[s];return e}function CO(t){function e(n,r,i,s){let o=n[s++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=s>=n.length;return o=!o&&ht.isArray(i)?i.length:o,l?(ht.hasOwnProp(i,o)?i[o]=[i[o],r]:i[o]=r,!a):((!i[o]||!ht.isObject(i[o]))&&(i[o]=[]),e(n,r,i[o],s)&&ht.isArray(i[o])&&(i[o]=$X(i[o])),!a)}if(ht.isFormData(t)&&ht.isFunction(t.entries)){const n={};return ht.forEachEntry(t,(r,i)=>{e(FX(r),i,n,0)}),n}return null}function UX(t,e,n){if(ht.isString(t))try{return(e||JSON.parse)(t),ht.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const C0={transitional:SO,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,s=ht.isObject(e);
vendor: 4,664 bytes, lines 63-65
63if(s&&ht.isHTMLForm(e)&&(e=new FormData(e)),ht.isFormData(e))return i?JSON.stringify(CO(e)):e;if(ht.isArrayBuffer(e)||ht.isBuffer(e)||ht.isStream(e)||ht.isFile(e)||ht.isBlob(e)||ht.isReadableStream(e))return e;if(ht.isArrayBufferView(e))return e.buffer;if(ht.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return LX(e,this.formSerializer).toString();if((a=ht.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return rx(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(n.setContentType("application/json",!1),UX(e)):e}],transformResponse:[function(e){const n=this.transitional||C0.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(ht.isResponse(e)||ht.isReadableStream(e))return e;if(e&&ht.isString(e)&&(r&&!this.responseType||i)){const o=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?Dn.from(a,Dn.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:fs.classes.FormData,Blob:fs.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ht.forEach(["delete","get","head","post","put","patch"],t=>{C0.headers[t]={}});const VX=ht.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),HX=t=>{const e={};let n,r,i;return t&&t.split(` 64`).forEach(function(o){i=o.indexOf(":"),n=o.substring(0,i).trim().toLowerCase(),r=o.substring(i+1).trim(),!(!n||e[n]&&VX[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},IT=Symbol("internals");function Bp(t){return t&&String(t).trim().toLowerCase()}function ly(t){return t===!1||t==null?t:ht.isArray(t)?t.map(ly):String(t)}function GX(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const WX=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function F1(t,e,n,r,i){if(ht.isFunction(r))return r.call(this,e,n);if(i&&(e=n),!!ht.isString(e)){if(ht.isString(r))return e.indexOf(r)!==-1;if(ht.isRegExp(r))return r.test(e)}}function qX(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function KX(t,e){const n=ht.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(i,s,o){return this[r].call(this,e,i,s,o)},configurable:!0})})}let Ws=class{constructor(e){e&&this.set(e)}set(e,n,r){const i=this;function s(a,l,u){const d=Bp(l);if(!d)throw new Error("header name must be a non-empty string");const f=ht.findKey(i,d);(!f||i[f]===void 0||u===!0||u===void 0&&i[f]!==!1)&&(i[f||l]=ly(a))}const o=(a,l)=>ht.forEach(a,(u,d)=>s(u,d,l));if(ht.isPlainObject(e)||e instanceof this.constructor)o(e,n);else if(ht.isString(e)&&(e=e.trim())&&!WX(e))o(HX(e),n);else if(ht.isHeaders(e))for(const[a,l]of e.entries())s(l,a,r);else e!=null&&s(n,e,r);return this}get(e,n){if(e=Bp(e),e){const r=ht.findKey(this,e);if(r){const i=this[r];if(!n)return i;if(n===!0)return GX(i);if(ht.isFunction(n))return n.call(this,i,r);if(ht.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Bp(e),e){const r=ht.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||F1(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let i=!1;function s(o){if(o=Bp(o),o){const a=ht.findKey(r,o);a&&(!n||F1(r,r[a],a,n))&&(delete r[a],i=!0)}}return ht.isArray(e)?e.forEach(s):s(e),i}clear(e){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const s=n[r];(!e||F1(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const n=this,r={};return ht.forEach(this,(i,s)=>{const o=ht.findKey(r,s);if(o){n[o]=ly(i),delete n[s];return}const a=e?qX(s):String(s).trim();a!==s&&delete n[s],n[a]=ly(i),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return ht.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=e&&ht.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(` 65`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);
vendor: 8,503 bytes, line 65
65return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[IT]=this[IT]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Bp(o);r[a]||(KX(i,o),r[a]=!0)}return ht.isArray(e)?e.forEach(s):s(e),this}};Ws.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ht.reduceDescriptors(Ws.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});ht.freezeMethods(Ws);function $1(t,e){const n=this||C0,r=e||n,i=Ws.from(r.headers);let s=r.data;return ht.forEach(t,function(a){s=a.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function _O(t){return!!(t&&t.__CANCEL__)}function qh(t,e,n){Dn.call(this,t??"canceled",Dn.ERR_CANCELED,e,n),this.name="CanceledError"}ht.inherits(qh,Dn,{__CANCEL__:!0});function EO(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new Dn("Request failed with status code "+n.status,[Dn.ERR_BAD_REQUEST,Dn.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function YX(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function XX(t,e){t=t||10;const n=new Array(t),r=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(l){const u=Date.now(),d=r[s];o||(o=u),n[i]=l,r[i]=u;let f=s,h=0;for(;f!==i;)h+=n[f++],f=f%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),u-o<e)return;const m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function QX(t,e){let n=0,r=1e3/e,i,s;const o=(u,d=Date.now())=>{n=d,i=null,s&&(clearTimeout(s),s=null),t.apply(null,u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?o(u,d):(i=u,s||(s=setTimeout(()=>{s=null,o(i)},r-f)))},()=>i&&o(i)]}const Wy=(t,e,n=3)=>{let r=0;const i=XX(50,250);return QX(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-r,u=i(l),d=o<=a;r=o;const f={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-o)/u:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(f)},n)},jT=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},TT=t=>(...e)=>ht.asap(()=>t(...e)),ZX=fs.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,fs.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(fs.origin),fs.navigator&&/(msie|trident)/i.test(fs.navigator.userAgent)):()=>!0,JX=fs.hasStandardBrowserEnv?{write(t,e,n,r,i,s){const o=[t+"="+encodeURIComponent(e)];ht.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),ht.isString(r)&&o.push("path="+r),ht.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function eQ(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function tQ(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function NO(t,e,n){let r=!eQ(e);return t&&(r||n==!1)?tQ(t,e):e}const zT=t=>t instanceof Ws?{...t}:t;function ad(t,e){e=e||{};const n={};function r(u,d,f,h){return ht.isPlainObject(u)&&ht.isPlainObject(d)?ht.merge.call({caseless:h},u,d):ht.isPlainObject(d)?ht.merge({},d):ht.isArray(d)?d.slice():d}function i(u,d,f,h){if(ht.isUndefined(d)){if(!ht.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!ht.isUndefined(d))return r(void 0,d)}function o(u,d){if(ht.isUndefined(d)){if(!ht.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in e)return r(u,d);if(f in t)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,d,f)=>i(zT(u),zT(d),f,!0)};return ht.forEach(Object.keys(Object.assign({},t,e)),function(d){const f=l[d]||i,h=f(t[d],e[d],d);ht.isUndefined(h)&&f!==a||(n[d]=h)}),n}const IO=t=>{const e=ad({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;e.headers=o=Ws.from(o),e.url=kO(NO(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let l;if(ht.isFormData(n)){if(fs.hasStandardBrowserEnv||fs.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((l=o.getContentType())!==!1){const[u,...d]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...d].join("; "))}}if(fs.hasStandardBrowserEnv&&(r&&ht.isFunction(r)&&(r=r(e)),r||r!==!1&&ZX(e.url))){const u=i&&s&&JX.read(s);u&&o.set(i,u)}return e},nQ=typeof XMLHttpRequest<"u",rQ=nQ&&function(t){return new Promise(function(n,r){const i=IO(t);let s=i.data;const o=Ws.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=i,d,f,h,m,y;function g(){m&&m(),y&&y(),i.cancelToken&&i.cancelToken.unsubscribe(d),i.signal&&i.signal.removeEventListener("abort",d)}let w=new XMLHttpRequest;w.open(i.method.toUpperCase(),i.url,!0),w.timeout=i.timeout;function v(){if(!w)return;const C=Ws.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),N={data:!a||a==="text"||a==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:C,config:t,request:w};EO(function(j){n(j),g()},function(j){r(j),g()},N),w=null}"onloadend"in w?w.onloadend=v:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(v)},w.onabort=function(){w&&(r(new Dn("Request aborted",Dn.ECONNABORTED,t,w)),w=null)},w.onerror=function(){r(new Dn("Network Error",Dn.ERR_NETWORK,t,w)),w=null},w.ontimeout=function(){let k=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const N=i.transitional||SO;i.timeoutErrorMessage&&(k=i.timeoutErrorMessage),r(new Dn(k,N.clarifyTimeoutError?Dn.ETIMEDOUT:Dn.ECONNABORTED,t,w)),w=null},s===void 0&&o.setContentType(null),"setRequestHeader"in w&&ht.forEach(o.toJSON(),function(k,N){w.setRequestHeader(N,k)}),ht.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),a&&a!=="json"&&(w.responseType=i.responseType),u&&([h,y]=Wy(u,!0),w.addEventListener("progress",h)),l&&w.upload&&([f,m]=Wy(l),w.upload.addEventListener("progress",f),w.upload.addEventListener("loadend",m)),(i.cancelToken||i.signal)&&(d=C=>{w&&(r(!C||C.type?new qh(null,t,w):C),w.abort(),w=null)},i.cancelToken&&i.cancelToken.subscribe(d),i.signal&&(i.signal.aborted?d():i.signal.addEventListener("abort",d)));const S=YX(i.url);if(S&&fs.protocols.indexOf(S)===-1){r(new Dn("Unsupported protocol "+S+":",Dn.ERR_BAD_REQUEST,t));return}w.send(s||null)})},iQ=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,i;const s=function(u){if(!i){i=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Dn?d:new qh(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{o=null,s(new Dn(`timeout ${e} of ms exceeded`,Dn.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),t=null)};t.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>ht.asap(a),l}},sQ=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,i;for(;r<n;)i=r+e,yield t.slice(r,i),r=i},oQ=async function*(t,e){for await(const n of aQ(t))yield*sQ(n,e)},aQ=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},PT=(t,e,n,r)=>{const i=oQ(t,e);let s=0,o,a=l=>{o||(o=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await i.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},ix=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",jO=ix&&typeof ReadableStream=="function",lQ=ix&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),TO=(t,...e)=>{try{return!!t(...e)}catch{return!1}},cQ=jO&&TO(()=>{let t=!1;
vendor: 4,093 bytes, lines 65-67
65const e=new Request(fs.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),AT=64*1024,yS=jO&&TO(()=>ht.isReadableStream(new Response("").body)),qy={stream:yS&&(t=>t.body)};ix&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!qy[e]&&(qy[e]=ht.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new Dn(`Response type '${e}' is not supported`,Dn.ERR_NOT_SUPPORT,r)})})})(new Response);const uQ=async t=>{if(t==null)return 0;if(ht.isBlob(t))return t.size;if(ht.isSpecCompliantForm(t))return(await new Request(fs.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(ht.isArrayBufferView(t)||ht.isArrayBuffer(t))return t.byteLength;if(ht.isURLSearchParams(t)&&(t=t+""),ht.isString(t))return(await lQ(t)).byteLength},dQ=async(t,e)=>{const n=ht.toFiniteNumber(t.getContentLength());return n??uQ(e)},fQ=ix&&(async t=>{let{url:e,method:n,data:r,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:l,responseType:u,headers:d,withCredentials:f="same-origin",fetchOptions:h}=IO(t);u=u?(u+"").toLowerCase():"text";let m=iQ([i,s&&s.toAbortSignal()],o),y;const g=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let w;try{if(l&&cQ&&n!=="get"&&n!=="head"&&(w=await dQ(d,r))!==0){let N=new Request(e,{method:"POST",body:r,duplex:"half"}),_;if(ht.isFormData(r)&&(_=N.headers.get("content-type"))&&d.setContentType(_),N.body){const[j,T]=jT(w,Wy(TT(l)));r=PT(N.body,AT,j,T)}}ht.isString(f)||(f=f?"include":"omit");const v="credentials"in Request.prototype;y=new Request(e,{...h,signal:m,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:v?f:void 0});let S=await fetch(y);const C=yS&&(u==="stream"||u==="response");if(yS&&(a||C&&g)){const N={};["status","statusText","headers"].forEach(M=>{N[M]=S[M]});const _=ht.toFiniteNumber(S.headers.get("content-length")),[j,T]=a&&jT(_,Wy(TT(a),!0))||[];S=new Response(PT(S.body,AT,j,()=>{T&&T(),g&&g()}),N)}u=u||"text";let k=await qy[ht.findKey(qy,u)||"text"](S,t);return!C&&g&&g(),await new Promise((N,_)=>{EO(N,_,{data:k,headers:Ws.from(S.headers),status:S.status,statusText:S.statusText,config:t,request:y})})}catch(v){throw g&&g(),v&&v.name==="TypeError"&&/fetch/i.test(v.message)?Object.assign(new Dn("Network Error",Dn.ERR_NETWORK,t,y),{cause:v.cause||v}):Dn.from(v,v&&v.code,t,y)}}),vS={http:NX,xhr:rQ,fetch:fQ};ht.forEach(vS,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const MT=t=>`- ${t}`,hQ=t=>ht.isFunction(t)||t===null||t===!1,zO={getAdapter:t=>{t=ht.isArray(t)?t:[t];const{length:e}=t;let n,r;const i={};for(let s=0;s<e;s++){n=t[s];let o;if(r=n,!hQ(n)&&(r=vS[(o=String(n)).toLowerCase()],r===void 0))throw new Dn(`Unknown adapter '${o}'`);if(r)break;i[o||"#"+s]=r}if(!r){const s=Object.entries(i).map(([a,l])=>`adapter ${a} `+(l===!1?"is not supported by the environment":"is not available in the build"));let o=e?s.length>1?`since : 66`+s.map(MT).join(` 67`):" "+MT(s[0]):"as no adapter specified";throw new Dn("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:vS};function U1(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new qh(null,t)}function BT(t){return U1(t),t.headers=Ws.from(t.headers),t.data=$1.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),zO.getAdapter(t.adapter||C0.adapter)(t).then(function(r){return U1(t),r.data=$1.call(t,t.transformResponse,r),r.headers=Ws.from(r.headers),r},function(r){return _O(r)||(U1(t),r&&r.response&&(r.response.data=$1.call(t,t.transformResponse,r.response),r.response.headers=Ws.from(r.response.headers))),Promise.reject(r)})}const PO="1.8.4",sx={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{sx[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const RT={};sx.transitional=function(e,n,r){function i(s,o){return"[Axios v"+PO+"] Transitional option '"+s+"'"+o+(r?". "+r:"")}return(s,o,a)=>
vendor: 4,467 bytes, lines 67-68
67{if(e===!1)throw new Dn(i(o," has been removed"+(n?" in "+n:"")),Dn.ERR_DEPRECATED);return n&&!RT[o]&&(RT[o]=!0,console.warn(i(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,o,a):!0}};sx.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function pQ(t,e,n){if(typeof t!="object")throw new Dn("options must be an object",Dn.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const s=r[i],o=e[s];if(o){const a=t[s],l=a===void 0||o(a,s,t);if(l!==!0)throw new Dn("option "+s+" must be "+l,Dn.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Dn("Unknown option "+s,Dn.ERR_BAD_OPTION)}}const cy={assertOptions:pQ,validators:sx},Pa=cy.validators;let Ju=class{constructor(e){this.defaults=e,this.interceptors={request:new NT,response:new NT}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=` 68`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=ad(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&cy.assertOptions(r,{silentJSONParsing:Pa.transitional(Pa.boolean),forcedJSONParsing:Pa.transitional(Pa.boolean),clarifyTimeoutError:Pa.transitional(Pa.boolean)},!1),i!=null&&(ht.isFunction(i)?n.paramsSerializer={serialize:i}:cy.assertOptions(i,{encode:Pa.function,serialize:Pa.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),cy.assertOptions(n,{baseUrl:Pa.spelling("baseURL"),withXsrfToken:Pa.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&ht.merge(s.common,s[n.method]);s&&ht.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=Ws.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let d,f=0,h;if(!l){const y=[BT.bind(this),void 0];for(y.unshift.apply(y,a),y.push.apply(y,u),h=y.length,d=Promise.resolve(n);f<h;)d=d.then(y[f++],y[f++]);return d}h=a.length;let m=n;for(f=0;f<h;){const y=a[f++],g=a[f++];try{m=y(m)}catch(w){g.call(this,w);break}}try{d=BT.call(this,m)}catch(y){return Promise.reject(y)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(e){e=ad(this.defaults,e);const n=NO(e.baseURL,e.url,e.allowAbsoluteUrls);return kO(n,e.params,e.paramsSerializer)}};ht.forEach(["delete","get","head","options"],function(e){Ju.prototype[e]=function(n,r){return this.request(ad(r||{},{method:e,url:n,data:(r||{}).data}))}});ht.forEach(["post","put","patch"],function(e){function n(r){return function(s,o,a){return this.request(ad(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Ju.prototype[e]=n(),Ju.prototype[e+"Form"]=n(!0)});let mQ=class AO{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{r.subscribe(a),s=a}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},e(function(s,o,a){r.reason||(r.reason=new qh(s,o,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new AO(function(i){e=i}),cancel:e}}};function gQ(t){return function(n){return t.apply(null,n)}}function bQ(t){return ht.isObject(t)&&t.isAxiosError===!0}const xS={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,Re
68setContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(xS).forEach(([t,e])=>{xS[e]=t});function MO(t){const e=new Ju(t),n=dO(Ju.prototype.request,e);return ht.extend(n,Ju.prototype,e,{allOwnKeys:!0}),ht.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return MO(ad(t,i))},n}const ui=MO(C0);ui.Axios=Ju;ui.CanceledError=qh;ui.CancelToken=mQ;ui.isCancel=_O;ui.VERSION=PO;ui.toFormData=rx;ui.AxiosError=Dn;ui.Cancel=ui.CanceledError;ui.all=function(e){return Promise.all(e)};ui.spread=gQ;ui.isAxiosError=bQ;ui.mergeConfig=ad;ui.AxiosHeaders=Ws;ui.formToJSON=t=>CO(ht.isHTMLForm(t)?new FormData(t):t);ui.getAdapter=zO.getAdapter;ui.HttpStatusCode=xS;ui.default=ui;const{Axios:FEe,AxiosError:yQ,CanceledError:Rf,isCancel:$Ee,CancelToken:UEe,VERSION:VEe,all:HEe,Cancel:GEe,isAxiosError:WEe,spread:qEe,toFormData:KEe,AxiosHeaders:YEe,HttpStatusCode:XEe,formToJSON:QEe,getAdapter:ZEe,mergeConfig:JEe}=ui,vQ=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>ai(async()=>{const{default:r}=await Promise.resolve().then(()=>Kh);return{default:r}},void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)};class K_ extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class xQ extends K_{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class OT extends K_{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class DT extends K_{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var wS;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(wS||(wS={}));var wQ=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};class kQ{constructor(e,{headers:n={},customFetch:r,region:i=wS.Any}={}){this.url=e,this.headers=n,this.region=i,this.fetch=vQ(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,n={}){var r;return wQ(this,void 0,void 0,function*(){try{const{headers:i,method:s,body:o}=n;let a={},{region:l}=n;l||(l=this.region);const u=new URL(`${this.url}/${e}`);l&&l!=="any"&&(a["x-region"]=l,u.searchParams.set("forceFunctionRegion",l));let d;o&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",d=o):typeof o=="string"?(a["Content-Type"]="text/plain",d=o):typeof FormData<"u"&&o instanceof FormData?d=o:(a["Content-Type"]="application/json",d=JSON.stringify(o)));const f=yield this.fetch(u.toString(),{method:s||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),i),body:d}).catch(g=>{throw new xQ(g)}),h=f.headers.get("x-relay-error");
68if(h&&h==="true")throw new OT(f);if(!f.ok)throw new DT(f);let m=((r=f.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),y;return m==="application/json"?y=yield f.json():m==="application/octet-stream"?y=yield f.blob():m==="text/event-stream"?y=f:m==="multipart/form-data"?y=yield f.formData():y=yield f.text(),{data:y,error:null,response:f}}catch(i){return{data:null,error:i,response:i instanceof DT||i instanceof OT?i.context:void 0}}})}}var Oi={},Zd={},Jd={},ef={},tf={},nf={},SQ=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},xh=SQ();const CQ=xh.fetch,BO=xh.fetch.bind(xh),RO=xh.Headers,_Q=xh.Request,EQ=xh.Response,Kh=Object.freeze(Object.defineProperty({__proto__:null,Headers:RO,Request:_Q,Response:EQ,default:BO,fetch:CQ},Symbol.toStringTag,{value:"Module"})),NQ=Y4(Kh);var cb={},LT;function OO(){if(LT)return cb;LT=1,Object.defineProperty(cb,"__esModule",{value:!0});class t extends Error{constructor(n){super(n.message),this.name="PostgrestError",this.details=n.details,this.hint=n.hint,this.co
68de=n.code}}return cb.default=t,cb}var FT;function DO(){if(FT)return nf;FT=1;var t=nf&&nf.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(nf,"__esModule",{value:!0});const e=t(NQ),n=t(OO());class r{constructor(s){var o,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(o=s.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:typeof fetch>"u"?this.fetch=e.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,o){return this.headers=new Headers(this.headers),this.headers.set(s,o),this}then(s,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const a=this.fetch;let l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var d,f,h,m;let y=null,g=null,w=null,v=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const _=await u.text();_===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((d=this.headers.get("Accept"))===null||d===void 0)&&d.includes("application/vnd.pgrst.plan+text"))?g=_:g=JSON.parse(_))}const k=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),N=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");k&&N&&N.length>1&&(w=parseInt(N[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(g)&&(g.length>1?(y={code:"PGRST116",details:`Results contain ${g.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},g=null,w=null,v=406,S="Not Acceptable"):g.length===1?g=g[0]:g=null)}else{const k=await u.text();try{y=JSON.parse(k),Array.isArray(y)&&u.status===404&&(g=[],y=null,v=200,S="OK")}catch{u.status===404&&k===""?(v=204,S="No Content"):y={message:k}}if(y&&this.isMaybeSingle&&(!((m=y==null?void 0:y.details)===null||m===void 0)&&m.includes("0 rows"))&&(y=null,v=200,S="OK"),y&&this.shouldThrowOnError)throw new n.default(y)}return{error:y,data:g,count:w,status:v,statusText:S}});return this.shouldThrowOnError||(l=l.catch(u=>{var d,f,h;return{error:{message:`${(d=u==null?void 0:u.name)!==null&&d!==void 0?d:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(h=u==null?void 0:u.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,o)}returns(){return this}overrideTypes(){return this}}return nf.default=r,nf}var $T;function LO(){if($T)return tf;$T=1;var t=tf&&tf.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(tf,"__esModule",{value:!0});const e=t(DO());class n extends e.default{select(i){let s=!1;const o=(i??"*").split("").map(a=>/\s/.test(a)&&!s?"":(a==='"'&&(s=!s),a)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(i,{ascending:s=!0,nullsFirst:o,foreignTable:a,referencedTable:l=a}={}){const u=l?`${l}.order`:"order",d=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${d?`${d},`:""}${i}.${s?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(i,{foreignTable:s,referencedTable:o=s}={}){const a=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(a,`${i}`),this}range(i,s,{foreignTable:o,referencedTable:a=o}={}){const l=typeof a>"u"?"offset":`${a}.offset`,u=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${i}`),this.url.searchParams.set(u,`${s-i+1}`),this}abortSignal(i){return this.signal=i,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
68explain({analyze:i=!1,verbose:s=!1,settings:o=!1,buffers:a=!1,wal:l=!1,format:u="text"}={}){var d;const f=[i?"analyze":null,s?"verbose":null,o?"settings":null,a?"buffers":null,l?"wal":null].filter(Boolean).join("|"),h=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${h}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(i){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${i}`),this}}return tf.default=n,tf}var UT;function Y_(){if(UT)return ef;UT=1;var t=ef&&ef.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ef,"__esModule",{value:!0});const e=t(LO());class n extends e.default{eq(i,s){return this.url.searchParams.append(i,`eq.${s}`),this}neq(i,s){return this.url.searchParams.append(i,`neq.${s}`),this}gt(i,s){return this.url.searchParams.append(i,`gt.${s}`),this}gte(i,s){return this.url.searchParams.append(i,`gte.${s}`),this}lt(i,s){return this.url.searchParams.append(i,`lt.${s}`),this}lte(i,s){return this.url.searchParams.append(i,`lte.${s}`),this}like(i,s){return this.url.searchParams.append(i,`like.${s}`),this}likeAllOf(i,s){return this.url.searchParams.append(i,`like(all).{${s.join(",")}}`),this}likeAnyOf(i,s){return this.url.searchParams.append(i,`like(any).{${s.join(",")}}`),this}ilike(i,s){return this.url.searchParams.append(i,`ilike.${s}`),this}ilikeAllOf(i,s){return this.url.searchParams.append(i,`ilike(all).{${s.join(",")}}`),this}ilikeAnyOf(i,s){return this.url.searchParams.append(i,`ilike(any).{${s.join(",")}}`),this}is(i,s){return this.url.searchParams.append(i,`is.${s}`),this}in(i,s){const o=Array.from(new Set(s)).map(a=>typeof a=="string"&&new RegExp("[,()]").test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(i,`in.(${o})`),this}contains(i,s){return typeof s=="string"?this.url.searchParams.append(i,`cs.${s}`):Array.isArray(s)?this.url.searchParams.append(i,`cs.{${s.join(",")}}`):this.url.searchParams.append(i,`cs.${JSON.stringify(s)}`),this}containedBy(i,s){return typeof s=="string"?this.url.searchParams.append(i,`cd.${s}`):Array.isArray(s)?this.url.searchParams.append(i,`cd.{${s.join(",")}}`):this.url.searchParams.append(i,`cd.${JSON.stringify(s)}`),this}rangeGt(i,s){return this.url.searchParams.append(i,`sr.${s}`),this}rangeGte(i,s){return this.url.searchParams.append(i,`nxl.${s}`),this}rangeLt(i,s){return this.url.searchParams.append(i,`sl.${s}`),this}rangeLte(i,s){return this.url.searchParams.append(i,`nxr.${s}`),this}rangeAdjacent(i,s){return this.url.searchParams.append(i,`adj.${s}`),this}overlaps(i,s){return typeof s=="string"?this.url.searchParams.append(i,`ov.${s}`):this.url.searchParams.append(i,`ov.{${s.join(",")}}`),this}textSearch(i,s,{config:o,type:a}={}){let l="";a==="plain"?l="pl":a==="phrase"?l="ph":a==="websearch"&&(l="w");const u=o===void 0?"":`(${o})`;return this.url.searchParams.append(i,`${l}fts${u}.${s}`),this}match(i){return Object.entries(i).forEach(([s,o])=>{this.url.searchParams.append(s,`eq.${o}`)}),this}not(i,s,o){return this.url.searchParams.append(i,`not.${s}.${o}`),this}or(i,{foreignTable:s,referencedTable:o=s}={}){const a=o?`${o}.or`:"or";return this.url.searchParams.append(a,`(${i})`),this}filter(i,s,o){return this.url.searchParams.append(i,`${s}.${o}`),this}}return ef.default=n,ef}var VT;function FO(){if(VT)return Jd;VT=1;var t=Jd&&Jd.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Jd,"__esModule",{value:!0});const e=t(Y_());class n{constructor(i,{headers:s={},schema:o,fetch:a}){this.url=i,this.headers=new Headers(s),this.schema=o,this.fetch=a}select(i,{head:s=!1,count:o}={}){const a=s?"HEAD":"GET";let l=!1;const u=(i??"*").split("").map(d=>/\s/.test(d)&&!l?"":(d==='"'&&(l=!l),d)).join("");return this.url.searchParams.set("select",u),o&&this.headers.append("Prefer",`count=${o}`),new e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(i,{count:s,defaultToNull:o=!0}={}){var a;const l="POST";if(s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(i)){const u=i.reduce((d,f)=>d.concat(Object.keys(f)),[]);if(u.length>0){const d=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",d.join(","))}}return new e.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}upsert(i,{onConflict:s,ignoreDuplicates:o=!1,count:a,defaultToNull:l=!0}={}){var u;const d="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),s!==void 0&&this.url.searchParams.set("on_conflict",s),a&&this.headers.append("Prefer",`count=${a}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(i)){const f=i.reduce((h,m)=>h.concat(Object.keys(m)),[]);if(f.length>0){const h=[...new Set(f)].map(m=>`"${m}"`);this.url.searchParams.set("columns",h.join(","))}}return new e.default({method:d,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(i,{count:s}={}){var o;const a="PATCH";return s&&this.headers.append("Prefer",`count=${s}`),new e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:i}={}){var s;const o="DELETE";return i&&this.headers.append("Prefer",`count=${i}`),new e.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}}return Jd.default=n,Jd}var HT;function IQ(){if(HT)return Zd;HT=1;var t=Zd&&Zd.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Zd,"__esModule",{value:!0});const e=t(FO()),n=t(Y_());
68class r{constructor(s,{headers:o={},schema:a,fetch:l}={}){this.url=s,this.headers=new Headers(o),this.schemaName=a,this.fetch=l}from(s){const o=new URL(`${this.url}/${s}`);return new e.default(o,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new r(this.url,{headers:this.headers,schema:s,fetch:this.fetch})}rpc(s,o={},{head:a=!1,get:l=!1,count:u}={}){var d;let f;const h=new URL(`${this.url}/rpc/${s}`);let m;a||l?(f=a?"HEAD":"GET",Object.entries(o).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{h.searchParams.append(g,w)})):(f="POST",m=o);const y=new Headers(this.headers);return u&&y.set("Prefer",`count=${u}`),new n.default({method:f,url:h,headers:y,schema:this.schemaName,body:m,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch})}}return Zd.default=r,Zd}var GT;function jQ(){if(GT)return Oi;GT=1;var t=Oi&&Oi.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Oi,"__esModule",{value:!0}),Oi.PostgrestError=Oi.PostgrestBuilder=Oi.PostgrestTransformBuilder=Oi.PostgrestFilterBuilder=Oi.PostgrestQueryBuilder=Oi.PostgrestClient=void 0;const e=t(IQ());Oi.PostgrestClient=e.default;const n=t(FO());Oi.PostgrestQueryBuilder=n.default;const r=t(Y_());Oi.PostgrestFilterBuilder=r.default;const i=t(LO());Oi.PostgrestTransformBuilder=i.default;const s=t(DO());Oi.PostgrestBuilder=s.default;const o=t(OO());return Oi.PostgrestError=o.default,Oi.default={PostgrestClient:e.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:r.default,PostgrestTransformBuilder:i.default,PostgrestBuilder:s.default,PostgrestError:o.default},Oi}var TQ=jQ();const zQ=Vo(TQ),{PostgrestClient:PQ,PostgrestQueryBuilder:eNe,PostgrestFilterBuilder:tNe,PostgrestTransformBuilder:nNe,PostgrestBuilder:rNe,PostgrestError:iNe}=zQ;class AQ{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"&&process.versions&&process.versions.node){const n=parseInt(process.versions.node.split(".")[0]);return n>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${n} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${n} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: 69import ws from "ws" 70new RealtimeClient(url, { transport: ws })`}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let n=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(n+=` 71 72Suggested solution: ${e.workaround}`),new Error(n)}static createWebSocket(e,n){const r=this.getWebSocketConstructor();return new r(e,n)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const MQ="2.15.4",BQ=`realtime-js/${MQ}`,RQ="1.0.0",kS=1e4,OQ=1e3,DQ=100;var pm;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(pm||(pm={}));var Ti;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Ti||(Ti={}));var aa;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(aa||(aa={}));var SS;(function(t){t.websocket="websocket"})(SS||(SS={}));var Pu;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Pu||(Pu={}));class LQ{constructor(){this.HEADER_LENGTH=1}decode(e,n){return e.constructor===ArrayBuffer?n(this._binaryDecode(e)):n(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const n=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,n,r)}_decodeBroadcast(e,n,r){const i=n.getUint8(1),s=n.getUint8(2);let o=this.HEADER_LENGTH+2;const a=r.decode(e.slice(o,o+i));o=o+i;const l=r.decode(e.slice(o,o+s));o=o+s;const u=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:a,event:l,payload:u}}}let $O=class{constructor(e,n){this.callback=e,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var Er;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.t
vendor: 4,784 bytes, line 72
72srange="tsrange",t.tstzrange="tstzrange"})(Er||(Er={}));const WT=(t,e,n={})=>{var r;const i=(r=n.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((s,o)=>(s[o]=FQ(o,t,e,i),s),{})},FQ=(t,e,n,r)=>{const i=e.find(a=>a.name===t),s=i==null?void 0:i.type,o=n[t];return s&&!r.includes(s)?UO(s,o):CS(o)},UO=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return HQ(e,n)}switch(t){case Er.bool:return $Q(e);case Er.float4:case Er.float8:case Er.int2:case Er.int4:case Er.int8:case Er.numeric:case Er.oid:return UQ(e);case Er.json:case Er.jsonb:return VQ(e);case Er.timestamp:return GQ(e);case Er.abstime:case Er.date:case Er.daterange:case Er.int4range:case Er.int8range:case Er.money:case Er.reltime:case Er.text:case Er.time:case Er.timestamptz:case Er.timetz:case Er.tsrange:case Er.tstzrange:return CS(e);default:return CS(e)}},CS=t=>t,$Q=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},UQ=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},VQ=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},HQ=(t,e)=>{if(typeof t!="string")return t;const n=t.length-1,r=t[n];if(t[0]==="{"&&r==="}"){let s;const o=t.slice(1,n);try{s=JSON.parse("["+o+"]")}catch{s=o?o.split(","):[]}return s.map(a=>UO(e,a))}return t},GQ=t=>typeof t=="string"?t.replace(" ","T"):t,VO=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};let V1=class{constructor(e,n,r={},i=kS){this.channel=e,this.event=n,this.payload=r,this.timeout=i,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,n){var r;return this._hasReceived(e)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:n})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:n}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(n))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}};var qT;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(qT||(qT={}));class mm{constructor(e,n){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(n==null?void 0:n.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},i=>{const{onJoin:s,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=mm.syncState(this.state,i,s,o),this.pendingDiffs.forEach(l=>{this.state=mm.syncDiff(this.state,l,s,o)}),this.pendingDiffs=[],a()}),this.channel._on(r.diff,{},i=>{const{onJoin:s,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(i):(this.state=mm.syncDiff(this.state,i,s,o),a())}),this.onJoin((i,s,o)=>{this.channel._trigger("presence",{event:"join",key:i,currentPresences:s,newPresences:o})}),this.onLeave((i,s,o)=>{this.channel._trigger("presence",{event:"leave",key:i,currentPresences:s,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,n,r,i){const s=this.cloneDeep(e),o=this.transformState(n),a={},l={};return this.map(s,(u,d)=>{o[u]||(l[u]=d)}),this.map(o,(u,d)=>{const f=s[u];if(f){const h=d.map(w=>w.presence_ref),m=f.map(w=>w.presence_ref),y=d.filter(w=>m.indexOf(w.presence_ref)<0),g=f.filter(w=>h.indexOf(w.presence_ref)<0);y.length>0&&(a[u]=y),g.length>0&&(l[u]=g)}else a[u]=d}),this.syncDiff(s,{joins:a,leaves:l},r,i)}static syncDiff(e,n,r,i){const{joins:s,leaves:o}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),i||(i=()=>{}),this.map(s,(a,l)=>{var u;
72const d=(u=e[a])!==null&&u!==void 0?u:[];if(e[a]=this.cloneDeep(l),d.length>0){const f=e[a].map(m=>m.presence_ref),h=d.filter(m=>f.indexOf(m.presence_ref)<0);e[a].unshift(...h)}r(a,d,l)}),this.map(o,(a,l)=>{let u=e[a];if(!u)return;const d=l.map(f=>f.presence_ref);u=u.filter(f=>d.indexOf(f.presence_ref)<0),e[a]=u,i(a,u,l),u.length===0&&delete e[a]}),e}static map(e,n){return Object.getOwnPropertyNames(e).map(r=>n(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((n,r)=>{const i=e[r];return"metas"in i?n[r]=i.metas.map(s=>(s.presence_ref=s.phx_ref,delete s.phx_ref,delete s.phx_ref_prev,s)):n[r]=i,n},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var KT;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(KT||(KT={}));var gm;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(gm||(gm={}));var Cl;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Cl||(Cl={}));class X_{constructor(e,n={config:{}},r){this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=Ti.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new V1(this,aa.join,this.params,this.timeout),this.rejoinTimer=new $O(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Ti.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Ti.closed,this.socket._remove(this)}),this._onError(i=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,i),this.state=Ti.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Ti.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",i=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,i),this.state=Ti.errored,this.rejoinTimer.scheduleTimeout())}),this._on(aa.reply,{},(i,s)=>{this._trigger(this._replyEventName(s),i)}),this.presence=new mm(this),this.broadcastEndpointURL=VO(this.socket.endPoint),this.private=this.params.config.private||!1}subscribe(e,n=this.timeout){var r,i,s;if(this.socket.isConnected()||this.socket.connect(),this.state==Ti.closed){const{config:{broadcast:o,presence:a,private:l}}=this.params,u=(i=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(m=>m.filter))!==null&&i!==void 0?i:[],d=!!this.bindings[gm.PRESENCE]&&this.bindings[gm.PRESENCE].length>0||((s=this.params.config.presence)===null||s===void 0?void 0:s.enabled)===!0,f={},h={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:d}),postgres_changes:u,private:l};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(m=>e==null?void 0:e(Cl.CHANNEL_ERROR,m)),this._onClose(()=>e==null?void 0:e(Cl.CLOSED)),this.updateJoinPayload(Object.assign({config:h},f)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:m})=>{var y;if(this.socket.setAuth(),m===void 0){e==null||e(Cl.SUBSCRIBED);return}else{const g=this.bindings.postgres_changes,w=(y=g==null?void 0:g.length)!==null&&y!==void 0?y:0,v=[];for(let S=0;S<w;S++){const C=g[S],{filter:{event:k,schema:N,table:_,filter:j}}=C,T=m&&m[S];if(T&&T.event===k&&T.schema===N&&T.table===_&&T.filter===j)v.push(Object.assign(Object.assign({},C),{id:T.id}));else{this.unsubscribe(),this.state=Ti.errored,e==null||e(Cl.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=v,e&&e(Cl.SUBSCRIBED);return}}).receive("error",m=>{this.state=Ti.errored,e==null||e(Cl.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(m).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Cl.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,n={}){return await this.send({type:"presence",event:"track",payload:e},n.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,n,r){return this.state===Ti.joined&&e===gm.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,n,r)}async send(e,n={}){var r,i;if(!this._canPush()&&e.type==="broadcast"){const{event:s,payload:o}=e,l={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((i=u.body)===null||i===void 0?void 0:i.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(s=>{var o,a,l;const u=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&s("ok"),u.receive("ok",()=>s("ok")),u.receive("error",()=>s("error")),u.receive("timeout",()=>s("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Ti.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(aa.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(i=>{r=new V1(this,aa.leave,{},e),r.receive("ok",()=>{n(),i("ok")}).receive("timeout",()=>{n(),i("timed out")}).receive("error",()=>{i("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r==null||r.destroy()})}
72teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Ti.closed,this.bindings={}}async _fetchWithTimeout(e,n,r){const i=new AbortController,s=setTimeout(()=>i.abort(),r),o=await this.socket.fetch(e,Object.assign(Object.assign({},n),{signal:i.signal}));return clearTimeout(s),o}_push(e,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let i=new V1(this,e,n,r);return this._canPush()?i.send():this._addToPushBuffer(i),i}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>DQ){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(e,n,r){return n}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,n,r){var i,s;const o=e.toLocaleLowerCase(),{close:a,error:l,leave:u,join:d}=aa;if(r&&[a,l,u,d].indexOf(o)>=0&&r!==this._joinRef())return;let h=this._onMessage(o,n,r);if(n&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(i=this.bindings.postgres_changes)===null||i===void 0||i.filter(m=>{var y,g,w;return((y=m.filter)===null||y===void 0?void 0:y.event)==="*"||((w=(g=m.filter)===null||g===void 0?void 0:g.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===o}).map(m=>m.callback(h,r)):(s=this.bindings[o])===null||s===void 0||s.filter(m=>{var y,g,w,v,S,C;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in m){const k=m.id,N=(y=m.filter)===null||y===void 0?void 0:y.event;return k&&((g=n.ids)===null||g===void 0?void 0:g.includes(k))&&(N==="*"||(N==null?void 0:N.toLocaleLowerCase())===((w=n.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const k=(S=(v=m==null?void 0:m.filter)===null||v===void 0?void 0:v.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return k==="*"||k===((C=n==null?void 0:n.event)===null||C===void 0?void 0:C.toLocaleLowerCase())}else return m.type.toLocaleLowerCase()===o}).map(m=>{if(typeof h=="object"&&"ids"in h){const y=h.data,{schema:g,table:w,commit_timestamp:v,type:S,errors:C}=y;h=Object.assign(Object.assign({},{schema:g,table:w,commit_timestamp:v,eventType:S,new:{},old:{},errors:C}),this._getPayloadRecords(y))}m.callback(h,r)})}_isClosed(){return this.state===Ti.closed}_isJoined(){return this.state===Ti.joined}_isJoining(){return this.state===Ti.joining}_isLeaving(){return this.state===Ti.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,n,r){const i=e.toLocaleLowerCase(),s={type:i,filter:n,callback:r};return this.bindings[i]?this.bindings[i].push(s):this.bindings[i]=[s],this}_off(e,n){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(i=>{var s;return!(((s=i.type)===null||s===void 0?void 0:s.toLocaleLowerCase())===r&&X_.isEqual(i.filter,n))})),this}static isEqual(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(aa.close,{},e)}_onError(e){this._on(aa.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Ti.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=WT(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=WT(e.columns,e.old_record)),n}}const H1=()=>{},ub={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},WQ=[1e3,2e3,5e3,1e4],qQ=1e4,KQ=` 73 addEventListener("message", (e) => { 74 if (e.data.event === "start") { 75 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 76 } 77 });`;class YQ{constructor(e,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=kS,this.transport=null,this.heartbeatIntervalMs=ub.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=H1,this.ref=0,this.reconnectTimer=null,this.logger=H1,this.conn=null,this.sendBuffer=[],this.serializer
77=new LQ,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=i=>{let s;return i?s=i:typeof fetch>"u"?s=(...o)=>ai(async()=>{const{default:a}=await Promise.resolve().then(()=>Kh);return{default:a}},void 0).then(({default:a})=>a(...o)).catch(a=>{throw new Error(`Failed to load @supabase/node-fetch: ${a.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):s=fetch,(...o)=>s(...o)},!(!((r=n==null?void 0:n.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${e}/${SS.websocket}`,this.httpEndpoint=VO(e),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=AQ.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const n=e.message;throw n.includes("Node.js")?new Error(`${n} 78 79To use Realtime in Node.js, you need to provide a WebSocket implementation: 80 81Option 1: Use Node.js 22+ which has native WebSocket support 82Option 2: Install and provide the "ws" package: 83 84 npm install ws 85 86 import ws from "ws" 87 const client = new RealtimeClient(url, { 88 ...options, 89 transport: ws 90 })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:RQ}))}disconnect(e,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},e?this.conn.close(e,n??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const n=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const e=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,n,r){this.logger(e,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case pm.connecting:return Pu.Connecting;case pm.open:return Pu.Open;case pm.closing:return Pu.Closing;default:return Pu.Closed}}isConnected(){return this.connectionState()===Pu.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,n={config:{}}){const r=`realtime:${e}`,i=this.getChannels().find(s=>s.topic===r);if(i)return i;{const s=new X_(`realtime:${e}`,n,this);return this.channels.push(s),s}}push(e){const{topic:n,event:r,payload:i,ref:s}=e,o=()=>{this.encode(e,a=>{var l;(l=this.conn)===null||l===void 0||l.send(a)})};this.log("push",`${n} ${r} (${s})`,i),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(OQ,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},ub.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>
900&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let n=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${e}"`),n.unsubscribe())}_remove(e){this.channels=this.channels.filter(n=>n.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply")try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}n.ref&&n.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:i,payload:s,ref:o}=n,a=o?`(${o})`:"",l=s.status||"";this.log("receive",`${l} ${r} ${i} ${a}`.trim(),s),this.channels.filter(u=>u._isMember(r)).forEach(u=>u._trigger(i,s,o)),this._triggerStateCallbacks("message",n)})}_clearTimer(e){var n;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this.workerRef.terminate()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var n;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(aa.error))}_appendParams(e,n){if(Object.keys(n).length===0)return e;const r=e.match(/\?/)?"&":"?",i=new URLSearchParams(n);return`${e}${r}${i}`}_workerObjectUrl(e){let n;if(e)n=e;else{const r=new Blob([KQ],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(e,n=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(e=null){let n;e?n=e:this.accessToken?n=await this.accessToken():n=this.accessTokenValue,this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(r=>{const i={access_token:n,version:BQ};n&&r.updateJoinPayload(i),r.joinedOnce&&r._isJoined()&&r._push(aa.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(n=>{this.log("error",`error setting auth in ${e}`,n)})}_triggerStateCallbacks(e,n){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(n)}catch(i){this.log("error",`error in ${e} callback`,i)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new $O(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},ub.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var n,r,i,s,o,a,l,u,d;if(this.transport=(n=e==null?void 0:e.transport)!==null&&n!==void 0?n:null,this.timeout=(r=e==null?void 0:e.timeout)!==null&&r!==void 0?r:kS,this.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:ub.HEARTBEAT_INTERVAL,this.worker=(s=e==null?void 0:e.worker)!==null&&s!==void 0?s:!1,this.accessToken=(o=e==null?void 0:e.accessToken)!==null&&o!==void 0?o:null,this.heartbeatCallback=(a=e==null?void 0:e.heartbeatCallback)!==null&&a!==void 0?a:H1,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(l=e==null?void 0:e.reconnectAfterMs)!==null&&l!==void 0?l:f=>WQ[f-1]||qQ,this.encode=(u=e==null?void 0:e.encode)!==null&&u!==void 0?u:(f,h)=>h(JSON.stringify(f)),this.decode=(d=e==null?void 0:e.decode)!==null&&d!==void 0?d:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}
90class Q_ extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function zi(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class XQ extends Q_{constructor(e,n,r){super(e),this.name="StorageApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class _S extends Q_{constructor(e,n){super(e),this.name="StorageUnknownError",this.originalError=n}}var QQ=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};const HO=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>ai(async()=>{const{default:r}=await Promise.resolve().then(()=>Kh);return{default:r}},void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},ZQ=()=>QQ(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield ai(()=>Promise.resolve().then(()=>Kh),void 0)).Response:Response}),ES=t=>{if(Array.isArray(t))return t.map(n=>ES(n));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([n,r])=>{const i=n.replace(/([-_][a-z])/gi,s=>s.toUpperCase().replace(/[-_]/g,""));e[i]=ES(r)}),e},JQ=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};var vd=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};const G1=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),eZ=(t,e,n)=>vd(void 0,void 0,void 0,function*(){const r=yield ZQ();t instanceof r&&!(n!=null&&n.noResolveJson)?t.json().then(i=>{const s=t.status||500,o=(i==null?void 0:i.statusCode)||s+"";e(new XQ(G1(i),s,o))}).catch(i=>{e(new _S(G1(i),i))}):e(new _S(G1(t),t))}),tZ=(t,e,n,r)=>{const i={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!r?i:(JQ(r)?(i.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),i.body=JSON.stringify(r)):i.body=r,e!=null&&e.duplex&&(i.duplex=e.duplex),Object.assign(Object.assign({},i),n))};function _0(t,e,n,r,i,s){return vd(this,void 0,void 0,function*(){return new Promise((o,a)=>{t(n,tZ(e,r,i,s)).then(l=>{if(!l.ok)throw l;return r!=null&&r.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>eZ(l,a,r))})})}function Ky(t,e,n,r){return vd(this,void 0,void 0,function*(){return _0(t,"GET",e,n,r)})}function Oa(t,e,n,r,i){return vd(this,void 0,void 0,function*(){return _0(t,"POST",e,r,i,n)})}function NS(t,e,n,r,i){return vd(this,void 0,void 0,function*(){return _0(t,"PUT",e,r,i,n)})}function nZ(t,e,n,r){return vd(this,void 0,void 0,function*(){return _0(t,"HEAD",e,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)})}function GO(t,e,n,r,i){return vd(this,void 0,void 0,function*(){return _0(t,"DELETE",e,r,i,n)})}var ws=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};const rZ={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},YT={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class iZ{constructor(e,n={},r,i){this.url=e,this.headers=n,this.bucketId=r,this.fetch=HO(i)}uploadOrUpdate(e,n,r,i){return ws(this,void 0,void 0,function*(){try{let s;const o=Object.assign(Object.assign({},YT),i);let a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;typeof Blob<"u"&&r instanceof Blob?(s=new FormData,s.append("cacheControl",o.cacheControl),l&&s.append("metadata",this.encodeMetadata(l)),s.append("",r)):typeof FormData<"u"&&r instanceof FormData?(s=r,s.append("cacheControl",o.cacheControl),l&&s.append("metadata",this.encodeMetadata(l))):(s=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),i!=null&&i.headers&&(a=Object.assign(Object.assign({},a),i.headers));const u=this._removeEmptyFolders(n),d=this._getFinalPath(u),f=yield(e=="PUT"?NS:Oa)(this.fetch,`${this.url}/object/${d}`,s,Object.assign({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(s){if(zi(s))return{data:null,error:s};throw s}})}upload(e,n,r){return ws(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,n,r)})}uploadToSignedUrl(e,n,r,i){return ws(this,void 0,void 0,function*(){const s=this._removeEmptyFolders(e),o=this._getFinalPath(s),a=new URL(this.url+`/object/upload/sign/${o}`);a.searchParams.set("token",n);try{let l;const u=Object.assign({upsert:YT.upsert},i),d=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",u.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",u.cacheControl)):(l=r,d["cache-control"]=`max-age=${u.cacheControl}`,d["content-type"]=u.contentType);const f=yield NS(this.fetch,a.toString(),l,{headers:d});return{data:{path:s,fullPath:f.Key},error:null}}catch(l){if(zi(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,n){return ws(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const i=Object.assign({},this.headers);n!=null&&n.upsert&&(i["x-upsert"]="true");const s=yield Oa(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:i}),o=new URL(this.url+s.url),a=o.searchParams.get("token");if(!a)throw new Q_("No token returned by API");return{data:{signedUrl:o.toString(),path:e,token:a},error:null}}catch(r){if(zi(r))return{data:null,error:r};throw r}})}update(e,n,r){return ws(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,n,r)})}move(e,n,r){return ws(this,void 0,void 0,function*(){try{return{data:yield Oa(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers}),error:null}}catch(i){if(zi(i))return{data:null,error:i};throw i}})}copy(e,n,r){return ws(this,void 0,void 0,function*(){try{return{data:{path:(yield Oa(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers})).Key},error:null}}catch(i){if(zi(i))return{data:null,error:i};throw i}})}createSignedUrl(e,n,r){return ws(this,void 0,void 0,function*(){try{let i=this._getFinalPath(e),s=yield Oa(this.fetch,`${this.url}/object/sign/${i}
90`,Object.assign({expiresIn:n},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return s={signedUrl:encodeURI(`${this.url}${s.signedURL}${o}`)},{data:s,error:null}}catch(i){if(zi(i))return{data:null,error:i};throw i}})}createSignedUrls(e,n,r){return ws(this,void 0,void 0,function*(){try{const i=yield Oa(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:e},{headers:this.headers}),s=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:i.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${s}`):null})),error:null}}catch(i){if(zi(i))return{data:null,error:i};throw i}})}download(e,n){return ws(this,void 0,void 0,function*(){const i=typeof(n==null?void 0:n.transform)<"u"?"render/image/authenticated":"object",s=this.transformOptsToQueryString((n==null?void 0:n.transform)||{}),o=s?`?${s}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield Ky(this.fetch,`${this.url}/${i}/${a}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(zi(a))return{data:null,error:a};throw a}})}info(e){return ws(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{const r=yield Ky(this.fetch,`${this.url}/object/info/${n}`,{headers:this.headers});return{data:ES(r),error:null}}catch(r){if(zi(r))return{data:null,error:r};throw r}})}exists(e){return ws(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{return yield nZ(this.fetch,`${this.url}/object/${n}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(zi(r)&&r instanceof _S){const i=r.originalError;if([400,404].includes(i==null?void 0:i.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,n){const r=this._getFinalPath(e),i=[],s=n!=null&&n.download?`download=${n.download===!0?"":n.download}`:"";s!==""&&i.push(s);const a=typeof(n==null?void 0:n.transform)<"u"?"render/image":"object",l=this.transformOptsToQueryString((n==null?void 0:n.transform)||{});l!==""&&i.push(l);let u=i.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}${u}`)}}}remove(e){return ws(this,void 0,void 0,function*(){try{return{data:yield GO(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(n){if(zi(n))return{data:null,error:n};throw n}})}list(e,n,r){return ws(this,void 0,void 0,function*(){try{const i=Object.assign(Object.assign(Object.assign({},rZ),n),{prefix:e||""});return{data:yield Oa(this.fetch,`${this.url}/object/list/${this.bucketId}`,i,{headers:this.headers},r),error:null}}catch(i){if(zi(i))return{data:null,error:i};throw i}})}listV2(e,n){return ws(this,void 0,void 0,function*(){try{const r=Object.assign({},e);return{data:yield Oa(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(r){if(zi(r))return{data:null,error:r};throw r}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const n=[];return e.width&&n.push(`width=${e.width}`),e.height&&n.push(`height=${e.height}`),e.resize&&n.push(`resize=${e.resize}`),e.format&&n.push(`format=${e.format}`),e.quality&&n.push(`quality=${e.quality}`),n.join("&")}}const sZ="2.11.0",oZ={"X-Client-Info":`storage-js/${sZ}`};var rf=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};class aZ{constructor(e,n={},r,i){const s=new URL(e);i!=null&&i.useNewHostname&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase.")),this.url=s.href,this.headers=Object.assign(Object.assign({},oZ),n),this.fetch=HO(r)}listBuckets(){return rf(this,void 0,void 0,function*(){try{return{data:yield Ky(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(zi(e))return{data:null,error:e};throw e}})}getBucket(e){return rf(this,void 0,void 0,function*(){try{return{data:yield Ky(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(n){if(zi(n))return{data:null,error:n};throw n}})}createBucket(e,n={public:!1}){return rf(this,void 0,void 0,function*(){try{return{data:yield Oa(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:n.type,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(zi(r))return{data:null,error:r};throw r}})}updateBucket(e,n){return rf(this,void 0,void 0,function*(){try{return{data:yield NS(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(zi(r))return{data:null,error:r};throw r}})}emptyBucket(e){return rf(this,void 0,void 0,function*(){try{return{data:yield Oa(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(zi(n))return{data:null,error:n};throw n}})}deleteBucket(e){return rf(this,void 0,void 0,function*(){try{return{data:yield GO(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(n){if(zi(n))return{data:null,error:n};throw n}})}}class lZ extends aZ{constructor(e,n={},r,i){super(e,n,r,i)}from(e){return new iZ(this.url,this.headers,e,this.fetch)}}const cZ="2.56.1";let im="";typeof Deno<"u"?im="deno":typeof document<"u"?im="web":typeof navigator<"u"&&navigator.product==="ReactNative"?im="react-native":im="node";const uZ={"X-Client-Info":`supabase-js-${im}/${cZ}`},dZ={headers:uZ}
90,fZ={schema:"public"},hZ={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},pZ={};var mZ=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};const gZ=t=>{let e;return t?e=t:typeof fetch>"u"?e=BO:e=fetch,(...n)=>e(...n)},bZ=()=>typeof Headers>"u"?RO:Headers,yZ=(t,e,n)=>{const r=gZ(n),i=bZ();return(s,o)=>mZ(void 0,void 0,void 0,function*(){var a;const l=(a=yield e())!==null&&a!==void 0?a:t;let u=new i(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${l}`),r(s,Object.assign(Object.assign({},o),{headers:u}))})};var vZ=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};function xZ(t){return t.endsWith("/")?t:t+"/"}function wZ(t,e){var n,r;const{db:i,auth:s,realtime:o,global:a}=t,{db:l,auth:u,realtime:d,global:f}=e,h={db:Object.assign(Object.assign({},l),i),auth:Object.assign(Object.assign({},u),s),realtime:Object.assign(Object.assign({},d),o),storage:{},global:Object.assign(Object.assign(Object.assign({},f),a),{headers:Object.assign(Object.assign({},(n=f==null?void 0:f.headers)!==null&&n!==void 0?n:{}),(r=a==null?void 0:a.headers)!==null&&r!==void 0?r:{})}),accessToken:()=>vZ(this,void 0,void 0,function*(){return""})};return t.accessToken?h.accessToken=t.accessToken:delete h.accessToken,h}const WO="2.71.1",_f=30*1e3,IS=3,W1=IS*_f,kZ="http://localhost:9999",SZ="supabase.auth.token",CZ={"X-Client-Info":`gotrue-js/${WO}`},jS="X-Supabase-Api-Version",qO={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},_Z=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,EZ=10*60*1e3;let Z_=class extends Error{constructor(e,n,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}};function On(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class NZ extends Z_{constructor(e,n,r){super(e,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function IZ(t){return On(t)&&t.name==="AuthApiError"}class KO extends Z_{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class Wc extends Z_{constructor(e,n,r,i){super(e,r,i),this.name=n,this.status=r}}class xc extends Wc{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function jZ(t){return On(t)&&t.name==="AuthSessionMissingError"}class db extends Wc{constructor(){super("Auth session or user missing","AuthInvalidToken
90ResponseError",500,void 0)}}class fb extends Wc{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class hb extends Wc{constructor(e,n=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function TZ(t){return On(t)&&t.name==="AuthImplicitGrantRedirectError"}class XT extends Wc{constructor(e,n=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class TS extends Wc{constructor(e,n){super(e,"AuthRetryableFetchError",n,void 0)}}function q1(t){return On(t)&&t.name==="AuthRetryableFetchError"}class QT extends Wc{constructor(e,n,r){super(e,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class zS extends Wc{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Yy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ZT=` 91\r=`.split(""),zZ=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<ZT.length;e+=1)t[ZT[e].charCodeAt(0)]=-2;for(let e=0;e<Yy.length;e+=1)t[Yy[e].charCodeAt(0)]=e;return t})();function JT(t,e,n){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(Yy[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(Yy[r]),e.queuedBits-=6}}function YO(t,e,n){const r=zZ[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)n(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function ez(t){const e=[],n=o=>{e.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},s=o=>{MZ(o,r,n)};for(let o=0;o<t.length;o+=1)YO(t.charCodeAt(o),i,s);return e.join("")}function PZ(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function AZ(t,e){for(let n=0;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>55295&&r<=56319){const i=(r-55296)*1024&65535;r=(t.charCodeAt(n+1)-56320&65535|i)+65536,n+=1}PZ(r,e)}}function MZ(t,e,n){if(e.utf8seq===0){if(t<=127){n(t);return}for(let r=1;r<6;r+=1)if((t>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&n(e.codepoint)}}function BZ(t){const e=[],n={queue:0,queuedBits:0},r=i=>{e.push(i)};for(let i=0;i<t.length;i+=1)YO(t.charCodeAt(i),n,r);return new Uint8Array(e)}function RZ(t){const e=[];return AZ(t,n=>e.push(n)),new Uint8Array(e)}function OZ(t){const e=[],n={queue:0,queuedBits:0},r=i=>{e.push(i)};return t.forEach(i=>JT(i,n,r)),JT(null,n,r),e.join("")}function DZ(t){return Math.round(Date.now()/1e3)+t}function LZ(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const na=()=>typeof window<"u"&&typeof document<"u",du={tested:!1,writable:!1},XO=()=>{if(!na())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(du.tested)return du.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),du.tested=!0,du.writable=!0}catch{du.tested=!0,du.writable=!1}return du.writable};function FZ(t){const e={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((i,s)=>{e[s]=i})}catch{}return n.searchParams.forEach((r,i)=>{e[i]=r}),e}const QO=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>ai(async()=>{const{default:r}=await Promise.resolve().then(()=>Kh);return{default:r}},void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},$Z=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Ef=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},fu=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},dc=async(t,e)=>{await t.removeItem(e)};class ox{constructor(){this.promise=new ox.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}ox.promiseConstructor=Promise;function K1(t){const e=t.split(".");if(e.length!==3)throw new zS("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!_Z.test(e[r]))throw new zS("JWT not in base64url format");return{header:JSON.parse(ez(e[0])),payload:JSON.parse(ez(e[1])),signature:BZ(e[2]),raw:{header:e[0],payload:e[1]}}}async function UZ(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function VZ(t,e){return new Promise((r,i)=>{(async()=>{for(let s=0;s<1/0;s++)try{const o=await t(s);if(!e(s,null,o)){r(o);return}}catch(o){if(!e(s,o)){i(o);return}}})()})}function HZ(t){return("0"+t.toString(16)).substr(-2)}function GZ(){const e=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let i="";for(let s=0;s<56;s++)i+=n.charAt(Math.floor(Math.random()*r));return i}return crypto.getRandomValues(e),Array.from(e,HZ).join("")}async function WZ(t){const n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",
91n),i=new Uint8Array(r);return Array.from(i).map(s=>String.fromCharCode(s)).join("")}async function qZ(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const n=await WZ(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function sf(t,e,n=!1){const r=GZ();let i=r;n&&(i+="/PASSWORD_RECOVERY"),await Ef(t,`${e}-code-verifier`,i);const s=await qZ(r);return[s,r===s?"plain":"s256"]}const KZ=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function YZ(t){const e=t.headers.get(jS);if(!e||!e.match(KZ))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function XZ(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function QZ(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const ZZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function of(t){if(!ZZ.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Y1(){const t={};return new Proxy(t,{get:(e,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function tz(t){return JSON.parse(JSON.stringify(t))}var JZ=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n};const ju=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),eJ=[502,503,504];async function nz(t){var e;if(!$Z(t))throw new TS(ju(t),0);if(eJ.includes(t.status))throw new TS(ju(t),t.status);let n;try{n=await t.json()}catch(s){throw new KO(ju(s),s)}let r;const i=YZ(t);if(i&&i.getTime()>=qO["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new QT(ju(n),t.status,((e=n.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new xc}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((s,o)=>s&&typeof o=="string",!0))throw new QT(ju(n),t.status,n.weak_password.reasons);throw new NZ(ju(n),t.status||500,r)}const tJ=(t,e,n,r)=>{const i={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),i.body=JSON.stringify(r),Object.assign(Object.assign({},i),n))};async function qn(t,e,n,r){var i;const s=Object.assign({},r==null?void 0:r.headers);s[jS]||(s[jS]=qO["2024-01-01"].name),r!=null&&r.jwt&&(s.Authorization=`Bearer ${r.jwt}`);const o=(i=r==null?void 0:r.query)!==null&&i!==void 0?i:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await nJ(t,e,n+a,{headers:s,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(l):{data:Object.assign({},l),error:null}}async function nJ(t,e,n,r,i,s){const o=tJ(e,r,i,s);let a;try{a=await t(n,Object.assign({},o))}catch(l){throw console.error(l),new TS(ju(l),0)}if(a.ok||await nz(a),r!=null&&r.noResolveJson)return a;try{return await a.json()}catch(l){await nz(l)}}function kl(t){var e;let n=null;oJ(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=DZ(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function rz(t){const e=kl(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Nc(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function rJ(t){return{data:t,error:null}}function iJ(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:i,verification_type:s}=t,o=JZ(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:n,hashed_token:r,redirect_to:i,verification_type:s},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function sJ(t){return t}function oJ(t){return t.access_token&&t.refresh_token&&t.expires_in}const X1=["global","local","others"];var aJ=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n};class lJ{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=QO(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,n=X1[0]){if(X1.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${X1.join(", ")}`);try{return await qn(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(On(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await qn(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Nc})}catch(r){if(On(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=aJ(e,["options"]),i=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(i.new_email=r==null?void 0:r.newEmail,delete i.newEmail),await qn(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:iJ,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(On(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await qn(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Nc})}catch(n){if(On(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,i,s,o,a,l;try{const u={nextPage:null,lastPage:0,total:0},d=await qn(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e==null?void 0:e.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(s=(i=e==null?void 0:e.perPage)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""},xform:sJ});if(d.error)throw d.error;const f=await d.json(),h=(o=d.headers.get("x-total-count"))!==null&&o!==void 0?o:0,m=(l=(a=d.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return m.length>0&&(m.forEach(y=>{const g=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(y.split(";")[1].split("=")[1]);u[`${w}Page`]=g}),u.total=parseInt(h)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(On(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){of(e);try{return await qn(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Nc})}catch(n){if(On(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){of(e);try{return await qn(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:Nc})}catch(r){if(On(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){of(e);
91try{return await qn(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:Nc})}catch(r){if(On(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){of(e.userId);try{const{data:n,error:r}=await qn(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:i=>({data:{factors:i},error:null})});return{data:n,error:r}}catch(n){if(On(n))return{data:null,error:n};throw n}}async _deleteFactor(e){of(e.userId),of(e.id);try{return{data:await qn(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if(On(n))return{data:null,error:n};throw n}}}function iz(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}function cJ(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const af={debug:!!(globalThis&&XO()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class ZO extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class uJ extends ZO{}async function dJ(t,e,n){af.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),af.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async i=>{if(i){af.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await n()}finally{af.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw af.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new uJ(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(af.debug)try{const s=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(s,null," "))}catch(s){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",s)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await n()}}))}cJ();const fJ={url:kZ,storageKey:SZ,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:CZ,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function sz(t,e,n){return await n()}const lf={};class Xm{constructor(e){var n,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Xm.nextInstanceID,Xm.nextInstanceID+=1,this.instanceID>0&&na()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const i=Object.assign(Object.assign({},fJ),e);if(this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.persistSession=i.persistSession,this.storageKey=i.storageKey,this.autoRefreshToken=i.autoRefreshToken,this.admin=new lJ({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=QO(i.fetch),this.lock=i.lock||sz,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,i.lock?this.lock=i.lock:na()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=dJ:this.lock=sz,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:XO()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=iz(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=iz(this.memoryStorage)),na()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(s){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",s)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async s=>{this._debug("received broadcast notification from other tab or client",s),await this._notifyAllSubscribers(s.data.event,s.data.session,!1)})}this.initialize()}get jwks(){var e,n;return(n=(e=lf[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(e){lf[this.storageKey]=Object.assign(Object.assign({},lf[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,n;return(n=(e=lf[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){lf[this.storageKey]=Object.assign(Object.assign({},lf[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${WO}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const n=FZ(window.location.href);let r="none";if(this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce"),na()&&this.detectSessionInUrl&&r!=="none"){const{data:i,error:s}=await this._getSessionFromURL(n,r);if(s){if(this._debug("#_initialize()","error detecting session from URL",s),TZ(s)){const l=(e=s.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:s}}return await this._removeSession(),{error:s}}const{session:o,redirectType:a}=i;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return On(n)?{error:n}:{error:new KO("Unexpected error during initialization",n)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var n,r,i;try{const s=await qn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(i=e==null?void 0:e.options)===null||i===void 0?void 0:i.captchaToken}},xform:kl}),{data:o,error:a}=s;
91if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(s){if(On(s))return{data:{user:null,session:null},error:s};throw s}}async signUp(e){var n,r,i;try{let s;if("email"in e){const{email:d,password:f,options:h}=e;let m=null,y=null;this.flowType==="pkce"&&([m,y]=await sf(this.storage,this.storageKey)),s=await qn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h==null?void 0:h.emailRedirectTo,body:{email:d,password:f,data:(n=h==null?void 0:h.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},code_challenge:m,code_challenge_method:y},xform:kl})}else if("phone"in e){const{phone:d,password:f,options:h}=e;s=await qn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:d,password:f,data:(r=h==null?void 0:h.data)!==null&&r!==void 0?r:{},channel:(i=h==null?void 0:h.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:kl})}else throw new fb("You must provide either an email or phone number and a password");const{data:o,error:a}=s;
91if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(s){if(On(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithPassword(e){try{let n;if("email"in e){const{email:s,password:o,options:a}=e;n=await qn(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:rz})}else if("phone"in e){const{phone:s,password:o,options:a}=e;n=await qn(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:rz})}else throw new fb("You must provide either an email or phone number and a password");const{data:r,error:i}=n;return i?{data:{user:null,session:null},error:i}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new db}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:i})}catch(n){if(On(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOAuth(e){var n,r,i,s;return await this._handleProviderSignIn(e.provider,{redirectTo:(n=e.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(i=e.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(s=e.options)===null||s===void 0?void 0:s.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:n}=e;if(n==="solana")return await this.signInWithSolana(e);throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}async signInWithSolana(e){var n,r,i,s,o,a,l,u,d,f,h,m;let y,g;if("message"in e)y=e.message,g=e.signature;else{const{chain:w,wallet:v,statement:S,options:C}=e;let k;if(na())if(typeof v=="object")k=v;else{const _=window;if("solana"in _&&typeof _.solana=="object"&&("signIn"in _.solana&&typeof _.solana.signIn=="function"||"signMessage"in _.solana&&typeof _.solana.signMessage=="function"))k=_.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!(C!=null&&C.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");k=v}const N=new URL((n=C==null?void 0:C.url)!==null&&n!==void 0?n:window.location.href);
91if("signIn"in k&&k.signIn){const _=await k.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},C==null?void 0:C.signInWithSolana),{version:"1",domain:N.host,uri:N.href}),S?{statement:S}:null));let j;if(Array.isArray(_)&&_[0]&&typeof _[0]=="object")j=_[0];else if(_&&typeof _=="object"&&"signedMessage"in _&&"signature"in _)j=_;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in j&&"signature"in j&&(typeof j.signedMessage=="string"||j.signedMessage instanceof Uint8Array)&&j.signature instanceof Uint8Array)y=typeof j.signedMessage=="string"?j.signedMessage:new TextDecoder().decode(j.signedMessage),g=j.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in k)||typeof k.signMessage!="function"||!("publicKey"in k)||typeof k!="object"||!k.publicKey||!("toBase58"in k.publicKey)||typeof k.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");y=[`${N.host} wants you to sign in with your Solana account:`,k.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${N.href}`,`Issued At: ${(i=(r=C==null?void 0:C.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&i!==void 0?i:new Date().toISOString()}`,...!((s=C==null?void 0:C.signInWithSolana)===null||s===void 0)&&s.notBefore?[`Not Before: ${C.signInWithSolana.notBefore}`]:[],...!((o=C==null?void 0:C.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${C.signInWithSolana.expirationTime}`]:[],...!((a=C==null?void 0:C.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${C.signInWithSolana.chainId}`]:[],...!((l=C==null?void 0:C.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${C.signInWithSolana.nonce}`]:[],...!((u=C==null?void 0:C.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${C.signInWithSolana.requestId}`]:[],...!((f=(d=C==null?void 0:C.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||f===void 0)&&f.length?["Resources",...C.signInWithSolana.resources.map(j=>`- ${j}`)]:[]].join(` 92`);const _=await k.signMessage(new TextEncoder().encode(y),"utf8");if(!_||!(_ instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=_}}try{const{data:w,error:v}=await qn(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:y,signature:OZ(g)},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(m=e.options)===null||m===void 0?void 0:m.captchaToken}}:null),xform:kl});if(v)throw v;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new db}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:v})}catch(w){if(On(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(e){const n=await fu(this.storage,`${this.storageKey}-code-verifier`),[r,i]=(n??"").split("/");try{const{data:s,error:o}=await qn(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:kl});if(await dc(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!s||!s.session||!s.user?{data:{user:null,session:null,redirectType:null},error:new db}:(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign(Object.assign({},s),{redirectType:i??null}),error:o})}catch(s){if(On(s))return{data:{user:null,session:null,redirectType:null},error:s};throw s}}async signInWithIdToken(e){try{const{options:n,provider:r,token:i,access_token:s,nonce:o}=e,a=await qn(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:i,access_token:s,nonce:o,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:kl}),{data:l,error:u}=a;return u?{data:{user:null,session:null},error:u}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new db}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:u})}catch(n){if(On(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOtp(e){var n,r,i,s,o;try{if("email"in e){const{email:a,options:l}=e;let u=null,d=null;this.flowType==="pkce"&&([u,d]=await sf(this.storage,this.storageKey));const{error:f}=await qn(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(r=l==null?void 0:l.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:u,code_challenge_method:d},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in e){const{phone:a,options:l}=e,{data:u,error:d}=await qn(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(i=l==null?void 0:l.data)!==null&&i!==void 0?i:{},create_user:(s=l==null?void 0:l.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:d}}throw new fb("You must provide either an email or phone number.")}
92catch(a){if(On(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var n,r;try{let i,s;"options"in e&&(i=(n=e.options)===null||n===void 0?void 0:n.redirectTo,s=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:a}=await qn(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:s}}),redirectTo:i,xform:kl});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,u=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(On(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithSSO(e){var n,r,i;try{let s=null,o=null;return this.flowType==="pkce"&&([s,o]=await sf(this.storage,this.storageKey)),await qn(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(n=e.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((i=e==null?void 0:e.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:s,code_challenge_method:o}),headers:this.headers,xform:rJ})}catch(s){if(On(s))return{data:null,error:s};throw s}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:n},error:r}=e;if(r)throw r;if(!n)throw new xc;const{error:i}=await qn(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return{data:{user:null,session:null},error:i}})}catch(e){if(On(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const n=`${this.url}/resend`;if("email"in e){const{email:r,type:i,options:s}=e,{error:o}=await qn(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:i,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},redirectTo:s==null?void 0:s.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:r,type:i,options:s}=e,{data:o,error:a}=await qn(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:i,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a}}throw new fb("You must provide either an email or phone number and a type")}catch(n){if(On(n))return{data:{user:null,session:null},error:n};throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async n=>n))}async _acquireLock(e,n){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await e(n)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const n=await fu(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?e=n:(this._debug("#getSession()","session from storage is not val
92id"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<W1:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await fu(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=Y1()}if(this.storage.isServer&&e.user){let o=this.suppressGetSessionWarning;e=new Proxy(e,{get:(l,u,d)=>(!o&&u==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,u,d))})}return{data:{session:e},error:null}}const{session:i,error:s}=await this._callRefreshToken(e.refresh_token);return s?{data:{session:null},error:s}:{data:{session:i},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await qn(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Nc}):await this._useSession(async n=>{var r,i,s;const{data:o,error:a}=n;if(a)throw a;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xc}:await qn(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(s=(i=o.session)===null||i===void 0?void 0:i.access_token)!==null&&s!==void 0?s:void 0,xform:Nc})})}catch(n){if(On(n))return jZ(n)&&(await this._removeSession(),await dc(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:n};throw n}}async updateUser(e,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,n))}async _updateUser(e,n={}){try{return await this._useSession(async r=>{const{data:i,error:s}=r;if(s)throw s;if(!i.session)throw new xc;const o=i.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await sf(this.storage,this.storageKey));const{data:u,error:d}=await qn(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n==null?void 0:n.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:Nc});if(d)throw d;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(r){if(On(r))return{data:{user:null},error:r};throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new xc;const n=Date.now()/1e3;let r=n,i=!0,s=null;const{payload:o}=K1(e.access_token);if(o.exp&&(r=o.exp,i=r<=n),i){const{session:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};s=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;s={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)}return{data:{user:s.user,session:s},error:null}}catch(n){if(On(n))return{data:{session:null,user:null},error:n};throw n}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async n=>{var r;if(!e){const{data:o,error:a}=n;if(a)throw a;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new xc;const{session:i,error:s}=await this._callRefreshToken(e.refresh_token);return s?{data:{user:null,session:null},error:s}:i?{data:{user:i.user,session:i},error:null}:{data:{user:null,session:null},error:null}})}catch(n){if(On(n))return{data:{user:null,session:null},error:n};throw n}}async _getSessionFromURL(e,n){try{if(!na())throw new hb("No browser detected.");
92if(e.error||e.error_description||e.error_code)throw new hb(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new XT("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new hb("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new XT("No code detected.");const{data:S,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const k=new URL(window.location.href);return k.searchParams.delete("code"),window.history.replaceState(window.history.state,"",k.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:i,access_token:s,refresh_token:o,expires_in:a,expires_at:l,token_type:u}=e;if(!s||!a||!o||!u)throw new hb("No session defined in URL");const d=Math.round(Date.now()/1e3),f=parseInt(a);let h=d+f;l&&(h=parseInt(l));const m=h-d;m*1e3<=_f&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${f}s`);const y=h-f;d-y>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",y,h,d):d-y<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",y,h,d);const{data:g,error:w}=await this._getUser(s);if(w)throw w;const v={provider_token:r,provider_refresh_token:i,access_token:s,expires_in:f,expires_at:h,refresh_token:o,token_type:u,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:v,redirectType:e.type},error:null}}catch(r){if(On(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const n=await fu(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&n)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:i,error:s}=n;if(s)return{error:s};const o=(r=i.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(IZ(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await dc(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const n=LZ(),r={id:n,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async n=>{var r,i;try{const{data:{session:s},error:o}=n;if(o)throw o;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(s){await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",s),console.error(s)}})}async resetPasswordForEmail(e,n={}){let r=null,i=null;this.flowType==="pkce"&&([r,i]=await sf(this.storage,this.storageKey,!0));try{return await qn(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:i,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(s){if(On(s))return{data:null,error:s};throw s}}async getUserIdentities(){var e;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=n.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(n){if(On(n))return{data:null,error:n};throw n}}async linkIdentity(e){var n;try{const{data:r,error:i}=await this._useSession(async s=>{var o,a,l,u,d;const{data:f,error:h}=s;if(h)throw h;const m=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await qn(this.fetch,"GET",m,{headers:this.headers,jwt:(d=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&d!==void 0?d:void 0})});if(i)throw i;return na()&&!(!((n=e.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),{data:{provider:e.provider,url:r==null?void 0:r.url},error:null}}catch(r){if(On(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async unlinkIdentity(e){try{return await this._useSession(async n=>{var r,i;const{data:s,error:o}=n;
92if(o)throw o;return await qn(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(i=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&i!==void 0?i:void 0})})}catch(n){if(On(n))return{data:null,error:n};throw n}}async _refreshAccessToken(e){const n=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await VZ(async i=>(i>0&&await UZ(200*Math.pow(2,i-1)),this._debug(n,"refreshing attempt",i),await qn(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:kl})),(i,s)=>{const o=200*Math.pow(2,i);return s&&q1(s)&&Date.now()+o-r<_f})}catch(r){if(this._debug(n,"error",r),On(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(n,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",n,"url",r),na()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,n;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const i=await fu(this.storage,this.storageKey);if(i&&this.userStorage){let o=await fu(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:i.user},await Ef(this.userStorage,this.storageKey+"-user",o)),i.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:Y1()}else if(i&&!i.user&&!i.user){const o=await fu(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(i.user=o.user,await dc(this.storage,this.storageKey+"-user"),await Ef(this.storage,this.storageKey,i)):i.user=Y1()}if(this._debug(r,"session from storage",i),!this._isValidSession(i)){this._debug(r,"session is not valid"),i!==null&&await this._removeSession();return}const s=((n=i.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<W1;if(this._debug(r,`session has${s?"":" not"} expired with margin of ${W1}s`),s){if(this.autoRefreshToken&&i.refresh_token){const{error:o}=await this._callRefreshToken(i.refresh_token);o&&(console.error(o),q1(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(i.user&&i.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(i.access_token);!a&&(o!=null&&o.user)?(i.user=o.user,await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(r,"error",i),console.error(i);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var n,r;if(!e)throw new xc;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const i=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(i,"begin");try{this.refreshingDeferred=new ox;const{data:s,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!s.session)throw new xc;await this._saveSession(s.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",s.session);const a={session:s.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(s){if(this._debug(i,"error",s),On(s)){const o={session:null,error:s};return q1(s)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(s),s}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(e,n,r=!0){const i=`#_notifyAllSubscribers(${e})`;this._debug(i,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:n});const s=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,n)}catch(l){s.push(l)}});if(await Promise.all(o),s.length>0){for(let a=0;a<s.length;a+=1)console.error(s[a]);throw s[0]}}finally{this._debug(i,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const n=Object.assign({},e),r=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&n.user&&await Ef(this.userStorage,this.storageKey+"-user",{user:n.user});const i=Object.assign({},n);delete i.user;const s=tz(i);await Ef(this.storage,this.storageKey,s)}else{const i=tz(n);await Ef(this.storage,this.storageKey,i)}}async _removeSession(){this._debug("#_removeSession()"),await dc(this.storage,this.storageKey),await dc(this.storage,this.storageKey+"-code-verifier"),await dc(this.storage,this.storageKey+"-user"),this.userStorage&&await dc(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&na()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
92catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),_f);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((r.expires_at*1e3-e)/_f);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${_f}ms, refresh threshold is ${IS} ticks`),i<=IS&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof ZO)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!na()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const n=`#_onVisibilityChanged(${e})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,n,r){const i=[`provider=${encodeURIComponent(n)}`];if(r!=null&&r.redirectTo&&i.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&i.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[s,o]=await sf(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(s)}`,code_challenge_method:`${encodeURIComponent(o)}`});i.push(a.toString())}if(r!=null&&r.queryParams){const s=new URLSearchParams(r.queryParams);i.push(s.toString())}return r!=null&&r.skipBrowserRedirect&&i.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${i.join("&")}`}async _unenroll(e){try{return await this._useSession(async n=>{var r;const{data:i,error:s}=n;return s?{data:null,error:s}:await qn(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(On(n))return{data:null,error:n};throw n}}async _enroll(e){try{return await this._useSession(async n=>{var r,i;const{data:s,error:o}=n;if(o)return{data:null,error:o};const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:l,error:u}=await qn(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&(!((i=l==null?void 0:l.totp)===null||i===void 0)&&i.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(n){if(On(n))return{data:null,error:n};throw n}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:i,error:s}=n;if(s)return{data:null,error:s};const{data:o,error:a}=await qn(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:a})})}catch(n){if(On(n))return{data:null,error:n};throw n}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:i,error:s}=n;return s?{data:null,error:s}:await qn(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(On(n))return{data:null,error:n};throw n}})}async _challengeAndVerify(e){const{data:n,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:n.id,code:e.code})}async _listFactors(){const{data:{user:e},error:n}=await this.getUser();if(n)return{data:null,error:n};const r=(e==null?void 0:e.factors)||[],i=r.filter(o=>o.factor_type==="totp"&&o.status==="verified"),s=r.filter(o=>o.factor_type==="phone"&&o.status==="verified");return{data:{all:r,totp:i,phone:s},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var n,r;const{data:{session:i},error:s}=e;if(s)return{data:null,error:s};if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=K1(i.access_token);let a=null;o.aal&&(a=o.aal);let l=a;((r=(n=i.user.factors)===null||n===void 0?void 0:n.filter(f=>f.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const d=o.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:d},error:null}}))}async fetchJwk(e,n={keys:[]}){let r=n.keys.find(a=>a.kid===e);if(r)return r;const i=Date.now();if(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+EZ>i)return r;const{data:s,error:o}=await qn(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!s.keys||s.keys.length===0||(this.jwks=s,this.jwks_cached_at=i,r=s.keys.find(a=>a.kid===e),!r)?null:r}async getClaims(e,n={}){try{let r=e;if(!r){const{data:m,error:y}
92=await this.getSession();if(y||!m.session)return{data:null,error:y};r=m.session.access_token}const{header:i,payload:s,signature:o,raw:{header:a,payload:l}}=K1(r);n!=null&&n.allowExpired||XZ(s.exp);const u=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!u){const{error:m}=await this.getUser(r);if(m)throw m;return{data:{claims:s,header:i,signature:o},error:null}}const d=QZ(i.alg),f=await crypto.subtle.importKey("jwk",u,d,!0,["verify"]);if(!await crypto.subtle.verify(d,f,o,RZ(`${a}.${l}`)))throw new zS("Invalid JWT signature");return{data:{claims:s,header:i,signature:o},error:null}}catch(r){if(On(r))return{data:null,error:r};throw r}}}Xm.nextInstanceID=0;const hJ=Xm;class pJ extends hJ{constructor(e){super(e)}}var mJ=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(t,e||[])).next())})};class gJ{constructor(e,n,r){var i,s,o;if(this.supabaseUrl=e,this.supabaseKey=n,!e)throw new Error("supabaseUrl is required.");if(!n)throw new Error("supabaseKey is required.");const a=xZ(e),l=new URL(a);this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const u=`sb-${l.hostname.split(".")[0]}-auth-token`,d={db:fZ,realtime:pZ,auth:Object.assign(Object.assign({},hZ),{storageKey:u}),global:dZ},f=wZ(r??{},d);this.storageKey=(i=f.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(s=f.global.headers)!==null&&s!==void 0?s:{},f.accessToken?(this.accessToken=f.accessToken,this.auth=new Proxy({},{get:(h,m)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(m)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=f.auth)!==null&&o!==void 0?o:{},this.headers,f.global.fetch),this.fetch=yZ(n,this._getAccessToken.bind(this),f.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},f.realtime)),this.rest=new PQ(new URL("rest/v1",l).href,{headers:this.headers,schema:f.db.schema,fetch:this.fetch}),this.storage=new lZ(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),f.accessToken||this._listenForAuthEvents()}get functions(){return new kQ(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,n={},r={}){return this.rest.rpc(e,n,r)}channel(e,n={config:{}}){return this.realtime.channel(e,n)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,n;return mJ(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:r}=yield this.auth.getSession();return(n=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&n!==void 0?n:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:i,storageKey:s,flowType:o,lock:a,debug:l},u,d){const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new pJ({url:this.authUrl.href,headers:Object.assign(Object.assign({},f),u),storageKey:s,autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:i,flowType:o,lock:a,debug:l,fetch:d,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new YQ(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(e,n,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?this.changedAccessToken=r:e==="SIGNED_OUT"&&(this.realtime.setAuth(),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const bJ=(t,e,n)=>new gJ(t,e,n);
92function yJ(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}yJ()&&console.warn("â ï¸ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const vJ="https://auth.cai.audio",xJ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImF0dHhycXZncGNnZ2RoZ2J1eGRkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTY0NTEyNDQsImV4cCI6MjA3MjAyNzI0NH0.luRNWny_NHUFhA0KNI-OlriUv4oLicNOifKPucTY8w8",xr=bJ(vJ,xJ,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"pkce"}}),wJ=Object.freeze(Object.defineProperty({__proto__:null,supabase:xr},Symbol.toStringTag,{value:"Module"})),oz={development:{caiServerFastAPI:"https://localhost:8000"},staging:{caiServerFastAPI:"https://staging.api.cai.audio"},production:{caiServerFastAPI:"https://api.cai.audio"}},JO="production",PS=JO==="development",kJ="G-8TQWBBQGTK",Yh=oz[JO]||oz.development,ar=(...t)=>{},pr=(...t)=>{},SJ=4,CJ=SJ*1024*1024*1024,Rp=1e6,_J=.8;function EJ(){if(typeof performance<"u"&&"memory"in performance&&performance.memory)return performance.memory.usedJSHeapSize}function NJ(){try{const t=EJ();if(t===void 0)return ar("Memory API not available (non-Chromium browser). Using fallback threshold:",Rp),Rp;const e=CJ-t,n=Math.floor(e*_J);return n<Rp?(ar(`Available memory is critically low (${(e/1024/1024).toFixed(2)}
92MB). Using fallback threshold.`),Rp):n}catch{return Rp}}const IJ=Yh.caiServerFastAPI,Au=ui.create({baseURL:IJ});Au.interceptors.request.use(async t=>{try{const{data:{session:e}}=await xr.auth.getSession(),n=(e==null?void 0:e.access_token)||"";n?t.headers.Authorization=`Bearer ${n}`:ar("No authentication token found for request to:",t.url)}catch{}return t},t=>Promise.reject(t));Au.interceptors.response.use(t=>t,t=>{var e,n,r,i;return(t.code==="ERR_NETWORK"||t.code==="ERR_CERT_AUTHORITY_INVALID"||(e=t.message)!=null&&e.includes("SSL")||(n=t.message)!=null&&n.includes("certificate"))&&pr("ð SSL/Certificate Error:",{message:t.message,code:t.code,url:(r=t.config)==null?void 0:r.url,baseURL:(i=t.config)==null?void 0:i.baseURL,hint:"Make sure mkcert CA is installed: mkcert -install"}),Promise.reject(t)});const tr={get:(t,e={})=>Au.get(t,e),post:(t,e,n={})=>Au.post(t,e,n),put:(t,e,n={})=>Au.put(t,e,n),patch:(t,e,n={})=>Au.patch(t,e,n),delete:(t,e={})=>Au.delete(t,e)};async function uy(t,e,n={}){var m;const{signal:r}=n,i=`${Yh.caiServerFastAPI}/api/v0/${t}`;let s;try{if(s=(m=(await xr.auth.getSession()).data.session)==null?void 0:m.access_token,!s)throw new Error("No token provided by Supabase")}catch(y){throw pr(`Error fetching authentication token: ${y.message}`,y),y}const o={Authorization:`Bearer ${s}`},a={url:i,method:"POST",headers:o,data:e,signal:r},{stream:l,headers:u,status:d}=await TJ(a);let f;const h=u.get("Content-Type")||"";if(h.includes("application/json"))f=await new Response(l).json();else if(h.includes("text/plain"))f=await new Response(l).text();else if(h.includes("application/octet-stream"))f=await new Response(l).arrayBuffer();else try{f=await new Response(l).json()}catch{f=await new Response(l).text()}return{data:f,status:d,statusText:d===200?"OK":"Error",headers:eD(u),config:a}}function jJ(t){let e=0;return new TransformStream({start(){e=0},transform(n,r){if(e+=n.byteLength,e>t){r.error(new Error(`Request Error: Payload exceeds ${t} bytes`));return}r.enqueue(n)}})}async function TJ(t){const{url:e,method:n,signal:r,headers:i,data:s}=t,{body:o,headers:a}=PJ(s,i),l=NJ(),u=await fetch(e,{signal:r,headers:a,method:n,body:o});if(!u.ok){const h=await u.text().catch(()=>"Unknown error"),m=new yQ(`Request failed with status ${u.status}: ${u.statusText}`);throw m.response={status:u.status,statusText:u.statusText,data:h,headers:eD(u.headers)},m.status=u.status,m}const d=u.headers.get("Content-Length");if(d&&parseInt(d,10)>l)throw new Error(`Request Error: Payload exceeds ${l} bytes`);let f;return u.body?f=u.body.pipeThrough(jJ(l)):f=new ReadableStream({start(h){h.close()}}),{stream:f,headers:u.headers,status:u.status}}function zJ(t){return t!=null&&typeof t=="object"&&!(t instanceof Blob||t instanceof ArrayBuffer||t instanceof Uint8Array||t instanceof URLSearchParams||t instanceof FormData||t instanceof ReadableStream)}function PJ(t,e){const n=new Headers(e);return t==null?{body:void 0,headers:n}:typeof t=="string"?(n.has("Content-Type")||n.set("Content-Type","text/plain;charset=UTF-8"),{body:t,headers:n}):t instanceof URLSearchParams?(n.has("Content-Type")||n.set("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"),{body:t.toString(),headers:n}):t instanceof FormData?{body:t,headers:n}:t instanceof Blob||t instanceof ReadableStream?{body:t,headers:n}:t instanceof ArrayBuffer||t instanceof Uint8Array?(n.has("Content-Type")||n.set("Content-Type","application/octet-stream"),{body:t,headers:n}):zJ(t)?(n.has("Content-Type")||n.set("Content-Type","application/json"),{body:JSON.stringify(t),headers:n}):{body:t,headers:n}}function eD(t){const e={};return t.forEach((n,r)=>{e[r]=n}),e}const AJ=Object.freeze(Object.defineProperty({__proto__:null,apiClient:tr,requestServer:uy},Symbol.toStringTag,{value:"Module"}));function Tc(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Q1={exports:{}};/*! 93 localForage -- Offline Storage, Improved 94 Version 1.10.0 95 https://localforage.github.io/localForage 96 (c) 2013-2017 Mozilla, Apache License 2.0 97*/var az;function MJ(){return az||(az=1,function(t,e){(function(n){t.exports=n()})(function(){return function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof Tc=="function"&&Tc;if(!d&&f)return f(u,!0);if(a)return a(u,!0);var h=new Error("Cannot find module '"+u+"'");throw h.code="MODULE_NOT_FOUND",h}var m=i[u]={exports:{}};
vendor: 29,150 bytes, line 97
97r[u][0].call(m.exports,function(y){var g=r[u][1][y];return o(g||y)},m,m.exports,n,r,i,s)}return i[u].exports}for(var a=typeof Tc=="function"&&Tc,l=0;l<s.length;l++)o(s[l]);return o}({1:[function(n,r,i){(function(s){var o=s.MutationObserver||s.WebKitMutationObserver,a;if(o){var l=0,u=new o(y),d=s.document.createTextNode("");u.observe(d,{characterData:!0}),a=function(){d.data=l=++l%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var f=new s.MessageChannel;f.port1.onmessage=y,a=function(){f.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?a=function(){var w=s.document.createElement("script");w.onreadystatechange=function(){y(),w.onreadystatechange=null,w.parentNode.removeChild(w),w=null},s.document.documentElement.appendChild(w)}:a=function(){setTimeout(y,0)};var h,m=[];function y(){h=!0;for(var w,v,S=m.length;S;){for(v=m,m=[],w=-1;++w<S;)v[w]();S=m.length}h=!1}r.exports=g;function g(w){m.push(w)===1&&!h&&a()}}).call(this,typeof jc<"u"?jc:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,r,i){var s=n(1);function o(){}var a={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];r.exports=f;function f(N){if(typeof N!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,N!==o&&g(this,N)}f.prototype.catch=function(N){return this.then(null,N)},f.prototype.then=function(N,_){if(typeof N!="function"&&this.state===u||typeof _!="function"&&this.state===l)return this;var j=new this.constructor(o);if(this.state!==d){var T=this.state===u?N:_;m(j,T,this.outcome)}else this.queue.push(new h(j,N,_));return j};function h(N,_,j){this.promise=N,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof j=="function"&&(this.onRejected=j,this.callRejected=this.otherCallRejected)}h.prototype.callFulfilled=function(N){a.resolve(this.promise,N)},h.prototype.otherCallFulfilled=function(N){m(this.promise,this.onFulfilled,N)},h.prototype.callRejected=function(N){a.reject(this.promise,N)},h.prototype.otherCallRejected=function(N){m(this.promise,this.onRejected,N)};function m(N,_,j){s(function(){var T;try{T=_(j)}catch(M){return a.reject(N,M)}T===N?a.reject(N,new TypeError("Cannot resolve promise with itself")):a.resolve(N,T)})}a.resolve=function(N,_){var j=w(y,_);if(j.status==="error")return a.reject(N,j.value);var T=j.value;if(T)g(N,T);else{N.state=u,N.outcome=_;for(var M=-1,V=N.queue.length;++M<V;)N.queue[M].callFulfilled(_)}return N},a.reject=function(N,_){N.state=l,N.outcome=_;for(var j=-1,T=N.queue.length;++j<T;)N.queue[j].callRejected(_);return N};function y(N){var _=N&&N.then;if(N&&(typeof N=="object"||typeof N=="function")&&typeof _=="function")return function(){_.apply(N,arguments)}}function g(N,_){var j=!1;function T(P){j||(j=!0,a.reject(N,P))}function M(P){j||(j=!0,a.resolve(N,P))}function V(){_(M,T)}var H=w(V);H.status==="error"&&T(H.value)}function w(N,_){var j={};try{j.value=N(_),j.status="success"}catch(T){j.status="error",j.value=T}return j}f.resolve=v;function v(N){return N instanceof this?N:a.resolve(new this(o),N)}f.reject=S;function S(N){var _=new this(o);return a.reject(_,N)}f.all=C;function C(N){var _=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=N.length,T=!1;if(!j)return this.resolve([]);for(var M=new Array(j),V=0,H=-1,P=new this(o);++H<j;)F(N[H],H);return P;function F(I,R){_.resolve(I).then(U,function(A){T||(T=!0,a.reject(P,A))});function U(A){M[R]=A,++V===j&&!T&&(T=!0,a.resolve(P,M))}}}f.race=k;function k(N){var _=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=N.length,T=!1;if(!j)return this.resolve([]);for(var M=-1,V=new this(o);++M<j;)H(N[M]);return V;function H(P){_.resolve(P).then(function(F){T||(T=!0,a.resolve(V,F))},function(F){T||(T=!0,a.reject(V,F))})}}},{1:1}],3:[function(n,r,i){(function(s){typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof jc<"u"?jc:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,r,i){var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(xe){return typeof xe}:function(xe){return xe&&typeof Symbol=="function"&&xe.constructor===Symbol&&xe!==Symbol.prototype?"symbol":typeof xe};function o(xe,Re){if(!(xe instanceof Re))throw new TypeError("Cannot call a class as a function")}function a(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var l=a();function u(){try{if(!l||!l.open)return!1;var xe=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),Re=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!xe||Re)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function d(xe,Re){xe=xe||[],Re=Re||{};try{return new Blob(xe,Re)}catch(Fe){if(Fe.name!=="TypeError")throw Fe;for(var _e=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,Ve=new _e,Ge=0;Ge<xe.length;Ge+=1)Ve.append(xe[Ge]);return Ve.getBlob(Re.type)}}typeof Promise>"u"&&n(3);var f=Promise;function h(xe,Re){Re&&xe.then(function(_e){Re(null,_e)},function(_e){Re(_e)})}function m(xe,Re,_e){typeof Re=="function"&&xe.then(Re),typeof _e=="function"&&xe.catch(_e)}function y(xe){return typeof xe!="string"&&(console.warn(xe+" used as a key, but it is not a string."),xe=String(xe)),xe}function g(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var w="local-forage-detect-blob-support",v=void 0,S={},C=Object.prototype.toString,k="readonly",N="readwrite";function _(xe){for(var Re=xe.length,_e=new ArrayBuffer(Re),Ve=new Uint8Array(_e),Ge=0;Ge<Re;Ge++)Ve[Ge]=xe.charCodeAt(Ge);return _e}function j(xe){return new f(function(Re){var _e=xe.transaction(w,N),Ve=d([""]);_e.objectStore(w).put(Ve,"key"),_e.onabort=function(Ge){Ge.preventDefault(),Ge.stopPropagation(),Re(!1)},_e.oncomplete=function(){var Ge=navigator.userAgent.match(/Chrome\/(\d+)/),Fe=navigator.userAgent.match(/Edge\//);Re(Fe||!Ge||parseInt(Ge[1],10)>=43)}}).catch(function(){return!1})}function T(xe){return typeof v=="boolean"?f.resolve(v):j(xe).then(function(Re){return v=Re,v})}function M(xe){var Re=S[xe.name],_e={};_e.promise=new f(function(Ve,Ge){_e.resolve=Ve,_e.reject=Ge}),Re.deferredOperations.push(_e),Re.dbReady?Re.dbReady=Re.dbReady.then(function(){return _e.promise}):Re.dbReady=_e.promise}function V(xe){var Re=S[xe.name],_e=Re.deferredOperations.pop();if(_e)return _e.resolve(),_e.promise}function H(xe,Re){var _e=S[xe.name],Ve=_e.deferredOperations.pop();if(Ve)return Ve.reject(Re),Ve.promise}function P(xe,Re){return new f(function(_e,Ve){if(S[xe.name]=S[xe.name]||$(),xe.db)if(Re)M(xe),xe.db.close();else return _e(xe.db);var Ge=[xe.name];Re&&Ge.push(xe.version);var Fe=l.open.apply(l,Ge);Re&&(Fe.onupgradeneeded=function(pt){var St=Fe.result;try{St.createObjectStore(xe.storeName),pt.oldVersion<=1&&St.createObjectStore(w)}catch(zt){if(zt.name==="ConstraintError")console.warn('The database "'+xe.name+'" has been upgraded from version '+pt.oldVersion+" to version "+pt.newVersion+', but the storage "'+xe.storeName+'" already exists.');else throw zt}}),Fe.onerror=function(pt){pt.preventDefault(),Ve(Fe.error)},Fe.onsuccess=function(){var pt=Fe.result;pt.onversionchange=function(St){St.target.close()},_e(pt),V(xe)}})}function F(xe){return P(xe,!1)}function I(xe){return P(xe,!0)}function R(xe,Re){if(!xe.db)return!0;var _e=!xe.db.objectStoreNames.contains(xe.storeName),Ve=xe.version<xe.db.version,Ge=xe.version>xe.db.version;if(Ve&&(xe.version!==Re&&console.warn('The database "'+xe.name+`" can't be downgraded from version `+xe.db.version+" to version "+xe.version+"."),xe.version=xe.db.version),Ge||_e){if(_e){var Fe=xe.db.version+1;Fe>xe.version&&(xe.version=Fe)}return!0}return!1}function U(xe){return new f(function(Re,_e){var Ve=new FileReader;Ve.onerror=_e,Ve.onloadend=function(Ge){var Fe=btoa(Ge.target.result||"");Re({__local_forage_encoded_blob:!0,data:Fe,type:xe.type})},Ve.readAsBinaryString(xe)})}function A(xe){var Re=_(atob(xe.data));return d([Re],{type:xe.type})}function W(xe){return xe&&xe.__local_forage_encoded_blob}function D(xe){var Re=this,_e=Re._initReady().then(function(){var Ve=S[Re._dbInfo.name];if(Ve&&Ve.dbReady)return Ve.dbReady});return m(_e,xe,xe),_e}function B(xe){M(xe);for(var Re=S[xe.name],_e=Re.forages,Ve=0;Ve<_e.length;Ve++){var Ge=_e[Ve];Ge._dbInfo.db&&(Ge._dbInfo.db.close(),Ge._dbInfo.db=null)}return xe.db=null,F(xe).then(function(Fe){return xe.db=Fe,R(xe)?I(xe):Fe}).then(function(Fe){xe.db=Re.db=Fe;for(var pt=0;pt<_e.length;pt++)_e[pt]._dbInfo.db=Fe}).catch(function(Fe){throw H(xe,Fe),Fe})}function L(xe,Re,_e,Ve){Ve===void 0&&(Ve=1);try{var Ge=xe.db.transaction(xe.storeName,Re);_e(null,Ge)}catch(Fe){if(Ve>0&&(!xe.db||Fe.name==="InvalidStateError"||Fe.name==="NotFoundError"))return f.resolve().then(function(){if(!xe.db||Fe.name==="NotFoundError"&&!xe.db.objectStoreNames.contains(xe.storeName)&&xe.version<=xe.db.version)return xe.db&&(xe.version=xe.db.version+1),I(xe)}).then(function(){return B(xe).then(function(){L(xe,Re,_e,Ve-1)})}).catch(_e);_e(Fe)}}function $(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function q(xe){var Re=this,_e={db:null};if(xe)for(var Ve in xe)_e[Ve]=xe[Ve];var Ge=S[_e.name];Ge||(Ge=$(),S[_e.name]=Ge),Ge.forages.push(Re),Re._initReady||(Re._initReady=Re.ready,Re.ready=D);var Fe=[];function pt(){return f.resolve()}for(var St=0;St<Ge.forages.length;St++){var zt=Ge.forages[St];zt!==Re&&Fe.push(zt._initReady().catch(pt))}var Nt=Ge.forages.slice(0);return f.all(Fe).then(function(){return _e.db=Ge.db,F(_e)}).then(function(At){return _e.db=At,R(_e,Re._defaultConfig.version)?I(_e):At}).then(function(At){_e.db=Ge.db=At,Re._dbInfo=_e;for(var Zt=0;Zt<Nt.length;Zt++){var Me=Nt[Zt];Me!==Re&&(Me._dbInfo.db=_e.db,Me._dbInfo.version=_e.version)}})}function Z(xe,Re){var _e=this;xe=y(xe);var Ve=new f(function(Ge,Fe){_e.ready().then(function(){L(_e._dbInfo,k,function(pt,St){if(pt)return Fe(pt);try{var zt=St.objectStore(_e._dbInfo.storeName),Nt=zt.get(xe);Nt.onsuccess=function(){var At=Nt.result;At===void 0&&(At=null),W(At)&&(At=A(At)),Ge(At)},Nt.onerror=function(){Fe(Nt.error)}}catch(At){Fe(At)}})}).catch(Fe)});return h(Ve,Re),Ve}function ie(xe,Re){var _e=this,Ve=new f(function(Ge,Fe){_e.ready().then(function(){L(_e._dbInfo,k,function(pt,St){if(pt)return Fe(pt);try{var zt=St.objectStore(_e._dbInfo.storeName),Nt=zt.openCursor(),At=1;Nt.onsuccess=function(){var Zt=Nt.result;if(Zt){var Me=Zt.value;W(Me)&&(Me=A(Me));var Qe=xe(Me,Zt.key,At++);Qe!==void 0?Ge(Qe):Zt.continue()}else Ge()},Nt.onerror=function(){Fe(Nt.error)}}catch(Zt){Fe(Zt)}})}).catch(Fe)});return h(Ve,Re),Ve}function ge(xe,Re,_e){var Ve=this;xe=y(xe);var Ge=new f(function(Fe,pt){var St;Ve.ready().then(function(){return St=Ve._dbInfo,C.call(Re)==="[object Blob]"?T(St.db).then(function(zt){return zt?Re:U(Re)}):Re}).then(function(zt){L(Ve._dbInfo,N,function(Nt,At){if(Nt)return pt(Nt);try{var Zt=At.objectStore(Ve._dbInfo.storeName);zt===null&&(zt=void 0);var Me=Zt.put(zt,xe);At.oncomplete=function(){zt===void 0&&(zt=null),Fe(zt)},At.onabort=At.onerror=function(){var Qe=Me.error?Me.error:Me.transaction.error;pt(Qe)}}catch(Qe){pt(Qe)}})}).catch(pt)});return h(Ge,_e),Ge}function re(xe,Re){var _e=this;xe=y(xe);var Ve=new f(function(Ge,Fe){_e.ready().then(function(){L(_e._dbInfo,N,function(pt,St){if(pt)return Fe(pt);try{var zt=St.objectStore(_e._dbInfo.storeName),Nt=zt.delete(xe);St.oncomplete=function(){Ge()},St.onerror=function(){Fe(Nt.error)},St.onabort=function(){var At=Nt.error?Nt.error:Nt.transaction.error;Fe(At)}}catch(At){Fe(At)}})}).catch(Fe)});return h(Ve,Re),Ve}function Y(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){L(Re._dbInfo,N,function(Fe,pt){if(Fe)return Ge(Fe);try{var St=pt.objectStore(Re._dbInfo.storeName),zt=St.clear();pt.oncomplete=function(){Ve()},pt.onabort=pt.onerror=function(){var Nt=zt.error?zt.error:zt.transaction.error;Ge(Nt)}}catch(Nt){Ge(Nt)}})}).catch(Ge)});return h(_e,xe),_e}function ne(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){L(Re._dbInfo,k,function(Fe,pt){if(Fe)return Ge(Fe);try{var St=pt.objectStore(Re._dbInfo.storeName),zt=St.count();zt.onsuccess=function(){Ve(zt.result)},zt.onerror=function(){Ge(zt.error)}}catch(Nt){Ge(Nt)}})}).catch(Ge)});return h(_e,xe),_e}function be(xe,Re){var _e=this,Ve=new f(function(Ge,Fe){if(xe<0){Ge(null);return}_e.ready().then(function(){L(_e._dbInfo,k,function(pt,St){if(pt)return Fe(pt);try{var zt=St.objectStore(_e._dbInfo.storeName),Nt=!1,At=zt.openKeyCursor();At.onsuccess=function(){var Zt=At.result;if(!Zt){Ge(null);return}xe===0||Nt?Ge(Zt.key):(Nt=!0,Zt.advance(xe))},At.onerror=function(){Fe(At.error)}}catch(Zt){Fe(Zt)}})}).catch(Fe)});return h(Ve,Re),Ve}function we(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){L(Re._dbInfo,k,function(Fe,pt){if(Fe)return Ge(Fe);try{var St=pt.objectStore(Re._dbInfo.storeName),zt=St.openKeyCursor(),Nt=[];zt.onsuccess=function(){var At=zt.result;if(!At){Ve(Nt);return}Nt.push(At.key),At.continue()},zt.onerror=function(){Ge(zt.error)}}catch(At){Ge(At)}})}).catch(Ge)});return h(_e,xe),_e}function te(xe,Re){Re=g.apply(this,arguments);var _e=this.config();xe=typeof xe!="function"&&xe||{},xe.name||(xe.name=xe.name||_e.name,xe.storeName=xe.storeName||_e.storeName);var Ve=this,Ge;if(!xe.name)Ge=f.reject("Invalid arguments");else{var Fe=xe.name===_e.name&&Ve._dbInfo.db,pt=Fe?f.resolve(Ve._dbInfo.db):F(xe).then(function(St){var zt=S[xe.name],Nt=zt.forages;zt.db=St;for(var At=0;At<Nt.length;At++)Nt[At]._dbInfo.db=St;return St});xe.storeName?Ge=pt.then(function(St){if(St.objectStoreNames.contains(xe.storeName)){var zt=St.version+1;M(xe);var Nt=S[xe.name],At=Nt.forages;St.close();for(var Zt=0;Zt<At.length;Zt++){var Me=At[Zt];Me._dbInfo.db=null,Me._dbInfo.version=zt}var Qe=new f(function(ae,K){var ee=l.open(xe.name,zt);ee.onerror=function(ue){var Ee=ee.result;Ee.close(),K(ue)},ee.onupgradeneeded=function(){var ue=ee.result;ue.deleteObjectStore(xe.storeName)},ee.onsuccess=function(){var ue=ee.result;ue.close(),ae(ue)}});return Qe.then(function(ae){Nt.db=ae;for(var K=0;K<At.length;K++){var ee=At[K];ee._dbInfo.db=ae,V(ee._dbInfo)}}).catch(function(ae){throw(H(xe,ae)||f.resolve()).catch(function(){}),ae})}}):Ge=pt.then(function(St){M(xe);var zt=S[xe.name],Nt=zt.forages;St.close();for(var At=0;At<Nt.length;At++){var Zt=Nt[At];Zt._dbInfo.db=null}var Me=new f(function(Qe,ae){var K=l.deleteDatabase(xe.name);K.onerror=function(){var ee=K.result;ee&&ee.close(),ae(K.error)},K.onblocked=function(){console.warn('dropInstance blocked for database "'+xe.name+'" until all open connections are closed')},K.onsuccess=function(){var ee=K.result;ee&&ee.close(),Qe(ee)}});return Me.then(function(Qe){zt.db=Qe;for(var ae=0;ae<Nt.length;ae++){var K=Nt[ae];V(K._dbInfo)}}).catch(function(Qe){throw(H(xe,Qe)||f.resolve()).catch(function(){}),Qe})})}return h(Ge,Re),Ge}var fe={_driver:"asyncStorage",_initStorage:q,_support:u(),iterate:ie,getItem:Z,setItem:ge,removeItem:re,clear:Y,length:ne,key:be,keys:we,dropInstance:te};function O(){return typeof openDatabase=="function"}var pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",he="~~local_forage_type~",le=/^~~local_forage_type~([^~]+)~/,oe="__lfsc__:",Q=oe.length,de="arbf",Ne="blob",Ce="si08",Ae="ui08",Ue="uic8",Se="si16",ve="si32",je="ur16",Te="ui32",ce="fl32",se="fl64",ye=Q+de.length,ke=Object.prototype.toString;function ze(xe){var Re=xe.length*.75,_e=xe.length,Ve,Ge=0,Fe,pt,St,zt;xe[xe.length-1]==="="&&(Re--,xe[xe.length-2]==="="&&Re--);var Nt=new ArrayBuffer(Re),At=new Uint8Array(Nt);for(Ve=0;Ve<_e;Ve+=4)Fe=pe.indexOf(xe[Ve]),pt=pe.indexOf(xe[Ve+1]),St=pe.indexOf(xe[Ve+2]),zt=pe.indexOf(xe[Ve+3]),At[Ge++]=Fe<<2|pt>>4,At[Ge++]=(pt&15)<<4|St>>2,At[Ge++]=(St&3)<<6|zt&63;return Nt}function qe(xe){var Re=new Uint8Array(xe),_e="",Ve;for(Ve=0;Ve<Re.length;Ve+=3)_e+=pe[Re[Ve]>>2],_e+=pe[(Re[Ve]&3)<<4|Re[Ve+1]>>4],_e+=pe[(Re[Ve+1]&15)<<2|Re[Ve+2]>>6],_e+=pe[Re[Ve+2]&63];return Re.length%3===2?_e=_e.substring(0,_e.length-1)+"=":Re.length%3===1&&(_e=_e.substring(0,_e.length-2)+"=="),_e}function ot(xe,Re){var _e="";if(xe&&(_e=ke.call(xe)),xe&&(_e==="[object ArrayBuffer]"||xe.buffer&&ke.call(xe.buffer)==="[object ArrayBuffer]")){var Ve,Ge=oe;xe instanceof ArrayBuffer?(Ve=xe,Ge+=de):(Ve=xe.buffer,_e==="[object Int8Array]"?Ge+=Ce:_e==="[object Uint8Array]"?Ge+=Ae:_e==="[object Uint8ClampedArray]"?Ge+=Ue:_e==="[object Int16Array]"?Ge+=Se:_e==="[object Uint16Array]"?Ge+=je:_e==="[object Int32Array]"?Ge+=ve:_e==="[object Uint32Array]"?Ge+=Te:_e==="[object Float32Array]"?Ge+=ce:_e==="[object Float64Array]"?Ge+=se:Re(new Error("Failed to get type for BinaryArray"))),Re(Ge+qe(Ve))}else if(_e==="[object Blob]"){var Fe=new FileReader;Fe.onload=function(){var pt=he+xe.type+"~"+qe(this.result);Re(oe+Ne+pt)},Fe.readAsArrayBuffer(xe)}else try{Re(JSON.stringify(xe))}catch(pt){console.error("Couldn't convert value into a JSON string: ",xe),Re(null,pt)}}function Ze(xe){if(xe.substring(0,Q)!==oe)return JSON.parse(xe);var Re=xe.substring(ye),_e=xe.substring(Q,ye),Ve;if(_e===Ne&&le.test(Re)){var Ge=Re.match(le);Ve=Ge[1],Re=Re.substring(Ge[0].length)}var Fe=ze(Re);switch(_e){case de:return Fe;case Ne:return d([Fe],{type:Ve});case Ce:return new Int8Array(Fe);case Ae:return new Uint8Array(Fe);case Ue:return new Uint8ClampedArray(Fe);case Se:return new Int16Array(Fe);case je:return new Uint16Array(Fe);case ve:return new Int32Array(Fe);case Te:return new Uint32Array(Fe);case ce:return new Float32Array(Fe);case se:return new Float64Array(Fe);default:throw new Error("Unkown type: "+_e)}}var _t={serialize:ot,deserialize:Ze,stringToBuffer:ze,bufferToString:qe};function tt(xe,Re,_e,Ve){xe.executeSql("CREATE TABLE IF NOT EXISTS "+Re.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],_e,Ve)}function gt(xe){var Re=this,_e={db:null};if(xe)for(var Ve in xe)_e[Ve]=typeof xe[Ve]!="string"?xe[Ve].toString():xe[Ve];var Ge=new f(function(Fe,pt){try{_e.db=openDatabase(_e.name,String(_e.version),_e.description,_e.size)}catch(St){return pt(St)}_e.db.transaction(function(St){tt(St,_e,function(){Re._dbInfo=_e,Fe()},function(zt,Nt){pt(Nt)})},pt)});return _e.serializer=_t,Ge}function dt(xe,Re,_e,Ve,Ge,Fe){xe.executeSql(_e,Ve,Ge,function(pt,St){St.code===St.SYNTAX_ERR?pt.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[Re.storeName],function(zt,Nt){Nt.rows.length?Fe(zt,St):tt(zt,Re,function(){zt.executeSql(_e,Ve,Ge,Fe)},Fe)},Fe):Fe(pt,St)},Fe)}function wt(xe,Re){var _e=this;xe=y(xe);var Ve=new f(function(Ge,Fe){_e.ready().then(function(){var pt=_e._dbInfo;pt.db.transaction(function(St){dt(St,pt,"SELECT * FROM "+pt.storeName+" WHERE key = ? LIMIT 1",[xe],function(zt,Nt){var At=Nt.rows.length?Nt.rows.item(0).value:null;At&&(At=pt.serializer.deserialize(At)),Ge(At)},function(zt,Nt){Fe(Nt)})})}).catch(Fe)});return h(Ve,Re),Ve}function Dt(xe,Re){var _e=this,Ve=new f(function(Ge,Fe){_e.ready().then(function(){var pt=_e._dbInfo;pt.db.transaction(function(St){dt(St,pt,"SELECT * FROM "+pt.storeName,[],function(zt,Nt){for(var At=Nt.rows,Zt=At.length,Me=0;Me<Zt;Me++){var Qe=At.item(Me),ae=Qe.value;if(ae&&(ae=pt.serializer.deserialize(ae)),ae=xe(ae,Qe.key,Me+1),ae!==void 0){Ge(ae);return}}Ge()},function(zt,Nt){Fe(Nt)})})}).catch(Fe)});return h(Ve,Re),Ve}function Kt(xe,Re,_e,Ve){var Ge=this;xe=y(xe);var Fe=new f(function(pt,St){Ge.ready().then(function(){Re===void 0&&(Re=null);var zt=Re,Nt=Ge._dbInfo;Nt.serializer.serialize(Re,function(At,Zt){Zt?St(Zt):Nt.db.transaction(function(Me){dt(Me,Nt,"INSERT OR REPLACE INTO "+Nt.storeName+" (key, value) VALUES (?, ?)",[xe,At],function(){pt(zt)},function(Qe,ae){St(ae)})},function(Me){if(Me.code===Me.QUOTA_ERR){if(Ve>0){pt(Kt.apply(Ge,[xe,zt,_e,Ve-1]));return}St(Me)}})})}).catch(St)});return h(Fe,_e),Fe}function rn(xe,Re,_e){return Kt.apply(this,[xe,Re,_e,1])}function pn(xe,Re){var _e=this;xe=y(xe);var Ve=new f(function(Ge,Fe){_e.ready().then(function(){var pt=_e._dbInfo;pt.db.transaction(function(St){dt(St,pt,"DELETE FROM "+pt.storeName+" WHERE key = ?",[xe],function(){Ge()},function(zt,Nt){Fe(Nt)})})}).catch(Fe)});return h(Ve,Re),Ve}function cn(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){var Fe=Re._dbInfo;Fe.db.transaction(function(pt){dt(pt,Fe,"DELETE FROM "+Fe.storeName,[],function(){Ve()},function(St,zt){Ge(zt)})})}).catch(Ge)});return h(_e,xe),_e}function kt(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){var Fe=Re._dbInfo;Fe.db.transaction(function(pt){dt(pt,Fe,"SELECT COUNT(key) as c FROM "+Fe.storeName,[],function(St,zt){var Nt=zt.rows.item(0).c;Ve(Nt)},function(St,zt){Ge(zt)})})}).catch(Ge)});return h(_e,xe),_e}function rt(xe,Re){var _e=this,Ve=new f(function(Ge,Fe){_e.ready().then(function(){var pt=_e._dbInfo;pt.db.transaction(function(St){dt(St,pt,"SELECT key FROM "+pt.storeName+" WHERE id = ? LIMIT 1",[xe+1],function(zt,Nt){var At=Nt.rows.length?Nt.rows.item(0).key:null;Ge(At)},function(zt,Nt){Fe(Nt)})})}).catch(Fe)});return h(Ve,Re),Ve}function Tt(xe){var Re=this,_e=new f(function(Ve,Ge){Re.ready().then(function(){var Fe=Re._dbInfo;Fe.db.transaction(function(pt){dt(pt,Fe,"SELECT key FROM "+Fe.storeName,[],function(St,zt){for(var Nt=[],At=0;At<zt.rows.length;At++)Nt.push(zt.rows.item(At).key);Ve(Nt)},function(St,zt){Ge(zt)})})}).catch(Ge)});return h(_e,xe),_e}function Mt(xe){return new f(function(Re,_e){xe.transaction(function(Ve){Ve.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(Ge,Fe){for(var pt=[],St=0;St<Fe.rows.length;St++)pt.push(Fe.rows.item(St).name);Re({db:xe,storeNames:pt})},function(Ge,Fe){_e(Fe)})},function(Ve){_e(Ve)})})}function Rt(xe,Re){Re=g.apply(this,arguments);var _e=this.config();xe=typeof xe!="function"&&xe||{},xe.name||(xe.name=xe.name||_e.name,xe.storeName=xe.storeName||_e.storeName);var Ve=this,Ge;return xe.name?Ge=new f(function(Fe){var pt;xe.name===_e.name?pt=Ve._dbInfo.db:pt=openDatabase(xe.name,"","",0),xe.storeName?Fe({db:pt,storeNames:[xe.storeName]}):Fe(Mt(pt))}).then(function(Fe){return new f(function(pt,St){Fe.db.transaction(function(zt){function Nt(Qe){return new f(function(ae,K){zt.executeSql("DROP TABLE IF EXISTS "+Qe,[],function(){ae()},function(ee,ue){K(ue)})})}for(var At=[],Zt=0,Me=Fe.storeNames.length;Zt<Me;Zt++)At.push(Nt(Fe.storeNames[Zt]));f.all(At).then(function(){pt()}).catch(function(Qe){St(Qe)})},function(zt){St(zt)})})}):Ge=f.reject("Invalid arguments"),h(Ge,Re),Ge}var Ct={_driver:"webSQLStorage",_initStorage:gt,_support:O(),iterate:Dt,getItem:wt,setItem:rn,removeItem:pn,clear:cn,length:kt,key:rt,keys:Tt,dropInstance:Rt};function Gt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Lt(xe,Re){var _e=xe.name+"/";return xe.storeName!==Re.storeName&&(_e+=xe.storeName+"/"),_e}function $t(){var xe="_localforage_support_test";try{return localStorage.setItem(xe,!0),localStorage.removeItem(xe),!1}catch{return!0}}function Qt(){return!$t()||localStorage.length>0}function Ye(xe){var Re=this,_e={};if(xe)for(var Ve in xe)_e[Ve]=xe[Ve];return _e.keyPrefix=Lt(xe,Re._defaultConfig),Qt()?(Re._dbInfo=_e,_e.serializer=_t,f.resolve()):f.reject()}function bt(xe){var Re=this,_e=Re.ready().then(function(){for(var Ve=Re._dbInfo.keyPrefix,Ge=localStorage.length-1;Ge>=0;Ge--){var Fe=localStorage.key(Ge);Fe.indexOf(Ve)===0&&localStorage.removeItem(Fe)}});return h(_e,xe),_e}function Ie(xe,Re){var _e=this;xe=y(xe);var Ve=_e.ready().then(function(){var Ge=_e._dbInfo,Fe=localStorage.getItem(Ge.keyPrefix+xe);return Fe&&(Fe=Ge.serializer.deserialize(Fe)),Fe});return h(Ve,Re),Ve}function it(xe,Re){var _e=this,Ve=_e.ready().then(function(){for(var Ge=_e._dbInfo,Fe=Ge.keyPrefix,pt=Fe.length,St=localStorage.length,zt=1,Nt=0;Nt<St;Nt++){var At=localStorage.key(Nt);if(At.indexOf(Fe)===0){var Zt=localStorage.getItem(At);if(Zt&&(Zt=Ge.serializer.deserialize(Zt)),Zt=xe(Zt,At.substring(pt),zt++),Zt!==void 0)return Zt}}});return h(Ve,Re),Ve}function ct(xe,Re){var _e=this,Ve=_e.ready().then(function(){var Ge=_e._dbInfo,Fe;try{Fe=localStorage.key(xe)}catch{Fe=null}return Fe&&(Fe=Fe.substring(Ge.keyPrefix.length)),Fe});return h(Ve,Re),Ve}function Ut(xe){var Re=this,_e=Re.ready().then(function(){for(var Ve=Re._dbInfo,Ge=localStorage.length,Fe=[],pt=0;pt<Ge;pt++){var St=localStorage.key(pt);St.indexOf(Ve.keyPrefix)===0&&Fe.push(St.substring(Ve.keyPrefix.length))}return Fe});return h(_e,xe),_e}function Et(xe){var Re=this,_e=Re.keys().then(function(Ve){return Ve.length});return h(_e,xe),_e}function yn(xe,Re){var _e=this;xe=y(xe);var Ve=_e.ready().then(function(){var Ge=_e._dbInfo;localStorage.removeItem(Ge.keyPrefix+xe)});return h(Ve,Re),Ve}function nn(xe,Re,_e){var Ve=this;xe=y(xe);var Ge=Ve.ready().then(function(){Re===void 0&&(Re=null);var Fe=Re;return new f(function(pt,St){var zt=Ve._dbInfo;zt.serializer.serialize(Re,function(Nt,At){if(At)St(At);else try{localStorage.setItem(zt.keyPrefix+xe,Nt),pt(Fe)}catch(Zt){(Zt.name==="QuotaExceededError"||Zt.name==="NS_ERROR_DOM_QUOTA_REACHED")&&St(Zt),St(Zt)}})})});return h(Ge,_e),Ge}function rr(xe,Re){if(Re=g.apply(this,arguments),xe=typeof xe!="function"&&xe||{},!xe.name){var _e=this.config();xe.name=xe.name||_e.name,xe.storeName=xe.storeName||_e.storeName}var Ve=this,Ge;return xe.name?Ge=new f(function(Fe){xe.storeName?Fe(Lt(xe,Ve._defaultConfig)):Fe(xe.name+"/")}).then(function(Fe){for(var pt=localStorage.length-1;pt>=0;pt--){var St=localStorage.key(pt);St.indexOf(Fe)===0&&localStorage.removeItem(St)}}):Ge=f.reject("Invalid arguments"),h(Ge,Re),Ge}var xn={_driver:"localStorageWrapper",_initStorage:Ye,_support:Gt(),iterate:it,getItem:Ie,setItem:nn,removeItem:yn,clear:bt,length:Et,key:ct,keys:Ut,dropInstance:rr},Bn=function(Re,_e){return Re===_e||typeof Re=="number"&&typeof _e=="number"&&isNaN(Re)&&isNaN(_e)},dr=function(Re,_e){for(var Ve=Re.length,Ge=0;Ge<Ve;){if(Bn(Re[Ge],_e))return!0;Ge++}return!1},gr=Array.isArray||function(xe){return Object.prototype.toString.call(xe)==="[object Array]"},on={},Fn={},Xn={INDEXEDDB:fe,WEBSQL:Ct,LOCALSTORAGE:xn},yt=[Xn.INDEXEDDB._driver,Xn.WEBSQL._driver,Xn.LOCALSTORAGE._driver],Wt=["dropInstance"],An=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Wt),Un={description:"",driver:yt.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Rr(xe,Re){xe[Re]=function(){var _e=arguments;return xe.ready().then(function(){return xe[Re].apply(xe,_e)})}}function yr(){for(var xe=1;xe<arguments.length;xe++){var Re=arguments[xe];if(Re)for(var _e in Re)Re.hasOwnProperty(_e)&&(gr(Re[_e])?arguments[0][_e]=Re[_e].slice():arguments[0][_e]=Re[_e])}return arguments[0]}var Ps=function(){function xe(Re){o(this,xe);for(var _e in Xn)if(Xn.hasOwnProperty(_e)){var Ve=Xn[_e],Ge=Ve._driver;this[_e]=Ge,on[Ge]||this.defineDriver(Ve)}this._defaultConfig=yr({},Un),this._config=yr({},this._defaultConfig,Re),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return xe.prototype.config=function(_e){if((typeof _e>"u"?"undefined":s(_e))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var Ve in _e){if(Ve==="storeName"&&(_e[Ve]=_e[Ve].replace(/\W/g,"_")),Ve==="version"&&typeof _e[Ve]!="number")return new Error("Database version must be a number.");this._config[Ve]=_e[Ve]}return"driver"in _e&&_e.driver?this.setDriver(this._config.driver):!0}else return typeof _e=="string"?this._config[_e]:this._config},xe.prototype.defineDriver=function(_e,Ve,Ge){var Fe=new f(function(pt,St){try{var zt=_e._driver,Nt=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!_e._driver){St(Nt);return}for(var At=An.concat("_initStorage"),Zt=0,Me=At.length;Zt<Me;Zt++){var Qe=At[Zt],ae=!dr(Wt,Qe);if((ae||_e[Qe])&&typeof _e[Qe]!="function"){St(Nt);return}}var K=function(){for(var Ee=function(Be){return function(){var De=new Error("Method "+Be+" is not implemented by the current driver"),Xe=f.reject(De);return h(Xe,arguments[arguments.length-1]),Xe}},Je=0,Ke=Wt.length;Je<Ke;Je++){var Oe=Wt[Je];_e[Oe]||(_e[Oe]=Ee(Oe))}};K();var ee=function(Ee){on[zt]&&console.info("Redefining LocalForage driver: "+zt),on[zt]=_e,Fn[zt]=Ee,pt()};"_support"in _e?_e._support&&typeof _e._support=="function"?_e._support().then(ee,St):ee(!!_e._support):ee(!0)}catch(ue){St(ue)}});return m(Fe,Ve,Ge),Fe},xe.prototype.driver=function(){return this._driver||null},xe.prototype.getDriver=function(_e,Ve,Ge){var Fe=on[_e]?f.resolve(on[_e]):f.reject(new Error("Driver not found."));return m(Fe,Ve,Ge),Fe}
97,xe.prototype.getSerializer=function(_e){var Ve=f.resolve(_t);return m(Ve,_e),Ve},xe.prototype.ready=function(_e){var Ve=this,Ge=Ve._driverSet.then(function(){return Ve._ready===null&&(Ve._ready=Ve._initDriver()),Ve._ready});return m(Ge,_e,_e),Ge},xe.prototype.setDriver=function(_e,Ve,Ge){var Fe=this;gr(_e)||(_e=[_e]);var pt=this._getSupportedDrivers(_e);function St(){Fe._config.driver=Fe.driver()}function zt(Zt){return Fe._extend(Zt),St(),Fe._ready=Fe._initStorage(Fe._config),Fe._ready}function Nt(Zt){return function(){var Me=0;function Qe(){for(;Me<Zt.length;){var ae=Zt[Me];return Me++,Fe._dbInfo=null,Fe._ready=null,Fe.getDriver(ae).then(zt).catch(Qe)}St();var K=new Error("No available storage method found.");return Fe._driverSet=f.reject(K),Fe._driverSet}return Qe()}}var At=this._driverSet!==null?this._driverSet.catch(function(){return f.resolve()}):f.resolve();return this._driverSet=At.then(function(){var Zt=pt[0];return Fe._dbInfo=null,Fe._ready=null,Fe.getDriver(Zt).then(function(Me){Fe._driver=Me._driver,St(),Fe._wrapLibraryMethodsWithReady(),Fe._initDriver=Nt(pt)})}).catch(function(){St();var Zt=new Error("No available storage method found.");return Fe._driverSet=f.reject(Zt),Fe._driverSet}),m(this._driverSet,Ve,Ge),this._driverSet},xe.prototype.supports=function(_e){return!!Fn[_e]},xe.prototype._extend=function(_e){yr(this,_e)},xe.prototype._getSupportedDrivers=function(_e){for(var Ve=[],Ge=0,Fe=_e.length;Ge<Fe;Ge++){var pt=_e[Ge];this.supports(pt)&&Ve.push(pt)}return Ve},xe.prototype._wrapLibraryMethodsWithReady=function(){for(var _e=0,Ve=An.length;_e<Ve;_e++)Rr(this,An[_e])},xe.prototype.createInstance=function(_e){return new xe(_e)},xe}(),Kr=new Ps;r.exports=Kr},{3:3}]},{},[4])(4)})}(Q1)),Q1.exports}var BJ=MJ();const jn=Vo(BJ),RJ=Object.freeze(Object.defineProperty({__proto__:null,default:jn},Symbol.toStringTag,{value:"Module"})),Z1=t=>`${t.type}-${t.id}`,AS=t=>{const[e,n]=t.split("-");return{type:e,id:parseInt(n)}};function Xy(t,e){switch(t.type){case J.Song:return`song:${t.id}`;case J.TextNode:return`text_node:${t.id}`;case J.EmbeddingNode:return`embedding_node:${t.id}`;case J.VisualMediaNode:return`visual_node:${t.id}`;case J.Bloob:{const n=e.getBloobById(t.id);return n?`song:${n.songId}`:null}case J.Note:{const n=e.getNoteById(t.id);if(!n)return null;const r=e.getBloobById(n.bloobId);return r?`song:${r.songId}`:null}default:return null}}let Ci=null,MS=null,bm=!1,dy=null,fy=null;const BS=new Set;function lz(){const t=ya();for(const e of BS)try{e(t)}catch{}}function ya(){return bm&&Ci!=null&&Ci.readyState===WebSocket.OPEN}function OJ(t){return BS.add(t),()=>{BS.delete(t)}}function cz(t){MS=t}function uz(t,e){dy=t,fy=e}function DJ(t){if(Ci!=null){try{Ci.close()}catch{}Ci=null}bm=!1;const e=new WebSocket(t);Ci=e,e.onopen=()=>{bm=!0,dy==null||dy(),lz()},e.onmessage=n=>{try{const r=JSON.parse(n.data);MS&&MS(r)}catch{}},e.onclose=()=>{Ci=null,bm=!1,fy==null||fy(),lz()},e.onerror=()=>{}}function LJ(){if(Ci!=null){try{Ci.close()}catch{}Ci=null}bm=!1}function dz(t){!ya()||!Ci||Ci.send(JSON.stringify({type:"subscribe",channels:t}))}function FJ(t){!ya()||!Ci||Ci.send(JSON.stringify({type:"unsubscribe",channels:t}))}function $J(t,e){return!ya()||!Ci?!1:(Ci.send(JSON.stringify({type:"op",channel:t,kind:"canvas",payload:e})),!0)}function UJ(t,e,n){return!ya()||!Ci?!1:(Ci.send(JSON.stringify({type:"op",channel:t,kind:"chat",payload:{client_id:e,operations:n}})),!0)}function tD(t,e){return!ya()||!Ci?!1:(Ci.send(JSON.stringify({type:"presence",channel:t,payload:e})),!0)}const fz=t=>{const e=JSON.stringify({pitch:t.pitch,pitchInt:t.pitchInt,velocity:t.velocity,startBeat:t.startBeat,durationInBeats:t.durationInBeats});let n=0;for(let r=0;r<e.length;r++){const i=e.charCodeAt(r);n=(n<<5)-n+i,n=n&n}return n.toString(16)},J1=t=>{const e=t.join("|");let n=0;for(let r=0;r<e.length;r++){const i=e.charCodeAt(r);n=(n<<5)-n+i,n=n&n}return n.toString(16)},ym=(t,e,n)=>{if(!e[t])throw new Error(`Cannot increment reference for non-existent NoteDetails: ${t}`);e[t].referenceCount=(e[t].referenceCount||0)+1},hz=(t,e)=>{const n=e[t];return n?(n.referenceCount=(n.referenceCount||0)-1,n.referenceCount<=0?(delete e[t],!0):!1):!1},Pm=class Pm{constructor(e){Xt(this,"operationTracker");Xt(this,"settingsUpdateTracker");Xt(this,"chatHistoryOperationTracker");Xt(this,"cloudTimestamps",null);Xt(this,"localTimestamps",null);Xt(this,"pendingAudioFileUploads",new Set);Xt(this,"pendingAudioFileDeletes",new Set);Xt(this,"settingsSyncInProgress",!1);Xt(this,"CLOUD_TIMESTAMP_KEY","cai_cloud_timestamps");Xt(this,"LOCAL_TIMESTAMP_KEY","cai_last_update_timestamps");
97Xt(this,"OFFLINE_OPERATION_SETS_KEY","cai_offline_operation_sets");Xt(this,"OFFLINE_CHAT_HISTORY_OPERATIONS_KEY","cai_offline_chat_history_operations");Xt(this,"OFFLINE_SETTINGS_UPDATES_KEY","cai_offline_settings_updates");Pm.instance=this,this.operationTracker=e,this.operationTracker.setSyncManager(this),this.settingsUpdateTracker=new UY,this.settingsUpdateTracker.setSyncManager(this),this.chatHistoryOperationTracker=Gy.getInstance(),this.chatHistoryOperationTracker.setSyncManager(this),this.initializeCloudTimestampsCache()}isSyncing(){return this.settingsSyncInProgress}hasPendingOperations(){return!1}queueAndUploadAudioFile(e){this.pendingAudioFileUploads.add(e),this.uploadPendingAudioFiles().catch(()=>{})}getLastSyncTime(){var e;return((e=this.localTimestamps)==null?void 0:e.last_synced)||null}async initializeCloudTimestampsCache(){await Promise.all([this.loadLocalTimestamps(),this.loadCloudTimestamps()]),setTimeout(()=>{this.checkAndTriggerInitialSync()},1e3)}async isNetworkOnline(){if(!navigator.onLine)return!1;try{const{apiClient:e}=await ai(async()=>{const{apiClient:i}=await Promise.resolve().then(()=>AJ);return{apiClient:i}},void 0),n=new AbortController,r=setTimeout(()=>n.abort(),2e3);return await e.get("/health",{signal:n.signal}),clearTimeout(r),!0}catch{return!1}}async saveOfflineOperationSets(e){try{const r=await jn.getItem(this.OFFLINE_OPERATION_SETS_KEY)||[],i=new Set(r.map(a=>a.id)),s=e.filter(a=>!i.has(a.id)),o=[...r,...s];await jn.setItem(this.OFFLINE_OPERATION_SETS_KEY,o)}catch{}}async loadOfflineOperationSets(){try{return await jn.getItem(this.OFFLINE_OPERATION_SETS_KEY)||[]}catch{return[]}}async clearOfflineOperationSets(){try{await jn.removeItem(this.OFFLINE_OPERATION_SETS_KEY)}catch{}}async saveOfflineChatHistoryOperations(e){try{const r=await jn.getItem(this.OFFLINE_CHAT_HISTORY_OPERATIONS_KEY)||[],i=new Set(r.map(a=>`${a.timestamp}_${a.thread_id}_${a.operation_type}`)),s=e.filter(a=>!i.has(`${a.timestamp}_${a.thread_id}_${a.operation_type}`)),o=[...r,...s];await jn.setItem(this.OFFLINE_CHAT_HISTORY_OPERATIONS_KEY,o)}catch{}}async loadOfflineChatHistoryOperations(){try{return await jn.getItem(this.OFFLINE_CHAT_HISTORY_OPERATIONS_KEY)||[]}catch{return[]}}async clearOfflineChatHistoryOperations(){try{await jn.removeItem(this.OFFLINE_CHAT_HISTORY_OPERATIONS_KEY)}catch{}}async saveOfflineSettingsUpdates(e){try{const r=await jn.getItem(this.OFFLINE_SETTINGS_UPDATES_KEY)||{},i=this.deepMergeSettings(r,e);await jn.setItem(this.OFFLINE_SETTINGS_UPDATES_KEY,i)}catch{}}async loadOfflineSettingsUpdates(){try{return await jn.getItem(this.OFFLINE_SETTINGS_UPDATES_KEY)||{}}catch{return{}}}async clearOfflineSettingsUpdates(){try{await jn.removeItem(this.OFFLINE_SETTINGS_UPDATES_KEY)}catch{}}
97deepMergeSettings(e,n){const r={...e};for(const i in n)n[i]&&typeof n[i]=="object"&&!Array.isArray(n[i])&&e[i]&&typeof e[i]=="object"&&!Array.isArray(e[i])?r[i]=this.deepMergeSettings(e[i],n[i]):r[i]=n[i];return r}dispatchOperationSet(e){this.pendingAudioFileUploads.size>0&&this.uploadPendingAudioFiles().catch(()=>{});const n=this.channelFromOperationSet(e),r=Array.isArray(e.operations)?e.operations.some(i=>(i==null?void 0:i.operation_type)==="delete"):!1;if(r&&ar("[dispatchOperationSet] delete opset",{opSetId:e==null?void 0:e.id,channel:n,wsConnected:ya(),opTypes:(e.operations||[]).map(i=>({operation_type:i==null?void 0:i.operation_type,cai_object_type:i==null?void 0:i.cai_object_type,cai_object_id:i==null?void 0:i.cai_object_id,domain_type:i==null?void 0:i.domain_type,domain_id:i==null?void 0:i.domain_id}))}),n&&ya()&&$J(n,[e])){r&&ar("[dispatchOperationSet] delete opset sent over WS",{opSetId:e==null?void 0:e.id,channel:n});return}r&&ar("[dispatchOperationSet] delete opset queued offline",{opSetId:e==null?void 0:e.id,channel:n}),this.saveOfflineOperationSets([e]).catch(()=>{})}dispatchChatOp(e){const n=this.channelFromChatOp(e),r=this.operationTracker.clientId;ya()&&UJ(n,r,[e])||this.saveOfflineChatHistoryOperations([e]).catch(()=>{})}channelFromOperationSet(e){var u,d,f,h;const n=e.operations??[];if(n.length===0)return null;const r=n[0],i=r.domain_type??((u=r.value)==null?void 0:u.domain_type),s=r.domain_id??((d=r.value)==null?void 0:d.domain_id);if(i!=null&&s!=null)return`${{song:"song",text:"text_node",embedding:"embedding_node",visual:"visual_node"}[i]??i}:${s}`;const o=((f=r.value)==null?void 0:f.songId)??((h=r.value)==null?void 0:h.inSongId);if(o!=null)return`song:${o}`;const a=r.cai_object_type,l=r.cai_object_id;if(a!=null&&l!=null){const y={Song:"song",TextNode:"text_node",EmbeddingNode:"embedding_node",VisualMediaNode:"visual_node"}[a];if(y!=null)return`${y}:${l}`}return null}channelFromChatOp(e){const n=e.value??{},r=n.objectType??"global",i=n.objectId??0;return r==="global"&&i===0?"global":`${{song:"song",text:"text_node",embedding:"embedding_node",visual:"visual_node"}[r]??r}:${i}`}async loadLocalTimestamps(){try{const e=await jn.getItem(this.LOCAL_TIMESTAMP_KEY);e?this.localTimestamps=e:this.localTimestamps={settings_timestamp:0,chat_history_timestamp:0,last_synced:0}}catch{this.localTimestamps={settings_timestamp:0,chat_history_timestamp:0,last_synced:0}}}saveLocalTimestamps(){this.localTimestamps&&jn.setItem(this.LOCAL_TIMESTAMP_KEY,this.localTimestamps).catch(()=>{})}updateLocalTimestamps(e){var n,r,i,s,o;this.localTimestamps={settings_timestamp:e.settings_timestamp,chat_history_timestamp:e.chat_history_timestamp??((n=this.localTimestamps)==null?void 0:n.chat_history_timestamp)??0,last_synced:e.last_synced??Date.now(),canvas_object_timestamps:e.canvas_object_timestamps!==void 0?this.mergeObjectTimestamps((r=this.localTimestamps)==null?void 0:r.canvas_object_timestamps,e.canvas_object_timestamps):(i=this.localTimestamps)==null?void 0:i.canvas_object_timestamps,thread_object_timestamps:e.thread_object_timestamps!==void 0?this.mergeObjectTimestamps((s=this.localTimestamps)==null?void 0:s.thread_object_timestamps,e.thread_object_timestamps):(o=this.localTimestamps)==null?void 0:o.thread_object_timestamps},this.saveLocalTimestamps()}async loadCloudTimestamps(){try{const e=await jn.getItem(this.CLOUD_TIMESTAMP_KEY);e&&(this.cloudTimestamps=e)}catch{}}saveCloudTimestamps(){this.cloudTimestamps&&jn.setItem(this.CLOUD_TIMESTAMP_KEY,this.cloudTimestamps).catch(()=>{})}updateLocalDomainTimestamp(e,n){if(this.localTimestamps){if(e==="global")this.localTimestamps.thread_object_timestamps||(this.localTimestamps.thread_object_timestamps={}),this.localTimestamps.thread_object_timestamps.global||(this.localTimestamps.thread_object_timestamps.global={}),this.localTimestamps.thread_object_timestamps.global[0]=n;else{const r=e.lastIndexOf(":");if(r===-1)return;const i=e.slice(0,r),s=parseInt(e.slice(r+1),10);if(Number.isNaN(s))return;const o=i==="song"?"song":i==="text_node"?"text":i==="embedding_node"?"embedding":i==="visual_node"?"visual":i;
97this.localTimestamps.canvas_object_timestamps||(this.localTimestamps.canvas_object_timestamps={}),this.localTimestamps.canvas_object_timestamps[i]||(this.localTimestamps.canvas_object_timestamps[i]={}),this.localTimestamps.canvas_object_timestamps[i][s]=n,this.localTimestamps.thread_object_timestamps||(this.localTimestamps.thread_object_timestamps={}),this.localTimestamps.thread_object_timestamps[o]||(this.localTimestamps.thread_object_timestamps[o]={}),this.localTimestamps.thread_object_timestamps[o][s]=n}this.saveLocalTimestamps()}}mergeObjectTimestamps(e,n){if(!n)return e??{};const r={...e??{}};for(const[i,s]of Object.entries(n))if(!(!s||typeof s!="object")){r[i]||(r[i]={});for(const[o,a]of Object.entries(s)){const l=typeof o=="string"?parseInt(o,10):o;if(Number.isNaN(l))continue;const u=r[i][l]??0;r[i][l]=Math.max(u,typeof a=="number"?a:0)}}return r}updateCloudTimestamps(e){var n,r,i;this.cloudTimestamps={settings_timestamp:e.settings_timestamp,chat_history_timestamp:e.chat_history_timestamp??((n=this.cloudTimestamps)==null?void 0:n.chat_history_timestamp)??0,last_updated:e.last_updated??Date.now(),canvas_object_timestamps:e.canvas_object_timestamps!==void 0?e.canvas_object_timestamps:(r=this.cloudTimestamps)==null?void 0:r.canvas_object_timestamps,thread_object_timestamps:e.thread_object_timestamps!==void 0?e.thread_object_timestamps:(i=this.cloudTimestamps)==null?void 0:i.thread_object_timestamps},this.saveCloudTimestamps()}async checkAndTriggerInitialSync(){try{const e=await this.fetchCloudTimestampsFromServer();e.success&&(this.updateCloudTimestamps({settings_timestamp:e.settings_timestamp||0,chat_history_timestamp:e.chat_history_timestamp||0,canvas_object_timestamps:e.canvas_object_timestamps,thread_object_timestamps:e.thread_object_timestamps}),this.pruneRevokedDomains());const n=this.getStaleDomainChannels();if(n.length>0){at.setState({isFetchingFromCloud:!0});try{const r=await tr.post("/api/v0/user-data/catch_up",{domains:n}),{state:i,domain_timestamps:s,roles_by_domain:o,policies_by_domain:a}=r.data;i&&Object.keys(i).length>0&&this.applyMergedStateToStore(i,{mergePartial:!0}),s&&typeof s=="object"&&this.updateLocalTimestampsFromCatchUp(s),o&&Object.keys(o).length>0&&at.getState().setDomainRolesByChannel(o),a&&Object.keys(a).length>0&&at.getState().setDomainPoliciesByChannel(a)}catch{ar("[CloudSyncManager] Initial catch-up failed")}finally{at.setState({isFetchingFromCloud:!1})}}await this.replayOfflineOpsAfterCatchUp(),await this.shouldSyncSettings()&&await this.performSettingsSync(),await this.checkAndLogInitialSettings()}catch{}}async checkAndLogInitialSettings(){try{const e=await this.hasExistingSettingsData(),n=this.cloudTimestamps&&this.cloudTimestamps.settings_timestamp>0;if(!e&&!n){const{initialSettingsState:r}=await ai(async()=>{const{initialSettingsState:s}=await Promise.resolve().then(()=>Cee);return{initialSettingsState:s}},void 0),i=this.serializeSettingsUpdates(r.settings);this.settingsUpdateTracker.addPendingUpdate(i)}}catch{}}async hasExistingSettingsData(){try{const e=this.getLocalStorageData();if(e&&e.state&&e.state.settings)return!0;const n=this.localTimestamps;return!!(n&&n.settings_timestamp>0)}catch{return!1}}async fetchCloudTimestampsFromServer(){try{const n=(await tr.get("/api/v0/user-data/timestamps",{headers:{"Content-Type":"application/json"}})).data;return{success:!0,operations_timestamp:n.operations_timestamp,settings_timestamp:n.settings_timestamp,chat_history_timestamp:n.chat_history_timestamp,canvas_object_timestamps:n.canvas_object_timestamps,thread_object_timestamps:n.thread_object_timestamps}}catch(e){if(e&&typeof e=="object"&&"response"in e){const n=e,r=n.response.status,i=n.response.statusText;return n.response.data,{success:!1,error:`HTTP ${r}: ${i}`}}return{success:!1,error:e instanceof Error?e.message:"Network error"}}}serializeSettingsUpdates(e){try{return JSON.parse(JSON.stringify(e))}catch{return{...e}}}async getUserId(){var e;try{const{supabase:n}=await ai(async()=>{const{supabase:i}=await Promise.resolve().then(()=>wJ);return{supabase:i}},void 0),{data:{session:r}}=await n.auth.getSession();return(e=r==null?void 0:r.user)!=null&&e.id?r.user.id:"anonymous-user"}catch{return"anonymous-user"}}async forceSync(){try{const e=await this.fetchCloudTimestampsFromServer();if(!e.success)return{success:!1,error:e.error||"Failed to fetch timestamps"};this.updateCloudTimestamps({settings_timestamp:e.settings_timestamp||0,chat_history_timestamp:e.chat_history_timestamp||0,canvas_object_timestamps:e.canvas_object_timestamps,thread_object_timestamps:e.thread_object_timestamps}),this.pruneRevokedDomains();const n=this.getStaleDomainChannels();if(n.length>0){const r=await tr.post("/api/v0/user-data/catch_up",{domains:n}),{state:i,domain_timestamps:s,roles_by_domain:o,policies_by_domain:a}=r.data;i&&Object.keys(i).length>0&&this.applyMergedStateToStore(i,{mergePartial:!0}),s&&typeof s=="object"&&this.updateLocalTimestampsFromCatchUp(s),o&&Object.keys(o).length>
970&&at.getState().setDomainRolesByChannel(o),a&&Object.keys(a).length>0&&at.getState().setDomainPoliciesByChannel(a)}return await this.replayOfflineOpsAfterCatchUp(),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Catch-up sync failed"}}}applyObjectStatesToStore(e){if(!(!e||e.length===0))try{const n={},r={},i={};for(const a of e){if(a.canvas&&typeof a.canvas=="object")for(const[u,d]of Object.entries(a.canvas))if(d&&typeof d=="object"){const f=n[u];n[u]=f&&typeof f=="object"?{...f,...d}:d}else n[u]=d;const l=`${a.object_type}:${a.object_id}`;if(i[l]||(i[l]=new Set),a.threads)for(const[u,d]of Object.entries(a.threads)){const f=typeof u=="string"?parseInt(u,10):Number(u);!isNaN(f)&&d&&(r[f]=d,i[l].add(f))}}const s=Object.keys(n).length>0?this.convertListsToSets(n):{},o=this.convertServerThreadsToFrontend(r);this.operationTracker.setSkipTrackingForRemoteOps(!0);try{at.setState(a=>{var l,u,d,f,h,m;if(s.songs&&(a.songs={...a.songs,...s.songs}),s.tracks&&(a.tracks={...a.tracks,...s.tracks}),s.bloobs&&(a.bloobs={...a.bloobs,...s.bloobs}),s.notes&&(a.notes={...a.notes,...s.notes}),s.noteDetails){a.noteDetails||(a.noteDetails={});for(const[y,g]of Object.entries(s.noteDetails))a.noteDetails[y]||(a.noteDetails[y]={...g,referenceCount:0})}if(s.textNodes&&(a.textNodes={...a.textNodes,...s.textNodes}),s.embeddingNodes&&(a.embeddingNodes={...a.embeddingNodes,...s.embeddingNodes}),s.visualMediaNodes&&(a.visualMediaNodes={...a.visualMediaNodes,...s.visualMediaNodes}),s.audioFiles){const y=Object.fromEntries(Object.entries(s.audioFiles).map(([g,w])=>{const v=w&&typeof w=="object"?w:{};return[g,{...v,referenceCount:v.referenceCount??1}]}));a.audioFiles={...a.audioFiles,...y}}Object.keys(o).length>0&&(a.threads={...a.threads,...o});for(const[y,g]of Object.entries(i)){if(!g||g.size===0)continue;const[w,v]=y.split(":"),S=Number(v);if(!Number.isNaN(S)){if(w==="song"&&((l=a.songs)!=null&&l[S])){const C=a.songs[S];C.threadIds||(C.threadIds=new Set),g.forEach(k=>C.threadIds.add(k))}else if(w==="text_node"&&((u=a.textNodes)!=null&&u[S])){const C=a.textNodes[S];C.threadIds||(C.threadIds=new Set),g.forEach(k=>C.threadIds.add(k))}else if(w==="embedding_node"&&((d=a.embeddingNodes)!=null&&d[S])){const C=a.embeddingNodes[S];C.threadIds||(C.threadIds=new Set),g.forEach(k=>C.threadIds.add(k))}else if(w==="visual_node"&&((f=a.visualMediaNodes)!=null&&f[S])){const C=a.visualMediaNodes[S];C.threadIds||(C.threadIds=new Set),g.forEach(k=>C.threadIds.add(k))}}}if(s.songs&&Object.values(s.songs).forEach(y=>{if((y==null?void 0:y.hasSoloedBloobs)===void 0&&(y!=null&&y.bloobIds)){const g=a.bloobs||{};y.hasSoloedBloobs=Array.from(y.bloobIds||[]).some(w=>{var v;return((v=g[w])==null?void 0:v.soloed)===!0})}}),s.songs&&a.noteDetails)for(const y of Object.values(s.songs)){const g=Array.from((y==null?void 0:y.bloobIds)??[]);for(const w of g){const v=(h=a.bloobs)==null?void 0:h[w],S=v?Array.from(v.noteIds??[]):[];for(const C of S){const k=(m=a.notes)==null?void 0:m[C],N=k==null?void 0:k.noteDetailsHash;N&&a.noteDetails[N]&&ym(N,a.noteDetails)}}}})}finally{this.operationTracker.setSkipTrackingForRemoteOps(!1)}}catch{}}applyMergedStateToStore(e,n){try{const r=this.convertListsToSets(e);ai(()=>Promise.resolve().then(()=>Sl),void 0).then(async({useCaiStore:i})=>{const s=i.getState(),o=(n==null?void 0:n.mergePartial)===!0;if(!o){const a=new Set(Object.keys(s.audioFiles||{}).map(Number)),l=new Set(r.audioFiles?Object.keys(r.audioFiles).map(Number):[]),u=Array.from(a).filter(d=>!l.has(d));if(u.length>0){const d=(await ai(async()=>{const{default:f}=await Promise.resolve().then(()=>RJ);return{default:f}},void 0)).default;await Promise.all(u.map(f=>d.removeItem(`audioFileData-${f}`)))}}if(i.setState(a=>{const l={...a,songs:o&&r.songs?{...a.songs||{},...r.songs}:r.songs||a.songs,tracks:o&&r.tracks?{...a.tracks||{},...r.tracks}:r.tracks||a.tracks,bloobs:o&&r.bloobs?{...a.bloobs||{},...r.bloobs}:r.bloobs||a.bloobs,notes:o&&r.notes?{...a.notes||{},...r.notes}:r.notes||a.notes,noteDetails:o&&r.noteDetails?{...a.noteDetails||{},...r.noteDetails}:r.noteDetails||a.noteDetails,textNodes:o&&r.textNodes?{...a.textNodes||{},...r.textNodes}:r.textNodes||a.textNodes,embeddingNodes:o&&r.embeddingNodes?{...a.embeddingNodes||{},...r.embeddingNodes}:r.embeddingNodes||a.embeddingNodes,visualMediaNodes:o&&r.visualMediaNodes?{...a.visualMediaNodes||{},...r.visualMediaNodes}:r.visualMediaNodes||a.visualMediaNodes,audioFiles:(()=>{const u=o&&r.audioFiles?{...a.audioFiles||{},...r.audioFiles}:r.audioFiles||a.audioFiles;return Object.fromEntries(Object.entries(u).map(([d,f])=>{const h=f&&typeof f=="object"?f:{};return[d,{...h,referenceCount:h.referenceCount??1}]}))})()};
97return Object.values(l.songs).forEach(u=>{const f=Array.from(u.bloobIds||[]).some(h=>{var m;return((m=l.bloobs[h])==null?void 0:m.soloed)===!0});u.hasSoloedBloobs=f}),l}),r.threads&&typeof r.threads=="object"){const a=r.threads,l={};Object.entries(a).forEach(([u,d])=>{const f=typeof u=="string"?parseInt(u,10):Number(u);!Number.isNaN(f)&&d&&(l[f]=d)}),Object.keys(l).length>0&&(o?this.mergeThreadsIntoStore(l):this.replaceThreadsInStore(l))}this.cleanupInvalidSelections(r)})}catch{}}cleanupInvalidSelections(e){try{ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{const r=n.getState(),i=Array.from(r.selectedCaiObjectKeys),s=[];i.forEach(o=>{var u,d,f,h,m,y,g,w,v,S,C,k,N,_;const a=AS(o);let l=!1;switch(a.type){case J.Bloob:l=((u=e.bloobs)==null?void 0:u[a.id])!==void 0||((d=r.bloobs)==null?void 0:d[a.id])!==void 0;break;case J.Song:l=((f=e.songs)==null?void 0:f[a.id])!==void 0||((h=r.songs)==null?void 0:h[a.id])!==void 0;break;case J.Track:l=((m=e.tracks)==null?void 0:m[a.id])!==void 0||((y=r.tracks)==null?void 0:y[a.id])!==void 0;break;case J.TextNode:l=((g=e.textNodes)==null?void 0:g[a.id])!==void 0||((w=r.textNodes)==null?void 0:w[a.id])!==void 0;break;case J.EmbeddingNode:l=((v=e.embeddingNodes)==null?void 0:v[a.id])!==void 0||((S=r.embeddingNodes)==null?void 0:S[a.id])!==void 0;break;case J.VisualMediaNode:l=((C=e.visualMediaNodes)==null?void 0:C[a.id])!==void 0||((k=r.visualMediaNodes)==null?void 0:k[a.id])!==void 0;break;case J.Note:l=((N=e.notes)==null?void 0:N[a.id])!==void 0||((_=r.notes)==null?void 0:_[a.id])!==void 0;break;default:l=!0}l||s.push(a)}),s.length>0&&r.deselectCaiObjects&&r.deselectCaiObjects(s)})}catch{}}convertListsToSets(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(n=>this.convertListsToSets(n));if(e.constructor===Object){const n={};for(const[r,i]of Object.entries(e))r==="bloobIds"||r==="noteIds"||r==="threadIds"||r==="trackIds"?n[r]=new Set(Array.isArray(i)?i:[]):n[r]=this.convertListsToSets(i);return n}return e}async performSettingsSync(){var e;if(!this.settingsSyncInProgress){this.settingsSyncInProgress=!0;try{const n=this.settingsUpdateTracker.getPendingUpdates(),r=Object.keys(n).length>0,i=this.localTimestamps&&this.cloudTimestamps&&this.localTimestamps.settings_timestamp<this.cloudTimestamps.settings_timestamp;if(!await this.isNetworkOnline()&&r){await this.saveOfflineSettingsUpdates(n),this.settingsUpdateTracker.clearPendingUpdates();return}this.cloudTimestamps&&this.cloudTimestamps.settings_timestamp>0&&i&&r&&this.settingsUpdateTracker.clearPendingUpdates();const a=Object.keys(this.settingsUpdateTracker.getPendingUpdates()).length>0,l=await this.loadOfflineSettingsUpdates(),u=Object.keys(l).length>0,d=a?this.deepMergeSettings(l,this.settingsUpdateTracker.getPendingUpdates()):l,f=Object.keys(d).length>0;if(!f&&!i)return;const h=f?this.serializeSettingsUpdates(d):{},m=await this.getUserId(),y={settings_updates:h,last_settings_update_timestamp:((e=this.localTimestamps)==null?void 0:e.settings_timestamp)||0,client_id:this.operationTracker.clientId},g=await this.sendSettingsSyncRequest(y);g.success?(this.updateLocalTimestamps({settings_timestamp:g.server_settings_timestamp}),g.needs_merged_state&&g.merged_settings&&this.applyMergedSettingsToLocalStorage(g.merged_settings),this.settingsUpdateTracker.clearPendingUpdates(),await this.clearOfflineSettingsUpdates()):!u&&a&&(await this.saveOfflineSettingsUpdates(this.settingsUpdateTracker.getPendingUpdates()),this.settingsUpdateTracker.clearPendingUpdates())}catch{try{const n=this.settingsUpdateTracker.getPendingUpdates();Object.keys(n).length>0&&(await this.isNetworkOnline()||(await this.saveOfflineSettingsUpdates(n),this.settingsUpdateTracker.clearPendingUpdates()))}catch{}}finally{this.settingsSyncInProgress=!1}}}async sendSettingsSyncRequest(e){try{return(await tr.post("/api/v0/user-data/settings_sync",e)).data}catch(n){return{success:!1,server_settings_timestamp:0,needs_merged_state:!1,message:n instanceof Error?n.message:"Unknown error"}}}mergeThreadsIntoStore(e){try{if(!e||typeof e!="object")return;ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{try{const r=this.convertServerThreadsToFrontend(e);if(Object.keys(r).length===0)return;n.setState(i=>{const s={...i.threads||{},...r},o=Object.values(s).filter(l=>l.songId==null||l.songId===void 0);let a=null;if(o.length>0){const l=o.map(d=>d.id),u=l.filter(d=>d<0);a=u.length>0?Math.min(...u):l[0]}i.threads=s,i.globalThreadId=a})}catch{}})}catch{}}convertServerThreadsToFrontend(e){const n={};return Object.entries(e).forEach(([r,i])=>{var h,m;const s=Number(r),o=i;if(isNaN(s)||s===0||!(o!=null&&o.content))return;const a=o.content,l=Array.isArray(a.messages)?a.messages:[];if(l.length===0&&((h=a.userPrompts)!=null&&h.length||(m=a.caiChatResponses)!=null&&m.length)){const y=a.userPrompts||[],g=a.caiChatResponses||[];for(let w=0;w<y.length;w++){const v=y[w],S=(v==null?void 0:v.timestamp)instanceof Date?v.timestamp.getTime():Date.now();if(l.push({id:`${S}-u-${s}`,timestamp:S,role:"user",body:typeof(v==null?void 0:v.message)=="str
97ing"?v.message:"(audio)"}),g[w]){const C=g[w],k=(C==null?void 0:C.timestamp)instanceof Date?C.timestamp.getTime():Date.now();l.push({id:`${k}-c-${s}`,timestamp:k,role:"cai",body:(C==null?void 0:C.message)??"",authorDisplayName:"Cai",links:(C==null?void 0:C.links)??[]})}}}const u=typeof o.createdAt=="number"?o.createdAt:Date.now(),d=typeof o.lastModified=="number"?o.lastModified:Date.now();let f=null;o.songId!=null&&o.songId!==void 0&&typeof o.songId=="number"&&(f=o.songId),n[s]={id:s,songId:f,objectType:o.objectType,objectId:o.objectId??f??0,content:{messages:l},createdAt:u,lastModified:d}}),n}replaceThreadsInStore(e){try{if(!e||typeof e!="object")return;ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{try{const r=this.convertServerThreadsToFrontend(e),i=Object.values(r).filter(o=>o.songId===null||o.songId===void 0);let s=null;if(i.length>0){const o=i.map(l=>l.id),a=o.filter(l=>l<0);a.length>0?s=Math.min(...a):s=o[0]}n.setState(o=>{o.threads=r,o.globalThreadId=s})}catch{}})}catch{}}applyMergedSettingsToLocalStorage(e){try{ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{n.setState(r=>{e.audio&&(r.settings.audio=e.audio),e.general&&(r.settings.general=e.general),e.recording&&(r.settings.recording=e.recording),e.appearance&&(r.settings.appearance=e.appearance)})})}catch{}}getLocalStorageData(){try{const e=localStorage.getItem("cai-storage");return e?JSON.parse(e):{}}catch{return{}}}saveToLocalStorage(e){try{localStorage.setItem("cai-storage",JSON.stringify(e))}catch{}}queueSettingsUpdate(e){this.settingsUpdateTracker.addPendingUpdate(e)}triggerSettingsSync(){this.settingsUpdateTracker.hasPendingUpdates()&&this.performSettingsSync().catch(()=>{})}async shouldSyncSettings(){if(this.settingsUpdateTracker.hasPendingUpdates())return!0;const n=await this.loadOfflineSettingsUpdates();return!!(Object.keys(n).length>0||this.cloudTimestamps&&this.localTimestamps&&this.localTimestamps.settings_timestamp<this.cloudTimestamps.settings_timestamp)}static getInstance(){return Pm.instance}getStaleDomainChannels(){var o,a,l,u,d,f;const e=[],n=(o=this.cloudTimestamps)==null?void 0:o.canvas_object_timestamps,r=(a=this.localTimestamps)==null?void 0:a.canvas_object_timestamps;if(n&&typeof n=="object")for(const[h,m]of Object.entries(n)){if(!m||typeof m!="object")continue;const y=r&&r[h]||{};for(const[g,w]of Object.entries(m)){const v=typeof w=="number"?w:0,S=y[g]??y[Number(g)]??0;v>S&&e.push(`${h}:${g}`)}}const i=(l=this.cloudTimestamps)==null?void 0:l.thread_object_timestamps,s=(u=this.localTimestamps)==null?void 0:u.thread_object_timestamps;if(i&&typeof i=="object")for(const[h,m]of Object.entries(i)){if(!m||typeof m!="object")continue;const y=s&&s[h]||{};for(const[g,w]of Object.entries(m)){const v=typeof w=="number"?w:0,S=y[g]??y[Number(g)]??0;if(v>S){const C=h==="global"&&g==="0"?"global":`${h}:${g}`;e.includes(C)||e.push(C)}}}return((d=i==null?void 0:i.global)==null?void 0:d[0])!=null&&((f=s==null?void 0:s.global)==null?void 0:f[0])==null&&(e.includes("global")||e.push("global")),e}removeDomainFromStore(e){var s,o,a,l;if(e==="global")return;const n=e.lastIndexOf(":");if(n===-1)return;const r=e.slice(0,n),i=parseInt(e.slice(n+1),10);if(!Number.isNaN(i)){this.operationTracker.setSkipTrackingForRemoteOps(!0);try{const u=at.getState();switch(r){case"song":(s=u.songs)!=null&&s[i]&&u.deleteSong(i);break;case"text_node":(o=u.textNodes)!=null&&o[i]&&u.deleteTextNode(i);break;case"embedding_node":(a=u.embeddingNodes)!=null&&a[i]&&u.deleteEmbeddingNode(i);break;case"visual_node":(l=u.visualMediaNodes)!=null&&l[i]&&u.deleteVisualMediaNode(i);break;default:break}}finally{this.operationTracker.setSkipTrackingForRemoteOps(!1)}this.clearLocalDomainTimestamp(e)}}clearLocalDomainTimestamp(e){var a,l;if(!this.localTimestamps||e==="global")return;const n=e.lastIndexOf(":");if(n===-1)return;const r=e.slice(0,n),i=e.slice(n+1),s=parseInt(i,10);if(Number.isNaN(s))return;(a=this.localTimestamps.canvas_object_timestamps)!=null&&a[r]&&(delete this.localTimestamps.
97canvas_object_timestamps[r][i],delete this.localTimestamps.canvas_object_timestamps[r][s],Object.keys(this.localTimestamps.canvas_object_timestamps[r]).length===0&&delete this.localTimestamps.canvas_object_timestamps[r]);const o=r==="song"?"song":r==="text_node"?"text":r==="embedding_node"?"embedding":r==="visual_node"?"visual":r;(l=this.localTimestamps.thread_object_timestamps)!=null&&l[o]&&(delete this.localTimestamps.thread_object_timestamps[o][i],delete this.localTimestamps.thread_object_timestamps[o][s],Object.keys(this.localTimestamps.thread_object_timestamps[o]).length===0&&delete this.localTimestamps.thread_object_timestamps[o]),this.saveLocalTimestamps()}pruneRevokedDomains(){var s;const e=(s=this.cloudTimestamps)==null?void 0:s.canvas_object_timestamps;if(!e||typeof e!="object")return;const n=new Set;for(const[o,a]of Object.entries(e))if(!(!a||typeof a!="object"))for(const l of Object.keys(a))n.add(`${o}:${l}`);const r=at.getState(),i=[];for(const o of Object.keys(r.songs||{})){const a=`song:${o}`;n.has(a)||i.push(a)}for(const o of Object.keys(r.textNodes||{})){const a=`text_node:${o}`;n.has(a)||i.push(a)}for(const o of Object.keys(r.embeddingNodes||{})){const a=`embedding_node:${o}`;n.has(a)||i.push(a)}for(const o of Object.keys(r.visualMediaNodes||{})){const a=`visual_node:${o}`;n.has(a)||i.push(a)}for(const o of i)this.removeDomainFromStore(o)}updateLocalTimestampsFromCatchUp(e){if(!(!e||!this.localTimestamps))for(const[n,r]of Object.entries(e))typeof r=="number"&&this.updateLocalDomainTimestamp(n,r)}async replayOfflineOpsAfterCatchUp(){var r,i,s,o,a,l,u,d,f,h;const e=await this.loadOfflineOperationSets(),n=await this.loadOfflineChatHistoryOperations();if(e.length>0){const y={user_id:await this.getUserId(),pending_operation_sets:e,last_operations_timestamp:0,last_settings_timestamp:((r=this.localTimestamps)==null?void 0:r.settings_timestamp)??0,client_id:this.operationTracker.clientId,client_timestamps_by_domain:((i=this.localTimestamps)==null?void 0:i.canvas_object_timestamps)??{}};try{const g=await tr.post("/api/v0/user-data/canvas_data_sync",y);(s=g.data)!=null&&s.merged_state&&Object.keys(g.data.merged_state).length>0&&this.applyMergedStateToStore(g.data.merged_state,{mergePartial:!0}),this.updateLocalTimestamps({settings_timestamp:((o=g.data)==null?void 0:o.cloud_settings_timestamp)??0,canvas_object_timestamps:(a=g.data)==null?void 0:a.object_timestamps}),(l=g.data)!=null&&l.roles_by_domain&&Object.keys(g.data.roles_by_domain).length>0&&at.getState().setDomainRolesByChannel(g.data.roles_by_domain),(u=g.data)!=null&&u.policies_by_domain&&Object.keys(g.data.policies_by_domain).length>0&&at.getState().setDomainPoliciesByChannel(g.data.policies_by_domain),await this.clearOfflineOperationSets()}catch{}}if(n.length>0)try{const m=await tr.post("/api/v0/user-data/chat_history_sync",{chat_history_operations:n,client_id:this.operationTracker.clientId});(d=m.data)!=null&&d.success&&((f=m.data)==null?void 0:f.server_chat_history_timestamp)!=null&&this.updateLocalTimestamps({settings_timestamp:((h=this.localTimestamps)==null?void 0:h.settings_timestamp)??0,chat_history_timestamp:m.data.server_chat_history_timestamp,thread_object_timestamps:m.data.object_timestamps}),await this.clearOfflineChatHistoryOperations()}catch{}}applyRemoteChatOperations(e){if(!e||e.length===0){ar("[applyRemoteChatOperations] Early return: no operations",{operations:e,length:e==null?void 0:e.length});return}ar("[applyRemoteChatOperations] Starting apply",{count:e.length,opTypes:e.map(n=>n.operation_type)}),ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{n.setState(r=>{var i,s,o,a,l;for(const u of e){const d=Number(u.thread_id),f=u.operation_type,h=u.value||{},m=u.timestamp||Date.now();if(isNaN(d)){ar("[applyRemoteChatOperations] Skip op: invalid thread_id",{op:u,thread_id:u.thread_id});continue}switch(ar("[applyRemoteChatOperations] Applying op",{opType:f,threadId:d,hasThread:!!((i=r.threads)!=null&&i[d])}),f){case"add":{const y=h.content||{},g=Array.isArray(y.messages)?y.messages:[],w={id:d,songId:h.songId??null,objectType:h.objectType,objectId:h.objectId??0,content:{messages:g},createdAt:h.createdAt??m,lastModified:m};if(r.threads[d]=w,(w.songId===null||w.songId===void 0)&&d<0&&(r.globalThreadId=d),w.songId!=null&&((s=r.songs)!=null&&s[w.songId])){const C=r.songs[w.songId];C.threadIds||(C.threadIds=new Set),C.threadIds.add(d)}const v=w.objectType,S=w.objectId;
97if(v==="text"&&((o=r.textNodes)!=null&&o[S])){const C=r.textNodes[S];C.threadIds||(C.threadIds=new Set),C.threadIds.add(d)}if(v==="embedding"&&((a=r.embeddingNodes)!=null&&a[S])){const C=r.embeddingNodes[S];C.threadIds||(C.threadIds=new Set),C.threadIds.add(d)}if(v==="visual"&&((l=r.visualMediaNodes)!=null&&l[S])){const C=r.visualMediaNodes[S];C.threadIds||(C.threadIds=new Set),C.threadIds.add(d)}break}case"append_message":{const y=r.threads[d];if(!(y!=null&&y.content))break;Array.isArray(y.content.messages)||(y.content.messages=[]);const g=h.message;g&&typeof g=="object"&&y.content.messages.push(g),y.lastModified=m;break}case"add_user_message":{const y=r.threads[d];if(!(y!=null&&y.content))break;Array.isArray(y.content.messages)||(y.content.messages=[]);const g=h.userPrompt;if(g){const w=g.timestamp instanceof Date?g.timestamp.getTime():m;y.content.messages.push({id:`${w}-u-${d}`,timestamp:w,role:"user",body:typeof g.message=="string"?g.message:"(audio)"})}y.lastModified=m;break}case"add_chat_response":{const y=r.threads[d];if(!(y!=null&&y.content))break;Array.isArray(y.content.messages)||(y.content.messages=[]);const g=h.chatResponse;if(g){const w=g.timestamp instanceof Date?g.timestamp.getTime():m;y.content.messages.push({id:`${w}-c-${d}`,timestamp:w,role:"cai",body:g.message??"",authorDisplayName:"Cai",links:g.links??[]})}y.lastModified=m;break}case"add_user_message_and_response":{const y=r.threads[d];if(!(y!=null&&y.content))break;Array.isArray(y.content.messages)||(y.content.messages=[]);const g=h.userPrompt,w=h.chatResponse;if(g){const v=g.timestamp instanceof Date?g.timestamp.getTime():m;y.content.messages.push({id:`${v}-u-${d}`,timestamp:v,role:"user",body:typeof g.message=="string"?g.message:"(audio)"})}if(w){const v=w.timestamp instanceof Date?w.timestamp.getTime():m;y.content.messages.push({id:`${v}-c-${d}`,timestamp:v,role:"cai",body:w.message??"",authorDisplayName:"Cai",links:w.links??[]})}y.lastModified=m;break}case"delete":{delete r.threads[d],r.globalThreadId===d&&(r.globalThreadId=null);break}}}ar("[applyRemoteChatOperations] Done. Thread count:",Object.keys(r.threads||{}).length)})})}applyRemoteCanvasOperations(e){!e||e.length===0||ai(async()=>{const{useCaiStore:n}=await Promise.resolve().then(()=>Sl);return{useCaiStore:n}},void 0).then(({useCaiStore:n})=>{ai(async()=>{const{canvasHistoryManager:r}=await Promise.resolve().then(()=>Ree);return{canvasHistoryManager:r}},void 0).then(({canvasHistoryManager:r})=>{const i=o=>n.setState(o),s=()=>n.getState();r.applyRemoteOperations(e,i,s)})})}async uploadPendingAudioFiles(){if(this.pendingAudioFileUploads.size===0)return;const{useCaiStore:e}=await ai(async()=>{const{useCaiStore:s}=await Promise.resolve().then(()=>Sl);return{useCaiStore:s}},void 0),{uploadAudioFileToBackend:n}=await ai(async()=>{const{uploadAudioFileToBackend:s}=await import("./audioFileUploader-CKMpGHaq.js");return{uploadAudioFileToBackend:s}},__vite__mapDeps([0,1,2,3,4])),r=Array.from(this.pendingAudioFileUploads),i=[];for(const s of r)try{const o=e.getState(),a=o.getAudioFileById(s);if(!a||a.sampleRate==null||a.samples==null||!a.fileName){i.push(s);continue}const l=await o.getAudioFileData(s);if(!l||l.length===0){i.push(s);continue}await n(s,l,{fileName:a.fileName,sampleRate:a.sampleRate,samples:a.samples,originalKey:a.originalKey,originalBpm:a.originalBpm,instrument:a.instrument})&&i.push(s)}catch{}i.forEach(s=>{this.pendingAudioFileUploads.delete(s)})}};Xt(Pm,"instance",null);let Ga=Pm;var jr=(t=>(t[t.Up=0]="Up",t[t.Right=1]="Right",t[t.Down=2]="Down",t[t.Left=3]="Left",t))(jr||{}),Tr=(t=>(t[t.Left=0]="Left",t[t.Right=1]="Right",t))(Tr||{}),ao=(t=>(t[t.Top=0]="Top",t[t.Bottom=1]="Bottom",t))(ao||{}),Qy=(t=>(t[t.Left=0]="Left",t[t.Right=1]="Right",t))(Qy||{}),Xi=(t=>(t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left",t.TopLeft="top-left",t.TopRight="top-right",t.BottomRight="bottom-right",t.BottomLeft="bottom-left",t))(Xi||{});const VJ=t=>{const e=t.toLowerCase().replace(/[_-]/g," ");for(const n of rO)if(e.includes(n.toLowerCase()))return n.split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ");return""},HJ=t=>{const e=[/_(\d{2,3})_/,/_(\d{2,3})bpm/i,/_(\d{2,3})_bpm/i,/(\d{2,3})_bpm/i,/(\d{2,3})bpm/i];for(const n of e){const r=t.match(n);if(r){const i=parseInt(r[1]);if(i>=30&&i<=300)return i}}return null},GJ=t=>{const e=t.toLowerCase();if(e.includes("drum")||e.includes("percussion")||e.includes("kit")||e.includes("beat"))return null;const n=[/([A-G][#b]?)maj(?:or)?/i,/([A-G][#b]?)_maj(?:or)?/i,/([A-G][#b]?)M(?![a-z])/,/([A-G][#b]?)min(?:or)?/i,/([A-G][#b]?)_min(?:or)?/i,/([A-G][#b]?)m(?![a-z])/i,/_([A-G][#b]?)(?:maj|min|m)?\./,/_([A-G][#b]?)$/];for(const r of n){const i=t.match(r);if(i){let s=i[1].toUpperCase();s={AB:"G#",BB:"A#",CB:"B",DB:"C#",EB:"D#",FB:"E",GB:"F#"}[s]||s;const a=i.index||0,l=e.substring(a+i[0].length);return e.substring(0,a).includes("min")||l.startsWith("min")||l.startsWith("m")||i[0].toLowerCase().includes("min")||i[0].endsWith("m")?{chroma:s,quality:"Minor"}:{chroma:s,quality:"Major"}}}},nD=t=>({instrument:VJ(t),originalBpm:HJ(t),originalKey:GJ(t)}),ax=t=>`audioFileData-${t}`;function J_(t){return Array.isArray(t)}const pb=async t=>{const e=await jn.getItem(ax(t));return e==null?null:J_(e)?e:e.data},RS=async(t,e,n)=>{await jn.setItem(ax(t),{data:e,referenceCount:n})},ek=async t=>{const e=ax(t),n=await jn.getItem(e);let r,i;return n==null?0:(J_(n)?(r=n,i=1):(r=n.data,i=n.referenceCount+1),await jn.setItem(e,{data:r,referenceCount:i}),i)},WJ=async t=>{const e=ax(t),n=await jn.getItem(e);if(n==null)return 0;let r,i;return J_(n)?(r=n,i=0):(r=n.data,i=Math.max(0,n.referenceCount-1)),i<=0?(await jn.removeItem(e),0):(await jn.setItem(e,{data:r,referenceCount:i}),i)},wh=8,E0=7,va=70,Zr=40,xi=15,Vu=127,eE=(wh*E0+1)*Zr,tE=90,Xh=(t,e)=>Zi(t,e,0),Zi=(t,e,n)=>(t*e+n)*va,qJ=t=>
97Math.floor(t/va),kh=(t,e)=>{const n=U2(e+"0"),i=p0(n,t),s=Bv(i)-1;return(wh*E0-s)*Zr},pz=(t,e)=>{const r=(wh*E0*Zr-t)/Zr;return X4(`${e.chroma}0 ${e.quality}`)(r+1)},KJ=(t,e)=>{const n=t.filter(a=>{if(!a)return!1;const l=e[a.noteDetailsHash];return l&&l.pitch});if(n.length===0)return"C4";const r=n.map(a=>{const l=e[a.noteDetailsHash];return l.pitchInt||Oo(l.pitch)});r.sort((a,l)=>a-l);const i=Math.floor(n.length/2),s=n.length%2===0?Math.round((r[i-1]+r[i])/2):r[i];return Km(s)},rD=t=>{const e=X4(`${t.chroma}0 ${t.quality}`),n=[];for(let r=1;r<=E0*wh;r++){const i=e(r);n.push(i)}return n},YJ=(t,e)=>{const n=p_(`${e.chroma} ${e.quality}`),{chroma:r}=Hh(t);return n.notes.includes(r)},Zy=(t,e,n)=>{const r=V2(t,n?"2m":"-2m");return YJ(r,e)?r:V2(t,n?"1A":"-1A")},mz=(t,e,n)=>V2(t,n?"8P":"-8P");function XJ(t,e,n){if(!e||!e.width||!e.height)return!1;const r=Zi(0,n.timeSignature.beatsPerBar,t.startBeat)-xi,i=kh(t.pitch,n.key.chroma)-Zr/2,s=e.pianoRollPosition.x,o=e.pianoRollPosition.y,a=s+e.width,l=o+e.height;return r>=s&&r<=a&&i>=o&&i<=l}const QJ={songs:{},bloobs:{},notes:{},noteDetails:{},tracks:{},textNodes:{},embeddingNodes:{},visualMediaNodes:{},audioFiles:{},fetchingAudioFiles:new Set},ZJ=t=>({type:J.Song,id:t,nextInSongId:0,label:void 0,key:{chroma:"C",quality:"Major"},bpm:120,timeSignature:{beatsPerBar:4,beatDuration:4},canvasPosition:{x:0,y:0},bars:1,tracks:1,bloobIds:new Set,trackIds:new Set,threadIds:new Set,hasSoloedBloobs:!1,metadata:{},createdAt:Date.now(),lastModified:Date.now()}),JJ=t=>({type:J.Bloob,id:t,songId:-1,inSongId:-1,label:void 0,color:"",instrument:qm,muted:!1,soloed:!1,songPosition:{bar:0,track:0},bars:0,noteIds:new Set,notes:[],volume:0,melodicRole:so.NONE,metadata:"",bloobType:Us.Midi,metadataOutdated:!0,createdAt:Date.now(),lastModified:Date.now()}),eee=t=>({type:J.Note,id:t,bloobId:-1,noteDetailsHash:""}),mb=t=>{if(t)return{...t,songPosition:{...t.songPosition}}},tee=(t,e)=>{const n=vh("client");n.setStateGetter(e);const r=(s,o,a,l)=>{o.forEach(u=>{var g;const d=s.notes[u];if(!d)return;const f=d.noteDetailsHash,h=a!==void 0?a:d.bloobId,m=s.bloobs[h];if(m&&ln(m)&&m.noteIds.delete(u),f){const w=s.noteDetails[f]?{...s.noteDetails[f]}:void 0,v=hz(f,s.noteDetails),S=((g=s.bloobs[d.bloobId])==null?void 0:g.songId)??0;if(n.trackDecrementOperation(f,S),v&&w){const{referenceCount:C,...k}=w;n.trackDeleteOperation("NoteDetails",0,{hash:f,...k},{domain_type:"song",domain_id:S})}}delete s.notes[u];const y=l.get(u);n.trackDeleteOperation(J.Note,u,y)})},i=(s,o,a)=>{const l=typeof a=="number"&&a>0?a:1,u=o&&typeof o.bar=="number"&&typeof o.track=="number"?o:{bar:0,track:0};if(e().getBloobsOverlappingWithPosition(s,u,l).length===0)return u;const f=e().getSongById(s),h=Math.max(f.tracks+8,u.track+8);for(let m=Math.max(0,u.track);m<=h;m++){const y={bar:u.bar,track:m};if(e().getBloobsOverlappingWithPosition(s,y,l).length===0)return y}return u};return{...QJ,getNextSongId:()=>Ra(J.Song),addSong:(s,o,a,l,u,d,f,h)=>{const m=e().getNextSongId(),y=e().addThread;let g=null;y&&(g=y(m));const w={type:J.Song,id:m,nextInSongId:0,key:s,bpm:o,timeSignature:a,canvasPosition:l,bars:d||4,tracks:f||1,bloobIds:new Set,trackIds:new Set,threadIds:g?new Set([g]):new Set,hasSoloedBloobs:!1,label:u||"Song "+m,metadata:h||{},createdAt:Date.now(),lastModified:Date.now()};return t(v=>{v.songs[w.id]=w}),n.trackAddOperation(J.Song,w.id,w),w.id},deleteSong:s=>{const o=e().songs[s],a=o?{...o}:void 0;if(!o)return!1;Array.from(o.bloobIds).forEach(f=>{e().deleteBloob(f)}),Array.from(o.trackIds??[]).forEach(f=>{e().deleteTrack(f)}),t(f=>{f.songs[s]&&(f.songs[s].bloobIds.clear(),f.songs[s].trackIds instanceof Set?f.songs[s].trackIds.clear():f.songs[s].trackIds=new Set,delete f.songs[s])});const d=e().deleteThreadsForSong;return d&&d(s),n.trackDeleteOperation(J.Song,s,a),!0},duplicateSong:(s,o)=>{const a=e().getSongById(s);if(!a)return-1;const l=e().addSong(a.key,a.bpm,a.timeSignature,o,a.label?a.label+" (copy)":void 0,a.bars,a.tracks,{...a.metadata});e().getBloobsInSong(s).forEach(d=>{e().duplicateBloob(d.id,d.songPosition,l)});for(const d of a.trackIds??new Set){const f=e().tracks[d];if(f){const h=e().addTrack(l,f.trackIndex);e().updateTrackEffects(h,{...f.effects}),e().updateTrackName(h,f.name),f.instrumentLock&&e().setTrackInstrumentLock(h,f.instrumentLock)}}return e().expandSongAsNecessary(l),l},addTracksToSong:(s,o,a)=>
97{if(a<0)throw new Error("can only add positive tracks");const l=e().songs[s],u=l?{...l}:void 0;switch(o){case ao.Bottom:{t(d=>{d.songs[s].tracks+=a,n.trackUpdateOperation(J.Song,s,{tracks:d.songs[s].tracks},u)});break}case ao.Top:{const d=new Map;l==null||l.bloobIds.forEach(f=>{const h=mb(e().bloobs[f]);h&&d.set(f,h)}),t(f=>{const h=f.songs[s];h.tracks+=a,h.canvasPosition.y-=a*bn,h.bloobIds.forEach(m=>{f.bloobs[m].songPosition.track+=a}),n.trackUpdateOperation(J.Song,s,{tracks:f.songs[s].tracks,canvasPosition:{x:f.songs[s].canvasPosition.x,y:f.songs[s].canvasPosition.y}},u),h.bloobIds.forEach(m=>{const y=f.bloobs[m],g=d.get(m);!y||!g||n.trackUpdateOperation(J.Bloob,m,{songPosition:{bar:y.songPosition.bar,track:y.songPosition.track}},g)})});break}}},removeTracksFromSongIfPossible:(s,o,a)=>{if(a<1)throw new Error("can only remove positive tracks");switch(o){case ao.Bottom:{const l=e().songs[s],u=Nu(l,h=>{h.tracks-=a});if(!ob(u,e().getBloobsInSong(s)))return;const d=l.tracks,f=d-a;for(let h=f;h<d;h++){const m=e().getTrackForSongTrackIndex(s,h);m&&e().deleteTrack(m.id)}t(h=>{h.songs[s].tracks-=a,n.trackUpdateOperation(J.Song,s,{tracks:h.songs[s].tracks})});break}case ao.Top:{const l=Nu(e().songs[s],y=>{y.tracks-=a}),u=Nu(e().getBloobsInSong(s),y=>{y.forEach(g=>{g.songPosition.track-=a})});if(!ob(l,u))return;const d=e().songs[s];for(let y=0;y<a;y++){const g=e().getTrackForSongTrackIndex(s,y);g&&e().deleteTrack(g.id)}for(const y of d.trackIds??new Set){const g=e().tracks[y];if(g&&g.trackIndex>=a){const w={...g};t(v=>{v.tracks[y].trackIndex-=a,v.tracks[y].lastModified=Date.now()}),n.trackUpdateOperation(J.Track,y,{trackIndex:e().tracks[y].trackIndex,lastModified:e().tracks[y].lastModified},w)}}const f=e().songs[s],h=f?{...f}:void 0,m=new Map;f==null||f.bloobIds.forEach(y=>{const g=mb(e().bloobs[y]);g&&m.set(y,g)}),t(y=>{const g=y.songs[s];g.tracks-=a,g.canvasPosition.y+=a*bn,g.bloobIds.forEach(w=>{y.bloobs[w].songPosition.track-=a}),n.trackUpdateOperation(J.Song,s,{tracks:y.songs[s].tracks,canvasPosition:{x:y.songs[s].canvasPosition.x,y:y.songs[s].canvasPosition.y}},h),g.bloobIds.forEach(w=>{const v=y.bloobs[w],S=m.get(w);!v||!S||n.trackUpdateOperation(J.Bloob,w,{songPosition:{bar:v.songPosition.bar,track:v.songPosition.track}},S)})});break}}},addBarsToSong:(s,o,a)=>{if(a<0)throw new Error("can only add positive tracks");const l=e().songs[s],u=l?{...l}:void 0;switch(o){case Tr.Right:{t(d=>{d.songs[s].bars+=a,n.trackUpdateOperation(J.Song,s,{bars:d.songs[s].bars},u)});break}case Tr.Left:{const d=new Map;l==null||l.bloobIds.forEach(f=>{const h=mb(e().bloobs[f]);h&&d.set(f,h)}),t(f=>{const h=f.songs[s];h.bars+=a,h.canvasPosition.x-=a*dn,h.bloobIds.forEach(m=>{f.bloobs[m].songPosition.bar+=a}),n.trackUpdateOperation(J.Song,s,{bars:f.songs[s].bars,canvasPosition:{x:f.songs[s].canvasPosition.x,y:f.songs[s].canvasPosition.y}},u),h.bloobIds.forEach(m=>{const y=f.bloobs[m],g=d.get(m);!y||!g||n.trackUpdateOperation(J.Bloob,m,{songPosition:{bar:y.songPosition.bar,track:y.songPosition.track}},g)})});break}}},removeBarsFromSongIfPossible:(s,o,a)=>{if(a<0)throw new Error("can only remove positive tracks");switch(o){case Tr.Right:{const l=Nu(e().songs[s],u=>{u.bars-=a});if(!ob(l,e().getBloobsInSong(s)))return;t(u=>{u.songs[s].bars-=a,n.trackUpdateOperation(J.Song,s,{bars:u.songs[s].bars})});break}case Tr.Left:{const l=Nu(e().songs[s],m=>{m.bars-=a}),u=Nu(e().getBloobsInSong(s),m=>{m.forEach(y=>{y.songPosition.bar-=a})});if(!ob(l,u))return!1;const d=e().songs[s],f=d?{...d}:void 0,h=new Map;d==null||d.bloobIds.forEach(m=>{const y=mb(e().bloobs[m]);y&&h.set(m,y)}),t(m=>{const y=m.songs[s];y.bars-=a,y.canvasPosition.x+=a*dn,y.bloobIds.forEach(g=>{m.bloobs[g].songPosition.bar-=a}),n.trackUpdateOperation(J.Song,s,{bars:m.songs[s].bars,canvasPosition:{x:m.songs[s].canvasPosition.x,y:m.songs[s].canvasPosition.y}},f),y.bloobIds.forEach(g=>{const w=m.bloobs[g],v=h.get(g);!w||!v||n.trackUpdateOperation(J.Bloob,g,{songPosition:{bar:w.songPosition.bar,track:w.songPosition.track}},v)})});break}}return!0},expandSongAsNecessary:s=>
97{e().getBloobsInSong(s).forEach(o=>{const a=e().songs[s];if(o.songPosition.bar<0){const l=-o.songPosition.bar;e().addBarsToSong(s,Tr.Left,l)}else if(o.songPosition.bar+o.bars>a.bars){const l=o.songPosition.bar+o.bars-a.bars;e().addBarsToSong(s,Tr.Right,l)}if(o.songPosition.track<0){const l=-o.songPosition.track;e().addTracksToSong(s,ao.Top,l)}else if(o.songPosition.track>=a.tracks){const l=o.songPosition.track+1-a.tracks;e().addTracksToSong(s,ao.Bottom,l)}})},shrinkSongWherePossible:s=>{const o=e().getSongById(s),a=e().getBloobsInSong(s);if(a.length===0)return;let l=o.tracks,u=0,d=o.bars,f=0;a.forEach(w=>{l=Math.min(l,w.songPosition.track),u=Math.max(u,w.songPosition.track),d=Math.min(d,w.songPosition.bar),f=Math.max(f,w.songPosition.bar+w.bars-1)});const h=l,m=o.tracks-u-1,y=d,g=o.bars-f-1;h>0&&e().removeTracksFromSongIfPossible(s,ao.Top,h),m>0&&e().removeTracksFromSongIfPossible(s,ao.Bottom,m),y>0&&e().removeBarsFromSongIfPossible(s,Tr.Left,y),g>0&&e().removeBarsFromSongIfPossible(s,Tr.Right,g)},organizeBloobs:s=>{var H;const o=e().getBloobsInSong(s);if(o.length===0)return;const a=(P,F)=>P.songPosition.bar<F.songPosition.bar+F.bars&&F.songPosition.bar<P.songPosition.bar+P.bars,l=(P,F)=>Math.max(0,Math.min(P.songPosition.bar+P.bars,F.songPosition.bar+F.bars)-Math.max(P.songPosition.bar,F.songPosition.bar)),u=P=>{if(P.length<=1)return!1;const F={};if(P.forEach(D=>{const B=D.songPosition.track;F[B]||(F[B]=[]),F[B].push(D)}),Object.keys(F).length<2)return!1;Object.values(F).forEach(D=>{D.sort((B,L)=>B.songPosition.bar-L.songPosition.bar)});const I=P.map(D=>D.songPosition.bar),R=P.map(D=>D.songPosition.bar+D.bars),U=Math.min(...I),A=Math.max(...R),W=A-U;for(const D in F){const B=F[D];if(B.sort(($,q)=>$.songPosition.bar-q.songPosition.bar),B[0].songPosition.bar!==U)return!1;let L=U;for(const $ of B){if($.songPosition.bar>L)return!1;L=Math.max(L,$.songPosition.bar+$.bars)}if(L!==A&&L!==U+Math.floor(W/2))return!1}return!0},d=P=>{var F;if(ln(P))return[Sn.Percussive,Sn.Drums].includes(Bc(P.instrument));if(En(P)){const R=((F=e().getAudioFileById(P.audioFileId).instrument)==null?void 0:F.toLowerCase())||"";return R.includes("drum")||R.includes("percussion")||R.includes("kit")||R.includes("beat")}return!1},f=(P,F)=>{var W,D;const I=ln(P)?P.instrument:qm,R=ln(F)?F.instrument:qm,A=((B,L)=>{const $=ci(B)-ci(L);return $!==0?$:B.toLowerCase().localeCompare(L.toLowerCase())})(I,R);return A!==0?A:((D=P.label)==null?void 0:D.toLowerCase().localeCompare((W=F.label)==null?void 0:W.toLowerCase()))??0},h=[],m=new Set;for(let P=0;P<o.length;P++){if(m.has(o[P].id))continue;const F=[o[P]];for(let I=0;I<o.length;I++)P===I||m.has(o[I].id)||a(o[P],o[I])&&F.push(o[I]);u(F)&&(h.push(F),F.forEach(I=>m.add(I.id)))}for(const P of o){if(m.has(P.id))continue;let F=null,I=0;for(const R of h){let U=!0,A=0;for(const W of R){if(!a(P,W)){U=!1;break}A+=l(P,W)}U&&(A>I||A===I&&R.length>((F==null?void 0:F.length)??0)||A===I&&R.length===((F==null?void 0:F.length)??0)&&Math.min(...R.map(W=>W.songPosition.bar))<Math.min(...(F??[P]).map(W=>W.songPosition.bar)))&&(I=A,F=R)}(F??h[h.push([])-1]).push(P),m.add(P.id)}h.sort((P,F)=>Math.min(...P.map(I=>I.songPosition.bar))-Math.min(...F.map(I=>I.songPosition.bar)));const y=[Sn.Piano,Sn.ChromaticPercussion,Sn.Organ,Sn.Guitar,Sn.Strings,Sn.Ensemble,Sn.Brass,Sn.Reed,Sn.SynthLead,Sn.SynthPad,Sn.SynthEffects,Sn.Ethnic,Sn.SoundEffects],g=P=>{var $;const F=[],I=[],R=[],U=[],A=[],W=[],D=[],B=[],L={};y.forEach(q=>L[q]=[]);for(const q of P){switch(q.melodicRole){case so.LEAD_MELODY:F.push(q);continue;case so.COUNTER_MELODY:I.push(q);continue;case so.OSTINATO:R.push(q);continue;case so.HARMONIC_FILL:U.push(q);continue;case so.TEXTURAL_FILL:A.push(q);continue;case so.PERCUSSION:W.push(q);continue;case so.BASSLINE:D.push(q);continue}const Z=(($=e().getBloobInstrument(q.id))==null?void 0:$.toLowerCase())||"";if(d(q)){W.push(q);continue}if(Z.includes("bass")){D.push(q);continue}let ie=!1;for(const ge of y)if(nO(ge).some(ne=>ne.toString().toLowerCase()===Z)===!0){L[ge].push(q),ie=!0;break}ie||B.push(q)}
97return[F,I,R,U,A,...Object.values(L),B,W,D].forEach(q=>q.sort(f)),[...F,...I,...R,...U,...A,...y.flatMap(q=>L[q]),...B,...W,...D]};let w=0;for(const P of h){const F=g(P),I=u(P),R=Math.max(...P.map(U=>U.bars));if(I){const U=Math.min(...P.map(B=>B.songPosition.bar)),A={};P.forEach(B=>{const L=B.songPosition.track;A[L]||(A[L]=[]),A[L].push(B)});const W=Object.keys(A).map(Number),D=Math.min(...W);Object.entries(A).forEach(([B,L])=>{L.sort((q,Z)=>q.songPosition.bar-Z.songPosition.bar);const $=parseInt(B)-D+1;L.forEach(q=>{const Z=q.songPosition.bar-U;e().updateBloobDetails(q.id,{songPosition:{bar:w+Z,track:$}})})})}else{const U=new Map,A=new Set;let W=0;for(const D of F){const B=((H=e().getBloobInstrument(D.id))==null?void 0:H.toLowerCase())||"";let L=U.get(B);L!==void 0&&A.has(L)&&(L=void 0),L===void 0&&(L=W,W+=1,U.set(B,L)),A.add(L),e().updateBloobDetails(D.id,{songPosition:{bar:w,track:L}})}}w+=R}const v=e().getBloobsInSong(s);let S=Math.max(...v.map(P=>P.songPosition.track),0);for(let P=0;P<v.length;P++){const F=v[P];for(let I=P+1;I<v.length;I++){const R=v[I];F.songPosition.track===R.songPosition.track&&a(F,R)&&(S+=1,e().updateBloobDetails(R.id,{songPosition:{bar:R.songPosition.bar,track:S}}))}}const C={};v.forEach(P=>{const F=P.songPosition.track;C[F]||(C[F]=[]),C[F].push(P)}),Object.values(C).forEach(P=>{P.sort((F,I)=>F.songPosition.bar-I.songPosition.bar)});const k=new Map;let N=0;Array.from(new Set(v.map(P=>P.songPosition.bar))).sort((P,F)=>P-F).forEach(P=>{k.set(P,N);const F=v.filter(I=>I.songPosition.bar===P);if(F.length>0){const I=Math.min(...F.map(R=>R.bars));N+=I}else N+=1}),v.forEach(P=>{const F=k.get(P.songPosition.bar);F!==void 0&&F!==P.songPosition.bar&&e().updateBloobDetails(P.id,{songPosition:{bar:F,track:P.songPosition.track}})});const j=e().getBloobsInSong(s),T=new Set;j.forEach(P=>{T.add(P.songPosition.track)});const M=Array.from(T).sort((P,F)=>P-F),V={};M.forEach((P,F)=>{V[P]=F+1}),j.forEach(P=>{const F=V[P.songPosition.track];F!==void 0&&F!==P.songPosition.track&&e().updateBloobDetails(P.id,{songPosition:{bar:P.songPosition.bar,track:F}})}),e().expandSongAsNecessary(s),e().shrinkSongWherePossible(s)},updateSongDetails:(s,o)=>{const a=e().songs[s],l=a?{...a}:void 0;let u=!1;if(t(d=>{const f=d.songs[s];f&&(o.key&&(f.key=o.key),o.bpm&&(f.bpm=o.bpm,u=!0),o.timeSignature&&(f.timeSignature=o.timeSignature),o.canvasPosition&&(f.canvasPosition=o.canvasPosition),o.label!==void 0&&(f.label=o.label),o.metadata!==void 0&&(f.metadata=o.metadata),o.lastModified!==void 0?f.lastModified=o.lastModified:f.lastModified=Date.now())}),u){const d=e().getSongById(s);d.bloobIds.forEach(f=>{const h=e().getBloobById(f);if(En(h)){const m=e().getAudioFileById(h.audioFileId),y=Jp(d.bpm,m.originalBpm);e().updateBloobDetails(h.id,{playbackRate:y})}})}n.trackUpdateOperation(J.Song,s,o,l)},getNextBloobId:()=>Ra(J.Bloob),getNextBloobInSongId:s=>{const o=e().songs[s].nextInSongId,a=o+1;return t(l=>{l.songs[s].nextInSongId=a}),n.trackUpdateOperation(J.Song,s,{nextInSongId:a}),o},addBloob:(s,o,a,l,u,d,f,h,m)=>{if("instrument"in o)return e().addMidiBloob(s,o.instrument,a,l,u,d,f,h,m);if("audioFileId"in o)return e().addAudioBloob(s,o.audioFileId,a,l,u,d,f,h,m)},addMidiBloob:(s,o,a,l,u,d,f,h,m)=>{const y=m??e().getNextBloobId(),g=e().bloobs[y];if(m!==void 0&&g)return e().expandSongAsNecessary(g.songId),n.trackAddOperation(J.Bloob,y,g),y;const w=i(s,l,a),v=e().getTrackForSongTrackIndex(s,w.track),S=(v==null?void 0:v.instrumentLock)||o,C={type:J.Bloob,id:y,inSongId:e().getNextBloobInSongId(s),songId:s,label:u,color:oi(S),instrument:S,muted:!1,soloed:!1,songPosition:w,bars:a,noteIds:new Set,notes:[],volume:.75,melodicRole:d||so.NONE,metadata:f||"",bloobType:Us.Midi,metadataOutdated:h??!0,createdAt:Date.now(),lastModified:Date.now()};return t(k=>{k.bloobs[C.id]=C,k.songs[C.songId].bloobIds.add(C.id)}),e().expandSongAsNecessary(C.songId),n.trackAddOperation(J.Bloob,C.id,C),C.id},addAudioBloob:(s,o,a,l,u,d,f,h,m,y)=>{const g=m??e().getNextBloobId(),w=e().bloobs[g];if(m!==void 0&&w)return e().expandSongAsNecessary(w.songId),n.trackAddOperation(J.Bloob,g,w),g;const v=e().getSongById(s),S=e().getAudioFileById(o),C=Jp(v.bpm,S.originalBpm),k=S.instrument,N=i(s,l,a),_={type:J.Bloob,id:g,
97songId:s,label:u,color:k?oi(k):"#7DC383",muted:!1,soloed:!1,songPosition:N,inSongId:e().getNextBloobInSongId(s),bars:a,volume:.25,melodicRole:d||so.NONE,metadata:f||"",bloobType:Us.Audio,audioFileId:o,playbackRate:C,metadataOutdated:h||!1,midiConversion:y??null,audioClipStartInSeconds:0,createdAt:Date.now(),lastModified:Date.now()};t(T=>{T.bloobs[_.id]=_,T.songs[_.songId].bloobIds.add(_.id)}),e().expandSongAsNecessary(_.songId),n.trackAddOperation(J.Bloob,_.id,_);const j=Ga.getInstance();return j&&j.queueAndUploadAudioFile(o),_.id},deleteBloob:s=>{const o=e().getBloobById(s);o&&(ln(o)?e().deleteMidiBloob(s):En(o)&&e().deleteAudioBloob(s))},deleteMidiBloob:s=>{const o=e().bloobs[s],a=o&&ln(o)?{...o}:void 0,l=o&&ln(o)?Array.from(o.noteIds):[],u=new Map;l.forEach(d=>{const f=e().notes[d];f&&u.set(d,{...f})}),t(d=>{const f=d.bloobs[s];if(!f||!ln(f))return;r(d,Array.from(f.noteIds),s,u);const h=f.songId;d.songs[h]&&d.songs[h].bloobIds.delete(s),f.soloed&&d.songs[h]&&(Array.from(d.songs[h].bloobIds).filter(y=>y!==s).some(y=>d.bloobs[y]&&d.bloobs[y].soloed)||e().updateSongDetails(h,{hasSoloedBloobs:!1})),delete d.bloobs[s],n.trackDeleteOperation(J.Bloob,s,a)})},deleteAudioBloob:s=>{const o=e().bloobs[s],a=o&&En(o)?{...o}:void 0;let l=!1;const u=En(o)?o.audioFileId:null;u&&Object.values(e().bloobs).forEach(d=>{d.id!==s&&En(d)&&d.audioFileId===u&&(l=!0)}),t(d=>{const f=d.bloobs[s];if(!f||!En(f))return;const h=f.songId;if(d.songs[h]&&d.songs[h].bloobIds.delete(s),u&&!l){const m=d.audioFiles[u];m?(m.referenceCount=Math.max(0,(m.referenceCount??1)-1),m.referenceCount===0&&e().deleteAudioFile(u)):e().deleteAudioFile(u)}if(f.soloed&&d.songs[h]&&(Array.from(d.songs[h].bloobIds).filter(y=>y!==s).some(y=>d.bloobs[y]&&d.bloobs[y].soloed)||e().updateSongDetails(h,{hasSoloedBloobs:!1})),delete d.bloobs[s],En(o)){const m=Ga.getInstance();m&&m.pendingAudioFileDeletes.add(o.audioFileId)}n.trackDeleteOperation(J.Bloob,s,a)})},duplicateBloob:(s,o,a)=>{const l=e().getBloobById(s);return!l||l.id===-1?-1:ln(l)?e().duplicateMidiBloob(s,o,a):En(l)?e().duplicateAudioBloob(s,o,a):-1},duplicateMidiBloob:(s,o,a)=>{var C;const l=e(),u=e().getBloobById(s);if(!u||u.id===-1||!ln(u))return-1;const d=a??u.songId,f=e().getNextBloobId(),h=e().getNextBloobInSongId(d),m=o&&typeof o.bar=="number"&&typeof o.track=="number"?o:u.songPosition??{bar:0,track:0},g=((C=e().getTrackForSongTrackIndex(d,m.track))==null?void 0:C.instrumentLock)||u.instrument,w=typeof u.bars=="number"&&u.bars>0?u.bars:1,v=Array.from(u.noteIds),S=[];if(v.length>0){let k=0;const N=new Set;v.forEach(_=>{const j=e().getNoteById(_);if(!j){k++;return}const T=e().noteDetails[j.noteDetailsHash];if(!T){k++,pr(`Skipping note ${_} during duplication - NoteDetails not found for hash: ${j.noteDetailsHash}`);return}const M={pitch:T.pitch,pitchInt:T.pitchInt,velocity:T.velocity,startBeat:T.startBeat,durationInBeats:T.durationInBeats},V=j.noteDetailsHash;let H=e().getNextNoteId(),P=0;const F=10;for(;N.has(H)||l.notes[H]!==void 0||e().notes[H]!==void 0;){if(P++,P>F){k++;return}H=e().getNextNoteId()}N.add(H),S.push({noteId:H,noteDetails:M,hash:V})}),k>0&&pr(`Duplication warning: Skipped ${k} out of ${v.length} notes when duplicating bloob ${s}`)}return t(k=>{k.noteDetails||(k.noteDetails={});const N=Date.now();k.bloobs[f]={type:J.Bloob,id:f,inSongId:h,songId:d,label:u.label?u.label+" (copy)":void 0,color:oi(g),instrument:g,muted:u.muted,soloed:u.soloed,songPosition:m,bars:w,noteIds:new Set,notes:[],volume:u.volume,volumeAutomation:u.volumeAutomation?[...u.volumeAutomation.map(_=>({..._}))]:void 0,melodicRole:u.melodicRole,metadata:u.metadata,metadataOutdated:u.metadataOutdated,notesContentHashInLastUpdate:u.notesContentHashInLastUpdate,bloobType:Us.Midi,createdAt:N,lastModified:N},k.songs[d].bloobIds.add(f),n.trackAddOperation(J.Bloob,f,k.bloobs[f]),S.forEach(({noteId:_,noteDetails:j,hash:T})=>{if(k.notes[_]!==void 0)return;k.noteDetails[T]||(k.noteDetails[T]={...j,referenceCount:0}),n.trackAddOperation("NoteDetails",0,{hash:T,...j},{domain_type:"song",domain_id:d});const M={type:J.Note,id:_,bloobId:f,noteDetailsHash:T};k.notes[M.id]=M;const V=k.bloobs[f];ln(V)&&V.noteIds.add(M.id),ym(T,k.noteDetails),n.trackIncrementOperation(T,d),n.trackAddOperation(J.Note,M.id,M,{domain_type:"song",domain_id:d})})}),e().expandSongAsNecessary(d),f},duplicateAudioBloob:(s,o,a)=>{const l=e().getBloobById(s);if(!l||l.id===-1||!En(l))return-1;const u=a??l.songId,d=e().getNextBloobId(),f=e().getNextBloobInSongId(u),h=o&&typeof o.bar=="number"&&typeof o.track=="number"?o:l.songPosition??{bar:0,track:0},m=typeof l.bars=="number"&&l.bars>0?l.bars:1;return t(y=>{y.bloobs[d]={type:J.Bloob,id:d,inSongId:f,songId:u,label:l.label?l.label+" (copy)":void 0,color:l.color,muted:l.muted,soloed:l.soloed,songPosition:h,bars:m,volume:l.volume,volumeAutomation:l.volumeAutomation?[...l.volumeAutomation.map(v
97=>({...v}))]:void 0,melodicRole:l.melodicRole,metadata:l.metadata,bloobType:Us.Audio,audioFileId:l.audioFileId,playbackRate:l.playbackRate,metadataOutdated:!1,midiConversion:l.midiConversion??null,audioClipStartInSeconds:l.audioClipStartInSeconds??0,createdAt:Date.now(),lastModified:Date.now()},y.songs[u].bloobIds.add(d);const g=l.audioFileId,w=y.audioFiles[g];w&&(w.referenceCount=(w.referenceCount??1)+1),n.trackAddOperation(J.Bloob,d,y.bloobs[d])}),ek(l.audioFileId),e().expandSongAsNecessary(u),d},deleteNotes:(s,o)=>{const a=new Map;s.forEach(l=>{const u=e().notes[l];u&&a.set(l,{...u})}),t(l=>{r(l,s,o,a)})},setBloobNotesContentHash:s=>{const o=e().bloobs[s];if(!o||!ln(o))return;const l=Array.from(o.noteIds).sort((u,d)=>u-d).map(u=>{var d;return(d=e().notes[u])==null?void 0:d.noteDetailsHash}).filter(u=>u!=null);t(u=>{const d=u.bloobs[s];d&&ln(d)&&(d.notesContentHashInLastUpdate=J1(l))})},checkIfBloobMetadataIsOutdated:s=>{var f;const o=e().getBloobById(s);if(!o)return!1;if(o.metadataOutdated!==void 0&&o.metadataOutdated!==null)return ar(`[metadataOutdated] bloob ${s}: ${o.metadataOutdated} (explicit flag)`),o.metadataOutdated;if(!ln(o))return!o.metadata||o.metadata==="";if(!o.notesContentHashInLastUpdate||o.notesContentHashInLastUpdate===""){const h=!o.metadata||o.metadata==="";return ar(`[metadataOutdated] bloob ${s}: ${h} (no baseline hash, no metadata=${!o.metadata})`),h}const l=Array.from(o.noteIds).sort((h,m)=>h-m).map(h=>{var m;return(m=e().notes[h])==null?void 0:m.noteDetailsHash}).filter(h=>h!=null),u=J1(l),d=u!==o.notesContentHashInLastUpdate;return ar(`[metadataOutdated] bloob ${s}: ${d} (hash ${d?"changed":"unchanged"} | baseline=${(f=o.notesContentHashInLastUpdate)==null?void 0:f.slice(0,8)}⦠current=${u.slice(0,8)}â¦)`),d},updateNoteDetails:(s,o)=>{const a=e().notes[s],l=a?{...a}:void 0;if(!a)return;const u=a.noteDetailsHash,d=e().noteDetails[u];if(!d)return;const f={pitch:o.newPitch??d.pitch,pitchInt:o.newPitch!==void 0?Oo(o.newPitch):d.pitchInt,velocity:o.newVelocity??d.velocity,startBeat:o.newStartBeat??d.startBeat,durationInBeats:o.newDurationInBeats??d.durationInBeats},h=fz(f);t(m=>{var g;const y=m.notes[s];if(y){if(u!==h){m.noteDetails||(m.noteDetails={});const w=((g=m.bloobs[m.notes[s].bloobId])==null?void 0:g.songId)??0,v=m.noteDetails[u]?{...m.noteDetails[u]}:void 0,S=hz(u,m.noteDetails);if(n.trackDecrementOperation(u,w),S&&v){const{referenceCount:C,...k}=v;n.trackDeleteOperation("NoteDetails",0,{hash:u,...k},{domain_type:"song",domain_id:w})}m.noteDetails[h]||(m.noteDetails[h]={...f,referenceCount:0},n.trackAddOperation("NoteDetails",0,{hash:h,...f},{domain_type:"song",domain_id:w})),ym(h,m.noteDetails),n.trackIncrementOperation(h,w),y.noteDetailsHash=h}n.trackUpdateOperation(J.Note,s,{noteDetailsHash:h},l)}})},copyNotes:s=>{let o=null;const a=s.map(l=>{const u=e().getNoteById(l);if(!u)throw new Error(`Note ${l} not found`);if(o===null)o=u.bloobId;else if(u.bloobId!==o)throw new Error("Cannot copy notes in different bloobs");const d=e().noteDetails[u.noteDetailsHash];if(!d)throw new Error(`NoteDetails not found for note ${l}`);return{pitch:d.pitch,velocity:d.velocity,startBeat:d.startBeat,durationInBeats:d.durationInBeats}});return e().addNotes(o,a)},shiftBloob:(s,o,a=1)=>{const l=e().getBloobById(s);let u=l.songPosition.bar,d=l.songPosition.track;switch(o){case jr.Up:d--;break;case jr.Right:u+=a;break;case jr.Down:d++;break;case jr.Left:u-=a;break}const f={bar:u,track:d},h=e().getBloobsOverlappingWithPosition(l.songId,f,l.bars).filter(m=>m.id!==s);if(h.length>0)if(o===jr.Left||o===jr.Right){let m=u;for(const y of h)o===jr.Right?m=Math.min(m,y.songPosition.bar-l.bars):m=Math.max(m,y.songPosition.bar+y.bars);if(m===l.songPosition.bar)return;f.bar=m}else return;e().updateBloobDetails(s,{songPosition:f}),e().expandSongAsNecessary(l.songId)},extendBloob:async(s,o)=>{const a=e().getBloobById(s),l=o===Qy.Left?{bar:a.songPosition.bar-a.bars,track:a.songPosition.track}:{...a.songPosition};if(e().updateBloobDetails(s,{songPosition:l,bars:a.bars*2}),En(a)){const u=e().getAudioFileById(a.audioFileId),d=await e().getAudioFileData(u.id),f=new AudioBuffer({numberOfChannels:d.length,sampleRate:u.sampleRate,length:d[0].length*2});d.forEach((m,y)=>{const g=new Float32Array(m.length*2);
97g.set(m,0),g.set(m,m.length),f.copyToChannel(g,y,0)});const h=await e().addAudioFile(u.fileName,f);e().updateAudioFileDetails(u.id,{newOriginalKey:u.originalKey,newOriginalBpm:u.originalBpm,newInstrument:u.instrument}),e().updateBloobDetails(s,{audioFileId:h})}else if(ln(a)){const u=e().getSongById(a.songId),d=Array.from(a.noteIds).map(f=>{const h=e().getNoteById(f),m=e().noteDetails[h.noteDetailsHash];if(!m)throw new Error(`NoteDetails not found for note ${f}`);return{pitch:m.pitch,velocity:m.velocity,startBeat:m.startBeat+a.bars*u.timeSignature.beatsPerBar,durationInBeats:m.durationInBeats}});e().addNotes(s,d)}e().expandSongAsNecessary(a.songId)},addBarsToBloobIfPossible:(s,o,a)=>{const l=e().getBloobById(s),u={bar:l.songPosition.bar-(o===Tr.Left?a:0),track:l.songPosition.track},d=l.bars+a;if(!e().getBloobsOverlappingWithPosition(l.songId,u,d).some(h=>h.id!==s)){if(En(l)&&o===Tr.Left){const h=e().getSongById(l.songId),m=ua(a,h.timeSignature,h.bpm),y=l.audioClipStartInSeconds??0,g=Math.max(0,y-m),w=y-g,v=w>0?a*(w/m):0;if(v<=0)return;t(S=>{const C=S.bloobs[s];C&&En(C)&&(C.audioClipStartInSeconds=g,C.songPosition={bar:l.songPosition.bar-v,track:l.songPosition.track},C.bars=l.bars+v)}),e().expandSongAsNecessary(l.songId);return}if(e().updateBloobDetails(s,{songPosition:u,bars:d}),o===Tr.Left&&ln(l)){const h=e().getSongById(l.songId);l.noteIds.forEach(m=>{const y=e().getNoteById(m),g=e().noteDetails[y.noteDetailsHash];if(!g)return;const w=g.startBeat+a*h.timeSignature.beatsPerBar;e().updateNoteDetails(m,{newStartBeat:w})})}e().expandSongAsNecessary(l.songId)}},removeBarsFromBloob:(s,o,a)=>{const l=e().getBloobById(s);if(a>=l.bars){e().deleteBloob(s);return}const u=l.bars-a;if(En(l)){const h=l.loopContentBars!=null&&u<=l.loopContentBars?{loopContentBars:null}:{},m=e().getSongById(l.songId);if(o===Tr.Left){const y=ua(a,m.timeSignature,m.bpm);t(g=>{const w=g.bloobs[s];w&&En(w)&&(w.audioClipStartInSeconds=(w.audioClipStartInSeconds??0)+y,w.songPosition={bar:l.songPosition.bar+a,track:l.songPosition.track},w.bars=u,h.loopContentBars===null&&delete w.loopContentBars)})}else e().updateBloobDetails(s,{bars:u,...h});return}const d={bar:l.songPosition.bar+(o===Tr.Left?a:0),track:l.songPosition.track},f=l.loopContentBars!=null&&u<=l.loopContentBars?{loopContentBars:null}:{};if(e().updateBloobDetails(s,{songPosition:d,bars:u,...f}),o===Tr.Left){const h=e().getSongById(l.songId);l.noteIds.forEach(m=>{const y=e().getNoteById(m),g=e().noteDetails[y.noteDetailsHash];if(g)if(g.startBeat<a*h.timeSignature.beatsPerBar)e().deleteNotes([m]);else{const w=g.startBeat-a*h.timeSignature.beatsPerBar;e().updateNoteDetails(m,{newStartBeat:w})}})}},setLoopBars:(s,o)=>{const a=e().getBloobById(s),l=a.loopContentBars??a.bars,u=a.songPosition;if(e().getBloobsOverlappingWithPosition(a.songId,u,o).some(h=>h.id!==s))return;const f=Math.max(l,o);e().updateBloobDetails(s,{bars:f,loopContentBars:l}),e().expandSongAsNecessary(a.songId)},clearLoop:s=>{const o=e().getBloobById(s);o.loopContentBars&&e().updateBloobDetails(s,{bars:o.loopContentBars,loopContentBars:null})},transposeBloobs:(s,o,a)=>{s.forEach(l=>{const u=e().getBloobById(l);u&&ln(u)&&e().transposeMidiBloobs([l],o,a)})},transposeMidiBloobs:(s,o,a)=>{s.forEach(l=>{const u=e().getBloobById(l);ln(u)&&ci(u.instrument)!==$r.BuiltInDrumMachine&&u.noteIds.forEach(d=>{const f=e().getNoteById(d),h=e().noteDetails[f.noteDetailsHash];if(!h)return;const m=cO(h.pitch,o,a);e().updateNoteDetails(d,{newPitch:m})})})},updateBloobDetails:(s,o)=>{const a=e().bloobs[s],l=a?{...a}:void 0;let u={...o};if(o.metadataOutdated===!1){const h=e().bloobs[s];if(h&&ln(h)){const m=Array.from(h.noteIds).sort((w,v)=>w-v),y=m.map(w=>{var v;return(v=e().notes[w])==null?void 0:v.noteDetailsHash}).filter(w=>w!=null),g=J1(y);u={...o,notesContentHashInLastUpdate:g},ar(`[metadataOutdated] bloob ${s}: setting metadata up to date, baseline hash=${g.slice(0,8)}⦠(${m.length} notes)`)}}if(o.songPosition!==void 0){const h=e().bloobs[s];if(h&&ln(h)){const m=e().getTrackForSongTrackIndex(h.songId,o.songPosition.track);m!=null&&m.instrumentLock&&(u={...u,instrument:m.instrumentLock})}}const d=e().getBloobById(s),f=En(d)?d.audioFileId:void 0;t(h=>{var y;const m=h.bloobs[s];if(m){if(u.bloobType!==void 0&&(m.bloobType=u.bloobType),u.songPosition!==void 0&&(m.songPosition=u.songPosition),u.bars!==void 0&&(m.bars=u.bars,(y=m.volumeAutomation)!=null&&y.length&&(m.volumeAutomation=m.volumeAutomation.filter(g=>g.bar<=u.bars))),u.loopContentBars!==void 0&&(u.loopContentBars===null?delete m.loopContentBars:m.loopContentBars=u.loopContentBars),u.muted!==void 0&&(m.muted=u.muted),u.soloed!==void 0){m.soloed=u.soloed;const g=h.songs[m.songId];if(u.soloed)g.hasSoloedBloobs=!0;else{const v=Array.from(g.bloobIds).some(S=>h.bloobs[S].soloed);g.hasSoloedBloobs=v}}if(u.label!==void 0&&(m.label=u.label),u.volume!==void 0&&(m.volume=u.volume),u.volumeAutomation!==void 0&&(m.volumeAutomation=u.volumeAutomation),u.melodicRole!==void 0&&(m.melodicRole=u.melodicRole),u.metadata!==void 0&&(m.metadata=u.metadata),u.metadataOutdated!==void 0&&(m.metadataOutdated=u.metadataOutdated),ln(m)&&u.notesContentHashInLastUpdate!==void 0&&(m.notesContentHashInLastUpdate=u.notesContentHashInLastUpdate),ln(m)&&u.instrument!==void 0&&(m.instrument=u.instrument,m.color=oi(u.instrument)),En(m)&&u.playbackRate!==void 0&&(m.playbackRate=u.playbackRate),En(m)&&u.audioFileId!==void 0){const g=m.audioFileId,w=u.audioFileId;if(g!==w){let v=!1;
97if(Object.values(e().bloobs).forEach(C=>{En(C)&&C.id!==s&&C.audioFileId===g&&(v=!0)}),!v){const C=h.audioFiles[g];C?(C.referenceCount=Math.max(0,(C.referenceCount??1)-1),C.referenceCount===0&&e().deleteAudioFile(g)):e().deleteAudioFile(g)}m.audioFileId=w;const S=h.audioFiles[w];S&&(S.referenceCount=(S.referenceCount??1)+1)}}En(m)&&u.midiConversion!==void 0&&(m.midiConversion=u.midiConversion),u.lastModified!==void 0?m.lastModified=u.lastModified:m.lastModified=Date.now(),e().updateSongDetails(m.songId,{lastModified:Date.now()}),n.trackUpdateOperation(J.Bloob,s,u,l)}}),u.audioFileId!=null&&u.audioFileId!==f&&ek(u.audioFileId)},convertToAudioBloob:(s,o)=>{const a=e().getBloobById(s);if(!a||En(a))return;const l={...a};e().deleteNotes(Array.from(a.noteIds));const u=e().getSongById(a.songId),d=e().getAudioFileById(o),f={type:J.Bloob,bloobType:Us.Audio,id:a.id,songId:a.songId,inSongId:a.inSongId,label:a.label,color:a.color,muted:a.muted,soloed:a.soloed,songPosition:a.songPosition,bars:a.bars,volume:a.volume,audioFileId:o,playbackRate:Jp(u.bpm,d.originalBpm),audioClipStartInSeconds:0};t(m=>{m.bloobs[s]=f;const y=m.audioFiles[o];y&&(y.referenceCount=(y.referenceCount??1)+1)}),ek(o),n.trackDeleteOperation(J.Bloob,s,l),n.trackAddOperation(J.Bloob,s,f);const h=Ga.getInstance();h&&h.queueAndUploadAudioFile(o)},splitBloob:(s,o)=>{const a=e().getBloobById(s);if(!a)return null;const l=e().getSongById(a.songId);if(!l)return null;const u=a.songPosition.bar,d=u+a.bars;if(o<=u||o>=d)return null;const f=o-u,h=a.bars-f,m=l.timeSignature.beatsPerBar;if(ln(a)){const y=f*m,g=e().getNotesInBloob(a.id),w=[],v=[],S=[];for(const k of g){const N=e().noteDetails[k.noteDetailsHash];if(!N)continue;const _=N.startBeat+N.durationInBeats;N.startBeat>=y?(w.push({pitch:N.pitch,velocity:N.velocity,startBeat:N.startBeat-y,durationInBeats:N.durationInBeats}),v.push(k.id)):_>y&&(S.push({id:k.id,newDuration:y-N.startBeat}),w.push({pitch:N.pitch,velocity:N.velocity,startBeat:0,durationInBeats:_-y}))}e().updateBloobDetails(s,{bars:f,lastModified:Date.now()});for(const{id:k,newDuration:N}of S)e().updateNoteDetails(k,{newDurationInBeats:N});v.length>0&&e().deleteNotes(v,s);const C=e().addMidiBloob(a.songId,a.instrument,h,{bar:o,track:a.songPosition.track},a.label,a.melodicRole,"",!0);return w.length>0&&e().addNotes(C,w),t(k=>{const N=k.bloobs[C];N&&(N.color=a.color,N.volume=a.volume)}),C}else if(En(a)){const y=ua(f,l.timeSignature,l.bpm),g=(a.audioClipStartInSeconds??0)+y,w=e().getNextBloobId(),v=e().getNextBloobInSongId(a.songId),S=Date.now(),C={type:J.Bloob,id:w,songId:a.songId,inSongId:v,label:a.label,color:a.color,muted:a.muted,soloed:!1,songPosition:{bar:o,track:a.songPosition.track},bars:h,volume:a.volume,volumeAutomation:void 0,melodicRole:a.melodicRole,metadata:a.metadata||"",bloobType:Us.Audio,audioFileId:a.audioFileId,playbackRate:a.playbackRate,metadataOutdated:!0,midiConversion:a.midiConversion??null,audioClipStartInSeconds:g,createdAt:S,lastModified:S};return t(k=>{var _;const N=k.bloobs[s];N&&(N.bars=f,N.lastModified=S,(_=N.volumeAutomation)!=null&&_.length&&(N.volumeAutomation=N.volumeAutomation.filter(j=>j.bar<=f))),k.bloobs[w]=C,k.songs[a.songId].bloobIds.add(w)}),n.trackUpdateOperation(J.Bloob,s,{bars:f,lastModified:S},{...a}),n.trackAddOperation(J.Bloob,w,C),e().expandSongAsNecessary(a.songId),w}return null},getNextNoteId:()=>Ra(J.Note),addNotes:(s,o)=>{if(o.length===0)return[];e().updateBloobDetails(s,{lastModified:Date.now()});const a=e(),l=[],u=new Set;let d=0;for(let h=0;h<o.length;h++){const m=o[h];let y=e().getNextNoteId(),g=0;const w=10;for(;u.has(y)||a.notes[y]!==void 0||e().notes[y]!==void 0;){if(g++,g>w){d++,y=-1;break}y=e().getNextNoteId()}y!==-1&&(u.add(y),l.push({note:m,noteId:y}))}if(d>0&&pr(`addNotes warning: ${d} out of ${o.length} notes were skipped due to ID collision issues`),l.length===0)return[];const f=l.map(({noteId:h})=>h);return t(h=>{h.noteDetails||(h.noteDetails={}),l.forEach(({note:m,noteId:y})=>{var k;if(h.notes[y]!==void 0)return;const g={pitch:m.pitch,pitchInt:Oo(m.pitch),velocity:m.velocity,startBeat:m.startBeat,durationInBeats:m.durationInBeats},w=fz(g),v=((k=h.bloobs[s])==null?void 0:k.songId)??0;h.noteDetails[w]||(h.noteDetails[w]={...g,referenceCount:0},n.trackAddOperation("NoteDetails",0,{hash:w,...g},{domain_type:"song",domain_id:v}));
97const S={type:J.Note,id:y,bloobId:s,noteDetailsHash:w};h.notes[S.id]=S;const C=h.bloobs[s];ln(C)&&C.noteIds.add(S.id),ym(w,h.noteDetails),n.trackIncrementOperation(w,v),n.trackAddOperation(J.Note,S.id,S,{domain_type:"song",domain_id:v})})}),f},getSongById:s=>e().songs[s]??ZJ(s),getBloobById:s=>e().bloobs[s]??JJ(s),getNoteById:s=>e().notes[s]??eee(s),getBloobByIdForRequest:s=>{const o=e().bloobs[s];if(!o)return o;if(ln(o)){const a=Array.from(o.noteIds).filter(d=>e().notes[d]!==void 0).map(d=>{const f=e().notes[d];if(!f)return null;const h=e().noteDetails[f.noteDetailsHash];return h?{pitch:h.pitch,pitchInt:h.pitchInt,velocity:h.velocity,startBeat:h.startBeat,durationInBeats:h.durationInBeats}:(pr(`NoteDetails not found for hash: ${f.noteDetailsHash}`),null)}).filter(d=>d!==null);e().checkIfBloobMetadataIsOutdated(s)&&e().updateBloobDetails(s,{metadataOutdated:!0});const{notesContentHashInLastUpdate:l,...u}=o;return{...u,notes:a}}return o},doesNoteExist:s=>e().notes[s]!==void 0,getBloobsInSongForRequest:s=>{try{const o={},a={},l=e().songs[s];return!l||!l.bloobIds?[]:(Array.from(l.bloobIds).filter(u=>e().bloobs[u]!==void 0).forEach(u=>{const d=e().bloobs[u];if(d)if(ln(d)){const f=d,h=e().songs[s],m=f.bars*h.timeSignature.beatsPerBar,y=f.loopContentBars,g=y?y*h.timeSignature.beatsPerBar:void 0,w=y&&y>0?Math.ceil(f.bars/y):1,v=Array.from(f.noteIds).filter(_=>e().notes[_]!==void 0).map(_=>{a[_]||(a[_]=e().notes[_]);const j=a[_];if(!j)return null;const T=e().noteDetails[j.noteDetailsHash];return T?{pitch:T.pitch,pitchInt:T.pitchInt,velocity:T.velocity,startBeat:T.startBeat,durationInBeats:T.durationInBeats}:(pr(`NoteDetails not found for hash: ${j.noteDetailsHash}`),null)}).filter(_=>_!==null),S=[];for(let _=0;_<w;_++){const j=_*(g??m);for(const T of v){if(g&&T.startBeat>=g)continue;const M=T.startBeat+j;M>=m||S.push({pitch:T.pitch,pitchInt:T.pitchInt,velocity:T.velocity,startBeat:M,durationInBeats:Math.min(T.durationInBeats,m-M)})}}const{notesContentHashInLastUpdate:C,...k}=f,N={...k,notes:S,metadataOutdated:e().checkIfBloobMetadataIsOutdated(u)};o[u]=N}else En(d)&&(o[u]={...d})}),Object.values(o))}catch{return[]}},getBloobsInSong:s=>{try{const o=e().getSongById(s);return!o||!o.bloobIds?[]:Array.from(o.bloobIds).filter(a=>e().bloobs[a]!==void 0).map(a=>e().getBloobById(a))}catch{return[]}},getNotesInBloob:s=>{try{const o=e().bloobs[s];return!o||!ln(o)?[]:Array.from(o.noteIds).filter(a=>e().notes[a]!==void 0).map(a=>e().getNoteById(a))}catch{return[]}},getBloobsOverlappingWithPosition:(s,o,a)=>{const l=e().getBloobsInSong(s),d=sO(l)[o.track];if(!d)return[];const f=[];return d.forEach(h=>{oO(o,a,h.songPosition,h.bars)&&f.push(h)}),f},findOpenSongPositionNear:(s,o,a)=>{const l=e().getSongById(s);if(!l)return null;const u=typeof a=="number"&&a>0?a:1,d=o&&typeof o.bar=="number"&&typeof o.track=="number"?o:{bar:0,track:0},f=d.track,h=d.bar-8,m=h+16,y=Math.max(8,l.tracks),g=0,w=l.tracks-1;let v=null,S=1/0;for(let C=h;C<=m;C++)for(let k=0;k<=y;k++)for(const N of[1,-1]){const _=f+N*k;if(_<g||_>w)continue;const j={bar:C,track:_};if(e().getBloobsOverlappingWithPosition(s,j,u).length===0){const M=2*Math.abs(C-(d.bar+u))+3*Math.abs(_-f);(M<S||M===S&&(v===null||C<v.bar||C===v.bar&&_<v.track))&&(S=M,v=j)}}if(!v)for(let C=h;C<=m;C++){const k={bar:C,track:0};if(e().getBloobsOverlappingWithPosition(s,k,u).length===0)return k}return v},getSongBloobContentBoundary:s=>{let o=1/0,a=-1/0;return e().getSongById(s).bloobIds.forEach(u=>{const d=e().getBloobById(u);d.songPosition.bar<o&&(o=d.songPosition.bar);const f=d.songPosition.bar+d.bars-1;f>a&&(a=f)}),{firstBarWithBloobContent:o,lastBarWithBloobContent:a}},getNextTrackId:()=>Ra(J.Track),addTrack:(s,o)=>{const a=e().getNextTrackId(),l=Date.now(),u={type:J.Track,id:a,songId:s,trackIndex:o,name:`Track ${o+1}`,instrumentLock:null,effects:{...oT},createdAt:l,lastModified:l};return t(d=>{d.tracks[a]=u,d.songs[s]&&(d.songs[s].trackIds instanceof Set||(d.songs[s].trackIds=new Set(Array.isArray(d.songs[s].trackIds)?d.songs[s].trackIds:[])),d.songs[s].trackIds.add(a))}),n.trackAddOperation(J.Track,a,u,{domain_type:"song",domain_id:s}),a},updateTrackName:(s,o)=>{const a=e().tracks[s];if(!a)return;const l={...a};t(u=>{const d=u.tracks[s];d&&(d.name=o,d.lastModified=Date.now())}),n.trackUpdateOperation(J.Track,s,{name:o,lastModified:e().tracks[s].lastModified},l)},setTrackInstrumentLock:(s,o)=>{const a=e().tracks[s];if(!a)return;const l={...a},u=o||null,d=e().songs[a.songId],f=new Map;d&&u&&d.bloobIds.forEach(m=>{const y=e().bloobs[m];y&&ln(y)&&y.songPosition.track===a.trackIndex&&y.instrument!==u&&f.set(m,{...y})});const h=Date.now();t(m=>{const y=m.tracks[s];if(!y||(y.instrumentLock=u,y.lastModified=h,!u))return;const g=m.songs[y.songId];g&&g.bloobIds.forEach(w=>{const v=m.bloobs[w];v&&ln(v)&&v.songPosition.track===y.trackIndex&&(v.instrument=u,v.color=oi(u),v.lastModified=h)})}),n.trackUpdateOperation(J.Track,s,{instrumentLock:u,lastModified:e().tracks[s].lastModified},l),u&&f.forEach((m,y)=>{const g=e().bloobs[y];!g||!ln(g)||n.trackUpdateOperation(J.Bloob,y,{instrument:g.instrument,color:g.color,lastModified:g.lastModified},m)})},updateTrackEffects:(s,o)=>{const a=e().tracks[s];if(!a)return;const l={...a};t(u=>{const d=u.tracks[s];d&&(o.eq&&(d.effects.eq={...d.effects.eq,...o.eq}
97),o.compressor&&(d.effects.compressor={...d.effects.compressor,...o.compressor}),o.reverb&&(d.effects.reverb={...d.effects.reverb,...o.reverb}),d.lastModified=Date.now())}),n.trackUpdateOperation(J.Track,s,{effects:e().tracks[s].effects,lastModified:e().tracks[s].lastModified},l)},deleteTrack:s=>{const o=e().tracks[s];if(!o)return;const a={...o};t(l=>{const u=l.tracks[s];if(!u)return;const d=l.songs[u.songId];d&&(d.trackIds instanceof Set||(d.trackIds=new Set(Array.isArray(d.trackIds)?d.trackIds:[])),d.trackIds.delete(s)),delete l.tracks[s]}),n.trackDeleteOperation(J.Track,s,a,{domain_type:"song",domain_id:o.songId})},getTrackForSongTrackIndex:(s,o)=>{const a=e().songs[s];if(!a)return;const l=a.trackIds instanceof Set?a.trackIds:new Set(Array.isArray(a.trackIds)?a.trackIds:[]);for(const u of l){const d=e().tracks[u];if(d&&d.trackIndex===o)return d}},getEffectiveTrackEffects:(s,o)=>{const a=e().getTrackForSongTrackIndex(s,o);return a?a.effects:oT},ensureTrackEntity:(s,o)=>{const a=e().getTrackForSongTrackIndex(s,o);if(a)return a;const l=e().addTrack(s,o);return e().tracks[l]},getNextTextNodeId:()=>Ra(J.TextNode),addTextNode:(s,o,a)=>{const l=e().getNextTextNodeId(),u=a||"",d=u.length,f=Math.max(1,u.split("<br>").length),h=d>200?Math.min(em*1.5,Math.max(em,d*1.5)):em,m=f>3?Math.min(tm*1.5,tm+f*28):tm,y={type:J.TextNode,id:l,canvasPosition:s,label:o,content:u,width:h,height:m,threadIds:new Set};return t(g=>{g.textNodes[y.id]=y}),n.trackAddOperation(J.TextNode,y.id,y),y.id},updateTextNode:(s,o)=>{const a=e().textNodes[s],l=a?{...a}:void 0;t(u=>{const d=u.textNodes[s];d&&(o.label!==void 0&&(d.label=o.label),o.content!==void 0&&(d.content=o.content),o.canvasPosition!==void 0&&(d.canvasPosition=o.canvasPosition),o.width!==void 0&&(d.width=o.width),o.height!==void 0&&(d.height=o.height),n.trackUpdateOperation(J.TextNode,s,o,l))})},deleteTextNode:s=>{var l,u;const o=e().textNodes[s],a=o?{...o}:void 0;(u=(l=e()).deleteThreadsForObject)==null||u.call(l,"text",s),t(d=>{delete d.textNodes[s],n.trackDeleteOperation(J.TextNode,s,a)})},duplicateTextNode:(s,o)=>{const a=e().getTextNodeById(s),l={...a,id:e().getNextTextNodeId(),canvasPosition:o,label:a.label?a.label+" (copy)":void 0,threadIds:new Set};return t(u=>{u.textNodes[l.id]=l}),n.trackAddOperation(J.TextNode,l.id,l),l.id},getNextEmbeddingNodeId:()=>Ra(J.EmbeddingNode),addEmbeddingNode:(s,o,a)=>{const l=e().getNextEmbeddingNodeId();let u=vc,d=Cf;if(a){const h=a.toLowerCase();h.includes("youtube.com")||h.includes("youtu.be")||h.includes("vimeo.com")||h.includes("twitch.tv")||h.includes("dailymotion.com")?(u=Math.min(900,vc*1.8),d=Math.min(650,Cf*1.6)):h.includes("spotify.com")||h.includes("soundcloud.com")||h.includes("bandcamp.com")||h.includes("apple.com/music")||h.includes("music.apple.com")?(u=Math.min(800,vc*1.6),d=Math.min(500,Cf*1.2)):h.includes("twitter.com")||h.includes("x.com")||h.includes("instagram.com")||h.includes("facebook.com")||h.includes("tiktok.com")||h.includes("linkedin.com")?(u=Math.min(700,vc*1.4),d=Math.min(550,Cf*1.3)):a.length>100?u=Math.min(750,vc*1.5):a.length>50&&(u=Math.min(650,vc*1.3))}const f={type:J.EmbeddingNode,id:l,canvasPosition:s,label:o,url:a||"",width:u,height:d,threadIds:new Set};return t(h=>{h.embeddingNodes[f.id]=f}),n.trackAddOperation(J.EmbeddingNode,f.id,f),f.id},updateEmbeddingNode:(s,o)=>{const a=e().embeddingNodes[s],l=a?{...a}:void 0;t(u=>{const d=u.embeddingNodes[s];d&&(o.label!==void 0&&(d.label=o.label),o.url!==void 0&&(d.url=o.url),o.canvasPosition!==void 0&&(d.canvasPosition=o.canvasPosition),o.width!==void 0&&(d.width=o.width),o.height!==void 0&&(d.height=o.height),n.trackUpdateOperation(J.EmbeddingNode,s,o,l))})},deleteEmbeddingNode:s=>{var l,u;const o=e().embeddingNodes[s],a=o?{...o}:void 0;(u=(l=e()).deleteThreadsForObject)==null||u.call(l,"embedding",s),t(d=>{delete d.embeddingNodes[s],n.trackDeleteOperation(J.EmbeddingNode,s,a)})},duplicateEmbeddingNode:(s,o)=>{const a=e().getEmbeddingNodeById(s),l={...a,id:e().getNextEmbeddingNodeId(),canvasPosition:o,label:a.label?a.label+" (copy)":void 0,threadIds:new Set};return t(u=>{u.embeddingNodes[l.id]=l}),n.trackAddOperation(J.EmbeddingNode,l.id,l),l.id},getTextNodeById:s=>{const o=e().textNodes[s];return o&&!o.threadIds?{...o,threadIds:new Set}:o??{type:J.TextNode,id:s,label:"",content:"",canvasPosition:{x:0,y:0},width:em,height:tm,threadIds:new Set}},getEmbeddingNodeById:s=>{const o=e().embeddingNodes[s];return o&&!o.threadIds?{...o,threadIds:new Set}:o??{type:J.EmbeddingNode,id:s,label:"",url:"",canvasPosition:{x:0,y:0},width:vc,height:Cf,threadIds:new Set}},getNextVisualMediaNodeId:()=>Ra(J.VisualMediaNode),addVisualMediaNode:(s,o,a)=>{const l=e().getNextVisualMediaNodeId();let u=nm,d=rm;a&&a.startsWith("data:")&&(a.startsWith("data:video/")?(u=Math.min(800,nm*1.5),d=Math.min(600,rm*1.5)):a.startsWith("data:image/")&&(u=Math.min(700,nm*1.3),d=Math.min(500,rm*1.3)));const f={type:J.VisualMediaNode,id:l,canvasPosition:s,label:o,mediaData:a||"",width:u,height:d,threadIds:new Set};return t(h=>{h.visualMediaNodes[f.id]=f}),n.trackAddOperation(J.VisualMediaNode,f.id,f),f.id},updateVisualMediaNode:(s,o)=>{const a=e().visualMediaNodes[s],l=a?{...a}:void 0;t(u=>{const d=u.visualMediaNodes[s];d&&(o.label!==void 0&&(d.label=o.label),o.mediaData!==void 0&&(d.mediaData=o.mediaData),o.canvasPosition!==void 0&&(d.canvasPosition=o.canvasPosition),o.width!==void 0&&(d.width=o.width),o.height!==void 0&&(d.height=o.height),n.trackUpdateOperation(J.VisualMediaNode,s,o,l))})},deleteVisualMediaNode:s=>{var l,u;const o=e().visualMediaNodes[s],a=o?{...o}:void 0;(u=(l=e()).deleteThreadsForObject)==null||u.call(l,"visual",s),t(d=>{delete d.visualMediaNodes[s],n.trackDeleteOperation(J.VisualMediaNode,s,a)})},duplicateVisualMediaNode:(s,o)=>{const a=e().getVisualMediaNodeById(s),l={...a,id:e().getNextVisualMediaNodeId(),canvasPosition:o,label:a.label?a.label+" (copy)":void 0};return t(u=>{u.visualMediaNodes[l.id]=l}),n.trackAddOperation(J.VisualMediaNode,l.id,l),l.id},getVisualMediaNodeById:s=>{const o=e().visualMediaNodes[s];return o&&!o.threadIds?{...o,threadIds:new Set}:o??{type:J.VisualMediaNode,id:s,label:"",mediaData:"",canvasPosition:{x:0,y:0},width:nm,height:rm,threadIds:new Set}},getAllTextNodes:()=>Object.values(e().textNodes),getAllEmbeddingNodes:()=>Object.values(e().embeddingNodes),getAllVisualMediaNodes:()=>Object.values(e().visualMediaNodes),getPlaybackInfo:(s,o)=>{const a=e().getSongById(s),l=[];
97return e().getBloobsInSong(s).forEach(u=>{if(!(u.muted||a.hasSoloedBloobs&&!u.soloed||u.songPosition.bar>o||u.songPosition.bar+u.bars<=o)&&ln(u)){const d=[];u.noteIds.forEach(f=>{const h=e().getNoteById(f),m=e().noteDetails[h.noteDetailsHash];if(!m)return;const y=u.songPosition.bar+m.startBeat/a.timeSignature.beatsPerBar;Math.floor(y)===o&&d.push(h)}),l.push({instrument:u.instrument,notes:d,volume:u.volume})}}),l},getAllInUseInstruments:()=>[...new Set(Object.values(e().bloobs).filter(s=>ln(s)).map(s=>s.instrument))],getNextAudioFileId:()=>Ra(J.AudioFile),addAudioFile:async(s,o,a)=>{const l=e().getNextAudioFileId(),u=nD(s),d=[];for(let m=0;m<o.numberOfChannels;m++)d.push(o.getChannelData(m));await RS(l,d,1);const f={id:l,fileName:s,originalKey:(a==null?void 0:a.originalKey)??u.originalKey,originalBpm:(a==null?void 0:a.originalBpm)??u.originalBpm,instrument:(a==null?void 0:a.originalInstrument)??u.instrument,sampleRate:o.sampleRate,samples:o.length,referenceCount:1};t(m=>{m.audioFiles[l]=f}),n.trackAddOperation(J.AudioFile,l,f);const h=Ga.getInstance();return h&&h.queueAndUploadAudioFile(l),l},deleteAudioFile:s=>{const o=e().audioFiles[s];o&&n.trackDeleteOperation(J.AudioFile,s,o),WJ(s),t(a=>{delete a.audioFiles[s]})},getAudioFileById:s=>{const o=e().audioFiles[s];return o||null},isAudioFileFetching:s=>e().fetchingAudioFiles.has(s),isAudioFileAvailable:async s=>await pb(s)!==null,getBloobInstrument:s=>{const o=e().getBloobById(s);if(ln(o))return o.instrument;if(En(o))return e().getAudioFileById(o.audioFileId).instrument},updateAudioFileDetails:(s,o)=>{const a=e().audioFiles[s];if(!a)return;const l={};o.newOriginalKey!==void 0&&(l.originalKey=o.newOriginalKey),o.newOriginalBpm!==void 0&&(l.originalBpm=o.newOriginalBpm),o.newInstrument!==void 0&&(l.instrument=o.newInstrument),Object.keys(l).length>0&&n.trackUpdateOperation(J.AudioFile,s,l,{...a}),t(f=>{const h=f.audioFiles[s];h&&(o.newOriginalKey!==void 0&&(h.originalKey=o.newOriginalKey),o.newOriginalBpm!==void 0&&(h.originalBpm=o.newOriginalBpm),o.newInstrument!==void 0&&(h.instrument=o.newInstrument))});
97const u=e().getAudioFileById(s),d=u.samples/u.sampleRate;o.newOriginalBpm&&Object.keys(e().bloobs).forEach(f=>{const h=Number(f),m=e().getBloobById(h);if(En(m)&&m.audioFileId===s){const y=e().getSongById(m.songId),g=Jp(y.bpm,o.newOriginalBpm),w=Math.ceil(H2(d,y.timeSignature,y.bpm));e().updateBloobDetails(h,{playbackRate:g,bars:w})}})},getAudioFileData:async s=>{var l;const o=await pb(s);if(o)return o;const a=e();if(a.fetchingAudioFiles.has(s)){const f=Date.now();for(;a.fetchingAudioFiles.has(s);){if(Date.now()-f>3e4)throw new Error(`Timeout waiting for audio file ${s} to load`);await new Promise(y=>setTimeout(y,100));const h=await pb(s);if(h)return h;if(!e().fetchingAudioFiles.has(s)){const y=await pb(s);if(y)return y;throw new Error(`Audio file ${s} fetch failed`)}}}t(u=>{u.fetchingAudioFiles=new Set(u.fetchingAudioFiles),u.fetchingAudioFiles.add(s)});try{const{downloadAudioFileFromBackend:u}=await ai(async()=>{const{downloadAudioFileFromBackend:y}=await import("./audioFileDownloader-C-2LE-Gt.js");return{downloadAudioFileFromBackend:y}},__vite__mapDeps([5,1,2,3,4])),d=e();let f;for(const y of Object.values(d.bloobs||{}))if(En(y)&&y.audioFileId===s){f=y.songId;break}const h=await u(s,f),m=((l=e().audioFiles[s])==null?void 0:l.referenceCount)??1;return await RS(s,h,m),h}catch(u){throw pr("Failed to download audio file",{audioFileId:s,error:u instanceof Error?u.message:String(u)}),u}finally{t(u=>{u.fetchingAudioFiles=new Set(u.fetchingAudioFiles),u.fetchingAudioFiles.delete(s)})}},doesSongWithNameExist:s=>Object.values(e().songs).some(o=>o.label===s),getSongName:s=>e().getSongById(s).label||`Song ${s}`,getBloobName:s=>{const o=e().getBloobById(s);if(o.label)return o.label;if(Gh(o))return"Empty";if(ln(o))return o.instrument?$l(o.instrument):`Midi Bloob ${s}`;if(En(o)){const a=e().getAudioFileById(o.audioFileId);if(a.fileName){if(a.fileName==="new-recording.wav")return"New Recording";const l=a.fileName.match(/^new-recording-(\d+)\.wav$/i);return l?`New Recording ${l[1]}`:a.fileName.replace(/\.[^/.]+$/,"")}return a.instrument?$l(a.instrument):`Audio Bloob ${s}`}return`Bloob ${s}`},getTextNodeName:s=>{const o=e().getTextNodeById(s);return o.label?o.label:`Note ${s}`},getEmbeddingNodeName:s=>{var l;const o=e().getEmbeddingNodeById(s);if(o.label)return o.label;const a=(l=o.url)==null?void 0:l.trim();if(!a)return`Link ${s}`;try{const d=new URL(a).hostname.replace("www.","");return d.includes("youtube.com")||d.includes("youtu.be")?"YouTube":d.includes("spotify.com")?"Spotify":d.includes("soundcloud.com")?"SoundCloud":d.includes("music.apple.com")?"Apple Music":d.includes("bandcamp.com")?"Bandcamp":d.includes("tidal.com")?"Tidal":d.includes("deezer.com")?"Deezer":d.includes("music.amazon.com")?"Amazon Music":d.includes("pandora.com")?"Pandora":d.charAt(0).toUpperCase()+d.slice(1)}catch{return`Link ${s}`}},getVisualMediaNodeName:s=>{const o=e().getVisualMediaNodeById(s);return o.label?o.label:`Visual ${s}`},getAudioFileDataRelevantToSongs:async s=>{const o={};return s.forEach(async a=>{e().getSongById(a).bloobIds.forEach(async u=>{const d=e().getBloobById(u);En(d)&&!o[d.audioFileId]&&(o[d.audioFileId]=await e().getAudioFileData(d.audioFileId))})}),o},getNoteIdsInRect:(s,o)=>{const a=e(),l=a.bloobs[s];if(!l||!ln(l))return[];const u=a.songs[l.songId];if(!u)return[];const d=[];return l.noteIds.forEach(f=>{const h=a.notes[f];if(!h)return;const m=a.noteDetails[h.noteDetailsHash];if(!m)return;const y={...h,startBeat:m.startBeat,pitch:m.pitch};XJ(y,o,u)&&d.push(f)}),d},getCaiObjectsInRect:s=>{const o=[];return Object.keys(e().songs).forEach(a=>{const l=e().getSongById(Number(a)),u={canvasPosition:l.canvasPosition,width:Yv(l.bars),height:$_(l.tracks)};lb(u,s)&&o.push(l)}),Object.keys(e().textNodes).forEach(a=>{const l=e().getTextNodeById(Number(a)),u={canvasPosition:l.canvasPosition,width:l.width,height:l.height};lb(u,s)&&o.push(l)}),Object.keys(e().embeddingNodes).forEach(a=>{const l=e().getEmbeddingNodeById(Number(a)),u={canvasPosition:l.canvasPosition,width:l.width,height:l.height};lb(u,s)&&o.push(l)}
97),Object.keys(e().visualMediaNodes).forEach(a=>{const l=e().getVisualMediaNodeById(Number(a)),u={canvasPosition:l.canvasPosition,width:l.width,height:l.height};lb(u,s)&&o.push(l)}),o},getAllCaiObjects:()=>{const s=[];return Object.values(e().songs).forEach(o=>{s.push({type:J.Song,id:o.id})}),Object.values(e().textNodes).forEach(o=>{s.push({type:J.TextNode,id:o.id})}),Object.values(e().embeddingNodes).forEach(o=>{s.push({type:J.EmbeddingNode,id:o.id})}),Object.values(e().visualMediaNodes).forEach(o=>{s.push({type:J.VisualMediaNode,id:o.id})}),s},clearCanvas:()=>{const s=Object.keys(e().songs).map(Number),o=Object.keys(e().textNodes).map(Number),a=Object.keys(e().embeddingNodes).map(Number),l=Object.keys(e().visualMediaNodes).map(Number);s.forEach(d=>{e().deleteSong(d)}),o.forEach(d=>{e().deleteTextNode(d)}),a.forEach(d=>{e().deleteEmbeddingNode(d)}),l.forEach(d=>{e().deleteVisualMediaNode(d)}),Object.keys(e().audioFiles).map(Number).forEach(d=>{e().deleteAudioFile(d)})}}};var gi=(t=>(t.Light="light",t.Dark="dark",t))(gi||{});const nee={theme:gi.Dark,useSystemTheme:!1,welcomeOpen:!1,uploadOpen:!1,exportOpen:!1,aboutOpen:!1,inspectStorageOpen:!1,initialSettingsOpen:!1,hotkeysOpen:!1,projectOpen:!1,mobileInspectorOpen:!1,mobileSearchOpen:!1,mobileRecordDetailsOpen:!1,showVolumeAutomation:!1},ree=t=>({...nee,setTheme:e=>{t(n=>{n.theme=e})},setUseSystemTheme:e=>{t(n=>{n.useSystemTheme=e})},closeWelcome:()=>{t(e=>{e.welcomeOpen=!1})},showUpload:()=>{t(e=>{e.uploadOpen=!0})},closeUpload:()=>{t(e=>{e.uploadOpen=!1})},showExport:()=>{t(e=>{e.exportOpen=!0})},closeExport:()=>{t(e=>{e.exportOpen=!1})},showAbout:()=>{t(e=>{e.aboutOpen=!0})},closeAbout:()=>{t(e=>{e.aboutOpen=!1})},showInspectStorage:()=>{t(e=>{e.inspectStorageOpen=!0})},closeInspectStorage:()=>{t(e=>{e.inspectStorageOpen=!1})},showInitialSettings:()=>{t(e=>{e.initialSettingsOpen=!0})},closeInitialSettings:()=>{t(e=>{e.initialSettingsOpen=!1})},showHotkeys:()=>{t(e=>{e.hotkeysOpen=!0})},closeHotkeys:()=>{t(e=>{e.hotkeysOpen=!1})},showProject:()=>{t(e=>{e.projectOpen=!0})},closeProject:()=>{t(e=>{e.projectOpen=!1})},showMobileInspector:()=>{t(e=>{e.mobileInspectorOpen=!0})},closeMobileInspector:()=>{t(e=>{e.mobileInspectorOpen=!1})},showMobileSearch:()=>{t(e=>{e.mobileSearchOpen=!0})},closeMobileSearch:()=>{t(e=>{e.mobileSearchOpen=!1})},showMobileRecordDetails:()=>{t(e=>{e.mobileRecordDetailsOpen=!0})},closeMobileRecordDetails:()=>{t(e=>{e.mobileRecordDetailsOpen=!1})},toggleVolumeAutomation:()=>{t(e=>{e.showVolumeAutomation=!e.showVolumeAutomation})}}),iee={},see=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=(o,a,l)=>{let u=o;if(a){const d=(l==null?void 0:l.equalityFn)||Object.is;let f=o(r.getState());u=h=>{const m=o(h);if(!d(f,m)){const y=f;a(f=m,y)}},l!=null&&l.fireImmediately&&a(f,f)}return i(u)},t(e,n,r)},oee=see;function aee(t,e){let n;try{n=t()}catch{return}return{getItem:i=>{var s;const o=l=>l===null?null:JSON.parse(l,void 0),a=(s=n.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const Qm=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return Qm(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Qm(r)(n)}}}},lee=(t,e)=>(n,r,i)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:w=>w,version:0,merge:(w,v)=>({...v,...w}),...e},o=!1;const a=new Set,l=new Set;let u;try{u=s.getStorage()}catch{}if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...w)},r,i);const d=Qm(s.serialize),f=()=>{const w=s.partialize({...r()});let v;const S=d({state:w,version:s.version}).then(C=>u.setItem(s.name,C)).catch(C=>{v=C});if(v)throw v;return S},h=i.setState;i.setState=(w,v)=>{h(w,v),f()};const m=t((...w)=>{n(...w),f()},r,i);let y;const g=()=>{var w;if(!u)return;o=!1,a.forEach(S=>S(r()));const v=((w=s.onRehydrateStorage)==null?void 0:w.call(s,r()))||void 0;return Qm(u.getItem.bind(u))(s.name).then(S=>{if(S)return s.deserialize(S)}).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==s.version){if(s.migrate)return s.migrate(S.state,S.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return S.state}).then(S=>{var C;
97return y=s.merge(S,(C=r())!=null?C:m),n(y,!0),f()}).then(()=>{v==null||v(y,void 0),o=!0,l.forEach(S=>S(y))}).catch(S=>{v==null||v(void 0,S)})};return i.persist={setOptions:w=>{s={...s,...w},w.getStorage&&(u=w.getStorage())},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>o,onHydrate:w=>(a.add(w),()=>{a.delete(w)}),onFinishHydration:w=>(l.add(w),()=>{l.delete(w)})},g(),y||m},cee=(t,e)=>(n,r,i)=>{let s={storage:aee(()=>localStorage),partialize:g=>g,version:0,merge:(g,w)=>({...w,...g}),...e},o=!1;const a=new Set,l=new Set;let u=s.storage;if(!u)return t((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...g)},r,i);const d=()=>{const g=s.partialize({...r()});return u.setItem(s.name,{state:g,version:s.version})},f=i.setState;i.setState=(g,w)=>{f(g,w),d()};const h=t((...g)=>{n(...g),d()},r,i);i.getInitialState=()=>h;let m;const y=()=>{var g,w;if(!u)return;o=!1,a.forEach(S=>{var C;return S((C=r())!=null?C:h)});const v=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(g=r())!=null?g:h))||void 0;return Qm(u.getItem.bind(u))(s.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==s.version){if(s.migrate)return[!0,s.migrate(S.state,S.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var C;const[k,N]=S;if(m=s.merge(N,(C=r())!=null?C:h),n(m,!0),k)return d()}).then(()=>{v==null||v(m,void 0),m=r(),o=!0,l.forEach(S=>S(m))}).catch(S=>{v==null||v(void 0,S)})};return i.persist={setOptions:g=>{s={...s,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>o,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(l.add(g),()=>{l.delete(g)})},s.skipHydration||y(),m||h},uee=(t,e)=>"getStorage"in e||"serialize"in e||"deserialize"in e?((iee?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),lee(t,e)):cee(t,e),dee=uee,fee=t=>(e,n,r)=>(r.setState=(i,s,...o)=>{const a=typeof i=="function"?Nu(i):i;return e(a,s,...o)},t(r.setState,n,r)),hee=fee,iD=async(t,e)=>{await jn.setItem(`instrumentRender-${t}`,e)},pee=async t=>await jn.getItem(`instrumentRender-${t}`),mee=async t=>{await jn.removeItem(`instrumentRender-${t}`)},gee={nextId:0,ids:{}},bee=(t,e)=>({...gee,addInstrument:async(n,r)=>{if(e().instrumentExists(n))throw new Error(`Instrument ${n} already exists, cannot add it again`);const i=e().nextId;await iD(i,r),t(s=>{s.ids[n]=i,s.nextId++})},deleteInstrument:async n=>{const r=e().getInstrumentId(n);await mee(r),t(i=>{delete i.ids[n]})},getInstrumentId:n=>e().ids[n],getRender:async n=>{const r=e().getInstrumentId(n);return await pee(r)},instrumentExists:n=>Object.keys(e().ids).includes(n)}),yee={bloobDetailsInfoOpen:!0,detailsBloobId:null,selectedNoteIds:new Set,highlightedPitch:null},vee=(t,e)=>({...yee,showBloobDetailsInfo:()=>{t(n=>{n.bloobDetailsInfoOpen=!0})},closeBloobDetailsInfo:()=>{t(n=>{n.bloobDetailsInfoOpen=!1})},showBloobDetails:n=>{t(r=>{r.detailsBloobId=n})},closeBloobDetails:()=>{t(n=>{n.detailsBloobId=null})},selectNotes:(n,r=!0)=>{t(i=>{r?n.forEach(s=>{i.selectedNoteIds.add(s)}):i.selectedNoteIds=new Set(n)})},deselectNotes:n=>{t(r=>{n.forEach(i=>{r.selectedNoteIds.delete(i)})})},deselectAllNotes:()=>{t(n=>{n.selectedNoteIds.clear()})},isNoteSelected:n=>e().selectedNoteIds.has(n),highlightPitch:n=>{t(r=>{r.highlightedPitch=n})},unhighlightPitch:()=>{t(n=>{n.highlightedPitch=null})}});var zn=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.MINIMIZED=1]="MINIMIZED",t[t.MAXIMIZED=2]="MAXIMIZED",t))(zn||{}),Hs=(t=>(t[t.MOVE=0]="MOVE",t[t.SELECT=1]="SELECT",t))(Hs||{});const xee=72,gz=20,bz=600,wee=.005,kee={selectedCaiObjectKeys:new Set,caiChatState:zn.DEFAULT,chatPositionSide:"left",dragMode:Hs.MOVE,workspaceView:"canvas",immersedSongId:null,timelineCursorBar:null,timelineCursorSongId:null,timelineLoopRegion:null,immersedBarWidth:xee},See=(t,e)=>({...kee,selectCaiObjects:(n,r=!1)=>{t(i=>
97{r||(i.selectedCaiObjectKeys=new Set),n.forEach(s=>{const o=Z1(s);i.selectedCaiObjectKeys.add(o)})})},deselectCaiObjects:n=>{t(r=>{n.forEach(i=>{const s=Z1(i);r.selectedCaiObjectKeys.delete(s)})})},deselectAllCaiObjects:()=>{t(n=>{n.selectedCaiObjectKeys=new Set})},setCaiChatState:n=>{t(r=>{r.caiChatState=n})},toggleChatPositionSide:()=>{t(n=>{n.chatPositionSide=n.chatPositionSide==="left"?"right":"left"})},isCaiObjectSelected:n=>{const r=Z1(n);return e().selectedCaiObjectKeys.has(r)},setDragMode:n=>{t(r=>{r.dragMode=n})},openImmersedSong:n=>{t(r=>{r.workspaceView="immersed-song",r.immersedSongId=n,r.timelineCursorBar=null,r.timelineCursorSongId=null,r.timelineLoopRegion=null})},closeImmersedSong:()=>{t(n=>{n.workspaceView="canvas",n.immersedSongId=null,n.timelineCursorBar=null,n.timelineCursorSongId=null,n.timelineLoopRegion=null})},setTimelineCursorBar:(n,r)=>{t(i=>{i.timelineCursorBar=n,n===null?i.timelineCursorSongId=null:r!=null?i.timelineCursorSongId=r:i.timelineCursorSongId=i.immersedSongId})},setTimelineLoopRegion:n=>{t(r=>{r.timelineLoopRegion=n})},setImmersedBarWidth:n=>{t(r=>{r.immersedBarWidth=Math.max(gz,Math.min(bz,n))})},zoomImmersedTimeline:n=>{t(r=>{const i=1-n*wee;r.immersedBarWidth=Math.max(gz,Math.min(bz,r.immersedBarWidth*i))})}});var zr=(t=>(t.MidiInstrument="Midi Instrument",t.VoiceToMidi="Voice to MIDI",t.Audio="Audio",t))(zr||{}),Hu=(t=>(t.EighthNote="1/8 Note",t.Triplet="Triplet",t.SixteenthNote="1/16 Note",t.ThirtySecondNote="1/32 Note",t))(Hu||{}),ls=(t=>(t.Off="Off",t.AlwaysOn="Always On",t.WhileRecordingOnly="While Recording Only",t))(ls||{});const Mu={settingsOpen:!1,settings:{general:{defaultInstrument:ft.AcousticGrandPiano,scrollPianorollDuringPlayback:!0,expansionAmount:1,dragSnapAmount:1/128,bloobNudgeAmount:1/256,hasSeenTutorial:!1,hideCollabAgenticHintModal:!1},recording:{snapToGrid:!0,gridDivision:Hu.SixteenthNote,snapToKey:!0},audio:{masterVolume:.5,metronome:{active:ls.WhileRecordingOnly,sound:m0.TR808,pitch:"G5",volume:80},loop:!1},appearance:{showBloobIds:!1}}},OS=(t,e)=>{const n=r=>{if(e){const i=JSON.parse(JSON.stringify(r));e.addPendingUpdate(i)}};return{...Mu,openSettings:()=>{t(r=>{r.settingsOpen=!0})},closeSettings:()=>{t(r=>{r.settingsOpen=!1})},setMasterVolume:r=>{if(r<0||r>1)throw new Error("Volume must be between 0 and 1");t(i=>{i.settings.audio.masterVolume=r,n({audio:i.settings.audio})})},setDefaultInstrument:r=>{t(i=>{i.settings.general.defaultInstrument=r,n({general:i.settings.general})})},setScrollPianorollDuringPlayback:r=>{t(i=>{i.settings.general.scrollPianorollDuringPlayback=r,n({general:i.settings.general})})},setMetronomeActive:r=>{t(i=>{i.settings.audio.metronome.active=r,n({audio:i.settings.audio})})},setMetronomeSound:r=>{t(i=>{i.settings.audio.metronome.sound=r,n({audio:i.settings.audio})})},setMetronomePitch:r=>{t(i=>{i.settings.audio.metronome.pitch=r,n({audio:i.settings.audio})})},setMetronomeVolume:r=>{t(i=>{i.settings.audio.metronome.volume=r,n({audio:i.settings.audio})})},setLoop:r=>{t(i=>{i.settings.audio.loop=r,n({audio:i.settings.audio})})},setShowBloobIds:r=>{t(i=>{i.settings.appearance.showBloobIds=r,n({appearance:i.settings.appearance})})},setExpansionAmount:r=>{t(i=>{i.settings.general.expansionAmount=r,n({general:i.settings.general})})},setDragSnapAmount:r=>{t(i=>{i.settings.general.dragSnapAmount=r,n({general:i.settings.general})})},setBloobNudgeAmount:r=>{t(i=>{i.settings.general.bloobNudgeAmount=r,n({general:i.settings.general})})},setHasSeenTutorial:r=>{t(i=>{i.settings.general.hasSeenTutorial=r,n({general:i.settings.general})})},setHideCollabAgenticHintModal:r=>{t(i=>{i.settings.general.hideCollabAgenticHintModal=r,n({general:i.settings.general})})},setSnapToGrid:r=>{t(i=>{i.settings.recording.snapToGrid=r,n({recording:i.settings.recording})})},setGridDivision:r=>{t(i=>{i.settings.recording.gridDivision=r,n({recording:i.settings.recording})})},setSnapToKey:r=>{t(i=>{i.settings.recording.snapToKey=r,n({recording:i.settings.recording})})}}},Cee=Object.freeze(Object.defineProperty({__proto__:null,createSettingsStore:OS,default:OS,initialSettingsState:Mu},Symbol.toStringTag,{value:"Module"})),_ee={threads:{},globalThreadId:null},Eee=(t,e)=>{const n=Gy.getInstance();
97return{..._ee,getNextThreadId:()=>Ra("thread"),addThread:(r,i,s,o,a)=>{var k,N,_,j,T,M,V;const l=typeof r=="string"&&["song","text","embedding","visual","global"].includes(r),u=l?r:r==null||r===-1?"global":"song",d=l?typeof i=="number"?i:0:u==="song"&&typeof r=="number"?r:0,f=l?s:typeof i=="object"&&i!==null?i:void 0,h=l?o??s:s??o,m=u==="global"||d===0;let y=e().getNextThreadId();m&&(y=-y);const g=Date.now(),w=[];if(f){const H=f.timestamp instanceof Date?f.timestamp.getTime():Date.now(),P=typeof f.message=="string"?f.message:"(audio)";w.push({id:`${H}-u-${y}`,timestamp:H,role:"user",body:P,authorId:a==null?void 0:a.authorId,authorDisplayName:a==null?void 0:a.authorDisplayName,transcribedFromAudio:a==null?void 0:a.transcribedFromAudio,inReplyToId:a==null?void 0:a.inReplyToId})}if(h){const H=h.timestamp instanceof Date?h.timestamp.getTime():Date.now();w.push({id:`${H}-c-${y}`,timestamp:H,role:"cai",body:h.message??"",authorDisplayName:"Cai",links:h.links??[]})}const v={id:y,songId:u==="song"?d:null,objectType:u,objectId:u==="global"?0:d,content:{messages:w},createdAt:g,lastModified:g};t(H=>{var F,I,R,U;const P=H;if(P.threads[y]=v,m&&(P.globalThreadId=y),u==="song"&&d!==0){const A=(F=P.songs)==null?void 0:F[d];A&&(A.threadIds||(A.threadIds=new Set),A.threadIds.add(y))}if(u==="text"&&((I=P.textNodes)!=null&&I[d])){const A=P.textNodes[d];A.threadIds||(A.threadIds=new Set),A.threadIds.add(y)}if(u==="embedding"&&((R=P.embeddingNodes)!=null&&R[d])){const A=P.embeddingNodes[d];A.threadIds||(A.threadIds=new Set),A.threadIds.add(y)}if(u==="visual"&&((U=P.visualMediaNodes)!=null&&U[d])){const A=P.visualMediaNodes[d];A.threadIds||(A.threadIds=new Set),A.threadIds.add(y)}}),n.trackOperation("add",y,{songId:v.songId,objectType:v.objectType,objectId:v.objectId,content:v.content,createdAt:g});const S=vh("client"),C=e();if(u==="song"&&d!==0){const H=(k=C.songs)==null?void 0:k[d];H!=null&&H.threadIds&&S.trackUpdateOperation(J.Song,d,{threadIds:Array.from(H.threadIds)})}return u==="text"&&((_=(N=C.textNodes)==null?void 0:N[d])!=null&&_.threadIds)&&S.trackUpdateOperation(J.TextNode,d,{threadIds:Array.from(C.textNodes[d].threadIds)}),u==="embedding"&&((T=(j=C.embeddingNodes)==null?void 0:j[d])!=null&&T.threadIds)&&S.trackUpdateOperation(J.EmbeddingNode,d,{threadIds:Array.from(C.embeddingNodes[d].threadIds)}),u==="visual"&&((V=(M=C.visualMediaNodes)==null?void 0:M[d])!=null&&V.threadIds)&&S.trackUpdateOperation(J.VisualMediaNode,d,{threadIds:Array.from(C.visualMediaNodes[d].threadIds)}),y},getThreadById:r=>e().threads[r]??null,getThreadForSong:r=>{var l;if(r===null||r===-1){const u=e().globalThreadId;return u===null?null:e().threads[u]??null}const s=(l=e().songs)==null?void 0:l[r];if(!s)return null;if(s.threadIds&&s.threadIds.size>0){const u=Array.from(s.threadIds),d=e().threads[u[0]]??null;if(d)return d}const o=e().threads;let a=null;for(const u of Object.values(o))u.songId===r&&(!a||u.lastModified>a.lastModified)&&(a=u);return a},getThreadForObject:(r,i)=>{var l,u,d,f,h,m;if(r==="song")return e().getThreadForSong(i);if(r==="global"||i===0)return e().getThreadForSong(null);const s=e();let o;if(r==="text"?o=(u=(l=s.textNodes)==null?void 0:l[i])==null?void 0:u.threadIds:r==="embedding"?o=(f=(d=s.embeddingNodes)==null?void 0:d[i])==null?void 0:f.threadIds:r==="visual"&&(o=(m=(h=s.visualMediaNodes)==null?void 0:h[i])==null?void 0:m.threadIds),!o||o.size===0){const y=e().threads;return Object.values(y).find(w=>w.objectType===r&&w.objectId===i)??null}const a=Array.from(o)[0];return e().threads[a]??null},getGlobalThread:()=>{const r=e().globalThreadId;return r===null?null:e().threads[r]??null},deleteThread:r=>{let i=null,s=null,o=null;t(l=>{var f,h,m,y;const u=l.threads[r];if(!u)return;const d=l;if(u.songId!==null&&u.objectType!=="text"&&u.objectType!=="embedding"&&u.objectType!=="visual"){const g=(f=d.songs)==null?void 0:f[u.songId];g&&g.threadIds&&(g.threadIds.delete(r),i=u.songId,s=Array.from(g.threadIds))}else if(u.objectType==="text"&&((h=d.textNodes)!=null&&h[u.objectId])){const g=d.textNodes[u.objectId];g.threadIds&&(g.threadIds.delete(r),o={type:"text",id:u.objectId,threadIds:Array.from(g.threadIds)})}else if(u.objectType==="embedding"&&((m=d.embeddingNodes)!=null&&m[u.objectId])){const g=d.embeddingNodes[u.objectId];g.threadIds&&(g.threadIds.delete(r),o={type:"embedding",id:u.objectId,threadIds:Array.from(g.threadIds)})}else if(u.objectType==="visual"&&((y=d.visualMediaNodes)!=null&&y[u.objectId])){const g=d.visualMediaNodes[u.objectId];g.threadIds&&(g.threadIds.delete(r),o={type:"visual",id:u.objectId,threadIds:Array.from(g.threadIds)})}else l.globalThreadId===r&&(l.globalThreadId=null);delete l.threads[r]}),n.trackOperation("delete",r,null);const a=vh("client");if(i!==null&&s!==null&&a.trackUpdateOperation(J.Song,i,{threadIds:s}),o){const l=o.type==="text"?J.TextNode:o.type==="embedding"?J.EmbeddingNode:J.VisualMediaNode;a.trackUpdateOperation(l,o.id,{threadIds:o.threadIds})}},deleteThreadsForSong:r=>{e().deleteThreadsForObject("song",r)},deleteThreadsForObject:(r,i)=>{var a,l,u,d,f,h,m;if(r==="song"){const g=(a=e().songs)==null?void 0:a[i];if(!(g!=null&&g.threadIds))return;
97Array.from(g.threadIds).forEach(w=>e().deleteThread(w));return}if(r==="global")return;const s=e();let o;r==="text"?o=(u=(l=s.textNodes)==null?void 0:l[i])==null?void 0:u.threadIds:r==="embedding"?o=(f=(d=s.embeddingNodes)==null?void 0:d[i])==null?void 0:f.threadIds:r==="visual"&&(o=(m=(h=s.visualMediaNodes)==null?void 0:h[i])==null?void 0:m.threadIds),o!=null&&o.size&&Array.from(o).forEach(y=>e().deleteThread(y))},clearAllThreads:()=>{t(r=>{const i=r;i.songs&&Object.values(i.songs).forEach(s=>{s!=null&&s.threadIds&&s.threadIds.clear()}),i.textNodes&&Object.values(i.textNodes).forEach(s=>{s!=null&&s.threadIds&&s.threadIds.clear()}),i.embeddingNodes&&Object.values(i.embeddingNodes).forEach(s=>{s!=null&&s.threadIds&&s.threadIds.clear()}),i.visualMediaNodes&&Object.values(i.visualMediaNodes).forEach(s=>{s!=null&&s.threadIds&&s.threadIds.clear()}),r.threads={},r.globalThreadId=null})},allThreads:()=>e().threads,songHasThreads:r=>e().objectHasThreads(r==null||r===-1?"global":"song",r??0),objectHasThreads:(r,i)=>{var a,l,u,d,f,h;if(r==="global"||i==null||i===0)return e().globalThreadId!==null;if(r==="song")return e().getThreadForSong(i)!==null;const s=e(),o=r==="text"?(l=(a=s.textNodes)==null?void 0:a[i])==null?void 0:l.threadIds:r==="embedding"?(d=(u=s.embeddingNodes)==null?void 0:u[i])==null?void 0:d.threadIds:(h=(f=s.visualMediaNodes)==null?void 0:f[i])==null?void 0:h.threadIds;return o!=null&&o.size>0},appendMessage:(r,i)=>{const s=Date.now();let o,a;t(l=>{const u=l.threads[r];u&&(u.content.messages||(u.content.messages=[]),u.content.messages.push(i),u.lastModified=s,o=u.objectType,a=u.objectId)}),n.trackOperation("append_message",r,{message:i,objectType:o,objectId:a})},addUserPrompt:(r,i)=>{const s=i.timestamp instanceof Date?i.timestamp.getTime():Date.now(),o=typeof i.message=="string"?i.message:"(audio)",a={id:`${s}-u-${r}`,timestamp:s,role:"user",body:o};e().appendMessage(r,a)},addResponse:(r,i)=>{const s=i.timestamp instanceof Date?i.timestamp.getTime():Date.now(),o={id:`${s}-c-${r}`,timestamp:s,role:"cai",body:i.message??"",authorDisplayName:"Cai",links:i.links??[]};e().appendMessage(r,o)},addUserPromptAndResponse:(r,i,s,o)=>{const a=i.timestamp instanceof Date?i.timestamp.getTime():Date.now(),l=typeof i.message=="string"?i.message:"(audio)",u={id:`${a}-u-${r}`,timestamp:a,role:"user",body:l,authorId:o==null?void 0:o.authorId,authorDisplayName:o==null?void 0:o.authorDisplayName,transcribedFromAudio:o==null?void 0:o.transcribedFromAudio,inReplyToId:o==null?void 0:o.inReplyToId},d=s.timestamp instanceof Date?s.timestamp.getTime():Date.now(),f={id:`${d}-c-${r}`,timestamp:d,role:"cai",body:s.message??"",authorDisplayName:"Cai",links:s.links??[],inReplyToId:u.id};e().appendMessage(r,u),e().appendMessage(r,f)}}};function Nee(){return{}}function Iee(){const t=Nee(),e=Object.keys(t),n=e.length>0;return{userMessage:"",awaitingResponse:n,abortController:n?t[e[e.length-1]].abortController:null,inFlightAgentRequests:t,displayRequestProgression:n,requestChatTitle:"",requestProgression:0,isChatOpen:!1,activeThreadId:null,lastError:null}}const jee=Iee(),Tee=(t,e)=>({...jee,setUserMessage:n=>{t(r=>{r.userMessage=n})},clearUserMessage:()=>{t(n=>{n.userMessage=""})},setAwaitingResponse:n=>{t(r=>{r.awaitingResponse=n,n||(r.abortController=null)})},setAbortController:n=>{t(r=>{r.abortController=n})},cancelRequest:()=>{const{inFlightAgentRequests:n}=e();Object.values(n).forEach(r=>r.abortController.abort()),t(r=>{r.inFlightAgentRequests={},r.awaitingResponse=!1,r.abortController=null})},addInFlightRequest:(n,r,i,s,o)=>{const a=90+Math.random()*60;t(l=>{l.inFlightAgentRequests[n]={abortController:s,objectType:r,objectId:i,userMessagePreview:o,startedAt:Date.now(),progressDurationSec:a},l.awaitingResponse=!0,l.abortController=s})},removeInFlightRequest:n=>{t(r=>{delete r.inFlightAgentRequests[n];const i=Object.keys(r.inFlightAgentRequests).length;if(r.awaitingResponse=i>0,i===0)r.abortController=null;else{const s=Object.values(r.inFlightAgentRequests);r.abortController=s[s.length-1].abortController}})},cancelRequestForContext:(n,r)=>{var o;const{inFlightAgentRequests:i}=e(),s=(o=Object.entries(i).find(([a,l])=>l.objectType===n&&l.objectId===r))==null?void 0:o[0];s&&(i[s].abortController.abort(),e().removeInFlightRequest(s))},cancelRequestById:n=>{const{inFlightAgentRequests:r}=e(),i=r[n];i&&(i.abortController.abort(),e().removeInFlightRequest(n))},getInFlightCount:()=>Object.keys(e().inFlightAgentRequests).length,isContextAwaitingResponse:(n,r)=>Object.values(e().inFlightAgentRequests).some(i=>i.objectType===n&&i.objectId===r),setDisplayRequestProgression:n=>{t(r=>{r.displayRequestProgression=n})},setRequestChatTitle:n=>{t(r=>{r.requestChatTitle=n})},setRequestProgression:n=>{t(r=>{r.requestProgression=n})},resetChatRequestState:()=>{t(n=>
97{Object.values(n.inFlightAgentRequests).forEach(r=>r.abortController.abort()),n.inFlightAgentRequests={},n.awaitingResponse=!1,n.abortController=null,n.displayRequestProgression=!1,n.requestChatTitle="",n.requestProgression=0,n.lastError=null})},setIsChatOpen:n=>{t(r=>{r.isChatOpen=n})},setActiveThreadId:n=>{t(r=>{r.activeThreadId=n})},setError:n=>{t(r=>{r.lastError=n})},clearError:()=>{t(n=>{n.lastError=null})}}),tk="1.0.0",DS=t=>{if(t==null)return t;if(typeof t!="function"){if(t instanceof Date)return t;if(t instanceof Set)return Array.from(t);if(t instanceof Map)return Array.from(t.entries());if(Array.isArray(t))return t.map(DS).filter(e=>e!==void 0);if(typeof t=="object"){const e={};for(const[n,r]of Object.entries(t)){const i=DS(r);i!==void 0&&(e[n]=i)}return e}return t}},zee=t=>{if(!t||typeof t!="object")return t;const e={...t};return e.songs&&Object.values(e.songs).forEach(n=>{const r=n;r.bloobIds&&!(r.bloobIds instanceof Set)&&(r.bloobIds=new Set(Array.isArray(r.bloobIds)?r.bloobIds:Object.keys(r.bloobIds).map(Number))),r.threadIds&&!(r.threadIds instanceof Set)&&(r.threadIds=new Set(Array.isArray(r.threadIds)?r.threadIds:Object.keys(r.threadIds).map(Number))),r.trackIds?r.trackIds instanceof Set||(r.trackIds=new Set(Array.isArray(r.trackIds)?r.trackIds:Object.keys(r.trackIds).map(Number))):r.trackIds=new Set}),e.tracks||(e.tracks={}),e.bloobs&&Object.values(e.bloobs).forEach(n=>{const r=n;r.bloobType==="Midi"&&r.noteIds&&!(r.noteIds instanceof Set)&&(r.noteIds=new Set(Array.isArray(r.noteIds)?r.noteIds:Object.keys(r.noteIds).map(Number)))}),e.fetchingAudioFiles&&!(e.fetchingAudioFiles instanceof Set)&&(e.fetchingAudioFiles=new Set(Array.isArray(e.fetchingAudioFiles)?e.fetchingAudioFiles:[])),e.selectedCaiObjectKeys&&!(e.selectedCaiObjectKeys instanceof Set)&&(e.selectedCaiObjectKeys=new Set(Array.isArray(e.selectedCaiObjectKeys)?e.selectedCaiObjectKeys:Object.keys(e.selectedCaiObjectKeys))),e.selectedNoteIds&&!(e.selectedNoteIds instanceof Set)&&(e.selectedNoteIds=new Set(Array.isArray(e.selectedNoteIds)?e.selectedNoteIds:Object.keys(e.selectedNoteIds).map(Number))),e.fetchingAudioFiles&&!(e.fetchingAudioFiles instanceof Set)&&(e.fetchingAudioFiles=new Set(Array.isArray(e.fetchingAudioFiles)?e.fetchingAudioFiles:[])),e},Pee=()=>({getItem:async t=>{try{ar("ð Persisted Storage: Loading state...");const e=await jn.getItem(t);let n=null,r;e!=null&&typeof e=="object"&&"state"in e?r=e:r={state:e,schema_version:void 0};const i=r.schema_version??"1.0.0";if(r.state!=null)try{if(n=zee(r.state),i!==tk){const s={state:r.state,schema_version:tk};await jn.setItem(t,s)}}catch{ar("â ï¸ Persisted Storage: Corrupted local data detected, clearing and starting fresh"),await jn.removeItem(t),n=null}return n?(ar("â
Persisted Storage: State loaded successfully"),{state:n}):(ar("ð Persisted Storage: No state found"),null)}catch{return null}},setItem:async(t,e)=>{try{const r={state:DS(e.state),schema_version:tk};await jn.setItem(t,r)}catch(n){throw n}},removeItem:async t=>{try{await jn.removeItem(t),ar("â
Persisted Storage: Data removed from local storage")}catch(e){throw e}}}),jl={name:"cai-storage",storage:Pee()};function Aee(t,e){const n={};if(!e||typeof e!="object")return n;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function Mee(t,e){return t.operations.map((i,s)=>({op:i,originalIndex:s})).filter(({op:i})=>i.cai_object_type!=="NoteDetails"?!0:i.operation_type==="add"||i.operation_type==="delete").slice().reverse().map(({op:i,originalIndex:s})=>{const o=`${s}`,a=e.get(o);switch(i.operation_type){case"add":return{...i,operation_type:"delete",value:void 0};case"delete":return{...i,operation_type:"add",value:a};case"update":{if(a===void 0)return{...i,value:{}};const l=Aee(i.value,a);return{...i,value:l}}default:return i}})}function Bee(t){const e=new Set([J.Song,J.Bloob,J.Note,J.Track,J.TextNode,J.EmbeddingNode,J.VisualMediaNode,J.AudioFile,"NoteDetails"]);return t.operations.every(n=>e.has(n.cai_object_type))}class sD{constructor(){Xt(this,"undoStack",[]);Xt(this,"redoStack",[]);Xt(this,"MAX_STACK_SIZE",50);Xt(this,"isApplyingOperation",!1)}captureOperationSet(e,n){if(this.isApplyingOperation||!e||e.operations.length===0||!Bee(e))return;const r=Mee(e,n),i={operationSet:e,inverseOperations:r,timestamp:Date.now(),description:e.description};this.undoStack.push(i),this.redoStack=[],this.undoStack.length>this.MAX_STACK_SIZE&&this.undoStack.shift()}undo(e,n){if(this.undoStack.length===0)return!1;this.isApplyingOperation=!0;try{const r=this.undoStack.pop();return[...r.inverseOperations].sort((s,o)=>{const a=s.cai_object_type==="NoteDetails",l=o.cai_object_type==="NoteDetails";return a&&!l?-1:!a&&l?1:0}
97).forEach(s=>{this.applyOperation(s,e,n)}),this.redoStack.push(r),!0}finally{this.isApplyingOperation=!1}}redo(e,n){if(this.redoStack.length===0)return!1;this.isApplyingOperation=!0;try{const r=this.redoStack.pop();return r.operationSet.operations.forEach(i=>{this.applyOperation(i,e,n)}),this.undoStack.push(r),!0}finally{this.isApplyingOperation=!1}}applyRemoteOperations(e,n,r){if(!e||e.length===0)return;const i=vh();i.setSkipTrackingForRemoteOps(!0),this.isApplyingOperation=!0;try{for(const s of e){const o=s;this.applyOperation(o,n,r)}}finally{i.setSkipTrackingForRemoteOps(!1),this.isApplyingOperation=!1}}applyOperation(e,n,r){const i=vh(),s=r();switch(e.operation_type){case"add":{const o=e.cai_object_type,a=e.cai_object_id;let l=e.value;if(o==="NoteDetails"&&l){const d=l.hash;if(d){n(h=>{h.noteDetails||(h.noteDetails={});const{hash:m,...y}=l;h.noteDetails[d]||(h.noteDetails[d]={...y,referenceCount:0})});const f=e.domain_type&&e.domain_id!=null?{domain_type:e.domain_type,domain_id:e.domain_id}:void 0;i.trackAddOperation(o,a,l,f);return}}l&&(l=this.restoreSetsInObject(l));const u=r();if(o===J.Bloob&&u.addBloob&&l){n(d=>{d.bloobs[a]=l,l&&l.songId&&d.songs[l.songId]&&d.songs[l.songId].bloobIds.add(a)}),l.bloobType===Us.Midi&&ln(l)?u.addBloob(l.songId,{instrument:l.instrument},l.bars,l.songPosition,l.label,l.melodicRole,l.metadata,l.metadataOutdated,a):l.bloobType===Us.Audio&&En(l)?u.addBloob(l.songId,{audioFileId:l.audioFileId},l.bars,l.songPosition,l.label,l.melodicRole,l.metadata,l.metadataOutdated,a):i.trackAddOperation(o,a,l);return}if(o===J.Note&&l){const d=l,f=d.bloobId,h=d.noteDetailsHash;n(m=>{var y;if(m.noteDetails||(m.noteDetails={}),h&&m.noteDetails[h]){ym(h,m.noteDetails);const g=((y=m.bloobs[f])==null?void 0:y.songId)??0;i.trackIncrementOperation(h,g)}if(m.notes[a]=d,f!==void 0){const g=m.bloobs[f];g&&ln(g)&&(g.noteIds.add(a),g.lastModified=Date.now()),m.noteReferences||(m.noteReferences={}),m.noteReferences[a]?m.noteReferences[a].add(f):m.noteReferences[a]=new Set([f])}}),i.trackAddOperation(o,a,l);return}if(o===J.Song&&l){n(d=>{const f={...l};f.bloobIds&&Array.isArray(f.bloobIds)?f.bloobIds=new Set(f.bloobIds):f.bloobIds||(f.bloobIds=new Set),f.trackIds&&Array.isArray(f.trackIds)?f.trackIds=new Set(f.trackIds):f.trackIds||(f.trackIds=new Set),d.songs[a]=f}),i.trackAddOperation(o,a,l);return}if(o===J.Track&&l){n(d=>{d.tracks[a]=l,l.songId&&d.songs[l.songId]&&(d.songs[l.songId].trackIds||(d.songs[l.songId].trackIds=new Set),d.songs[l.songId].trackIds.add(a))}),i.trackAddOperation(o,a,l);return}n(d=>{switch(o){case J.Note:d.notes[a]=l;break;case J.TextNode:d.textNodes[a]=l;break;case J.EmbeddingNode:d.embeddingNodes[a]=l;break;case J.VisualMediaNode:d.visualMediaNodes[a]=l;break;case J.AudioFile:d.audioFiles[a]=l;break}}),i.trackAddOperation(o,a,l);break}case"update":{const o=e.cai_object_type,a=e.cai_object_id,l=e.value;let u;switch(o){case J.Song:u=s.songs[a];break;case J.Bloob:u=s.bloobs[a];break;case J.Note:u=s.notes[a];break;case J.Track:u=s.tracks[a];break;case J.TextNode:u=s.textNodes[a];break;case J.EmbeddingNode:u=s.embeddingNodes[a];break;case J.VisualMediaNode:u=s.visualMediaNodes[a];break;case J.AudioFile:u=s.audioFiles[a];break}n(f=>{let h;switch(o){case J.Song:h=f.songs[a];break;case J.Bloob:h=f.bloobs[a];break;case J.Note:h=f.notes[a];break;case J.Track:h=f.tracks[a];break;case J.TextNode:h=f.textNodes[a];break;case J.EmbeddingNode:h=f.embeddingNodes[a];break;case J.VisualMediaNode:h=f.visualMediaNodes[a];break;case J.AudioFile:h=f.audioFiles[a];break}if(h){const m=this.restoreSetsInObject(l);if(Object.assign(h,m),o===J.Bloob&&"soloed"in m){const y=h,g=f.songs[y.songId];if(g)if(m.soloed===!0)g.hasSoloedBloobs=!0;else{const v=Array.from(g.bloobIds||[]).some(S=>{var C;return((C=f.bloobs[S])==null?void 0:C.soloed)===!0});g.hasSoloedBloobs=v}}}});const d=u?{...u,bloobIds:u.bloobIds?Array.from(u.bloobIds):[],trackIds:u.trackIds?Array.from(u.trackIds):[],noteIds:u.noteIds?Array.from(u.noteIds):[],threadIds:u.threadIds?Array.from(u.threadIds):[]}:void 0;i.trackUpdateOperation(o,a,l,d);break}case"delete":{const o=e.cai_object_type,a=e.cai_object_id,l=r();if(o==="NoteDetails")return;if(o===J.Bloob&&l.deleteBloob){l.deleteBloob(a),l.deselectCaiObjects&&l.deselectCaiObjects([{type:J.Bloob,id:a}]);return}if(o===J.Song&&l.deleteSong){l.deleteSong(a),l.deselectCaiObjects&&l.deselectCaiObjects([{type:J.Song,id:a}]);return}if(o===J.Note&&l.deleteNotes){l.deleteNotes([a]),l.deselectNotes&&l.deselectNotes([a]);return}if(o===J.AudioFile&&l.deleteAudioFile){l.deleteAudioFile(a);return}if(o===J.Track&&l.deleteTrack){l.deleteTrack(a);return}let u;switch(o){case J.Note:u=s.notes[a];break;case J.Track:u=s.tracks[a];break;case J.TextNode:u=s.textNodes[a];break;case J.EmbeddingNode:u=s.embeddingNodes[a];break;case J.VisualMediaNode:u=s.visualMediaNodes[a];break;case J.AudioFile:u=s.audioFiles[a];break}if(o===J.TextNode&&l.deleteTextNode){l.deleteTextNode(a),l.deselectCaiObjects&&l.deselectCaiObjects([{type:J.TextNode,id:a}]);return}if(o===J.EmbeddingNode&&l.deleteEmbeddingNode){l.deleteEmbeddingNode(a),l.deselectCaiObjects&&l.deselectCaiObjects([{type:J.EmbeddingNode,id:a}]);return}if(o===J.VisualMediaNode&&l.deleteVisualMediaNode){l.deleteVisualMediaNode(a),l.deselectCaiObjects&&l.deselectCaiObjects([{type:J.VisualMediaNode,id:a}]);return}n(f=>{switch(o){case J.Note:delete f.notes[a];break;case J.TextNode:delete f.textNodes[a];break;case J.EmbeddingNode:delete f.embeddingNodes[a];break;case J.VisualMediaNode:delete f.visualMediaNodes[a];break;case J.AudioFile:delete f.audioFiles[a];break}}),l.deselectCaiObjects&&l.deselectCaiObjects([{type:o,id:a}]);const d=u?{...u,bloobIds:u.bloobIds?Array.from(u.bloobIds):[],trackIds:u.trackIds?Array.from(u.trackIds):[],noteIds:u.noteIds?Array.from(u.noteIds):[],threadIds:u.threadIds?Array.from(u.threadIds):[]}:void 0;i.trackDeleteOperation(o,a,d);break}}}reset(){this.undoStack=[],this.redoStack=[]}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}getUndoStackSize(){return this.undoStack.length}getRedoStackSize(){return this.redoStack.length}isCurrentlyApplying(){return this.isApplyingOperation}restoreSetsInObject(e){if(!e||typeof e!="object")return e;const n={...e};return n.bloobIds&&Array.isArray(n.bloobIds)&&(n.bloobIds=new Set(n.bloobIds)),n.trackIds&&Array.isArray(n.trackIds)&&(n.trackIds=new Set(n.trackIds)),n.noteIds&&Array.isArray(n.noteIds)&&(n.noteIds=new Set(n.noteIds)),n.threadIds&&Array.isArray(n.threadIds)&&(n.threadIds=new Set(n.threadIds)),n}}const sm=new sD,Ree=Object.freeze(Object.defineProperty({__proto__:null,CanvasHistoryManager:sD,canvasHistoryManager:sm},Symbol.toStringTag,{value:"Module"})),Oee={audioEnabledSource:zr.VoiceToMidi,audioDisabledSource:zr.VoiceToMidi,nextNewRecordingId:0},Dee=(t,e)=>({...Oee,setSource:n=>{t(r=>{n!==zr.Audio&&(r.audioDisabledSource=zr.VoiceToMidi),r.audioEnabledSource=n})},getNextNewRecordingName:()=>{const n=e().nextNewRecordingId,r=n===0?"new-recording.wav":`new-recording-${n}.wav`;return t(i=>{i.nextNewRecordingId++}),r}}
97),oD="lastDataUpdateTimestamp",LS="cai-shared-by-me",FS="cai-shared-with-me",Lee=async t=>{await jn.setItem(oD,t)},Fee=async()=>await jn.getItem(oD)||0;TY();const Bu=vh("client"),Nf=new Ga(Bu),at=tO()(dee(hee((t,e)=>{const n=(r,i)=>{t(s=>{typeof r=="function"?r(s):Object.assign(s,r)},i),setTimeout(()=>{Bu.flushPendingOperations("auto-flush")},100)};return{...tee(n,e),...ree(n),...vee(n,e),...bee(n,e),...See(n,e),...OS(n,Nf.settingsUpdateTracker),...Eee(n,e),...Tee(n,e),...Dee(n,e),isFetchingFromCloud:!1,currentUserId:null,currentUserName:null,setCurrentUserIdentity:(r,i)=>{t(s=>{s.currentUserId=r,s.currentUserName=i??null})},domainRoleByChannel:{},setDomainRolesByChannel:r=>{t(i=>{i.domainRoleByChannel={...i.domainRoleByChannel,...r}})},domainPolicyByChannel:{},setDomainPoliciesByChannel:r=>{t(i=>{const s={};for(const[o,a]of Object.entries(r))s[o]={allowCopy:a.allow_copy,allowExport:a.allow_export};i.domainPolicyByChannel={...i.domainPolicyByChannel,...s}})},sharedByMe:null,setSharedByMe:r=>{t(i=>{i.sharedByMe=r}),jn.setItem(LS,r).catch(()=>{})},sharedWithMe:null,setSharedWithMe:r=>{t(i=>{i.sharedWithMe=r}),jn.setItem(FS,r).catch(()=>{})},collaboratorPresenceByChannel:{},updateCollaboratorPresence:(r,i,s)=>{t(o=>{const a=o.collaboratorPresenceByChannel[r]||{},l=a[i]||{userId:i,name:null,email:null,bloobId:null,updatedAt:0},u={...a,[i]:{...l,userId:i,name:s.name??l.name,email:s.email??l.email,bloobId:s.bloobId!==void 0?s.bloobId:l.bloobId,updatedAt:Date.now()}};o.collaboratorPresenceByChannel={...o.collaboratorPresenceByChannel,[r]:u}})}}}),{...jl,partialize:t=>{const{sharedByMe:e,sharedWithMe:n,inFlightAgentRequests:r,awaitingResponse:i,abortController:s,displayRequestProgression:o,...a}=t;return a},onRehydrateStorage:()=>async(t,e)=>{if(!e){if(t){t.resetChatRequestState();try{const n=await jn.getItem(LS);n!=null&&(t.sharedByMe=n)}catch{}try{const n=await jn.getItem(FS);n!=null&&(t.sharedWithMe=n)}catch{}}}}})),If=t=>t instanceof Set?Array.from(t).map(If):t instanceof Map?Object.fromEntries(Array.from(t.entries()).map(([e,n])=>[If(e),If(n)])):Array.isArray(t)?t.map(If):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,If(n)])):t,$ee=()=>{const t=async()=>{const r=await jl.storage.getItem(jl.name);if(r&&r.state){const i=If(r.state);return JSON.stringify(i,null,2)}return"{}"};return{retrieveStorage:t,downloadStorage:async()=>{const r=await t(),i=new Blob([r],{type:"application/json"}),s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=`cai-storage-${new Date().toISOString()}.json`,o.click(),URL.revokeObjectURL(s)},replaceStorage:async r=>{try{const s=JSON.parse(r);await jl.storage.setItem(jl.name,{state:s}),await new Promise(o=>setTimeout(o,100)),await at.persist.rehydrate()}catch(i){throw i}}}},lx=()=>{const[t,e]=x.useState(()=>at.persist.hasHydrated());return x.useEffect(()=>{if(at.persist.hasHydrated()){e(!0);return}return at.persist.onFinishHydration(()=>e(!0))},[]),t},aD=(t=!1)=>{const[e,n]=x.useState(!1),[r,i]=x.useState(!1),[s,o]=x.useState("checking");return x.useEffect(()=>{const a=async()=>{if(t&&at.persist.hasHydrated())try{const l=at.getState();if(Object.keys(l.bloobs).length>0||Object.keys(l.songs).length>0||Object.keys(l.notes).length>0)o("none");else{i(!0),n(!0),o("loading");try{o("none")}catch(d){const f=d instanceof Error&&d.message==="No cloud data available";o(f?"none":"error")}finally{n(!1),i(!1)}}}catch{n(!1),i(!1),o("error")}};if(t)return at.persist.onFinishHydration(()=>{a()})},[t]),{isInitializing:e,needsCloudData:r,cloudDataStatus:s}},Ln=()=>({undo:()=>{const e=sm.undo(at.setState,at.getState);return e&&Bu.flushPendingOperations("Undo operations"),e},redo:()=>{const e=sm.redo(at.setState,at.getState);return e&&Bu.flushPendingOperations("Redo operations"),e},reset:()=>{sm.reset(),jn.clear()},commitToStore:()=>{const e=Bu.getCapturedStateMap(),n=Bu.flushPendingOperations();n&&n.operations.length>0&&sm.captureOperationSet(n,e),Bu.clearCapturedState()}}),mn=()=>at(t=>({bloobs:t.bloobs,notes:t.notes,noteDetails:t.noteDetails,songs:t.songs,tracks:t.tracks,audioFiles:t.audioFiles,fetchingAudioFiles:t.fetchingAudioFiles,textNodes:t.textNodes,embeddingNodes:t.embeddingNodes,visualMediaNodes:t.visualMediaNodes,getSongById:t.getSongById,getSongName:t.getSongName,getBloobById:t.getBloobById,getBloobName:t.getBloobName,getBloobByIdForRequest:t.getBloobByIdForRequest,doesNoteExist:t.doesNoteExist,getNoteById:t.getNoteById,getAudioFileById:t.getAudioFileById,getTextNodeById:t.getTextNodeById,getTextNodeName:t.getTextNodeName,getEmbeddingNodeById:t.getEmbeddingNodeById,getEmbeddingNodeName:t.getEmbeddingNodeName,getVisualMediaNodeById:t.getVisualMediaNodeById,getVisualMediaNodeName:t.getVisualMediaNodeName,getAllTextNodes:t.getAllTextNodes,getAllEmbeddingNodes:t.getAllEmbeddingNodes,getAllVisualMediaNodes:t.getAllVisualMediaNodes,getBloobsInSong:t.getBloobsInSong,getBloobsInSongForRequest:t.getBloobsInSongForRequest,getNotesInBloob:t.getNotesInBloob,getBloobsOverlappingWithPosition:t.getBloobsOverlappingWithPosition,findOpenSongPositionNear:t.findOpenSongPositionNear,getSongBloobContentBoundary:t.getSongBloobContentBoundary,getPlaybackInfo:t.getPlaybackInfo,getAllInUseInstruments:t.getAllInUseInstruments,getAudioFileData:t.getAudioFileData,isAudioFileFetching:t.isAudioFileFetching,isAudioFileAvailable:t.isAudioFileAvailable,getAudioFileDataRelevantToSongs:t.getAudioFileDataRelevantToSongs,doesSongWithNameExist:t.doesSongWithNameExist,getCaiObjectsInRect:t.getCaiObjectsInRect,getNoteIdsInRect:t.getNoteIdsInRect,getAllCaiObjects:t.getAllCaiObjects})),Gn=()=>at(t=>({addSong:(...e)=>t.addSong(...e),deleteSong:(...e)=>t.deleteSong(...e),duplicateSong:(...e)=>t.duplicateSong(...e),addTracksToSong:(...e)=>t.addTracksToSong(...e),removeTracksFromSongIfPossible:(...e)=>t.removeTracksFromSongIfPossible(...e),addBarsToSong:(...e)=>t.addBarsToSong(...e),removeBarsFromSongIfPossible:(...e)=>t.removeBarsFromSongIfPossible(...e),expandSongAsNecessary:(...e)=>t.expandSongAsNecessary(...e),shrinkSongWherePossible:(...e)=>t.shrinkSongWherePossible(...e),organizeBloobs:(...e)=>t.organizeBloobs(...e),updateSongDetails:(...e)=>t.updateSongDetails(...e),addTrack:(...e)=>t.addTrack(...e),setTrackInstrumentLock:(...e)=>t.setTrackInstrumentLock(...e),updateTrackName:(...e)=>t.updateTrackName(...e),updateTrackEffects:(...e)=>t.updateTrackEffects(...e),deleteTrack:(...e)=>t.deleteTrack(...e),getTrackForSongTrackIndex:t.getTrackForSongTrackIndex,getEffectiveTrackEffects:t.getEffectiveTrackEffects,ensureTrackEntity:t.ensureTrackEntity,addBloob:(...e)=>t.addBloob(...e),addMidiBloob:(...e)=>t.addMidiBloob(...e),addAudioBloob:(...e)=>t.addAudioBloob(...e),deleteBloob:(...e)=>t.deleteBloob(...e),deleteMidiBloob:(...e)=>t.deleteMidiBloob(...e),deleteAudioBloob:(...e)=>t.deleteAudioBloob(...e),duplicateBloob:(...e)=>t.duplicateBloob(...e),duplicateMidiBloob:(...e)=>t.duplicateMidiBloob(...e),duplicateAudioBloob:(...e)=>t.duplicateAudioBloob(...e),shiftBloob:(...e)=>t.shiftBloob(...e),extendBloob:(...e)=>t.extendBloob(...e),addBarsToBloobIfPossible:(...e)=>t.addBarsToBloobIfPossible(...e),removeBarsFromBloob:(...e)=>t.removeBarsFromBloob(...e),setLoopBars:(...e)=>t.setLoopBars(...e),clearLoop:(...e)=>t.clearLoop(...e),transposeBloobs:(...e)=>t.transposeBloobs(...e),transposeMidiBloobs:(...e)=>t.transposeMidiBloobs(...e),updateBloobDetails:(...e)=>t.updateBloobDetails(...e),convertToAudioBloob:(...e)=>t.convertToAudioBloob(...e),splitBloob:(...e)=>t.splitBloob(...e),addNotes:(...e)=>t.addNotes(...e),deleteNotes:(...e)=>t.deleteNotes(...e),updateNoteDetails:(...e)=>t.updateNoteDetails(...e),copyNotes:(...e)=>t.copyNotes(...e),addAudioFile:(...e)=>t.addAudioFile(...e),deleteAudioFile:(...e)=>t.deleteAudioFile(...e),updateAudioFileDetails:(...e)=>t.updateAudioFileDetails(...e),addTextNode:(...e)=>t.addTextNode(...e),updateTextNode:(...e)=>t.updateTextNode(...e),deleteTextNode:(...e)=>t.deleteTextNode(...e),duplicateTextNode:(...e)=>t.duplicateTextNode(...e),addEmbeddingNode:(...e)=>t.addEmbeddingNode(...e),updateEmbeddingNode:(...e)=>t.updateEmbeddingNode(...e),deleteEmbeddingNode:(...e)=>t.deleteEmbeddingNode(...e),duplicateEmbeddingNode:(...e)=>t.duplicateEmbeddingNode(...e),addVisualMediaNode:(...e)=>t.addVisualMediaNode(...e),updateVisualMediaNode:(...e)=>t.updateVisualMediaNode(...e),deleteVisualMediaNode:(...e)=>t.deleteVisualMediaNode(...e),duplicateVisualMediaNode:(...e)=>t.duplicateVisualMediaNode(...e),clearCanvas:(...e)=>t.clearCanvas(...e)}
97)),xd=()=>{const{selectedSingleCaiObject:t,selectedCaiObjects:e}=Yn(),n=at(i=>{var l,u,d,f,h,m,y,g,w,v,S,C;if(!t){const k=e.filter(j=>j.type===J.Bloob).map(j=>j.id);if(k.length>0&&k.length===e.length){const j=(l=i.bloobs)==null?void 0:l[k[0]];if(j&&k.every(M=>{var V,H;return((H=(V=i.bloobs)==null?void 0:V[M])==null?void 0:H.songId)===j.songId})){const M=(u=i.songs)==null?void 0:u[j.songId];if(M!=null&&M.threadIds&&M.threadIds.size>0){const H=Array.from(M.threadIds),P=i.threads[H[0]]??null;if(P)return{thread:P,lastModified:P.lastModified}}let V=null;for(const H of Object.values(i.threads))H.songId===j.songId&&(!V||H.lastModified>V.lastModified)&&(V={thread:H,lastModified:H.lastModified});return V}}const N=i.globalThreadId;if(N===null)return null;const _=i.threads[N]??null;return _?{thread:_,lastModified:_.lastModified}:null}let s;switch(t.type){case J.Bloob:{const k=(d=i.bloobs)==null?void 0:d[t.id];if(!k)return null;s={objectType:"song",objectId:k.songId};break}case J.Note:{const k=(f=i.notes)==null?void 0:f[t.id];if(!k)return null;const N=(h=i.bloobs)==null?void 0:h[k.bloobId];if(!N)return null;s={objectType:"song",objectId:N.songId};break}case J.Song:{s={objectType:"song",objectId:t.id};break}case J.TextNode:s={objectType:"text",objectId:t.id};break;case J.EmbeddingNode:s={objectType:"embedding",objectId:t.id};break;case J.VisualMediaNode:s={objectType:"visual",objectId:t.id};break;default:s={objectType:"global",objectId:0}}if(s.objectType==="global"||s.objectId===0){const k=i.globalThreadId;if(k===null)return null;const N=i.threads[k]??null;return N?{thread:N,lastModified:N.lastModified}:null}if(s.objectType==="song"){const k=(m=i.songs)==null?void 0:m[s.objectId];if(!k)return null;if(k.threadIds&&k.threadIds.size>0){const _=Array.from(k.threadIds),j=i.threads[_[0]]??null;if(j)return{thread:j,lastModified:j.lastModified}}let N=null;for(const _ of Object.values(i.threads))_.songId===s.objectId&&(!N||_.lastModified>N.lastModified)&&(N={thread:_,lastModified:_.lastModified});return N}const o=s.objectType==="text"?(g=(y=i.textNodes)==null?void 0:y[s.objectId])==null?void 0:g.threadIds:s.objectType==="embedding"?(v=(w=i.embeddingNodes)==null?void 0:w[s.objectId])==null?void 0:v.threadIds:(C=(S=i.visualMediaNodes)==null?void 0:S[s.objectId])==null?void 0:C.threadIds;if(o!=null&&o.size){const k=Array.from(o)[0],N=i.threads[k]??null;if(N)return{thread:N,lastModified:N.lastModified}}let a=null;for(const k of Object.values(i.threads))k.objectType===s.objectType&&k.objectId===s.objectId&&(!a||k.lastModified>a.lastModified)&&(a={thread:k,lastModified:k.lastModified});return a}),r=at(i=>({getThreadForSong:i.getThreadForSong,getThreadForObject:i.getThreadForObject,addThread:i.addThread,getThreadById:i.getThreadById,getGlobalThread:i.getGlobalThread,deleteThreadById:i.deleteThread,deleteThreadsForSong:i.deleteThreadsForSong,deleteThreadsForObject:i.deleteThreadsForObject,songHasThreads:i.songHasThreads,objectHasThreads:i.objectHasThreads,addUserPrompt:i.addUserPrompt,addResponse:i.addResponse,addUserPromptAndResponse:i.addUserPromptAndResponse,appendMessage:i.appendMessage,allThreads:i.allThreads,clearAllThreads:i.clearAllThreads}));return x.useMemo(()=>({currentThread:(n==null?void 0:n.thread)??null,getThreadForSong:r.getThreadForSong,getThreadForObject:r.getThreadForObject,addThread:r.addThread,getThreadById:r.getThreadById,getGlobalThread:r.getGlobalThread,deleteThreadById:r.deleteThreadById,deleteThreadsForSong:r.deleteThreadsForSong,deleteThreadsForObject:r.deleteThreadsForObject,songHasThreads:r.songHasThreads,objectHasThreads:r.objectHasThreads,addUserPrompt:r.addUserPrompt,addResponse:r.addResponse,addUserPromptAndResponse:r.addUserPromptAndResponse,appendMessage:r.appendMessage,allThreads:r.allThreads,clearAllThreads:r.clearAllThreads}),[n,r])},wd=t=>at(e=>e.songs[t]),qc=t=>at(e=>e.bloobs[t]),lD=t=>at(e=>e.notes[t]),Uee=t=>at(e=>e.textNodes[t]),Vee=t=>at(e=>e.embeddingNodes[t]),Hee=t=>at(e=>e.visualMediaNodes[t]),cD=t=>at(e=>{const n=e.bloobs[t];return n?ln(n)?Array.from(n.noteIds).map(r=>e.notes[r]):[]:[]}),Pn=()=>at(t=>({theme:t.theme,useSystemTheme:t.useSystemTheme,welcomeOpen:t.welcomeOpen,uploadOpen:t.uploadOpen,exportOpen:t.exportOpen,aboutOpen:t.aboutOpen,inspectStorageOpen:t.inspectStorageOpen,initialSettingsOpen:t.initialSettingsOpen,isDarkMode:t.theme==="dark",hotkeysOpen:t.hotkeysOpen,projectOpen:t.projectOpen,mobileInspectorOpen:t.mobileInspectorOpen,mobileSearchOpen:t.mobileSearchOpen,mobileRecordDetail
97sOpen:t.mobileRecordDetailsOpen,showVolumeAutomation:t.showVolumeAutomation})),Br=()=>at(t=>({setTheme:t.setTheme,setUseSystemTheme:t.setUseSystemTheme,closeWelcome:t.closeWelcome,showInspectStorage:t.showInspectStorage,closeInspectStorage:t.closeInspectStorage,showUpload:t.showUpload,closeUpload:t.closeUpload,showExport:t.showExport,closeExport:t.closeExport,showAbout:t.showAbout,closeAbout:t.closeAbout,showInitialSettings:t.showInitialSettings,closeInitialSettings:t.closeInitialSettings,showHotkeys:t.showHotkeys,closeHotkeys:t.closeHotkeys,showProject:t.showProject,closeProject:t.closeProject,showMobileInspector:t.showMobileInspector,closeMobileInspector:t.closeMobileInspector,showMobileSearch:t.showMobileSearch,closeMobileSearch:t.closeMobileSearch,showMobileRecordDetails:t.showMobileRecordDetails,closeMobileRecordDetails:t.closeMobileRecordDetails,toggleVolumeAutomation:t.toggleVolumeAutomation})),cx=()=>at(t=>({getInstrumentId:t.getInstrumentId,instrumentExists:t.instrumentExists,getRender:t.getRender,allInstrumentNames:Object.keys(t.ids)})),nE=()=>at(t=>({addInstrument:t.addInstrument,deleteInstrument:t.deleteInstrument})),Ho=()=>at(t=>({detailsBloobId:t.detailsBloobId,bloobDetailsOpen:t.detailsBloobId!==null,bloobDetailsInfoOpen:t.bloobDetailsInfoOpen,selectedNoteIds:t.selectedNoteIds,isNoteSelected:t.isNoteSelected,highlightedPitch:t.highlightedPitch})),Xs=()=>at(t=>({showBloobDetailsInfo:t.showBloobDetailsInfo,closeBloobDetailsInfo:t.closeBloobDetailsInfo,showBloobDetails:t.showBloobDetails,closeBloobDetails:t.closeBloobDetails,selectNotes:t.selectNotes,deselectNotes:t.deselectNotes,deselectAllNotes:t.deselectAllNotes,highlightPitch:t.highlightPitch,unhighlightPitch:t.unhighlightPitch})),Yn=()=>{const{caiChatState:t,chatPositionSide:e,isCaiObjectSelected:n,selectedCaiObjectKeys:r,dragMode:i,workspaceView:s,immersedSongId:o,timelineCursorBar:a,timelineCursorSongId:l,timelineLoopRegion:u,immersedBarWidth:d}=at(y=>({caiChatState:y.caiChatState,chatPositionSide:y.chatPositionSide,isCaiObjectSelected:y.isCaiObjectSelected,selectedCaiObjectKeys:y.selectedCaiObjectKeys,dragMode:y.dragMode,workspaceView:y.workspaceView,immersedSongId:y.immersedSongId,timelineCursorBar:y.timelineCursorBar,timelineCursorSongId:y.timelineCursorSongId,timelineLoopRegion:y.timelineLoopRegion,immersedBarWidth:y.immersedBarWidth})),f=x.useMemo(()=>Array.from(r),[r]),h=x.useMemo(()=>f.map(y=>AS(y)),[f]),m=x.useMemo(()=>f.length===1?AS(f[0]):null,[f]);return{caiChatState:t,chatPositionSide:e,isCaiObjectSelected:n,selectedCaiObjects:h,selectedSingleCaiObject:m,dragMode:i,workspaceView:s,immersedSongId:o,timelineCursorBar:a,timelineCursorSongId:l,timelineLoopRegion:u,immersedBarWidth:d}},cr=()=>at(t=>({selectCaiObjects:t.selectCaiObjects,selectCaiObject:(e,n=!1)=>{t.selectCaiObjects([e],n)},deselectAllCaiObjects:t.deselectAllCaiObjects,deselectCaiObjects:t.deselectCaiObjects,deselectCaiObject:e=>{t.deselectCaiObjects([e])},setCaiChatState:t.setCaiChatState,toggleChatPositionSide:t.toggleChatPositionSide,setDragMode:t.setDragMode,openImmersedSong:t.openImmersedSong,closeImmersedSong:t.closeImmersedSong,setTimelineCursorBar:t.setTimelineCursorBar,setTimelineLoopRegion:t.setTimelineLoopRegion,setImmersedBarWidth:t.setImmersedBarWidth,zoomImmersedTimeline:t.zoomImmersedTimeline})),bi=()=>at(t=>({settingsOpen:t.settingsOpen||Mu.settingsOpen,generalSettings:t.settings.general||Mu.settings.general,audioSettings:t.settings.audio||Mu.settings.audio,appearanceSettings:t.settings.appearance||Mu.settings.appearance,recordingSettings:t.settings.recording||Mu.settings.recording})),il=()=>at(t=>({setMasterVolume:(...e)=>t.setMasterVolume(...e),setDefaultInstrument:(...e)=>t.setDefaultInstrument(...e),setScrollPianorollDuringPlayback:(...e)=>t.setScrollPianorollDuringPlayback(...e),openSettings:t.openSettings,closeSettings:t.closeSettings,setMetronomeActive:(...e)=>t.setMetronomeActive(...e),setMetronomeSound:(...e)=>t.setMetronomeSound(...e),setMetronomePitch:(...e)=>t.setMetronomePitch(...e),setMetronomeVolume:(...e)=>t.setMetronomeVolume(...e),setLoop:(...e)=>t.setLoop(...e),setShowBloobIds:(...e)=>t.setShowBloobIds(...e),setExpansionAmount:(...e)=>t.setExpansionAmount(...e),setDragSnapAmount:(...e)=>
97t.setDragSnapAmount(...e),setBloobNudgeAmount:(...e)=>t.setBloobNudgeAmount(...e),setHasSeenTutorial:(...e)=>t.setHasSeenTutorial(...e),setHideCollabAgenticHintModal:(...e)=>t.setHideCollabAgenticHintModal(...e),setSnapToGrid:(...e)=>t.setSnapToGrid(...e),setGridDivision:(...e)=>t.setGridDivision(...e),setSnapToKey:(...e)=>t.setSnapToKey(...e)})),uD=()=>at(t=>({audioEnabledSource:t.audioEnabledSource,audioDisabledSource:t.audioDisabledSource})),rE=()=>at(t=>({setSource:t.setSource,getNextNewRecordingName:t.getNextNewRecordingName})),Qh=()=>({isFetchingFromCloud:at(e=>e.isFetchingFromCloud),isSyncing:()=>Nf.isSyncing(),hasPendingOperations:()=>Nf.hasPendingOperations(),getLastSyncTime:()=>Nf.getLastSyncTime(),forceSync:()=>Nf.forceSync(),applyObjectStatesToStore:e=>Nf.applyObjectStatesToStore(e),isAvailable:()=>navigator.onLine}),iE=()=>at(t=>({currentUserId:t.currentUserId,currentUserName:t.currentUserName})),sE=t=>at(e=>{const n=`song:${t}`,r=e.collaboratorPresenceByChannel[n]||{},i=Date.now(),s=15e3,o={};for(const[a,l]of Object.entries(r))i-l.updatedAt<=s&&(o[a]=l);return o});function kd(t){const e=at(r=>r.domainRoleByChannel[t]);if(!e)return;const n=e.toLowerCase();if(n==="owner")return"owner";if(n==="editor")return"editor";if(n==="viewer")return"viewer"}function Vr(t){return kd(t)!=="viewer"}function N0(t){const e=kd(t);return e===void 0||e==="owner"}function I0(t){const e=kd(t),n=at(r=>r.domainPolicyByChannel[t]);return e===void 0||e==="owner"?!0:(n==null?void 0:n.allowCopy)??!1}function dD(t){const e=kd(t),n=at(r=>r.domainPolicyByChannel[t]);return e===void 0||e==="owner"?!0:(n==null?void 0:n.allowExport)??!1}function fD(t){const e=kd(t),n=at(u=>u.sharedByMe);if(!t||t==="global")return!1;const r=t.split(":"),i=r[0],s=parseInt(r[1],10);if(!i||r.length<2||isNaN(s))return!1;if(e==="editor"||e==="viewer")return!0;const o=(n??[]).find(u=>u.object_type===i&&u.object_id===s),a=(o==null?void 0:o.members)??[],l=(o==null?void 0:o.pending_invites)??[];return a.length>0||l.length>0}const Sl=Object.freeze(Object.defineProperty({__proto__:null,SHARED_BY_ME_STORAGE_KEY:LS,SHARED_WITH_ME_STORAGE_KEY:FS,getLastDataUpdateTimestamp:Fee,updateLastDataUpdateTimestamp:Lee,useBloob:qc,useCaiStore:at,useCanCopyDomain:I0,useCanDeleteDomainRoot:N0,useCanEditDomain:Vr,useCanExportDomain:dD,useCanvas:Yn,useCanvasActions:cr,useChatHistory:xd,useCloudDataInitialization:aD,useCloudSync:Qh,useCurrentUserIdentity:iE,useData:mn,useDataActions:Gn,useDetails:Ho,useDetailsActions:Xs,useDisplay:Pn,useDisplayActions:Br,useDomainRole:kd,useEmbeddingNode:Vee,useGeneratedInstrument:cx,useGeneratedInstrumentActions:nE,useHasMultipleCollaborators:fD,useHistory:Ln,useNote:lD,useNotes:cD,useRecording:uD,useRecordingActions:rE,useSettings:bi,useSettingsActions:il,useSong:wd,useSongCollaboratorPresence:sE,useStorage:$ee,useStoreHydrated:lx,useTextNode:Uee,useVisualMediaNode:Hee},Symbol.toStringTag,{value:"Module"})),sl=()=>{const{screenToFlowPosition:t,flowToScreenPosition:e,setViewport:n}=k0(),{getSongById:r,getBloobById:i,getTextNodeById:s,getEmbeddingNodeById:o,getVisualMediaNodeById:a}=mn(),l=x.useCallback(m=>t(m),[t]),u=x.useCallback(m=>e(m),[e]),d=x.useCallback(m=>{var C;const{width:y,height:g}=((C=document.querySelector(".react-flow__pane"))==null?void 0:C.getBoundingClientRect())||{width:window.innerWidth,height:window.innerHeight},w=1,v=-m.x+y/2/w,S=-m.y+g/2/w;n({x:v,y:S,zoom:w},{duration:1e3}),setTimeout(()=>{var k;(k=document.querySelector(".react-flow"))==null||k.dispatchEvent(new Event("mouseup"))},2e3)},[n]),f=x.useCallback(m=>{let y;switch(m.type){case J.Song:{const g=r(m.id);y=mT(g,{bar:g.bars/2,track:g.tracks/2});break}case J.Bloob:{const g=i(m.id),w=r(g.songId);y=mT(w,{bar:g.songPosition.bar+g.bars/2,track:g.songPosition.track+1/2});break}case J.TextNode:{const g=s(m.id);y={x:g.canvasPosition.x+g.width/2,y:g.canvasPosition.y+g.height/2};break}case J.EmbeddingNode:{const g=o(m.id);y={x:g.canvasPosition.x+g.width/2,y:g.canvasPosition.y+g.height/2};break}case J.VisualMediaNode:{const g=a(m.id);y={x:g.canvasPosition.x+g.width/2,y:g.canvasPosition.y+g.height/2};break}}d(y)},[i,o,r,s,a,d]),h=x.useCallback(()=>
97{const{innerWidth:m,innerHeight:y}=window,g=m*0,w=y*.2,v=(m-g)/2-90,S=(y-w)/2-180,C={x:v+Math.random()*g,y:S+Math.random()*w};return l(C)},[l]);return{clientToCanvasPosition:l,canvasToClientPosition:u,setClientPosition:d,getRandomViewportCenteredCanvasPosition:h,centerCaiObject:f}},yz={light:{"cai-primary":It.zinc[100],"cai-secondary":It.zinc[900]},dark:{"cai-primary":It.zinc[900],"cai-secondary":It.zinc[100]}},Si={caiBlue:{DEFAULT:"rgb(107, 136, 204)",300:"rgb(148, 174, 235)",400:"rgb(124, 155, 230)",500:"rgb(107, 136, 204)"},caiGreen:{DEFAULT:"rgb(125, 195, 131)",500:"rgb(125, 195, 131)"},caiPeach:{DEFAULT:"rgb(248, 194, 145)",200:"rgb(253, 225, 195)",500:"rgb(248, 194, 145)"}},oE=()=>{const{theme:t}=Pn(),e=x.useMemo(()=>yz[t]["cai-primary"],[t]),n=x.useMemo(()=>yz[t]["cai-secondary"],[t]);return{caiPrimary:e,caiSecondary:n}},Gee=768,Hn=()=>{const[t,e]=x.useState(!1),[n,r]=x.useState(0);x.useEffect(()=>{const s=()=>{const o=window.innerWidth<=Gee,a=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e(o||a)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[]),x.useEffect(()=>{const s=()=>{const o=window.innerWidth;r(o)};return s(),window.addEventListener("resize",s),window.addEventListener("orientationchange",s),window.visualViewport&&window.visualViewport.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),window.visualViewport&&window.visualViewport.removeEventListener("resize",s)}},[]);const i=x.useMemo(()=>t&&n>0&&n<430,[t,n]);return{isMobile:t,isMobileSmall:i}},hD=()=>{const[t,e]=x.useState(ya),[n,r]=x.useState(navigator.onLine);return x.useEffect(()=>OJ(e),[]),x.useEffect(()=>{const s=()=>r(!0),o=()=>r(!1);return window.addEventListener("online",s),window.addEventListener("offline",o),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",o)}},[]),{status:t?"online":n?"server_unavailable":"offline",isOnline:t,isServerAvailable:t,lastChecked:null,isOffline:!n,isServerUnavailable:n&&!t,refresh:()=>{}}};/** 98 * @license lucide-react v0.484.0 - ISC 99 * 100 * This source code is licensed under the ISC license. 101 * See the LICENSE file in the root directory of this source tree. 102 */const Wee=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qee=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),vz=t=>{const e=qee(t);return e.charAt(0).toUpperCase()+e.slice(1)},pD=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** 103 * @license lucide-react v0.484.0 - ISC 104 * 105 * This source code is licensed under the ISC license. 106 * See the LICENSE file in the root directory of this source tree. 107 */var Kee={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** 108 * @license lucide-react v0.484.0 - ISC 109 * 110 * This source code is licensed under the ISC license. 111 * See the LICENSE file in the root directory of this source tree. 112 */const Yee=x.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},l)=>x.createElement("svg",{ref:l,...Kee,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:pD("lucide",i),...a},[...o.map(([u,d])=>x.createElement(u,d)),...Array.isArray(s)?s:[s]]));/** 113 * @license lucide-react v0.484.0 - ISC 114 * 115 * This source code is licensed under the ISC license. 116 * See the LICENSE file in the root directory of this source tree. 117 */const xt=(t,e)=>{const n=x.forwardRef(({className:r,...i},s)=>x.createElement(Yee,{ref:s,iconNode:e,className:pD(`lucide-${Wee(vz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=vz(t),n};/** 118 * @license lucide-react v0.484.0 - ISC 119 * 120 * This source code is licensed under the ISC license. 121 * See the LICENSE file in the root directory of this source tree. 122 */const Xee=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l
122-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Qee=xt("activity",Xee);/** 123 * @license lucide-react v0.484.0 - ISC 124 * 125 * This source code is licensed under the ISC license. 126 * See the LICENSE file in the root directory of this source tree. 127 */const Zee=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],Jee=xt("align-end-vertical",Zee);/** 128 * @license lucide-react v0.484.0 - ISC 129 * 130 * This source code is licensed under the ISC license. 131 * See the LICENSE file in the root directory of this source tree. 132 */const ete=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],tte=xt("align-start-vertical",ete);/** 133 * @license lucide-react v0.484.0 - ISC 134 * 135 * This source code is licensed under the ISC license. 136 * See the LICENSE file in the root directory of this source tree. 137 */const nte=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],rte=xt("arrow-left",nte);/** 138 * @license lucide-react v0.484.0 - ISC 139 * 140 * This source code is licensed under the ISC license. 141 * See the LICENSE file in the root directory of this source tree. 142 */const ite=[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]],mD=xt("arrow-right-to-line",ite);/** 143 * @license lucide-react v0.484.0 - ISC 144 * 145 * This source code is licensed under the ISC license. 146 * See the LICENSE file in the root directory of this source tree. 147 */const ste=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xz=xt("arrow-right",ste);/** 148 * @license lucide-react v0.484.0 - ISC 149 * 150 * This source code is licensed under the ISC license. 151 * See the LICENSE file in the root directory of this source tree. 152 */const ote=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],ate=xt("arrow-up-right",ote);/** 153 * @license lucide-react v0.484.0 - ISC 154 * 155 * This source code is licensed under the ISC license. 156 * See the LICENSE file in the root directory of this source tree. 157 */const lte=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],cte=xt("arrow-up",lte);/** 158 * @license lucide-react v0.484.0 - ISC 159 * 160 * This source code is licensed under the ISC license. 161 * See the LICENSE file in the root directory of this source tree. 162 */const ute=[["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"}]],gb=xt("audio-lines",ute);/** 163 * @license lucide-react v0.484.0 - ISC 164 * 165 * This source code is licensed under the ISC license. 166 * See the LICENSE file in the root directory of this source tree. 167 */const dte=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],ux=xt("book-open",dte);/** 168 * @license lucide-react v0.484.0 - ISC 169 * 170 * This source code is licensed under the ISC license. 171 * See the LICENSE file in the root directory of this source tree. 172 */const fte=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ml=xt("check",fte);/** 173 * @license lucide-react v0.484.0 - ISC 174 * 175 * This source code is licensed under the ISC license. 176 * See the LICENSE file in the root directory of this source tree. 177 */const hte=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vi=xt("chevron-down",hte);/** 178 * @license lucide-react v0.484.0 - ISC 179 * 180 * This source code is licensed under the ISC license. 181 * See the LICENSE file in the root directory of this source tree. 182 */const pte=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Sh=xt("chevron-left",pte);/** 183 * @license lucide-react v0.484.0 - ISC 184 * 185 * This source code is licensed under the ISC license. 186 * See the LICENSE file in the root directory of this source tree. 187 */const mte=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pi=xt("chevron-right",mte);/** 188 * @license lucide-react v0.484.0 - ISC 189 * 190 * This source code is licensed under the ISC license. 191 * See the LICENSE file in the root directory of this source tree. 192 */const gte=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],j0=xt("chevron-up",gte);/** 193 * @license lucide-react v0.484.0 - ISC 194 * 195 * This source code is licensed under the ISC license. 196 * See the LICENSE file in the root directory of this source tree. 197 */const bte=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],T0=xt("circle-alert",bte);/** 198 * @license lucide-react v0.484.0 - ISC 199 * 200 * This source code is licensed under the ISC license. 201 * See the LICENSE file in the root directory of this source tree. 202 */const yte=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],vte=xt("circle-check",yte);/** 203 * @license lucide-react v0.484.0 - ISC 204 * 205 * This source code is licensed under the ISC license. 206 * See the LICENSE file in the root directory of this source tree. 207 */const xte=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],$S=xt("circle-check-big",xte);
207/** 208 * @license lucide-react v0.484.0 - ISC 209 * 210 * This source code is licensed under the ISC license. 211 * See the LICENSE file in the root directory of this source tree. 212 */const wte=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],dx=xt("circle-help",wte);/** 213 * @license lucide-react v0.484.0 - ISC 214 * 215 * This source code is licensed under the ISC license. 216 * See the LICENSE file in the root directory of this source tree. 217 */const kte=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],wz=xt("circle-plus",kte);/** 218 * @license lucide-react v0.484.0 - ISC 219 * 220 * This source code is licensed under the ISC license. 221 * See the LICENSE file in the root directory of this source tree. 222 */const Ste=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Cte=xt("circle-x",Ste);/** 223 * @license lucide-react v0.484.0 - ISC 224 * 225 * This source code is licensed under the ISC license. 226 * See the LICENSE file in the root directory of this source tree. 227 */const _te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ld=xt("circle",_te);/** 228 * @license lucide-react v0.484.0 - ISC 229 * 230 * This source code is licensed under the ISC license. 231 * See the LICENSE file in the root directory of this source tree. 232 */const Ete=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],Nte=xt("clock",Ete);/** 233 * @license lucide-react v0.484.0 - ISC 234 * 235 * This source code is licensed under the ISC license. 236 * See the LICENSE file in the root directory of this source tree. 237 */const Ite=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],wc=xt("cloud-upload",Ite);/** 238 * @license lucide-react v0.484.0 - ISC 239 * 240 * This source code is licensed under the ISC license. 241 * See the LICENSE file in the root directory of this source tree. 242 */const jte=[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]],fx=xt("clover",jte);/** 243 * @license lucide-react v0.484.0 - ISC 244 * 245 * This source code is licensed under the ISC license. 246 * See the LICENSE file in the root directory of this source tree. 247 */const Tte=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],US=xt("code",Tte);/** 248 * @license lucide-react v0.484.0 - ISC 249 * 250 * This source code is licensed under the ISC license. 251 * See the LICENSE file in the root directory of this source tree. 252 */const zte=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Pte=xt("command",zte);/** 253 * @license lucide-react v0.484.0 - ISC 254 * 255 * This source code is licensed under the ISC license. 256 * See the LICENSE file in the root directory of this source tree. 257 */const Ate=[["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"}]],Do=xt("copy",Ate);/** 258 * @license lucide-react v0.484.0 - ISC 259 * 260 * This source code is licensed under the ISC license. 261 * See the LICENSE file in the root directory of this source tree. 262 */const Mte=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Bte=xt("credit-card",Mte);/** 263 * @license lucide-react v0.484.0 - ISC 264 * 265 * This source code is licensed under the ISC license. 266 * See the LICENSE file in the root directory of this source tree. 267 */const Rte=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],cd=xt("download",Rte);
267/** 268 * @license lucide-react v0.484.0 - ISC 269 * 270 * This source code is licensed under the ISC license. 271 * See the LICENSE file in the root directory of this source tree. 272 */const Ote=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Dte=xt("ellipsis",Ote);/** 273 * @license lucide-react v0.484.0 - ISC 274 * 275 * This source code is licensed under the ISC license. 276 * See the LICENSE file in the root directory of this source tree. 277 */const Lte=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ch=xt("external-link",Lte);/** 278 * @license lucide-react v0.484.0 - ISC 279 * 280 * This source code is licensed under the ISC license. 281 * See the LICENSE file in the root directory of this source tree. 282 */const Fte=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],gD=xt("eye-off",Fte);/** 283 * @license lucide-react v0.484.0 - ISC 284 * 285 * This source code is licensed under the ISC license. 286 * See the LICENSE file in the root directory of this source tree. 287 */const $te=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Jy=xt("eye",$te);/** 288 * @license lucide-react v0.484.0 - ISC 289 * 290 * This source code is licensed under the ISC license. 291 * See the LICENSE file in the root directory of this source tree. 292 */const Ute=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],$i=xt("file-text",Ute);/** 293 * @license lucide-react v0.484.0 - ISC 294 * 295 * This source code is licensed under the ISC license. 296 * See the LICENSE file in the root directory of this source tree. 297 */const Vte=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],vm=xt("file",Vte);/** 298 * @license lucide-react v0.484.0 - ISC 299 * 300 * This source code is licensed under the ISC license. 301 * See the LICENSE file in the root directory of this source tree. 302 */const Hte=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],kz=xt("folder-down",Hte);/** 303 * @license lucide-react v0.484.0 - ISC 304 * 305 * This source code is licensed under the ISC license. 306 * See the LICENSE file in the root directory of this source tree. 307 */const Gte=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],nk=xt("folder-plus",Gte);/** 308 * @license lucide-react v0.484.0 - ISC 309 * 310 * This source code is licensed under the ISC license. 311 * See the LICENSE file in the root directory of this source tree. 312 */const Wte=[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]],qte=xt("gallery-horizontal-end",Wte);/** 313 * @license lucide-react v0.484.0 - ISC 314 * 315 * This source code is licensed under the ISC license. 316 * See the LICENSE file in the root directory of this source tree. 317 */const Kte=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Yte=xt("globe",Kte);/** 318 * @license lucide-react v0.484.0 - ISC 319 * 320 * This source code is licensed under the ISC license. 321 * See the LICENSE file in the root directory of this source tree. 322 */const Xte=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],Sz=xt("graduation-cap",Xte);/** 323 * @license lucide-react v0.484.0 - ISC 324 * 325 * This source code is licensed under the ISC license. 326 * See the LICENSE file in the root directory of this source tree. 327 */const Qte=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],VS=xt("grip-horizontal",Qte);/** 328 * @license lucide-react v0.484.0 - ISC 329 * 330 * This source code is licensed under the ISC license. 331 * See the LICENSE file in the root directory of this source tree. 332 */const Zte=[["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"}]],hy=xt("headphones",Zte);/** 333 * @license lucide-react v0.484.0 - ISC 334 * 335 * This source code is licensed under the ISC license. 336 * See the LICENSE file in the root directory of this source tree. 337 */const Jte=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Gs=xt("image",Jte);/** 338 * @license lucide-react v0.484.0 - ISC 339 * 340 * This source code is licensed under the ISC license. 341 * See the LICENSE file in the root directory of this source tree. 342 */const ene=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],tne=xt("inbox",ene);/** 343 * @license lucide-react v0.484.0 - ISC 344 * 345 * This source code is licensed under the ISC license. 346 * See the LICENSE file in the root directory of this source tree. 347 */const nne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Kc=xt("info",nne);/** 348 * @license lucide-react v0.484.0 - ISC 349 * 350 * This source code is licensed under the ISC license. 351 * See the LICENSE file in the root directory of this source tree. 352 */const rne=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],aE=xt("keyboard",rne);/** 353 * @license lucide-react v0.484.0 - ISC 354 * 355 * This source code is licensed under the ISC license. 356 * See the LICENSE file in the root directory of this source tree. 357 */const ine=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],bD=xt("lightbulb",ine);/** 358 * @license lucide-react v0.484.0 - ISC 359 * 360 * This source code is licensed under the ISC license. 361 * See the LICENSE file in the root directory of this source tree. 362 */const sne=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Ka=xt("link",sne);/** 363 * @license lucide-react v0.484.0 - ISC 364 * 365 * This source code is licensed under the ISC license. 366 * See the LICENSE file in the root directory of this source tree. 367 */const one=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Da=xt("loader-circle",one);/** 368 * @license lucide-react v0.484.0 - ISC 369 * 370 * This source code is licensed under the ISC license. 371 * See the LICENSE file in the root directory of this source tree. 372 */const ane=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],xm=xt("lock",ane);/** 373 * @license lucide-react v0.484.0 - ISC 374 * 375 * This source code is licensed under the ISC license. 376 * See the LICENSE file in the root directory of this source tree. 377 */const lne=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],yD=xt("log-out",lne);/** 378 * @license lucide-react v0.484.0 - ISC 379 * 380 * This source code is licensed under the ISC license. 381 * See the LICENSE file in the root directory of this source tree. 382 */const cne=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],_h=xt("mail",cne);/** 383 * @license lucide-react v0.484.0 - ISC 384 * 385 * This source code is licensed under the ISC license. 386 * See the LICENSE file in the root directory of this source tree. 387 */const une=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],vD=xt("maximize-2",une);/** 388 * @license lucide-react v0.484.0 - ISC 389 * 390 * This source code is licensed under the ISC license. 391 * See the LICENSE file in the root directory of this source tree. 392 */const dne=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],xD=xt("menu",dne);/** 393 * @license lucide-react v0.484.0 - ISC 394 * 395 * This source code is licensed under the ISC license. 396 * See the LICENSE file in the root directory of this source tree. 397 */const fne=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],bb=xt("message-circle",fne);/** 398 * @license lucide-react v0.484.0 - ISC 399 * 400 * This source code is licensed under the ISC license. 401 * See the LICENSE file in the root directory of this source tree. 402 */const hne=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],wD=xt("message-square",hne);/** 403 * @license lucide-react v0.484.0 - ISC 404 * 405 * This source code is licensed under the ISC license. 406 * See the LICENSE file in the root directory of this source tree.
407 */const pne=[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]],Eh=xt("mic-vocal",pne);/** 408 * @license lucide-react v0.484.0 - ISC 409 * 410 * This source code is licensed under the ISC license. 411 * See the LICENSE file in the root directory of this source tree. 412 */const mne=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Rc=xt("mic",mne);/** 413 * @license lucide-react v0.484.0 - ISC 414 * 415 * This source code is licensed under the ISC license. 416 * See the LICENSE file in the root directory of this source tree. 417 */const gne=[["path",{d:"M5 12h14",key:"1ays0h"}]],kD=xt("minus",gne);/** 418 * @license lucide-react v0.484.0 - ISC 419 * 420 * This source code is licensed under the ISC license. 421 * See the LICENSE file in the root directory of this source tree. 422 */const bne=[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],SD=xt("minimize-2",bne);/** 423 * @license lucide-react v0.484.0 - ISC 424 * 425 * This source code is licensed under the ISC license. 426 * See the LICENSE file in the root directory of this source tree. 427 */const yne=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],vne=xt("moon",yne);/** 428 * @license lucide-react v0.484.0 - ISC 429 * 430 * This source code is licensed under the ISC license. 431 * See the LICENSE file in the root directory of this source tree. 432 */const xne=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],wne=xt("mouse-pointer",xne);/** 433 * @license lucide-react v0.484.0 - ISC 434 * 435 * This source code is licensed under the ISC license. 436 * See the LICENSE file in the root directory of this source tree. 437 */const kne=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],ev=xt("move",kne);/** 438 * @license lucide-react v0.484.0 - ISC 439 * 440 * This source code is licensed under the ISC license. 441 * See the LICENSE file in the root directory of this source tree. 442 */const Sne=[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]],hx=xt("music-2",Sne);/** 443 * @license lucide-react v0.484.0 - ISC 444 * 445 * This source code is licensed under the ISC license. 446 * See the LICENSE file in the root directory of this source tree. 447 */const Cne=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Mn=xt("music",Cne);/** 448 * @license lucide-react v0.484.0 - ISC 449 * 450 * This source code is licensed under the ISC license. 451 * See the LICENSE file in the root directory of this source tree. 452 */const _ne=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],lE=xt("palette",_ne);/** 453 * @license lucide-react v0.484.0 - ISC 454 * 455 * This source code is licensed under the ISC license. 456 * See the LICENSE file in the root directory of this source tree. 457 */const Ene=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],Zm=xt("pause",Ene);/** 458 * @license lucide-react v0.484.0 - ISC 459 * 460 * This source code is licensed under the ISC license. 461 * See the LICENSE file in the root directory of this source tree. 462 */const Nne=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Ine=xt("pen-line",Nne);/** 463 * @license lucide-react v0.484.0 - ISC 464 * 465 * This source code is licensed under the ISC license. 466 * See the LICENSE file in the root directory of this source tree. 467 */const jne=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],Cz=xt("pen-tool",jne);/** 468 * @license lucide-react v0.484.0 - ISC 469 * 470 * This source code is licensed under the ISC license. 471 * See the LICENSE file in the root directory of this source tree. 472 */const Tne=[["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"}]],Tl=xt("pencil",Tne);/** 473 * @license lucide-react v0.484.0 - ISC 474 * 475 * This source code is licensed under the ISC license. 476 * See the LICENSE file in the root directory of this source tree. 477 */const zne=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],ka=xt("play",zne);/** 478 * @license lucide-react v0.484.0 - ISC 479 * 480 * This source code is licensed under the ISC license. 481 * See the LICENSE file in the root directory of this source tree. 482 */const Pne=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Yf=xt("plus",Pne);/** 483 * @license lucide-react v0.484.0 - ISC 484 * 485 * This source code is licensed under the ISC license. 486 * See the LICENSE file in the root directory of this source tree. 487 */const Ane=[["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"}]],HS=xt("redo-2",Ane);/** 488 * @license lucide-react v0.484.0 - ISC 489 * 490 * This source code is licensed under the ISC license. 491 * See the LICENSE file in the root directory of this source tree. 492 */const Mne=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],tv=xt("refresh-cw",Mne);/** 493 * @license lucide-react v0.484.0 - ISC 494 * 495 * This source code is licensed under the ISC license. 496 * See the LICENSE file in the root directory of this source tree. 497 */const Bne=[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]],GS=xt("repeat-2",Bne);/** 498 * @license lucide-react v0.484.0 - ISC 499 * 500 * This source code is licensed under the ISC license. 501 * See the LICENSE file in the root directory of this source tree. 502 */const Rne=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}
502],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],Xf=xt("reply",Rne);/** 503 * @license lucide-react v0.484.0 - ISC 504 * 505 * This source code is licensed under the ISC license. 506 * See the LICENSE file in the root directory of this source tree. 507 */const One=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],CD=xt("rotate-ccw",One);/** 508 * @license lucide-react v0.484.0 - ISC 509 * 510 * This source code is licensed under the ISC license. 511 * See the LICENSE file in the root directory of this source tree. 512 */const Dne=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Lne=xt("save",Dne);/** 513 * @license lucide-react v0.484.0 - ISC 514 * 515 * This source code is licensed under the ISC license. 516 * See the LICENSE file in the root directory of this source tree. 517 */const Fne=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],px=xt("search",Fne);/** 518 * @license lucide-react v0.484.0 - ISC 519 * 520 * This source code is licensed under the ISC license. 521 * See the LICENSE file in the root directory of this source tree. 522 */const $ne=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Nh=xt("send",$ne);/** 523 * @license lucide-react v0.484.0 - ISC 524 * 525 * This source code is licensed under the ISC license. 526 * See the LICENSE file in the root directory of this source tree. 527 */const Une=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],_z=xt("settings-2",Une);/** 528 * @license lucide-react v0.484.0 - ISC 529 * 530 * This source code is licensed under the ISC license. 531 * See the LICENSE file in the root directory of this source tree. 532 */const Vne=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],cE=xt("settings",Vne);/** 533 * @license lucide-react v0.484.0 - ISC 534 * 535 * This source code is licensed under the ISC license. 536 * See the LICENSE file in the root directory of this source tree. 537 */const Hne=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Gne=xt("share-2",Hne);/** 538 * @license lucide-react v0.484.0 - ISC 539 * 540 * This source code is licensed under the ISC license. 541 * See the LICENSE file in the root directory of this source tree. 542 */const Wne=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],yb=xt("shield",Wne);/** 543 * @license lucide-react v0.484.0 - ISC 544 * 545 * This source code is licensed under the ISC license. 546 * See the LICENSE file in the root directory of this source tree. 547 */const qne=[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]],_D=xt("skip-forward",qne);/** 548 * @license lucide-react v0.484.0 - ISC 549 * 550 * This source code is licensed under the ISC license. 551 * See the LICENSE file in the root directory of this source tree. 552 */const Kne=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],Ez=xt("sliders-horizontal",Kne);/** 553 * @license lucide-react v0.484.0 - ISC 554 * 555 * This source code is licensed under the ISC license. 556 * See the LICENSE file in the root directory of this source tree. 557 */const Yne=[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]],mx=xt("sliders-vertical",Yne);/** 558 * @license lucide-react v0.484.0 - ISC 559 * 560 * This source code is licensed under the ISC license. 561 * See the LICENSE file in the root directory of this source tree. 562 */const Xne=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Qne=xt("smartphone",Xne);/** 563 * @license lucide-react v0.484.0 - ISC 564 * 565 * This source code is licensed under the ISC license. 566 * See the LICENSE file in the root directory of this source tree. 567 */const Zne=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],uo=xt("sparkles",Zne);/** 568 * @license lucide-react v0.484.0 - ISC 569 * 570 * This source code is licensed under the ISC license. 571 * See the LICENSE file in the root directory of this source tree. 572 */const Jne=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],ED=xt("square-dashed",Jne);/** 573 * @license lucide-react v0.484.0 - ISC 574 * 575 * This source code is licensed under the ISC license. 576 * See the LICENSE file in the root directory of this source tree. 577 */const ere=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],nv=xt("square",ere);/** 578 * @license lucide-react v0.484.0 - ISC 579 * 580 * This source code is licensed under the ISC license. 581 * See the LICENSE file in the root directory of this source tree. 582 */const tre=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}
582]],WS=xt("star",tre);/** 583 * @license lucide-react v0.484.0 - ISC 584 * 585 * This source code is licensed under the ISC license. 586 * See the LICENSE file in the root directory of this source tree. 587 */const nre=[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]],ND=xt("sun-moon",nre);/** 588 * @license lucide-react v0.484.0 - ISC 589 * 590 * This source code is licensed under the ISC license. 591 * See the LICENSE file in the root directory of this source tree. 592 */const rre=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ID=xt("sun",rre);/** 593 * @license lucide-react v0.484.0 - ISC 594 * 595 * This source code is licensed under the ISC license. 596 * See the LICENSE file in the root directory of this source tree. 597 */const ire=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Gu=xt("target",ire);/** 598 * @license lucide-react v0.484.0 - ISC 599 * 600 * This source code is licensed under the ISC license. 601 * See the LICENSE file in the root directory of this source tree. 602 */const sre=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],ore=xt("timer",sre);/** 603 * @license lucide-react v0.484.0 - ISC 604 * 605 * This source code is licensed under the ISC license. 606 * See the LICENSE file in the root directory of this source tree. 607 */const are=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],js=xt("trash-2",are);/** 608 * @license lucide-react v0.484.0 - ISC 609 * 610 * This source code is licensed under the ISC license. 611 * See the LICENSE file in the root directory of this source tree. 612 */const lre=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],cre=xt("trash",lre);/** 613 * @license lucide-react v0.484.0 - ISC 614 * 615 * This source code is licensed under the ISC license. 616 * See the LICENSE file in the root directory of this source tree. 617 */const ure=[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]],dre=xt("trending-up-down",ure);/** 618 * @license lucide-react v0.484.0 - ISC 619 * 620 * This source code is licensed under the ISC license. 621 * See the LICENSE file in the root directory of this source tree. 622 */const fre=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],z0=xt("triangle-alert",fre);/** 623 * @license lucide-react v0.484.0 - ISC 624 * 625 * This source code is licensed under the ISC license. 626 * See the LICENSE file in the root directory of this source tree. 627 */const hre=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],pre=xt("trending-up",hre);/** 628 * @license lucide-react v0.484.0 - ISC 629 * 630 * This source code is licensed under the ISC license. 631 * See the LICENSE file in the root directory of this source tree. 632 */const mre=[["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"}]],qS=xt("undo-2",mre);/** 633 * @license lucide-react v0.484.0 - ISC 634 * 635 * This source code is licensed under the ISC license. 636 * See the LICENSE file in the root directory of this source tree. 637 */const gre=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],gx=xt("upload",gre);/** 638 * @license lucide-react v0.484.0 - ISC 639 * 640 * This source code is licensed under the ISC license. 641 * See the LICENSE file in the root directory of this source tree. 642 */const bre=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}
642],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]],yre=xt("user-check",bre);/** 643 * @license lucide-react v0.484.0 - ISC 644 * 645 * This source code is licensed under the ISC license. 646 * See the LICENSE file in the root directory of this source tree. 647 */const vre=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],xre=xt("user-minus",vre);/** 648 * @license lucide-react v0.484.0 - ISC 649 * 650 * This source code is licensed under the ISC license. 651 * See the LICENSE file in the root directory of this source tree. 652 */const wre=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],wm=xt("user",wre);/** 653 * @license lucide-react v0.484.0 - ISC 654 * 655 * This source code is licensed under the ISC license. 656 * See the LICENSE file in the root directory of this source tree. 657 */const kre=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],bx=xt("users",kre);/** 658 * @license lucide-react v0.484.0 - ISC 659 * 660 * This source code is licensed under the ISC license. 661 * See the LICENSE file in the root directory of this source tree. 662 */const Sre=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ul=xt("video",Sre);/** 663 * @license lucide-react v0.484.0 - ISC 664 * 665 * This source code is licensed under the ISC license. 666 * See the LICENSE file in the root directory of this source tree. 667 */const Cre=[["path",{d:"M11 4.702a.705.705 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.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Ya=xt("volume-2",Cre);/** 668 * @license lucide-react v0.484.0 - ISC 669 * 670 * This source code is licensed under the ISC license. 671 * See the LICENSE file in the root directory of this source tree. 672 */const _re=[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.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.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]],Ih=xt("volume-off",_re);/** 673 * @license lucide-react v0.484.0 - ISC 674 * 675 * This source code is licensed under the ISC license. 676 * See the LICENSE file in the root directory of this source tree. 677 */const Ere=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],KS=xt("wand-sparkles",Ere);/** 678 * @license lucide-react v0.484.0 - ISC 679 * 680 * This source code is licensed under the ISC license. 681 * See the LICENSE file in the root directory of this source tree. 682 */const Nre=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ire=xt("wifi-off",Nre);/** 683 * @license lucide-react v0.484.0 - ISC 684 * 685 * This source code is licensed under the ISC license. 686 * See the LICENSE file in the root directory of this source tree. 687 */const jre=[["path",{d:"M12 20h.01",key:"zekei9"}
687],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Tre=xt("wifi",jre);/** 688 * @license lucide-react v0.484.0 - ISC 689 * 690 * This source code is licensed under the ISC license. 691 * See the LICENSE file in the root directory of this source tree. 692 */const zre=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],jD=xt("wrench",zre);/** 693 * @license lucide-react v0.484.0 - ISC 694 * 695 * This source code is licensed under the ISC license. 696 * See the LICENSE file in the root directory of this source tree. 697 */const Pre=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],nr=xt("x",Pre);/** 698 * @license lucide-react v0.484.0 - ISC 699 * 700 * This source code is licensed under the ISC license. 701 * See the LICENSE file in the root directory of this source tree. 702 */const Are=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Qf=xt("zap",Are),Wr=({onClose:t,widthClass:e,heightClass:n,blurBackground:r,closeOnEscape:i=!0,closeOnBackdropClick:s=!0,children:o})=>{const a=x.useRef(null);return x.useEffect(()=>{if(!i)return;const l=u=>{u.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,i]),x.useEffect(()=>{const l=requestAnimationFrame(()=>{var u;(u=a.current)==null||u.focus()});return()=>cancelAnimationFrame(l)},[]),x.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),c.jsxs("div",{id:"modal-dialog","data-testid":"modal-dialog",className:"fixed inset-0 z-51 flex items-center justify-center",children:[c.jsx("div",{className:`absolute inset-0 ${r?"bg-black/50 backdrop-blur-sm":"bg-black/50"}`,onClick:s?t:void 0}),c.jsx("div",{className:`relative ${e||""} ${n||""} bg-zinc-100/20 dark:bg-zinc-900/20 backdrop-blur-sm text-zinc-800 dark:text-zinc-100 rounded-lg flex flex-col overflow-hidden border border-zinc-300 dark:border-zinc-800`,tabIndex:-1,role:"dialog","aria-modal":"true",ref:a,children:o})]})},TD=({isOpen:t,onClose:e,isOffline:n,isServerUnavailable:r,isOnline:i=!1,lastSyncTime:s=null})=>{const{theme:o}=Pn(),a=o===gi.Dark,[l,u]=x.useState(!1),d=async()=>{if(!l){u(!0);try{await jn.clear(),window.location.reload()}catch{u(!1)}}};if(!t)return null;const f=y=>{if(!y)return"Never";const w=Date.now()-y,v=Math.floor(w/1e3),S=Math.floor(v/60),C=Math.floor(S/60);return v<60?"Just now":S<60?`${S} minute${S!==1?"s":""} ago`:C<24?`${C} hour${C!==1?"s":""} ago`:new Date(y).toLocaleString()},m=i&&!n&&!r?{icon:c.jsx(vte,{size:24,className:"text-green-500"}),title:"Connection is working",message:"Your connection is working properly. All changes are being automatically synced to the cloud. If you are not seeing the latest changes you expect, you can force a sync by clicking the button below.",lastSyncTime:s}:n?{icon:c.jsx(Ire,{size:24,className:"text-red-500"}),title:"You are offline",message:"Your device is not connected to the internet. You may not be seeing the latest changes from other devices, and your changes are being saved locally. Once you reconnect, your changes will be synced automatically.",lastSyncTime:null}:r?{icon:c.jsx(T0,{size:24,className:"text-red-500"}),title:"Server cannot be reached",message:"The server is temporarily unavailable. You may not be seeing the latest changes, and your changes are being saved locally. Once the server is available again, your changes will be synced automatically.",lastSyncTime:null}:null;return m?c.jsx(Wr,{onClose:e,widthClass:"w-[500px]",blurBackground:!0,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors ${a?"bg-gradient-to-br from-zinc-800/95 to-zinc-900/95 backdrop-blur-sm text-zinc-100":"bg-gradient-to-br from-zinc-100/95 to-zinc-200/95 backdrop-blur-sm text-zinc-800"}`,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${a?"border-zinc-700":"border-zinc-300"}`,children:[c.jsxs("div",{className:"flex items-center gap-3",children:[m.icon,c.jsx("h2",{className:"text-xl font-semibold",children:m.title})]}),c.jsx("button",{onClick:e,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${a?"hover:bg-zinc-100":"hover:bg-zinc-900"}`,"aria-label":"Close modal",children:c.jsx(nr,{size:20})})]}),c.jsxs("div",{className:"flex-1 p-6 overflow-y-auto",children:[c.jsx("p",{className:`text-sm leading-relaxed ${a?"text-zinc-300":"text-zinc-600"}`,children:m.message}),m.lastSyncTime!==null&&m.lastSyncTime!==void 0&&c.jsx("div",{className:`mt-4 pt-4 border-t ${a?"border-zinc-700":"border-zinc-300"}`,children:c.jsxs("p",{className:`text-xs ${a?"text-zinc-400":"text-zinc-500"}`,children:["Last synced: ",f(m.lastSyncTime)]})})]}),c.jsxs("div",{className:`p-4 border-t ${a?"border-zinc-700":"border-zinc-300"}`,children:[i&&c.jsx("button",{type:"button",onClick:d,disabled:l,className:`w-full px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2 mb-3 ${a?"bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed":"bg-zinc-300 hover:bg-zinc-400 text-zinc-900 disabled:opacity-50 disabled:cursor-not-allowed"}`,children:l?"Clearing and refreshingâ¦":c.jsxs(c.Fragment,{children:[c.jsx(tv,{size:16}),"Force sync"]})}),c.jsx("button",{onClick:e,className:`w-full px-4 py-2 rounded-lg font-medium transition-colors ${a?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-zinc-200 hover:bg-zinc-300 text-zinc-900"}`,children:"Understood"})]})]})}):null},uE=x.createContext({});function P0(t){const e=x.useRef(null);return e.current===null&&(e.current=t()),e.current}const yx=x.createContext(null),A0=x.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class Mre extends x.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Bre({children:t,isPresent:e}){const n=x.useId(),r=x.useRef(null),i=x.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=x.useContext(A0);return x.useInsertionEffect(()=>{const{width:o,height:a,top:l,left:u}=i.current;if(e||!r.current||!o||!a)return;r.current.dataset.motionPopId=n;const d=document.createElement("style");return s&&(d.nonce=s),document.head.appendChild(d),d.sheet&&d.sheet.insertRule(` 703 [data-motion-pop-id="${n}"] { 704 position: absolute !important; 705 width: ${o}px !important; 706 height: ${a}px !important; 707 top: ${l}px !important; 708 left: ${u}px !important; 709 } 710 `),()=>{document.head.removeChild(d)}},[e]),c.jsx(Mre,{isPresent:e,childRef:r,sizeRef:i,children:x.cloneElement(t,{ref:r})})}const Rre=({children:t,initial:e,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:o})=>{const a=P0(Ore),l=x.useId(),u=x.useCallback(f=>{a.set(f,!0);for(const h of a.values())if(!h)return;r&&r()},[a,r]),d=x.useMemo(()=>({id:l,initial:e,isPresent:n,custom:i,onExitComplete:u,register:f=>(a.set(f,!1),()=>a.delete(f))}),s?[Math.random(),u]:[n,u]);return x.useMemo(()=>{a.forEach((f,h)=>a.set(h,!1))},[n]),x.useEffect(()=>{!n&&!a.size&&r&&r()},[n]),o==="popLayout"&&(t=c.jsx(Bre,{isPresent:n,children:t})),c.jsx(yx.Provider,{value:d,children:t})};function Ore(){return new Map}function zD(t=!0){const e=x.useContext(yx);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=e,s=x.useId();x.useEffect(()=>{t&&i(s)},[t]);const o=x.useCallback(()=>t&&r&&r(s),[s,r,t]);return!n&&r?[!1,o]:[!0]}const vb=t=>t.key||"";function Nz(t){const e=[];
vendor: 33,699 bytes, line 710
710return x.Children.forEach(t,n=>{x.isValidElement(n)&&e.push(n)}),e}const dE=typeof window<"u",vx=dE?x.useLayoutEffect:x.useEffect,Vn=({children:t,custom:e,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:o=!1})=>{const[a,l]=zD(o),u=x.useMemo(()=>Nz(t),[t]),d=o&&!a?[]:u.map(vb),f=x.useRef(!0),h=x.useRef(u),m=P0(()=>new Map),[y,g]=x.useState(u),[w,v]=x.useState(u);vx(()=>{f.current=!1,h.current=u;for(let k=0;k<w.length;k++){const N=vb(w[k]);d.includes(N)?m.delete(N):m.get(N)!==!0&&m.set(N,!1)}},[w,d.length,d.join("-")]);const S=[];if(u!==y){let k=[...u];for(let N=0;N<w.length;N++){const _=w[N],j=vb(_);d.includes(j)||(k.splice(N,0,_),S.push(_))}s==="wait"&&S.length&&(k=S),v(Nz(k)),g(u);return}const{forceRender:C}=x.useContext(uE);return c.jsx(c.Fragment,{children:w.map(k=>{const N=vb(k),_=o&&!a?!1:u===w||d.includes(N),j=()=>{if(m.has(N))m.set(N,!0);else return;let T=!0;m.forEach(M=>{M||(T=!1)}),T&&(C==null||C(),v(h.current),o&&(l==null||l()),r&&r())};return c.jsx(Rre,{isPresent:_,initial:!f.current||n?void 0:!1,custom:_?void 0:e,presenceAffectsLayout:i,mode:s,onExitComplete:_?void 0:j,children:k},N)})})},go=t=>t;let PD=go;function fE(t){let e;return()=>(e===void 0&&(e=t()),e)}const jh=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r},Bl=t=>t*1e3,Rl=t=>t/1e3,Dre={useManualTiming:!1};function Lre(t){let e=new Set,n=new Set,r=!1,i=!1;const s=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function a(u){s.has(u)&&(l.schedule(u),t()),u(o)}const l={schedule:(u,d=!1,f=!1)=>{const m=f&&r?e:n;return d&&s.add(u),m.has(u)||m.add(u),u},cancel:u=>{n.delete(u),s.delete(u)},process:u=>{if(o=u,r){i=!0;return}r=!0,[e,n]=[n,e],e.forEach(a),e.clear(),r=!1,i&&(i=!1,l.process(u))}};return l}const xb=["read","resolveKeyframes","update","preRender","render","postRender"],Fre=40;function AD(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=xb.reduce((v,S)=>(v[S]=Lre(s),v),{}),{read:a,resolveKeyframes:l,update:u,preRender:d,render:f,postRender:h}=o,m=()=>{const v=performance.now();n=!1,i.delta=r?1e3/60:Math.max(Math.min(v-i.timestamp,Fre),1),i.timestamp=v,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),d.process(i),f.process(i),h.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(m))},y=()=>{n=!0,r=!0,i.isProcessing||t(m)};return{schedule:xb.reduce((v,S)=>{const C=o[S];return v[S]=(k,N=!1,_=!1)=>(n||y(),C.schedule(k,N,_)),v},{}),cancel:v=>{for(let S=0;S<xb.length;S++)o[xb[S]].cancel(v)},state:i,steps:o}}const{schedule:Mr,cancel:Fc,state:Li,steps:rk}=AD(typeof requestAnimationFrame<"u"?requestAnimationFrame:go,!0),MD=x.createContext({strict:!1}),Iz={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Th={};for(const t in Iz)Th[t]={isEnabled:e=>Iz[t].some(n=>!!e[n])};function $re(t){for(const e in t)Th[e]={...Th[e],...t[e]}}const Ure=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function rv(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Ure.has(t)}let BD=t=>!rv(t);function Vre(t){t&&(BD=e=>e.startsWith("on")?!rv(e):t(e))}try{Vre(require("@emotion/is-prop-valid").default)}catch{}function Hre(t,e,n){const r={};for(const i in t)i==="values"&&typeof t.values=="object"||(BD(i)||n===!0&&rv(i)||!e&&!rv(i)||t.draggable&&i.startsWith("onDrag"))&&(r[i]=t[i]);return r}function Gre(t){if(typeof Proxy>"u")return t;const e=new Map,n=(...r)=>t(...r);return new Proxy(n,{get:(r,i)=>i==="create"?t:(e.has(i)||e.set(i,t(i)),e.get(i))})}const xx=x.createContext({});function Jm(t){return typeof t=="string"||Array.isArray(t)}function wx(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}const hE=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],pE=["initial",...hE];function kx(t){return wx(t.animate)||pE.some(e=>Jm(t[e]))}function RD(t){return!!(kx(t)||t.variants)}function Wre(t,e){if(kx(t)){const{initial:n,animate:r}=t;return{initial:n===!1||Jm(n)?n:void 0,animate:Jm(r)?r:void 0}}return t.inherit!==!1?e:{}}function qre(t){const{initial:e,animate:n}=Wre(t,x.useContext(xx));return x.useMemo(()=>({initial:e,animate:n}),[jz(e),jz(n)])}function jz(t){return Array.isArray(t)?t.join(" "):t}const Kre=Symbol.for("motionComponentSymbol");function Of(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Yre(t,e,n){return x.useCallback(r=>{r&&t.onMount&&t.onMount(r),e&&(r?e.mount(r):e.unmount()),n&&(typeof n=="function"?n(r):Of(n)&&(n.current=r))},[e])}const mE=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Xre="framerAppearId",OD="data-"+mE(Xre),{schedule:gE}=AD(queueMicrotask,!1),DD=x.createContext({});function Qre(t,e,n,r,i){var s,o;const{visualElement:a}=x.useContext(xx),l=x.useContext(MD),u=x.useContext(yx),d=x.useContext(A0).reducedMotion,f=x.useRef(null);r=r||l.renderer,!f.current&&r&&(f.current=r(t,{visualState:e,parent:a,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:d}));const h=f.current,m=x.useContext(DD);h&&!h.projection&&i&&(h.type==="html"||h.type==="svg")&&Zre(f.current,n,i,m);const y=x.useRef(!1);x.useInsertionEffect(()=>{h&&y.current&&h.update(n,u)});const g=n[OD],w=x.useRef(!!g&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,g))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,g)));return vx(()=>{h&&(y.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),gE.render(h.render),w.current&&h.animationState&&h.animationState.animateChanges())}),x.useEffect(()=>{h&&(!w.current&&h.animationState&&h.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var v;(v=window.MotionHandoffMarkAsComplete)===null||v===void 0||v.call(window,g)}),w.current=!1))}),h}function Zre(t,e,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:LD(t.parent)),t.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Of(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,layoutScroll:l,layoutRoot:u})}function LD(t){if(t)return t.options.allowProjection!==!1?t.projection:LD(t.parent)}function Jre({preloadedFeatures:t,createVisualElement:e,useRender:n,useVisualState:r,Component:i}){var s,o;t&&$re(t);function a(u,d){let f;const h={...x.useContext(A0),...u,layoutId:eie(u)},{isStatic:m}=h,y=qre(u),g=r(u,m);if(!m&&dE){tie();const w=nie(h);f=w.MeasureLayout,y.visualElement=Qre(i,g,h,e,w.ProjectionNode)}return c.jsxs(xx.Provider,{value:y,children:[f&&y.visualElement?c.jsx(f,{visualElement:y.visualElement,...h}):null,n(i,u,Yre(g,y.visualElement,d),g,m,y.visualElement)]})}a.displayName=`motion.${typeof i=="string"?i:`create(${(o=(s=i.displayName)!==null&&s!==void 0?s:i.name)!==null&&o!==void 0?o:""})`}`;const l=x.forwardRef(a);return l[Kre]=i,l}function eie({layoutId:t}){const e=x.useContext(uE).id;return e&&t!==void 0?e+"-"+t:t}function tie(t,e){x.useContext(MD).strict}function nie(t){const{drag:e,layout:n}=Th;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:e!=null&&e.isEnabled(t)||n!=null&&n.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}const rie=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function bE(t){return typeof t!="string"||t.includes("-")?!1:!!(rie.indexOf(t)>-1||/[A-Z]/u.test(t))}function Tz(t){const e=[{},{}];return t==null||t.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function yE(t,e,n,r){if(typeof e=="function"){const[i,s]=Tz(r);e=e(n!==void 0?n:t.custom,i,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,s]=Tz(r);e=e(n!==void 0?n:t.custom,i,s)}return e}const YS=t=>Array.isArray(t),iie=t=>!!(t&&typeof t=="object"&&t.mix&&t.toValue),sie=t=>YS(t)?t[t.length-1]||0:t,Ui=t=>!!(t&&t.getVelocity);function py(t){const e=Ui(t)?t.get():t;return iie(e)?e.toValue():e}function oie({scrapeMotionValuesFromProps:t,createRenderState:e,onUpdate:n},r,i,s){const o={latestValues:aie(r,i,s,t),renderState:e()};return n&&(o.onMount=a=>n({props:r,current:a,...o}),o.onUpdate=a=>n(a)),o}const FD=t=>(e,n)=>{const r=x.useContext(xx),i=x.useContext(yx),s=()=>oie(t,e,r,i);return n?s():P0(s)};function aie(t,e,n,r){const i={},s=r(t,{});for(const h in s)i[h]=py(s[h]);let{initial:o,animate:a}=t;const l=kx(t),u=RD(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const f=d?a:o;if(f&&typeof f!="boolean"&&!wx(f)){const h=Array.isArray(f)?f:[f];for(let m=0;m<h.length;m++){const y=yE(t,h[m]);if(y){const{transitionEnd:g,transition:w,...v}=y;for(const S in v){let C=v[S];if(Array.isArray(C)){const k=d?C.length-1:0;C=C[k]}C!==null&&(i[S]=C)}for(const S in g)i[S]=g[S]}}}return i}const Zh=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Sd=new Set(Zh),$D=t=>e=>typeof e=="string"&&e.startsWith(t),UD=$D("--"),lie=$D("var(--"),vE=t=>lie(t)?cie.test(t.split("/*")[0].trim()):!1,cie=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,VD=(t,e)=>e&&typeof t=="number"?e.transform(t):t,Vl=(t,e,n)=>n>e?e:n<t?t:n,Jh={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},e0={...Jh,transform:t=>Vl(0,1,t)},wb={...Jh,default:1},M0=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),kc=M0("deg"),Xa=M0("%"),_n=M0("px"),uie=M0("vh"),die=M0("vw"),zz={...Xa,parse:t=>Xa.parse(t)/100,transform:t=>Xa.transform(t*100)},fie={borderWidth:_n,borderTopWidth:_n,borderRightWidth:_n,borderBottomWidth:_n,borderLeftWidth:_n,borderRadius:_n,radius:_n,borderTopLeftRadius:_n,borderTopRightRadius:_n,borderBottomRightRadius:_n,borderBottomLeftRadius:_n,width:_n,maxWidth:_n,height:_n,maxHeight:_n,top:_n,right:_n,bottom:_n,left:_n,padding:_n,paddingTop:_n,paddingRight:_n,paddingBottom:_n,paddingLeft:_n,margin:_n,marginTop:_n,marginRight:_n,marginBottom:_n,marginLeft:_n,backgroundPositionX:_n,backgroundPositionY:_n},hie={rotate:kc,rotateX:kc,rotateY:kc,rotateZ:kc,scale:wb,scaleX:wb,scaleY:wb,scaleZ:wb,skew:kc,skewX:kc,skewY:kc,distance:_n,translateX:_n,translateY:_n,translateZ:_n,x:_n,y:_n,z:_n,perspective:_n,transformPerspective:_n,opacity:e0,originX:zz,originY:zz,originZ:_n},Pz={...Jh,transform:Math.round},xE={...fie,...hie,zIndex:Pz,size:_n,fillOpacity:e0,strokeOpacity:e0,numOctaves:Pz},pie={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},mie=Zh.length;function gie(t,e,n){let r="",i=!0;for(let s=0;s<mie;s++){const o=Zh[s],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=VD(a,xE[o]);if(!l){i=!1;const d=pie[o]||o;r+=`${d}(${u}) `}n&&(e[o]=u)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function wE(t,e,n){const{style:r,vars:i,transformOrigin:s}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(Sd.has(l)){o=!0;continue}else if(UD(l)){i[l]=u;continue}else{const d=VD(u,xE[l]);l.startsWith("origin")?(a=!0,s[l]=d):r[l]=d}}if(e.transform||(o||n?r.transform=gie(e,t.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:d=0}=s;r.transformOrigin=`${l} ${u} ${d}`}}const bie={offset:"stroke-dashoffset",array:"stroke-dasharray"},yie={offset:"strokeDashoffset",array:"strokeDasharray"};function vie(t,e,n=1,r=0,i=!0){t.pathLength=1;const s=i?bie:yie;t[s.offset]=_n.transform(-r);const o=_n.transform(e),a=_n.transform(n);t[s.array]=`${o} ${a}`}function Az(t,e,n){return typeof t=="string"?t:_n.transform(e+n*t)}function xie(t,e,n){const r=Az(e,t.x,t.width),i=Az(n,t.y,t.height);return`${r} ${i}`}function kE(t,{attrX:e,attrY:n,attrScale:r,originX:i,originY:s,pathLength:o,pathSpacing:a=1,pathOffset:l=0,...u},d,f){if(wE(t,u,f),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:h,style:m,dimensions:y}=t;h.transform&&(y&&(m.transform=h.transform),delete h.transform),y&&(i!==void 0||s!==void 0||m.transform)&&(m.transformOrigin=xie(y,i!==void 0?i:.5,s!==void 0?s:.5)),e!==void 0&&(h.x=e),n!==void 0&&(h.y=n),r!==void 0&&(h.scale=r),o!==void 0&&vie(h,o,a,l,!1)}const SE=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),HD=()=>({...SE(),attrs:{}}),CE=t=>typeof t=="string"&&t.toLowerCase()==="svg";function GD(t,{style:e,vars:n},r,i){Object.assign(t.style,e,i&&i.getProjectionStyles(r));for(const s in n)t.style.setProperty(s,n[s])}const WD=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function qD(t,e,n,r){GD(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(WD.has(i)?i:mE(i),e.attrs[i])}const iv={};function wie(t){Object.assign(iv,t)}function KD(t,{layout:e,layoutId:n}){return Sd.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!iv[t]||t==="opacity")}function _E(t,e,n){var r;const{style:i}=t,s={};for(const o in i)(Ui(i[o])||e.style&&Ui(e.style[o])||KD(o,t)||((r=n==null?void 0:n.getValue(o))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(s[o]=i[o]);return s}function YD(t,e,n){const r=_E(t,e,n);for(const i in t)if(Ui(t[i])||Ui(e[i])){const s=Zh.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=t[i]}return r}function kie(t,e){try{e.dimensions=typeof t.getBBox=="function"?t.getBBox():t.getBoundingClientRect()}catch{e.dimensions={x:0,y:0,width:0,height:0}}}const Mz=["x","y","width","height","cx","cy","r"],Sie={useVisualState:FD({scrapeMotionValuesFromProps:YD,createRenderState:HD,onUpdate:({props:t,prevProps:e,current:n,renderState:r,latestValues:i})=>{if(!n)return;let s=!!t.drag;if(!s){for(const a in i)if(Sd.has(a)){s=!0;break}}if(!s)return;let o=!e;if(e)for(let a=0;a<Mz.length;a++){const l=Mz[a];t[l]!==e[l]&&(o=!0)}o&&Mr.read(()=>{kie(n,r),Mr.render(()=>{kE(r,i,CE(n.tagName),t.transformTemplate),qD(n,r)})})}})},Cie={useVisualState:FD({scrapeMotionValuesFromProps:_E,createRenderState:SE})};function XD(t,e,n){for(const r in e)!Ui(e[r])&&!KD(r,n)&&(t[r]=e[r])}function _ie({transformTemplate:t},e){return x.useMemo(()=>{const n=SE();return wE(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Eie(t,e){const n=t.style||{},r={};return XD(r,n,t),Object.assign(r,_ie(t,e)),r}function Nie(t,e){const n={},r=Eie(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}function Iie(t,e,n,r){const i=x.useMemo(()=>{const s=HD();return kE(s,e,CE(r),t.transformTemplate),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};XD(s,t.style,t),i.style={...s,...i.style}}return i}function jie(t=!1){return(n,r,i,{latestValues:s},o)=>{const l=(bE(n)?Iie:Nie)(r,s,o,n),u=Hre(r,typeof n=="string",t),d=n!==x.Fragment?{...u,...l,ref:i}:{},{children:f}=r,h=x.useMemo(()=>Ui(f)?f.get():f,[f]);return x.createElement(n,{...d,children:h})}}function Tie(t,e){return function(r,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...bE(r)?Sie:Cie,preloadedFeatures:t,useRender:jie(i),createVisualElement:e,Component:r};return Jre(o)}}function QD(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}function Sx(t,e,n){const r=t.getProps();return yE(r,e,n!==void 0?n:r.custom,t)}const zie=fE(()=>window.ScrollTimeline!==void 0);class Pie{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>"finished"in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let r=0;r<this.animations.length;r++)this.animations[r][e]=n}attachTimeline(e,n){const r=this.animations.map(i=>{if(zie()&&i.attachTimeline)return i.attachTimeline(e);if(typeof n=="function")return n(i)});return()=>{r.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let n=0;n<this.animations.length;n++)e=Math.max(e,this.animations[n].duration);return e}runAll(e){this.animations.forEach(n=>n[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Aie extends Pie{then(e,n){return Promise.all(this.animations).then(e).catch(n)}}function EE(t,e){return t?t[e]||t.default||t:void 0}const XS=2e4;function ZD(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<XS;)e+=n,r=t.next(e);return e>=XS?1/0:e}function NE(t){return typeof t=="function"}function Bz(t,e){t.timeline=e,t.onfinish=null}const IE=t=>Array.isArray(t)&&typeof t[0]=="number",Mie={linearEasing:void 0};function Bie(t,e){const n=fE(t);return()=>{var r;return(r=Mie[e])!==null&&r!==void 0?r:n()}}const sv=Bie(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),JD=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let s=0;s<i;s++)r+=t(jh(0,i-1,s))+", ";return`linear(${r.substring(0,r.length-2)})`};function e6(t){return!!(typeof t=="function"&&sv()||!t||typeof t=="string"&&(t in QS||sv())||IE(t)||Array.isArray(t)&&t.every(e6))}const om=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,QS={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:om([0,.65,.55,1]),circOut:om([.55,0,1,.45]),backIn:om([.31,.01,.66,-.59]),backOut:om([.33,1.53,.69,.99])};function t6(t,e){if(t)return typeof t=="function"&&sv()?JD(t,e):IE(t)?om(t):Array.isArray(t)?t.map(n=>t6(n,e)||QS.easeOut):QS[t]}const ra={x:!1,y:!1};function n6(){return ra.x||ra.y}function Rie(t,e,n){var r;if(t instanceof Element)return[t];if(typeof t=="string"){let i=document;const s=(r=void 0)!==null&&r!==void 0?r:i.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t)}function r6(t,e){const n=Rie(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function Rz(t){return e=>{e.pointerType==="touch"||n6()||t(e)}}function Oie(t,e,n={}){const[r,i,s]=r6(t,n),o=Rz(a=>{const{target:l}=a,u=e(a);if(typeof u!="function"||!l)return;const d=Rz(f=>{u(f),l.removeEventListener("pointerleave",d)});l.addEventListener("pointerleave",d,i)});return r.forEach(a=>{a.addEventListener("pointerenter",o,i)}),s}const i6=(t,e)=>e?t===e?!0:i6(t,e.parentElement):!1,jE=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Die=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Lie(t){return Die.has(t.tagName)||t.tabIndex!==-1}const am=new WeakSet;function Oz(t){return e=>{e.key==="Enter"&&t(e)}}function ik(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Fie=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=Oz(()=>{if(am.has(n))return;ik(n,"down");const i=Oz(()=>{ik(n,"up")}),s=()=>ik(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",s,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function Dz(t){return jE(t)&&!n6()}function $ie(t,e,n={}){const[r,i,s]=r6(t,n),o=a=>{const l=a.currentTarget;if(!Dz(a)||am.has(l))return;am.add(l);const u=e(a),d=(m,y)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),!(!Dz(m)||!am.has(l))&&(am.delete(l),typeof u=="function"&&u(m,{success:y}))},f=m=>{d(m,n.useGlobalTarget||i6(l,m.target))},h=m=>{d(m,!1)};window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",h,i)};return r.forEach(a=>{!Lie(a)&&a.getAttribute("tabindex")===null&&(a.tabIndex=0),(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),a.addEventListener("focus",u=>Fie(u,i),i)}),s}function Uie(t){return t==="x"||t==="y"?ra[t]?null:(ra[t]=!0,()=>{ra[t]=!1}):ra.x||ra.y?null:(ra.x=ra.y=!0,()=>{ra.x=ra.y=!1})}const s6=new Set(["width","height","top","left","right","bottom",...Zh]);let my;function Vie(){my=void 0}const Qa={now:()=>(my===void 0&&Qa.set(Li.isProcessing||Dre.useManualTiming?Li.timestamp:performance.now()),my),set:t=>{my=t,queueMicrotask(Vie)}};function TE(t,e){t.indexOf(e)===-1&&t.push(e)}function zE(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}class PE{constructor(){this.subscriptions=[]}add(e){return TE(this.subscriptions,e),()=>zE(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let s=0;s<i;s++){const o=this.subscriptions[s];o&&o(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function o6(t,e){return e?t*(1e3/e):0}const Lz=30,Hie=t=>!isNaN(parseFloat(t));class Gie{constructor(e,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,i=!0)=>{const s=Qa.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Qa.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Hie(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new PE);const r=this.events[e].add(n);return e==="change"?()=>{r(),Mr.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e,n=!0){!n||!this.passiveEffect?this.updateAndNotify(e,n):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Qa.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Lz)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Lz);return o6(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function zh(t,e){return new Gie(t,e)}function Wie(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,zh(n))}function AE(t,e){const n=Sx(t,e);let{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(const o in s){const a=sie(s[o]);Wie(t,o,a)}}function qie(t){return!!(Ui(t)&&t.add)}function ZS(t,e){const n=t.getValue("willChange");if(qie(n))return n.add(e)}function a6(t){return t.props[OD]}const l6=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Kie=1e-7,Yie=12;function Xie(t,e,n,r,i){let s,o,a=0;do o=e+(n-e)/2,s=l6(o,r,i)-t,s>0?n=o:e=o;while(Math.abs(s)>Kie&&++a<Yie);return o}function B0(t,e,n,r){if(t===e&&n===r)return go;const i=s=>Xie(s,0,1,t,n);return s=>s===0||s===1?s:l6(i(s),e,r)}const c6=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,u6=t=>e=>1-t(1-e),d6=B0(.33,1.53,.69,.99),ME=u6(d6),f6=c6(ME),h6=t=>(t*=2)<1?.5*ME(t):.5*(2-Math.pow(2,-10*(t-1))),BE=t=>1-Math.sin(Math.acos(t)),p6=u6(BE),m6=c6(BE),g6=t=>/^0[^.\s]+$/u.test(t);function Qie(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||g6(t):!0}const km=t=>Math.round(t*1e5)/1e5,RE=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Zie(t){return t==null}const Jie=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,OE=(t,e)=>n=>!!(typeof n=="string"&&Jie.test(n)&&n.startsWith(t)||e&&!Zie(n)&&Object.prototype.hasOwnProperty.call(n,e)),b6=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(RE);return{[t]:parseFloat(i),[e]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},ese=t=>Vl(0,255,t),sk={...Jh,transform:t=>Math.round(ese(t))},Wu={test:OE("rgb","red"),parse:b6("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+sk.transform(t)+", "+sk.transform(e)+", "+sk.transform(n)+", "+km(e0.transform(r))+")"};function tse(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const JS={test:OE("#"),parse:tse,transform:Wu.transform},Df={test:OE("hsl","hue"),parse:b6("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+Xa.transform(km(e))+", "+Xa.transform(km(n))+", "+km(e0.transform(r))+")"},us={test:t=>Wu.test(t)||JS.test(t)||Df.test(t),parse:t=>Wu.test(t)?Wu.parse(t):Df.test(t)?Df.parse(t):JS.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Wu.transform(t):Df.transform(t)},nse=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function rse(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(RE))===null||e===void 0?void 0:e.length)||0)+(((n=t.match(nse))===null||n===void 0?void 0:n.length)||0)>0}const y6="number",v6="color",ise="var",sse="var(",Fz="${}",ose=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function t0(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(ose,l=>(us.test(l)?(r.color.push(s),i.push(v6),n.push(us.parse(l))):l.startsWith(sse)?(r.var.push(s),i.push(ise),n.push(l)):(r.number.push(s),i.push(y6),n.push(parseFloat(l))),++s,Fz)).split(Fz);return{values:n,split:a,indexes:r,types:i}}function x6(t){return t0(t).values}function w6(t){const{split:e,types:n}=t0(t),r=e.length;return i=>{let s="";for(let o=0;o<r;o++)if(s+=e[o],i[o]!==void 0){const a=n[o];a===y6?s+=km(i[o]):a===v6?s+=us.transform(i[o]):s+=i[o]}return s}}const ase=t=>typeof t=="number"?0:t;function lse(t){const e=x6(t);return w6(t)(e.map(ase))}const $c={test:rse,parse:x6,createTransformer:w6,getAnimatableNone:lse},cse=new Set(["brightness","contrast","saturate","opacity"]);function use(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(RE)||[];if(!r)return t;const i=n.replace(r,"");let s=cse.has(e)?1:0;return r!==n&&(s*=100),e+"("+s+i+")"}const dse=/\b([a-z-]*)\(.*?\)/gu,eC={...$c,getAnimatableNone:t=>{const e=t.match(dse);return e?e.map(use).join(" "):t}},fse={...xE,color:us,backgroundColor:us,outlineColor:us,fill:us,stroke:us,borderColor:us,borderTopColor:us,borderRightColor:us,borderBottomColor:us,borderLeftColor:us,filter:eC,WebkitFilter:eC},DE=t=>fse[t];function k6(t,e){let n=DE(t);return n!==eC&&(n=$c),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const hse=new Set(["auto","none","0"]);function pse(t,e,n){let r=0,i;for(;r<t.length&&!i;){const s=t[r];typeof s=="string"&&!hse.has(s)&&t0(s).values.length&&(i=t[r]),r++}if(i&&n)for(const s of e)t[s]=k6(n,i)}const $z=t=>t===Jh||t===_n,Uz=(t,e)=>parseFloat(t.split(", ")[e]),Vz=(t,e)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;const i=r.match(/^matrix3d\((.+)\)$/u);if(i)return Uz(i[1],e);{const s=r.match(/^matrix\((.+)\)$/u);return s?Uz(s[1],t):0}},mse=new Set(["x","y","z"]),gse=Zh.filter(t=>!mse.has(t));function bse(t){const e=[];return gse.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const Ph={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:Vz(4,13),y:Vz(5,14)};Ph.translateX=Ph.x;Ph.translateY=Ph.y;const ed=new Set;let tC=!1,nC=!1;function S6(){if(nC){const t=Array.from(ed).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=bse(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([s,o])=>{var a;(a=r.getValue(s))===null||a===void 0||a.set(o)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}nC=!1,tC=!1,ed.forEach(t=>t.complete()),ed.clear()}function C6(){ed.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(nC=!0)})}function yse(){C6(),S6()}class LE{constructor(e,n,r,i,s,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=s,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ed.add(this),tC||(tC=!0,Mr.read(C6),Mr.resolveKeyframes(S6))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;for(let s=0;s<e.length;s++)if(e[s]===null)if(s===0){const o=i==null?void 0:i.get(),a=e[e.length-1];if(o!==void 0)e[0]=o;else if(r&&n){const l=r.readValue(n,a);l!=null&&(e[0]=l)}e[0]===void 0&&(e[0]=a),i&&o===void 0&&i.set(e[0])}else e[s]=e[s-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),ed.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,ed.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const _6=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),vse=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function xse(t){const e=vse.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}function E6(t,e,n=1){const[r,i]=xse(t);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const o=s.trim();return _6(o)?parseFloat(o):o}return vE(i)?E6(i,e,n+1):i}const N6=t=>e=>e.test(t),wse={test:t=>t==="auto",parse:t=>t},I6=[Jh,_n,Xa,kc,die,uie,wse],Hz=t=>I6.find(N6(t));class j6 extends LE{constructor(e,n,r,i,s){super(e,n,r,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),vE(u))){const d=E6(u,n.current);d!==void 0&&(e[l]=d),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!s6.has(r)||e.length!==2)return;const[i,s]=e,o=Hz(i),a=Hz(s);if(o!==a)if($z(o)&&$z(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)Qie(e[i])&&r.push(i);r.length&&pse(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ph[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){var e;const{element:n,name:r,unresolvedKeyframes:i}=this;if(!n||!n.current)return;const s=n.getValue(r);s&&s.jump(this.measuredOrigin,!1);const o=i.length-1,a=i[o];i[o]=Ph[r](n.measureViewportBox(),window.getComputedStyle(n.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),!((e=this.removedTransforms)===null||e===void 0)&&e.length&&this.removedTransforms.forEac
vendor: 11,932 bytes, line 710
710h(([l,u])=>{n.getValue(l).set(u)}),this.resolveNoneKeyframes()}}const Gz=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&($c.test(t)||t==="0")&&!t.startsWith("url("));function kse(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Sse(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const s=t[t.length-1],o=Gz(i,e),a=Gz(s,e);return!o||!a?!1:kse(t)||(n==="spring"||NE(n))&&r}const Cse=t=>t!==null;function Cx(t,{repeat:e,repeatType:n="loop"},r){const i=t.filter(Cse),s=e&&n!=="loop"&&e%2===1?0:i.length-1;return!s||r===void 0?i[s]:r}const _se=40;class T6{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:o="loop",...a}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Qa.now(),this.options={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:s,repeatType:o,...a},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>_se?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&yse(),this._resolved}onKeyframesResolved(e,n){this.resolvedAt=Qa.now(),this.hasAttemptedResolve=!0;const{name:r,type:i,velocity:s,delay:o,onComplete:a,onUpdate:l,isGenerator:u}=this.options;if(!u&&!Sse(e,r,i,s))if(o)this.options.duration=0;else{l&&l(Cx(e,this.options,n)),a&&a(),this.resolveFinishedPromise();return}const d=this.initPlayback(e,n);d!==!1&&(this._resolved={keyframes:e,finalKeyframe:n,...d},this.onPostResolved())}onPostResolved(){}then(e,n){return this.currentFinishedPromise.then(e,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}}const Jr=(t,e,n)=>t+(e-t)*n;function ok(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Ese({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,s=0,o=0;if(!e)i=s=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=ok(l,a,t+1/3),s=ok(l,a,t),o=ok(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function ov(t,e){return n=>n>0?e:t}const ak=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},Nse=[JS,Wu,Df],Ise=t=>Nse.find(e=>e.test(t));function Wz(t){const e=Ise(t);if(!e)return!1;let n=e.parse(t);return e===Df&&(n=Ese(n)),n}const qz=(t,e)=>{const n=Wz(t),r=Wz(e);if(!n||!r)return ov(t,e);const i={...n};return s=>(i.red=ak(n.red,r.red,s),i.green=ak(n.green,r.green,s),i.blue=ak(n.blue,r.blue,s),i.alpha=Jr(n.alpha,r.alpha,s),Wu.transform(i))},jse=(t,e)=>n=>e(t(n)),R0=(...t)=>t.reduce(jse),rC=new Set(["none","hidden"]);function Tse(t,e){return rC.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function zse(t,e){return n=>Jr(t,e,n)}function FE(t){return typeof t=="number"?zse:typeof t=="string"?vE(t)?ov:us.test(t)?qz:Mse:Array.isArray(t)?z6:typeof t=="object"?us.test(t)?qz:Pse:ov}function z6(t,e){const n=[...t],r=n.length,i=t.map((s,o)=>FE(s)(s,e[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function Pse(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=FE(t[i])(t[i],e[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function Ase(t,e){var n;const r=[],i={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const o=e.types[s],a=t.indexes[o][i[o]],l=(n=t.values[a])!==null&&n!==void 0?n:0;r[s]=l,i[o]++}return r}const Mse=(t,e)=>{const n=$c.createTransformer(e),r=t0(t),i=t0(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?rC.has(t)&&!i.values.length||rC.has(e)&&!r.values.length?Tse(t,e):R0(z6(Ase(r,i),i.values),n):ov(t,e)};function P6(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Jr(t,e,n):FE(t)(t,e)}const Bse=5;function A6(t,e,n){const r=Math.max(e-Bse,0);return o6(n-t(r),e-r)}const li={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Kz=.001;function Rse({duration:t=li.duration,bounce:e=li.bounce,velocity:n=li.velocity,mass:r=li.mass}){let i,s,o=1-e;o=Vl(li.minDamping,li.maxDamping,o),t=Vl(li.minDuration,li.maxDuration,Rl(t)),o<1?(i=u=>{const d=u*o,f=d*t,h=d-n,m=iC(u,o),y=Math.exp(-f);return Kz-h/m*y},s=u=>{const f=u*o*t,h=f*n+n,m=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-f),g=iC(Math.pow(u,2),o);return(-i(u)+Kz>0?-1:1)*((h-m)*y)/g}):(i=u=>{const d=Math.exp(-u*t),f=(u-n)*t+1;return-.001+d*f},s=u=>{const d=Math.exp(-u*t),f=(n-u)*(t*t);return d*f});const a=5/t,l=Dse(i,s,a);if(t=Bl(t),isNaN(l))return{stiffness:li.stiffness,damping:li.damping,duration:t};{const u=Math.pow(l,2)*r;return{stiffness:u,damping:o*2*Math.sqrt(r*u),duration:t}}}const Ose=12;function Dse(t,e,n){let r=n;for(let i=1;i<Ose;i++)r=r-t(r)/e(r);return r}function iC(t,e){return t*Math.sqrt(1-e*e)}const Lse=["duration","bounce"],Fse=["stiffness","damping","mass"];function Yz(t,e){return e.some(n=>t[n]!==void 0)}function $se(t){let e={velocity:li.velocity,stiffness:li.stiffness,damping:li.damping,mass:li.mass,isResolvedFromDuration:!1,...t};if(!Yz(t,Fse)&&Yz(t,Lse))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*Vl(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:li.mass,stiffness:i,damping:s}}else{const n=Rse(t);e={...e,...n,mass:li.mass},e.isResolvedFromDuration=!0}return e}function M6(t=li.visualDuration,e=li.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const s=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:s},{stiffness:l,damping:u,mass:d,duration:f,velocity:h,isResolvedFromDuration:m}=$se({...n,velocity:-Rl(n.velocity||0)}),y=h||0,g=u/(2*Math.sqrt(l*d)),w=o-s,v=Rl(Math.sqrt(l/d)),S=Math.abs(w)<5;r||(r=S?li.restSpeed.granular:li.restSpeed.default),i||(i=S?li.restDelta.granular:li.restDelta.default);let C;if(g<1){const N=iC(v,g);C=_=>{const j=Math.exp(-g*v*_);return o-j*((y+g*v*w)/N*Math.sin(N*_)+w*Math.cos(N*_))}}else if(g===1)C=N=>o-Math.exp(-v*N)*(w+(y+v*w)*N);else{const N=v*Math.sqrt(g*g-1);C=_=>{const j=Math.exp(-g*v*_),T=Math.min(N*_,300);return o-j*((y+g*v*w)*Math.sinh(T)+N*w*Math.cosh(T))/N}}const k={calculatedDuration:m&&f||null,next:N=>{const _=C(N);if(m)a.done=N>=f;else{let j=0;g<1&&(j=N===0?Bl(y):A6(C,N,_));const T=Math.abs(j)<=r,M=Math.abs(o-_)<=i;a.done=T&&M}return a.value=a.done?o:_,a},toString:()=>{const N=Math.min(ZD(k),XS),_=JD(j=>k.next(N*j).value,N,30);return N+"ms "+_}};return k}function Xz({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:d}){const f=t[0],h={done:!1,value:f},m=T=>a!==void 0&&T<a||l!==void 0&&T>l,y=T=>a===void 0?l:l===void 0||Math.abs(a-T)<Math.abs(l-T)?a:l;let g=n*e;const w=f+g,v=o===void 0?w:o(w);v!==w&&(g=v-f);const S=T=>-g*Math.exp(-T/r),C=T=>v+S(T),k=T=>{const M=S(T),V=C(T);h.done=Math.abs(M)<=u,h.value=h.done?v:V};let N,_;const j=T=>{m(h.value)&&(N=T,_=M6({keyframes:[h.value,y(h.value)],velocity:A6(C,T,h.value),damping:i,stiffness:s,restDelta:u,restSpeed:d}))};return j(0),{calculatedDuration:null,next:T=>{let M=!1;return!_&&N===void 0&&(M=!0,k(T),j(T)),N!==void 0&&T>=N?_.next(T-N):(!M&&k(T),h)}}}const Use=B0(.42,0,1,1),Vse=B0(0,0,.58,1),B6=B0(.42,0,.58,1),Hse=t=>Array.isArray(t)&&typeof t[0]!="number",Gse={linear:go,easeIn:Use,easeInOut:B6,easeOut:Vse,circIn:BE,circInOut:m6,circOut:p6,backIn:ME,backInOut:f6,backOut:d6,anticipate:h6},Qz=t=>{if(IE(t)){PD(t.length===4);const[e,n,r,i]=t;return B0(e,n,r,i)}else if(typeof t=="string")return Gse[t];return t};function Wse(t,e,n){const r=[],i=n||P6,s=t.length-1;for(let o=0;o<s;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||go:e;a=R0(l,a)}r.push(a)}return r}function qse(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const s=t.length;if(PD(s===e.length),s===1)return()=>e[0];if(s===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Wse(e,r,i),l=a.length,u=d=>{if(o&&d<t[0])return e[0];let f=0;if(l>1)for(;f<t.length-2&&!(d<t[f+1]);f++);const h=jh(t[f],t[f+1],d);return a[f](h)};return n?d=>u(Vl(t[0],t[s-1],d)):u}function Kse(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=jh(0,e,r);t.push(Jr(n,1,i))}}function Yse(t){const e=[0];return Kse(e,t.length-1),e}function Xse(t,e){return t.map(n=>n*e)}function Qse(t,e){return t.map(()=>e||B6).splice(0,t.length-1)}function av({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=Hse(r)?r.map(Qz):Qz(r),s={done:!1,value:e[0]},o=Xse(n&&n.length===e.length?n:Yse(e),t),a=qse(o,e,{ease:Array.isArray(i)?i:Qse(e,i)});return{calculatedDuration:t,next:l=>(s.value=a(l),s.done=l>=t,s)}}const Zse=t=>{const e=({timestamp:n})=>t(n);return{start:()=>Mr.update(e,!0),stop:()=>Fc(e),now:()=>Li.isProcessing?Li.timestamp:Qa.now()}},Jse={decay:Xz,inertia:Xz,tween:av,keyframes:av,spring:M6},eoe=t=>t/100;class _x extends T6{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:l}=this.options;l&&l()};const{name:n,motionValue:r,element:i,keyframes:s}=this.options,o=(i==null?void 0:i.KeyframeResolver)||LE,a=(l,u)=>this.onKeyframesResolved(l,u);this.resolver=new o(s,a,n,r,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:o=0}=this.options,a=NE(n)?n:Jse[n]||av;let l,u;a!==av&&typeof e[0]!="number"&&(l=R0(eoe,P6(e[0],e[1])),e=[0,100]);const d=a({...this.options,keyframes:e});s==="mirror"&&(u=a({...this.options,keyframes:[...e].reverse(),velocity:-o})),d.calculatedDuration===null&&(d.calculatedDuration=ZD(d));const{calculatedDuration:f}=d,h=f+i,m=h*(r+1)-i;return{generator:d,mirroredGenerator:u,mapPercentToKeyframes:l,calculatedDuration:f,resolvedDuration:h,totalDuration:m}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!e?this.pause():this.state=this.pendingPlayState}tick(e,n=!1){const{resolved:r}=this;if(!r){const{keyframes:T}=this.options;return{done:!0,value:T[T.length-1]}}const{finalKeyframe:i,generator:s,mirroredGenerator:o,mapPercentToKeyframes:a,keyframes:l,calculatedDuration:u,totalDuration:d,resolvedDuration:f}=r;if(this.startTime===null)return s.next(0);const{delay:h,repeat:m,repeatType:y,repeatDelay:g,onUpdate:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-d/this.speed,this.startTime)),n?this.currentTime=e:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const v=this.currentTime-h*(this.speed>=0?1:-1),S=this.speed>=0?v<0:v>d;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=d);let C=this.currentTime,k=s;if(m){const T=Math.min(this.currentTime,d)/f;let M=Math.floor(T),V=T%1;!V&&T>=1&&(V=1),V===1&&M--,M=Math.min(M,m+1),!!(M%2)&&(y==="reverse"?(V=1-V,g&&(V-=g/f)):y==="mirror"&&(k=o)),C=Vl(0,1,V)*f}const N=S?{done:!1,value:l[0]}:k.next(C);a&&(N.value=a(N.value));let{done:_}=N;!S&&u!==null&&(_=this.speed>=0?this.currentTime>=d:this.currentTime<=0);const j=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&_);return j&&i!==void 0&&(N.value=Cx(l,this.options,i)),w&&w(N.value),j&&this.finish(),N}get duration(){const{resolved:e}=this;return e?Rl(e.calculatedDuration):0}
vendor: 54,603 bytes, line 710
710get time(){return Rl(this.currentTime)}set time(e){e=Bl(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=Rl(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:e=Zse,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=e(s=>this.tick(s))),n&&n();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(e=this.currentTime)!==null&&e!==void 0?e:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}function toe(t){return new _x(t)}const noe=new Set(["opacity","clipPath","filter","transform"]);function roe(t,e,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeInOut",times:l}={}){const u={[e]:n};l&&(u.offset=l);const d=t6(a,i);return Array.isArray(d)&&(u.easing=d),t.animate(u,{delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"})}const ioe=fE(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),lv=10,soe=2e4;function ooe(t){return NE(t.type)||t.type==="spring"||!e6(t.ease)}function aoe(t,e){const n=new _x({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:t[0]};const i=[];let s=0;for(;!r.done&&s<soe;)r=n.sample(s),i.push(r.value),s+=lv;return{times:void 0,keyframes:i,duration:s-lv,ease:"linear"}}const R6={anticipate:h6,backInOut:f6,circInOut:m6};function loe(t){return t in R6}class Zz extends T6{constructor(e){super(e);const{name:n,motionValue:r,element:i,keyframes:s}=this.options;this.resolver=new j6(s,(o,a)=>this.onKeyframesResolved(o,a),n,r,i),this.resolver.scheduleResolve()}initPlayback(e,n){let{duration:r=300,times:i,ease:s,type:o,motionValue:a,name:l,startTime:u}=this.options;if(!a.owner||!a.owner.current)return!1;if(typeof s=="string"&&sv()&&loe(s)&&(s=R6[s]),ooe(this.options)){const{onComplete:f,onUpdate:h,motionValue:m,element:y,...g}=this.options,w=aoe(e,g);e=w.keyframes,e.length===1&&(e[1]=e[0]),r=w.duration,i=w.times,s=w.ease,o="keyframes"}const d=roe(a.owner.current,l,e,{...this.options,duration:r,times:i,ease:s});return d.startTime=u??this.calcStartTime(),this.pendingTimeline?(Bz(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{const{onComplete:f}=this.options;a.set(Cx(e,this.options,n)),f&&f(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:r,times:i,type:o,ease:s,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:n}=e;return Rl(n)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:n}=e;return Rl(n.currentTime||0)}set time(e){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.currentTime=Bl(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:n}=e;return n.playbackRate}set speed(e){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:n}=e;return n.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:n}=e;return n.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{const{resolved:n}=this;if(!n)return go;const{animation:r}=n;Bz(r,e)}return go}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:n,keyframes:r,duration:i,type:s,ease:o,times:a}=e;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:u,onUpdate:d,onComplete:f,element:h,...m}=this.options,y=new _x({...m,keyframes:r,duration:i,type:s,ease:o,times:a,isGenerator:!0}),g=Bl(this.time);u.setWithVelocity(y.sample(g-lv).value,y.sample(g).value,lv)}const{onStop:l}=this.options;l&&l(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:n,name:r,repeatDelay:i,repeatType:s,damping:o,type:a}=e;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=n.owner.getProps();return ioe()&&r&&noe.has(r)&&!l&&!u&&!i&&s!=="mirror"&&o!==0&&a!=="inertia"}}const coe={type:"spring",stiffness:500,damping:25,restSpeed:10},uoe=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),doe={type:"keyframes",duration:.8},foe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},hoe=(t,{keyframes:e})=>e.length>2?doe:Sd.has(t)?t.startsWith("scale")?uoe(e[1]):coe:foe;function poe({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:o,repeatDelay:a,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const $E=(t,e,n,r={},i,s)=>o=>{const a=EE(r,t)||{},l=a.delay||r.delay||0;let{elapsed:u=0}=r;u=u-Bl(l);let d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:h=>{e.set(h),a.onUpdate&&a.onUpdate(h)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:i};poe(a)||(d={...d,...hoe(t,d)}),d.duration&&(d.duration=Bl(d.duration)),d.repeatDelay&&(d.repeatDelay=Bl(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let f=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(f=!0)),f&&!s&&e.get()!==void 0){const h=Cx(d.keyframes,a);if(h!==void 0)return Mr.update(()=>{d.onUpdate(h),d.onComplete()}),new Aie([])}return!s&&Zz.supports(d)?new Zz(d):new _x(d)};function moe({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function O6(t,e,{delay:n=0,transitionOverride:r,type:i}={}){var s;let{transition:o=t.getDefaultTransition(),transitionEnd:a,...l}=e;r&&(o=r);const u=[],d=i&&t.animationState&&t.animationState.getState()[i];for(const f in l){const h=t.getValue(f,(s=t.latestValues[f])!==null&&s!==void 0?s:null),m=l[f];if(m===void 0||d&&moe(d,f))continue;const y={delay:n,...EE(o||{},f)};let g=!1;if(window.MotionHandoffAnimation){const v=a6(t);if(v){const S=window.MotionHandoffAnimation(v,f,Mr);S!==null&&(y.startTime=S,g=!0)}}ZS(t,f),h.start($E(f,h,m,t.shouldReduceMotion&&s6.has(f)?{type:!1}:y,t,g));const w=h.animation;w&&u.push(w)}return a&&Promise.all(u).then(()=>{Mr.update(()=>{a&&AE(t,a)})}),u}function sC(t,e,n={}){var r;const i=Sx(t,e,n.type==="exit"?(r=t.presenceContext)===null||r===void 0?void 0:r.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const o=i?()=>Promise.all(O6(t,i,n)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:f,staggerDirection:h}=s;return goe(t,e,d+u,f,h,n)}:()=>Promise.resolve(),{when:l}=s;if(l){const[u,d]=l==="beforeChildren"?[o,a]:[a,o];return u().then(()=>d())}else return Promise.all([o(),a(n.delay)])}function goe(t,e,n=0,r=0,i=1,s){const o=[],a=(t.variantChildren.size-1)*r,l=i===1?(u=0)=>u*r:(u=0)=>a-u*r;return Array.from(t.variantChildren).sort(boe).forEach((u,d)=>{u.notify("AnimationStart",e),o.push(sC(u,e,{...s,delay:n+l(d)}).then(()=>u.notify("AnimationComplete",e)))}),Promise.all(o)}function boe(t,e){return t.sortNodePosition(e)}function D6(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>sC(t,s,n));r=Promise.all(i)}else if(typeof e=="string")r=sC(t,e,n);else{const i=typeof e=="function"?Sx(t,e,n.custom):e;r=Promise.all(O6(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const yoe=pE.length;function L6(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?L6(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<yoe;n++){const r=pE[n],i=t.props[r];(Jm(i)||i===!1)&&(e[r]=i)}return e}const voe=[...hE].reverse(),xoe=hE.length;function woe(t){return e=>Promise.all(e.map(({animation:n,options:r})=>D6(t,n,r)))}function koe(t){let e=woe(t),n=Jz(),r=!0;const i=l=>(u,d)=>{var f;const h=Sx(t,d,l==="exit"?(f=t.presenceContext)===null||f===void 0?void 0:f.custom:void 0);if(h){const{transition:m,transitionEnd:y,...g}=h;u={...u,...g,...y}}return u};function s(l){e=l(t)}function o(l){const{props:u}=t,d=L6(t.parent)||{},f=[],h=new Set;let m={},y=1/0;for(let w=0;w<xoe;w++){const v=voe[w],S=n[v],C=u[v]!==void 0?u[v]:d[v],k=Jm(C),N=v===l?S.isActive:null;N===!1&&(y=w);let _=C===d[v]&&C!==u[v]&&k;if(_&&r&&t.manuallyAnimateOnMount&&(_=!1),S.protectedKeys={...m},!S.isActive&&N===null||!C&&!S.prevProp||wx(C)||typeof C=="boolean")continue;const j=Soe(S.prevProp,C);let T=j||v===l&&S.isActive&&!_&&k||w>y&&k,M=!1;const V=Array.isArray(C)?C:[C];let H=V.reduce(i(v),{});N===!1&&(H={});const{prevResolvedValues:P={}}=S,F={...P,...H},I=A=>{T=!0,h.has(A)&&(M=!0,h.delete(A)),S.needsAnimating[A]=!0;const W=t.getValue(A);W&&(W.liveStyle=!1)};for(const A in F){const W=H[A],D=P[A];if(m.hasOwnProperty(A))continue;let B=!1;YS(W)&&YS(D)?B=!QD(W,D):B=W!==D,B?W!=null?I(A):h.add(A):W!==void 0&&h.has(A)?I(A):S.protectedKeys[A]=!0}S.prevProp=C,S.prevResolvedValues=H,S.isActive&&(m={...m,...H}),r&&t.blockInitialAnimation&&(T=!1),T&&(!(_&&j)||M)&&f.push(...V.map(A=>({animation:A,options:{type:v}})))}if(h.size){const w={};h.forEach(v=>{const S=t.getBaseTarget(v),C=t.getValue(v);C&&(C.liveStyle=!0),w[v]=S??null}),f.push({animation:w})}let g=!!f.length;return r&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(g=!1),r=!1,g?e(f):Promise.resolve()}function a(l,u){var d;if(n[l].isActive===u)return Promise.resolve();(d=t.variantChildren)===null||d===void 0||d.forEach(h=>{var m;return(m=h.animationState)===null||m===void 0?void 0:m.setActive(l,u)}),n[l].isActive=u;const f=o(l);for(const h in n)n[h].protectedKeys={};return f}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>n,reset:()=>{n=Jz(),r=!0}}}function Soe(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!QD(e,t):!1}function hu(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Jz(){return{animate:hu(!0),whileInView:hu(),whileHover:hu(),whileTap:hu(),whileDrag:hu(),whileFocus:hu(),exit:hu()}}class Yc{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Coe extends Yc{constructor(e){super(e),e.animationState||(e.animationState=koe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();wx(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)===null||e===void 0||e.call(this)}}let _oe=0;class Eoe extends Yc{constructor(){super(...arguments),this.id=_oe++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>n(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const Noe={animation:{Feature:Coe},exit:{Feature:Eoe}};function n0(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function O0(t){return{point:{x:t.pageX,y:t.pageY}}}const Ioe=t=>e=>jE(e)&&t(e,O0(e));function Sm(t,e,n,r){return n0(t,e,Ioe(n),r)}const eP=(t,e)=>Math.abs(t-e);function joe(t,e){const n=eP(t.x,e.x),r=eP(t.y,e.y);return Math.sqrt(n**2+r**2)}class F6{constructor(e,n,{transformPagePoint:r,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=ck(this.lastMoveEventInfo,this.history),h=this.startEvent!==null,m=joe(f.offset,{x:0,y:0})>=3;if(!h&&!m)return;const{point:y}=f,{timestamp:g}=Li;this.history.push({...y,timestamp:g});const{onStart:w,onMove:v}=this.handlers;h||(w&&w(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,f)},this.handlePointerMove=(f,h)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=lk(h,this.transformPagePoint),Mr.update(this.updatePoint,!0)},this.handlePointerUp=(f,h)=>{this.end();const{onEnd:m,onSessionEnd:y,resumeAnimation:g}=this.handlers;if(this.dragSnapToOrigin&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=ck(f.type==="pointercancel"?this.lastMoveEventInfo:lk(h,this.transformPagePoint),this.history);this.startEvent&&m&&m(f,w),y&&y(f,w)},!jE(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.contextWindow=i||window;const o=O0(e),a=lk(o,this.transformPagePoint),{point:l}=a,{timestamp:u}=Li;this.history=[{...l,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,ck(a,this.history)),this.removeListeners=R0(Sm(this.contextWindow,"pointermove",this.handlePointerMove),Sm(this.contextWindow,"pointerup",this.handlePointerUp),Sm(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Fc(this.updatePoint)}}function lk(t,e){return e?{point:e(t.point)}:t}function tP(t,e){return{x:t.x-e.x,y:t.y-e.y}}function ck({point:t},e){return{point:t,delta:tP(t,$6(e)),offset:tP(t,Toe(e)),velocity:zoe(e,.1)}}function Toe(t){return t[0]}function $6(t){return t[t.length-1]}function zoe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const i=$6(t);for(;n>=0&&(r=t[n],!(i.timestamp-r.timestamp>Bl(e)));)n--;if(!r)return{x:0,y:0};const s=Rl(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const U6=1e-4,Poe=1-U6,Aoe=1+U6,V6=.01,Moe=0-V6,Boe=0+V6;function ko(t){return t.max-t.min}function Roe(t,e,n){return Math.abs(t-e)<=n}function nP(t,e,n,r=.5){t.origin=r,t.originPoint=Jr(e.min,e.max,t.origin),t.scale=ko(n)/ko(e),t.translate=Jr(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Poe&&t.scale<=Aoe||isNaN(t.scale))&&(t.scale=1),(t.translate>=Moe&&t.translate<=Boe||isNaN(t.translate))&&(t.translate=0)}function Cm(t,e,n,r){nP(t.x,e.x,n.x,r?r.originX:void 0),nP(t.y,e.y,n.y,r?r.originY:void 0)}function rP(t,e,n){t.min=n.min+e.min,t.max=t.min+ko(e)}function Ooe(t,e,n){rP(t.x,e.x,n.x),rP(t.y,e.y,n.y)}function iP(t,e,n){t.min=e.min-n.min,t.max=t.min+ko(e)}function _m(t,e,n){iP(t.x,e.x,n.x),iP(t.y,e.y,n.y)}function Doe(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?Jr(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?Jr(n,t,r.max):Math.min(t,n)),t}function sP(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Loe(t,{top:e,left:n,bottom:r,right:i}){return{x:sP(t.x,n,i),y:sP(t.y,e,r)}}function oP(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function Foe(t,e){return{x:oP(t.x,e.x),y:oP(t.y,e.y)}}function $oe(t,e){let n=.5;const r=ko(t),i=ko(e);return i>r?n=jh(e.min,e.max-r,t.min):r>i&&(n=jh(t.min,t.max-i,e.min)),Vl(0,1,n)}function Uoe(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const oC=.35;function Voe(t=oC){return t===!1?t=0:t===!0&&(t=oC),{x:aP(t,"left","right"),y:aP(t,"top","bottom")}}function aP(t,e,n){return{min:lP(t,e),max:lP(t,n)}}function lP(t,e){return typeof t=="number"?t:t[e]||0}const cP=()=>({translate:0,scale:1,origin:0,originPoint:0}),Lf=()=>({x:cP(),y:cP()}),uP=()=>({min:0,max:0}),hi=()=>({x:uP(),y:uP()});function Po(t){return[t("x"),t("y")]}function H6({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function Hoe({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Goe(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function uk(t){return t===void 0||t===1}function aC({scale:t,scaleX:e,scaleY:n}){return!uk(t)||!uk(e)||!uk(n)}function Tu(t){return aC(t)||G6(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function G6(t){return dP(t.x)||dP(t.y)}function dP(t){return t&&t!=="0%"}function cv(t,e,n){const r=t-n,i=e*r;return n+i}function fP(t,e,n,r,i){return i!==void 0&&(t=cv(t,i,r)),cv(t,n,r)+e}function lC(t,e=0,n=1,r,i){t.min=fP(t.min,e,n,r,i),t.max=fP(t.max,e,n,r,i)}function W6(t,{x:e,y:n}){lC(t.x,e.translate,e.scale,e.originPoint),lC(t.y,n.translate,n.scale,n.originPoint)}const hP=.999999999999,pP=1.0000000000001;function Woe(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let s,o;for(let a=0;a<i;a++){s=n[a],o=s.projectionDelta;const{visualElement:l}=s.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&$f(t,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,W6(t,o)),r&&Tu(s.latestValues)&&$f(t,s.latestValues))}e.x<pP&&e.x>hP&&(e.x=1),e.y<pP&&e.y>hP&&(e.y=1)}function Ff(t,e){t.min=t.min+e,t.max=t.max+e}function mP(t,e,n,r,i=.5){const s=Jr(t.min,t.max,i);lC(t,e,n,s,r)}function $f(t,e){mP(t.x,e.x,e.scaleX,e.scale,e.originX),mP(t.y,e.y,e.scaleY,e.scale,e.originY)}function q6(t,e){return H6(Goe(t.getBoundingClientRect(),e))}function qoe(t,e,n){const r=q6(t,n),{scroll:i}=e;return i&&(Ff(r.x,i.offset.x),Ff(r.y,i.offset.y)),r}const K6=({current:t})=>t?t.ownerDocument.defaultView:null,Koe=new WeakMap;class Yoe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=hi(),this.visualElement=e}start(e,{snapToCursor:n=!1}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(O0(d).point)},s=(d,f)=>{const{drag:h,dragPropagation:m,onDragStart:y}=this.getProps();if(h&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Uie(h),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Po(w=>{let v=this.getAxisMotionValue(w).get()||0;if(Xa.test(v)){const{projection:S}=this.visualElement;if(S&&S.layout){const C=S.layout.layoutBox[w];C&&(v=ko(C)*(parseFloat(v)/100))}}this.originPoint[w]=v}),y&&Mr.postRender(()=>y(d,f)),ZS(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},o=(d,f)=>{const{dragPropagation:h,dragDirectionLock:m,onDirectionLock:y,onDrag:g}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=f;if(m&&this.currentDirection===null){this.currentDirection=Xoe(w),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",f.point,w),this.updateAxis("y",f.point,w),this.visualElement.render(),g&&g(d,f)},a=(d,f)=>this.stop(d,f),l=()=>Po(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)===null||f===void 0?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new F6(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,contextWindow:K6(this.visualElement)})}stop(e,n){const r=this.isDragging;if(this.cancel(),!r)return;const{velocity:i}=n;this.startAnimation(i);const{onDragEnd:s}=this.getProps();s&&Mr.postRender(()=>s(e,n))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,r){const{drag:i}=this.getProps();if(!r||!kb(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(o=Doe(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){var e;const{dragConstraints:n,dragElastic:r}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(e=this.visualElement.projection)===null||e===void 0?void 0:e.layout,s=this.constraints;n&&Of(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Loe(i.layoutBox,n):this.constraints=!1,this.elastic=Voe(r),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Po(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Uoe(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Of(e))return!1;const r=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=qoe(r,i.root,this.visualElement.getTransformPagePoint());let o=Foe(i.layout.layoutBox,s);if(n){const a=n(Hoe(o));this.hasMutatedConstraints=!!a,a&&(o=H6(a))}return o}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Po(d=>{if(!kb(d,n,this.currentDirection))return;let f=l&&l[d]||{};o&&(f={min:0,max:0});const h=i?200:1e6,m=i?40:1e7,y={type:"inertia",velocity:r?e[d]:0,bounceStiffness:h,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(d,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return ZS(this.visualElement,e),r.start($E(e,r,0,n,this.visualElement,!1))}stopAnimation(){Po(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Po(e=>{var n;return(n=this.getAxisMotionValue(e).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(e){var n;return(n=this.getAxisMotionValue(e).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){Po(n=>{const{drag:r}=this.getProps();if(!kb(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];s.set(e[n]-Jr(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Of(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Po(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=$oe({min:l,max:l},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Po(o=>{if(!kb(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(Jr(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;Koe.set(this.visualElement,this);const e=this.visualElement.current,n=Sm(e,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();Of(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Mr.read(r);const o=n0(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Po(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=l[d].translate,f.set(f.get()+l[d].translate))}),this.visualElement.render())});return()=>{o(),n(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=oC,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function kb(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Xoe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Qoe extends Yc{constructor(e){super(e),this.removeGroupControls=go,this.removeListeners=go,this.controls=new Yoe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||go}unmount(){this.removeGroupControls(),this.removeListeners()}}const gP=t=>(e,n)=>{t&&Mr.postRender(()=>t(e,n))};class Zoe extends Yc{constructor(){super(...arguments),this.removePointerDownListener=go}onPointerDown(e){this.session=new F6(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:K6(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:gP(e),onStart:gP(n),onMove:r,onEnd:(s,o)=>{delete this.session,i&&Mr.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=Sm(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const gy={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function bP(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Op={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(_n.test(t))t=parseFloat(t);else return t;const n=bP(t,e.target.x),r=bP(t,e.target.y);return`${n}% ${r}%`}},Joe={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=$c.parse(t);if(i.length>5)return r;const s=$c.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=Jr(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),s(i)}};class eae extends x.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;wie(tae),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),gy.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,o=r.projection;return o&&(o.isPresent=s,i||e.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Mr.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),gE.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=e;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Y6(t){const[e,n]=zD(),r=x.useContext(uE);return c.jsx(eae,{...t,layoutGroup:r,switchLayoutGroup:x.useContext(DD),isPresent:e,safeToRemove:n})}const tae={borderRadius:{...Op,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Op,borderTopRightRadius:Op,borderBottomLeftRadius:Op,borderBottomRightRadius:Op,boxShadow:Joe};function nae(t,e,n){const r=Ui(t)?t:zh(t);return r.start($E("",r,e,n)),r.animation}function rae(t){return t instanceof SVGElement&&t.tagName!=="svg"}const iae=(t,e)=>t.depth-e.depth;class sae{constructor(){this.children=[],this.isDirty=!1}add(e){TE(this.children,e),this.isDirty=!0}remove(e){zE(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(iae),this.isDirty=!1,this.children.forEach(e)}}function oae(t,e){const n=Qa.now(),r=({timestamp:i})=>{const s=i-n;s>=e&&(Fc(r),t(s-e))};return Mr.read(r,!0),()=>Fc(r)}const X6=["TopLeft","TopRight","BottomLeft","BottomRight"],aae=X6.length,yP=t=>typeof t=="string"?parseFloat(t):t,vP=t=>typeof t=="number"||_n.test(t);function lae(t,e,n,r,i,s){i?(t.opacity=Jr(0,n.opacity!==void 0?n.opacity:1,cae(r)),t.opacityExit=Jr(e.opacity!==void 0?e.opacity:1,0,uae(r))):s&&(t.opacity=Jr(e.opacity!==void 0?e.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let o=0;o<aae;o++){const a=`border${X6[o]}Radius`;let l=xP(e,a),u=xP(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||vP(l)===vP(u)?(t[a]=Math.max(Jr(yP(l),yP(u),r),0),(Xa.test(u)||Xa.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=Jr(e.rotate||0,n.rotate||0,r))}function xP(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const cae=Q6(0,.5,p6),uae=Q6(.5,.95,go);function Q6(t,e,n){return r=>r<t?0:r>e?1:n(jh(t,e,r))}function wP(t,e){t.min=e.min,t.max=e.max}function To(t,e){wP(t.x,e.x),wP(t.y,e.y)}function kP(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function SP(t,e,n,r,i){return t-=e,t=cv(t,1/n,r),i!==void 0&&(t=cv(t,1/i,r)),t}function dae(t,e=0,n=1,r=.5,i,s=t,o=t){if(Xa.test(e)&&(e=parseFloat(e),e=Jr(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Jr(s.min,s.max,r);t===s&&(a-=e),t.min=SP(t.min,e,n,a,i),t.max=SP(t.max,e,n,a,i)}function CP(t,e,[n,r,i],s,o){dae(t,e[n],e[r],e[i],e.scale,s,o)}const fae=["x","scaleX","originX"],hae=["y","scaleY","originY"];function _P(t,e,n,r){CP(t.x,e,fae,n?n.x:void 0,r?r.x:void 0),CP(t.y,e,hae,n?n.y:void 0,r?r.y:void 0)}function EP(t){return t.translate===0&&t.scale===1}function Z6(t){return EP(t.x)&&EP(t.y)}function NP(t,e){return t.min===e.min&&t.max===e.max}function pae(t,e){return NP(t.x,e.x)&&NP(t.y,e.y)}function IP(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function J6(t,e){return IP(t.x,e.x)&&IP(t.y,e.y)}function jP(t){return ko(t.x)/ko(t.y)}function TP(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class mae{constructor(){this.members=[]}add(e){TE(this.members,e),e.scheduleRender()}remove(e){if(zE(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function gae(t,e,n){let r="";const i=t.x.translate/e.x,s=t.y.translate/e.y,o=(n==null?void 0:n.z)||0;if((i||s||o)&&(r=`translate3d(${i}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:f,rotateY:h,skewX:m,skewY:y}=n;u&&(r=`perspective(${u}px) ${r}`),d&&(r+=`rotate(${d}deg) `),f&&(r+=`rotateX(${f}deg) `),h&&(r+=`rotateY(${h}deg) `),m&&(r+=`skewX(${m}deg) `),y&&(r+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}const zu={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},lm=typeof window<"u"&&window.MotionDebug!==void 0,dk=["","X","Y","Z"],bae={visibility:"hidden"},zP=1e3;let yae=0;function fk(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function e8(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=a6(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Mr,!(i||s))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&e8(r)}function t8({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=e==null?void 0:e()){this.id=yae++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,lm&&(zu.totalNodes=zu.resolvedTargetDeltas=zu.recalculatedProjection=0),this.nodes.forEach(wae),this.nodes.forEach(Eae),this.nodes.forEach(Nae),this.nodes.forEach(kae),lm&&window.MotionDebug.record(zu)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new sae)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new PE),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,a=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=rae(o),this.instance=o;const{layoutId:l,layout:u,visualElement:d}=this.options;if(d&&!d.current&&d.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),a&&(u||l)&&(this.isLayoutDirty=!0),t){let f;const h=()=>this.root.updateBlockedByResize=!1;t(o,()=>{this.root.updateBlockedByResize=!0,f&&f(),f=oae(h,250),gy.hasAnimatedSinceResize&&(gy.hasAnimatedSinceResize=!1,this.nodes.forEach(AP))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||u)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:h,hasRelativeTargetChanged:m,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||d.getDefaultTransition()||Pae,{onLayoutAnimationStart:w,onLayoutAnimationComplete:v}=d.getProps(),S=!this.targetLayout||!J6(this.targetLayout,y)||m,C=!h&&m;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||C||h&&(S||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(f,C);const k={...EE(g,"layout"),onPlay:w,onComplete:v};(d.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k)}else h||AP(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Fc(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Iae),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&e8(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const f=this.path[d];f.shouldResetTransform=!0,f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(PP);return}this.isUpdating||this.nodes.forEach(Cae),this.isUpdating=!1,this.nodes.forEach(_ae),this.nodes.forEach(vae),this.nodes.forEach(xae),this.clearAllSnapshots();const a=Qa.now();Li.delta=Vl(0,1e3/60,a-Li.timestamp),Li.timestamp=a,Li.isProcessing=!0,rk.update.process(Li),rk.preRender.process(Li),rk.render.process(Li),Li.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,gE.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Sae),this.sharedNodes.forEach(jae)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Mr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Mr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=hi(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Z6(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;o&&(a||Tu(this.latestValues)||d)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Aae(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:a}=this.options;if(!a)return hi();const l=a.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(Mae))){const{scroll:d}=this.root;d&&(Ff(l.x,d.offset.x),Ff(l.y,d.offset.y))}return l}removeElementScroll(o){var a;const l=hi();if(To(l,o),!((a=this.scroll)===null||a===void 0)&&a.wasRoot)return l;for(let u=0;u<this.path.length;u++){const d=this.path[u],{scroll:f,options:h}=d;d!==this.root&&f&&h.layoutScroll&&(f.wasRoot&&To(l,o),Ff(l.x,f.offset.x),Ff(l.y,f.offset.y))}return l}applyTransform(o,a=!1){const l=hi();To(l,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&$f(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Tu(d.latestValues)&&$f(l,d.latestValues)}return Tu(this.latestValues)&&$f(l,this.latestValues),l}removeTransform(o){const a=hi();To(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Tu(u.latestValues))continue;aC(u.latestValues)&&u.updateSnapshot();const d=hi(),f=u.measurePageBox();To(d,f),_P(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Tu(this.latestValues)&&_P(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Li.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var a;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const u=!!this.resumingFrom||this!==l;if(!(o||u&&this.isSharedProjectionDirty||this.isProjectionDirty||!((a=this.parent)===null||a===void 0)&&a.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:f,layoutId:h}=this.options;if(!(!this.layout||!(f||h))){if(this.resolvedRelativeTargetAt=Li.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=hi(),this.relativeTargetOrigin=hi(),_m(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),To(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=hi(),this.targetWithTransforms=hi()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ooe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):To(this.target,this.layout.layoutBox),W6(this.target,this.targetDelta)):To(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=hi(),this.relativeTargetOrigin=hi(),_m(this.relativeTargetOrigin,this.target,m.target),To(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}lm&&zu.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||aC(this.parent.latestValues)||G6(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const a=this.getLead(),l=!!this.resumingFrom||this!==a;let u=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(u=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(u=!1),this.resolvedRelativeTargetAt===Li.timestamp&&(u=!1),u)return;const{layout:d,layoutId:f}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||f))return;To(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Woe(this.layoutCorrected,this.treeScale,this.path,l),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=hi());const{target:y}=a;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(kP(this.prevProjectionDelta.x,this.projectionDelta.x),kP(this.prevProjectionDelta.y,this.projectionDelta.y)),Cm(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!TP(this.projectionDelta.x,this.prevProjectionDelta.x)||!TP(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",y)),lm&&zu.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var a;if((a=this.options.visualElement)===null||a===void 0||a.scheduleRender(),o){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Lf(),this.projectionDelta=Lf(),this.projectionDeltaWithTransform=Lf()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},f=Lf();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const h=hi(),m=l?l.source:void 0,y=this.layout?this.layout.source:void 0,g=m!==y,w=this.getStack(),v=!w||w.members.length<=1,S=!!(g&&!v&&this.options.crossfade===!0&&!this.path.some(zae));this.animationProgress=0;let C;this.mixTargetDelta=k=>{const N=k/1e3;MP(f.x,o.x,N),MP(f.y,o.y,N),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(_m(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Tae(this.relativeTarget,this.relativeTargetOrigin,h,N),C&&pae(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=hi()),To(C,this.relativeTarget)),g&&(this.animationValues=d,lae(d,u,this.latestValues,N,S,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Fc(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Mr.update(()=>{gy.hasAnimatedSinceResize=!0,this.currentAnimation=nae(0,zP,{...o,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(zP),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:d}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&n8(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||hi();const f=ko(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+f;const h=ko(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+h}To(a,l),$f(a,d),Cm(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new mae),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&fk("z",o,u,this.animationValues);for(let d=0;d<dk.length;d++)fk(`rotate${dk[d]}`,o,u,this.animationValues),fk(`skew${dk[d]}`,o,u,this.animationValues);o.render();for(const d in u)o.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);o.scheduleRender()}getProjectionStyles(o){var a,l;if(!this.instance||this.isSVG)return;if(!this.isVisible)return bae;const u={visibility:""},d=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,u.opacity="",u.pointerEvents=py(o==null?void 0:o.pointerEvents)||"",u.transform=d?d(this.latestValues,""):"none",u;const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){const g={};return this.options.layoutId&&(g.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,g.pointerEvents=py(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Tu(this.latestValues)&&(g.transform=d?d({},""):"none",this.hasProjected=!1),g}const h=f.animationValues||f.latestValues;this.applyTransformsToTarget(),u.transform=gae(this.projectionDeltaWithTransform,this.treeScale,h),d&&(u.transform=d(h,u.transform));const{x:m,y}=this.projectionDelta;u.transformOrigin=`${m.origin*100}% ${y.origin*100}% 0`,f.animationValues?u.opacity=f===this?(l=(a=h.opacity)!==null&&a!==void 0?a:this.latestValues.opacity)!==null&&l!==void 0?l:1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:u.opacity=f===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const g in iv){if(h[g]===void 0)continue;const{correct:w,applyTo:v}=iv[g],S=u.transform==="none"?h[g]:w(h[g],f);if(v){const C=v.length;for(let k=0;k<C;k++)u[v[k]]=S}else u[g]=S}return this.options.layoutId&&(u.pointerEvents=f===this?py(o==null?void 0:o.pointerEvents)||"":"none"),u}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var a;return(a=o.currentAnimation)===null||a===void 0?void 0:a.stop()}),this.root.nodes.forEach(PP),this.root.sharedNodes.clear()}}}function vae(t){t.updateLayout()}function xae(t){var e;const n=((e=t.resumeFrom)===null||e===void 0?void 0:e.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&n&&t.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=t.layout,{animationType:s}=t.options,o=n.source!==t.layout.source;s==="size"?Po(f=>{const h=o?n.measuredBox[f]:n.layoutBox[f],m=ko(h);h.min=r[f].min,h.max=h.min+m}):n8(s,n.layoutBox,r)&&Po(f=>{const h=o?n.measuredBox[f]:n.layoutBox[f],m=ko(r[f]);h.max=h.min+m,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+m)});const a=Lf();Cm(a,r,n.layoutBox);const l=Lf();o?Cm(l,t.applyTransform(i,!0),n.measuredBox):Cm(l,r,n.layoutBox);const u=!Z6(a);let d=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:h,layout:m}=f;if(h&&m){const y=hi();_m(y,n.layoutBox,h.layoutBox);const g=hi();_m(g,r,m.layoutBox),J6(y,g)||(d=!0),f.options.layoutRoot&&(t.relativeTarget=g,t.relativeTargetOrigin=y,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:l,layoutDelta:a,hasLayoutChanged:u,hasRelativeTargetChanged:d})}else if(t.isLead()){const{onExitComplete:r}=t.options;r&&r()}t.options.transition=void 0}function wae(t){lm&&zu.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function kae(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Sae(t){t.clearSnapshot()}function PP(t){t.clearMeasurements()}function Cae(t){t.isLayoutDirty=!1}function _ae(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function AP(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Eae(t){t.resolveTargetDelta()}function Nae(t){t.calcProjection()}
vendor: 6,638 bytes, line 710
710function Iae(t){t.resetSkewAndRotation()}function jae(t){t.removeLeadSnapshot()}function MP(t,e,n){t.translate=Jr(e.translate,0,n),t.scale=Jr(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function BP(t,e,n,r){t.min=Jr(e.min,n.min,r),t.max=Jr(e.max,n.max,r)}function Tae(t,e,n,r){BP(t.x,e.x,n.x,r),BP(t.y,e.y,n.y,r)}function zae(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Pae={duration:.45,ease:[.4,0,.1,1]},RP=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),OP=RP("applewebkit/")&&!RP("chrome/")?Math.round:go;function DP(t){t.min=OP(t.min),t.max=OP(t.max)}function Aae(t){DP(t.x),DP(t.y)}function n8(t,e,n){return t==="position"||t==="preserve-aspect"&&!Roe(jP(e),jP(n),.2)}function Mae(t){var e;return t!==t.root&&((e=t.scroll)===null||e===void 0?void 0:e.wasRoot)}const Bae=t8({attachResizeListener:(t,e)=>n0(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),hk={current:void 0},r8=t8({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!hk.current){const t=new Bae({});t.mount(window),t.setOptions({layoutScroll:!0}),hk.current=t}return hk.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Rae={pan:{Feature:Zoe},drag:{Feature:Qoe,ProjectionNode:r8,MeasureLayout:Y6}};function LP(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,s=r[i];s&&Mr.postRender(()=>s(e,O0(e)))}class Oae extends Yc{mount(){const{current:e}=this.node;e&&(this.unmount=Oie(e,n=>(LP(this.node,n,"Start"),r=>LP(this.node,r,"End"))))}unmount(){}}class Dae extends Yc{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=R0(n0(this.node.current,"focus",()=>this.onFocus()),n0(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function FP(t,e,n){const{props:r}=t;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),s=r[i];s&&Mr.postRender(()=>s(e,O0(e)))}class Lae extends Yc{mount(){const{current:e}=this.node;e&&(this.unmount=$ie(e,n=>(FP(this.node,n,"Start"),(r,{success:i})=>FP(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cC=new WeakMap,pk=new WeakMap,Fae=t=>{const e=cC.get(t.target);e&&e(t)},$ae=t=>{t.forEach(Fae)};function Uae({root:t,...e}){const n=t||document;pk.has(n)||pk.set(n,{});const r=pk.get(n),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver($ae,{root:t,...e})),r[i]}function Vae(t,e,n){const r=Uae(e);return cC.set(t,n),r.observe(t),()=>{cC.delete(t),r.unobserve(t)}}const Hae={some:0,all:1};class Gae extends Yc{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:Hae[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,s&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),h=u?d:f;h&&h(l)};return Vae(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Wae(e,n))&&this.startObserver()}unmount(){}}function Wae({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const qae={inView:{Feature:Gae},tap:{Feature:Lae},focus:{Feature:Dae},hover:{Feature:Oae}},Kae={layout:{ProjectionNode:r8,MeasureLayout:Y6}},uC={current:null},i8={current:!1};function Yae(){if(i8.current=!0,!!dE)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>uC.current=t.matches;t.addListener(e),e()}else uC.current=!1}const Xae=[...I6,us,$c],Qae=t=>Xae.find(N6(t)),$P=new WeakMap;function Zae(t,e,n){for(const r in e){const i=e[r],s=n[r];if(Ui(i))t.addValue(r,i);else if(Ui(s))t.addValue(r,zh(i,{owner:t}));else if(s!==i)if(t.hasValue(r)){const o=t.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(r);t.addValue(r,zh(o!==void 0?o:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const UP=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Jae{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=LE,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Qa.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Mr.render(this.render,!1,!0))};const{latestValues:l,renderState:u,onUpdate:d}=o;this.onUpdate=d,this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=kx(n),this.isVariantNode=RD(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:f,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const y=h[m];l[m]!==void 0&&Ui(y)&&y.set(l[m],!1)}}mount(e){this.current=e,$P.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEac
vendor: 6,124 bytes, line 710
710h((n,r)=>this.bindToMotionValue(r,n)),i8.current||Yae(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:uC.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){$P.delete(this.current),this.projection&&this.projection.unmount(),Fc(this.notifyUpdate),Fc(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=Sd.has(e),i=n.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&Mr.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),s=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),s(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Th){const n=Th[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):hi()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<UP.length;r++){const i=UP[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const s="on"+i,o=e[s];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Zae(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=zh(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){var r;let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(r=this.getBaseTargetFromProps(this.props,e))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(_6(i)||g6(i))?i=parseFloat(i):!Qae(i)&&$c.test(n)&&(i=k6(e,n)),this.setBaseTarget(e,Ui(i)?i.get():i)),Ui(i)?i.get():i}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var n;const{initial:r}=this.props;let i;if(typeof r=="string"||typeof r=="object"){const o=yE(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(i=o[e])}if(r&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!Ui(s)?s:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new PE),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}}class s8 extends Jae{constructor(){super(...arguments),this.KeyframeResolver=j6}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Ui(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function ele(t){return window.getComputedStyle(t)}class tle extends s8{constructor(){super(...arguments),this.type="html",this.renderInstance=GD}readValueFromInstance(e,n){if(Sd.has(n)){const r=DE(n);return r&&r.default||0}else{const r=ele(e),i=(UD(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return q6(e,n)}build(e,n,r){wE(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return _E(e,n,r)}}class nle extends s8{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=hi}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Sd.has(n)){const r=DE(n);return r&&r.default||0}return n=WD.has(n)?n:mE(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return YD(e,n,r)}build(e,n,r){kE(e,n,this.isSVGTag,r.transformTemplate)}renderInstance(e,n,r,i){qD(e,n,r,i)}mount(e){this.isSVGTag=CE(e.tagName),super.mount(e)}}const rle=(t,e)=>bE(t)?new nle(e):new tle(e,{allowProjection:t!==x.Fragment}),ile=Tie({...Noe,...qae,...Rae,...Kae},rle),et=Gre(ile);function dC(t){const e=P0(()=>zh(t)),{isStatic:n}=x.useContext(A0);
710if(n){const[,r]=x.useState(t);x.useEffect(()=>e.on("change",r),[])}return e}function VP(t){return typeof t=="number"?t:parseFloat(t)}function HP(t,e={}){const{isStatic:n}=x.useContext(A0),r=x.useRef(null),i=dC(Ui(t)?VP(t.get()):t),s=x.useRef(i.get()),o=x.useRef(()=>{}),a=()=>{const u=r.current;u&&u.time===0&&u.sample(Li.delta),l(),r.current=toe({keyframes:[i.get(),s.current],velocity:i.getVelocity(),type:"spring",restDelta:.001,restSpeed:.01,...e,onUpdate:o.current})},l=()=>{r.current&&r.current.stop()};return x.useInsertionEffect(()=>i.attach((u,d)=>n?d(u):(s.current=u,o.current=d,Mr.update(a),i.get()),l),[JSON.stringify(e)]),vx(()=>{if(Ui(t))return t.on("change",u=>i.set(VP(u)))},[i]),i}function sle(t){t.values.forEach(e=>e.stop())}function fC(t,e){[...e].reverse().forEach(r=>{const i=t.getVariant(r);i&&AE(t,i),t.variantChildren&&t.variantChildren.forEach(s=>{fC(s,e)})})}function ole(t,e){if(Array.isArray(e))return fC(t,e);if(typeof e=="string")return fC(t,[e]);AE(t,e)}function ale(){const t=new Set,e={subscribe(n){return t.add(n),()=>void t.delete(n)},start(n,r){const i=[];return t.forEach(s=>{i.push(D6(s,n,{transitionOverride:r}))}),Promise.all(i)},set(n){return t.forEach(r=>{ole(r,n)})},stop(){t.forEach(n=>{sle(n)})},mount(){return()=>{e.stop()}}};return e}function lle(){const t=P0(ale);return vx(t.mount,[]),t}const cle=lle,ule=()=>{const{status:t,isOffline:e,isServerUnavailable:n}=hD(),{isSyncing:r,hasPendingOperations:i,getLastSyncTime:s}=Qh(),[o,a]=x.useState(!1),[l,u]=x.useState(0),[d,f]=x.useState(!1),{theme:h}=Pn(),m=h===gi.Dark,y=()=>{a(!0)};x.useEffect(()=>{const C=()=>{const N=r()||i();f(_=>_!==N?N:_)};C();const k=setInterval(()=>{C()},200);return()=>clearInterval(k)},[]),x.useEffect(()=>{if(d){const C=setInterval(()=>{u(k=>(k+1)%3)},300);return()=>clearInterval(C)}else u(0)},[d]);const g=t==="online",w=d&&g,v=w?"bg-yellow-500":g?"bg-green-500":"bg-red-500";let S;return w?S=c.jsxs(c.Fragment,{children:["Saving",c.jsx("span",{style:{opacity:l===0?1:.3},children:"."}),c.jsx("span",{style:{opacity:l===1?1:.3},children:"."}),c.jsx("span",{style:{opacity:l===2?1:.3},children:"."})]}):S=g?"Online":"Offline",c.jsxs(c.Fragment,{children:[c.jsxs(et.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},onClick:y,className:"flex items-center gap-1 px-5 py-0 rounded-lg transition-colors cursor-pointer",style:{backgroundColor:"transparent",border:"none"},"aria-label":"Network status",children:[c.jsx("span",{className:"text-[7px] font-medium",style:{color:m?"rgb(244, 244, 245)":"rgb(24, 24, 27)"},children:S}),c.jsx("div",{className:`w-1 h-1 rounded-full ${v}`})]}),o&&c.jsx(TD,{isOpen:o,onClose:()=>a(!1),isOffline:e,isServerUnavailable:n,isOnline:g,lastSyncTime:s()})]})},o8=x.createContext(null),zs=()=>{const t=x.useContext(o8);if(!t)throw new Error("useSongPlayer must be used within a SongPlayerContext");return t};function UE(t){const{setTimelineCursorBar:e,setTimelineLoopRegion:n}=cr(),{timelineCursorSongId:r,timelineLoopRegion:i}=Yn(),{seekPlayback:s}=zs(),o=x.useRef(t);o.current=t;const a=x.useRef(s);a.current=s;const l=x.useRef({setTimelineCursorBar:e,setTimelineLoopRegion:n});l.current={setTimelineCursorBar:e,setTimelineLoopRegion:n};const u=x.useRef(null),d=x.useRef(null),[f,h]=x.useState(null),m=x.useCallback(w=>{if(w.button!==0)return;w.preventDefault(),w.stopPropagation();const v=o.current,S=v.clientXToBar(w.clientX),C=r===v.songId&&i?i:null;let k="new",N=S,_,j;if(C){const T=v.hitTestEdge(w.clientX,C);T==="left"?(k="extend-left",_=C.endBar,N=C.startBar):T==="right"&&(k="extend-right",j=C.startBar,N=C.endBar)}u.current={mode:k,startClientX:w.clientX,startBar:N,isDragging:!1,..._!==void 0?{fixedEndBar:_}:{},...j!==void 0?{fixedStartBar:j}:{}};try{w.currentTarget.setPointerCapture(w.pointerId),d.current={element:w.currentTarget,pointerId:w.pointerId}}catch{}},[r,i]);x.useEffect(()=>{const w=S=>{const C=u.current;if(!C)return;const k=o.current,N=Math.abs(S.clientX-C.startClientX);if(!C.isDragging&&N<k.getDragThresholdPx())return;C.isDragging=!0;const _=k.clientXToBar(S.clientX);if(C.mode==="extend-left"&&C.fixedEndBar!=null){const j=Math.max(0,Math.min(_,C.fixedEndBar-ab));h({startBar:j,endBar:C.fixedEndBar})}else if(C.mode==="extend-right"&&C.fixedStartBar!=null){const j=k.clientXToExclusiveEndBar(S.clientX),T=Math.min(k.totalBars,Math.max(C.fixedStartBar+ab,j));h({startBar:C.fixedStartBar,endBar:T})}else{const j=Math.min(C.startBar,_),T=Math.max(C.startBar,_)+1;h({startBar:j,endBar:T})}},v=S=>{var _;const C=u.current;if(!C)return;u.current=null;
710const k=o.current,N=l.current;try{const j=d.current;j!=null&&j.element.hasPointerCapture(j.pointerId)&&j.element.releasePointerCapture(j.pointerId)}catch{}if(d.current=null,C.isDragging){const j=k.clientXToBar(S.clientX);if(C.mode==="extend-left"&&C.fixedEndBar!=null){const T=Math.max(0,Math.min(j,C.fixedEndBar-ab));N.setTimelineLoopRegion({startBar:T,endBar:C.fixedEndBar}),N.setTimelineCursorBar(T,k.songId)}else if(C.mode==="extend-right"&&C.fixedStartBar!=null){const T=k.clientXToExclusiveEndBar(S.clientX),M=Math.min(k.totalBars,Math.max(C.fixedStartBar+ab,T));N.setTimelineLoopRegion({startBar:C.fixedStartBar,endBar:M}),N.setTimelineCursorBar(C.fixedStartBar,k.songId)}else{const T=Math.min(C.startBar,j),M=Math.max(C.startBar,j)+1;N.setTimelineLoopRegion({startBar:T,endBar:M}),N.setTimelineCursorBar(T,k.songId)}h(null)}else{const j=k.clientXToBar(S.clientX);N.setTimelineCursorBar(j,k.songId),C.mode==="new"&&N.setTimelineLoopRegion(null),h(null)}(_=k.onPointerUp)==null||_.call(k),a.current()};return window.addEventListener("pointermove",w),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[]);const y=x.useCallback(w=>{w.stopPropagation(),e(null),n(null),h(null)},[e,n]),g=f??(r===t.songId?i:null);return{handlePointerDown:m,handleDoubleClick:y,rulerDragRegion:f,activeLoopRegion:g}}const mk={current:null},gk={current:null},di=()=>{const t=x.useCallback(()=>{mk.current&&mk.current.focus()},[]),e=x.useCallback(()=>{gk.current&&gk.current.focus()},[]);return{canvasWrapperRef:mk,focusCanvas:t,caiChatInputRef:gk,focusCaiChat:e}},Xc=({onClick:t,onDoubleClick:e,delay:n=300,threshold:r=50})=>{const i=x.useRef(null),{isMobile:s}=Hn(),o=u=>({x:"clientX"in u?u.clientX:u.touches[0].clientX,y:"clientY"in u?u.clientY:u.touches[0].clientY}),a=x.useCallback(u=>{if(t==null||t(u),s){const d=o(u);if(i.current){const f=u.timeStamp-i.current.timeStamp,h=o(i.current),m=Math.sqrt(Math.pow(d.x-h.x,2)+Math.pow(d.y-h.y,2));if(f<n&&m<r){setTimeout(()=>{e==null||e(u)},0),i.current=null;return}}i.current=u}},[n,s,t,e,r]),l=x.useCallback(u=>{e==null||e(u)},[e]);return{onSingle:a,onDouble:l}};function dle(t,e,n){return Math.max(e,Math.min(t,n))}const Ur={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function GP(t,e,n){return e===0||Math.abs(e)===1/0?Math.pow(t,n*5):t*e*n/(e+n*t)}function WP(t,e,n,r=.15){return r===0?dle(t,e,n):t<e?-GP(e-t,n-e,r)+e:t>n?+GP(t-n,n-e,r)+n:t}function fle(t,[e,n],[r,i]){const[[s,o],[a,l]]=t;return[WP(e,s,o,r),WP(n,a,l,i)]}function hle(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ple(t){var e=hle(t,"string");return typeof e=="symbol"?e:String(e)}function wi(t,e,n){return e=ple(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qP(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qP(Object(n),!0).forEach(function(r){wi(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qP(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const a8={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function KP(t){return t?t[0].toUpperCase()+t.slice(1):""}const mle=["enter","leave"];function gle(t=!1,e){return t&&!mle.includes(e)}function ble(t,e="",n=!1){const r=a8[t],i=r&&r[e]||e;return"on"+KP(t)+KP(i)+(gle(n,i)?"Capture":"")}const yle=["gotpointercapture","lostpointercapture"];function vle(t){let e=t.substring(2).toLowerCase();const n=!!~e.indexOf("passive");n&&(e=e.replace("passive",""));const r=yle.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(r);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:n}}function xle(t,e=""){const n=a8[t],r=n&&n[e]||e;return t+r}function Ex(t){return"touches"in t}function l8(t){return Ex(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function wle(t){return Array.from(t.touches).filter(e=>{var n,r;return e.target===t.currentTarget||((n=t.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,e.target))})}function kle(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function c8(t){return Ex(t)?kle(t)[0]:t}function hC(t,e){try{const n=e.clientX-t.clientX,r=e.clientY-t.clientY,i=(e.clientX+t.clientX)/2,s=(e.clientY+t.clientY)/2,o=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function Sle(t){return wle(t).map(e=>e.identifier)}function YP(t,e){const[n,r]=Array.from(t.touches).filter(i=>e.includes(i.identifier));return hC(n,r)}function bk(t){const e=c8(t);return Ex(t)?e.identifier:e.pointerId}function Ah(t){const e=c8(t);return[e.clientX,e.clientY]}const XP=40,QP=800;function u8(t){let{deltaX:e,deltaY:n,deltaMode:r}=t;return r===1?(e*=XP,n*=XP):r===2&&(e*=QP,n*=QP),[e,n]}function Cle(t){var e,n;const{scrollX:r,scrollY:i,scrollLeft:s,scrollTop:o}=t.currentTarget;return[(e=r??s)!==null&&e!==void 0?e:0,(n=i??o)!==null&&n!==void 0?n:0]}function _le(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:n,altKey:r,metaKey:i,ctrlKey:s}=t;Object.assign(e,{shiftKey:n,altKey:r,metaKey:i,ctrlKey:s})}return e}function uv(t,...e){return typeof t=="function"?t(...e):t}function Ele(){}function Nle(...t){return t.length===0?Ele:t.length===1?t[0]:function(){let e;for(const n of t)e=n.apply(this,arguments)||e;return e}}function ZP(t,e){return Object.assign({},e,t||{})}const Ile=32;let d8=class{constructor(e,n,r){this.ctrl=e,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}
vendor: 26,057 bytes, line 710
710get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:n,ingKey:r,args:i}=this;n[r]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=e.target,n.currentTarget=e.currentTarget,n.lastOffset=r.from?uv(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=e.timeStamp)}computeValues(e){const n=this.state;n._values=e,n.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:n,config:r,shared:i}=this;n.args=this.args;let s=0;if(e&&(n.event=e,r.preventDefault&&e.cancelable&&n.event.preventDefault(),n.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,_le(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-n.timeStamp,n.timeStamp=e.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const _=n._delta.map(Math.abs);Ur.addTo(n._distance,_)}this.axisIntent&&this.axisIntent(e);const[o,a]=n._movement,[l,u]=r.threshold,{_step:d,values:f}=n;if(r.hasCustomTransform?(d[0]===!1&&(d[0]=Math.abs(o)>=l&&f[0]),d[1]===!1&&(d[1]=Math.abs(a)>=u&&f[1])):(d[0]===!1&&(d[0]=Math.abs(o)>=l&&Math.sign(o)*l),d[1]===!1&&(d[1]=Math.abs(a)>=u&&Math.sign(a)*u)),n.intentional=d[0]!==!1||d[1]!==!1,!n.intentional)return;const h=[0,0];if(r.hasCustomTransform){const[_,j]=f;h[0]=d[0]!==!1?_-d[0]:0,h[1]=d[1]!==!1?j-d[1]:0}else h[0]=d[0]!==!1?o-d[0]:0,h[1]=d[1]!==!1?a-d[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(h);const m=n.offset,y=n._active&&!n._blocked||n.active;y&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=i[this.ingKey]=n._active,e&&(n.first&&("bounds"in r&&(n._bounds=uv(r.bounds,n)),this.setup&&this.setup()),n.movement=h,this.computeOffset()));const[g,w]=n.offset,[[v,S],[C,k]]=n._bounds;n.overflow=[g<v?-1:g>S?1:0,w<C?-1:w>k?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const N=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=fle(n._bounds,n.offset,N),n.delta=Ur.sub(n.offset,m),this.computeMovement(),y&&(!n.last||s>Ile)){n.delta=Ur.sub(n.offset,m);const _=n.delta.map(Math.abs);Ur.addTo(n.distance,_),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&s>0&&(n.velocity=[_[0]/s,_[1]/s],n.timeDelta=s)}}emit(){const e=this.state,n=this.shared,r=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!r.triggerAllEvents)return;const i=this.handler(ei(ei(ei({},n),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}};function jle([t,e],n){const r=Math.abs(t),i=Math.abs(e);if(r>i&&r>n)return"x";if(i>r&&i>n)return"y"}class D0 extends d8{constructor(...e){super(...e),wi(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Ur.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Ur.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const n=this.state,r=this.config;if(!n.axis&&e){const i=typeof r.axisThreshold=="object"?r.axisThreshold[l8(e)]:r.axisThreshold;n.axis=jle(n._movement,i)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const Tle=t=>t,JP=.15,f8={enabled(t=!0){return t},eventOptions(t,e,n){return ei(ei({},n.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[JP,JP];case!1:return[0,0];default:return Ur.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return Ur.toVector(t)},transform(t,e,n){const r=t||n.shared.transform;return this.hasCustomTransform=!!r,r||Tle},threshold(t){return Ur.toVector(t,0)}},zle=0,Cd=ei(ei({},f8),{},{axis(t,e,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(t=zle){return t},bounds(t={}){if(typeof t=="function")return s=>Cd.bounds(t(s));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:n=1/0,top:r=-1/0,bottom:i=1/0}=t;return[[e,n],[r,i]]}}),eA={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Ple extends D0{constructor(...e){super(...e),wi(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const n=e._bounds.getBoundingClientRect(),r=e.currentTarget.getBoundingClientRect(),i={left:n.left-r.left+e.offset[0],right:n.right-r.right+e.offset[0],top:n.top-r.top+e.offset[1],bottom:n.bottom-r.bottom+e.offset[1]};e._bounds=Cd.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const n=this.config,r=this.state;if(e.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(e.buttons):n.pointerButtons!==-1&&n.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);n.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&r._pointerActive)&&(this.start(e),this.setupPointer(e),r._pointerId=bk(e),r._pointerActive=!0,this.computeValues(Ah(e)),this.computeInitial(),n.preventScrollAxis&&l8(e)!=="mouse"?(r._active=!1,this.setupScrollPrevention(e)):n.delay>0?(this.setupDelayTrigger(e),n.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const n=this.state,r=this.config;if(!n._pointerActive)return;const i=bk(e);if(n._pointerId!==void 0&&i!==n._pointerId)return;const s=Ah(e);if(document.pointerLockElement===e.target?n._delta=[e.movementX,e.movementY]:(n._delta=Ur.sub(s,n._values),this.computeValues(s)),Ur.addTo(n._movement,n._delta),this.compute(e),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(e);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const i=bk(e);if(n._pointerId!==void 0&&i!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=n._distance;if(n.tap=s<=r.tapsThreshold&&o<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[a,l]=n._delta,[u,d]=n._movement,[f,h]=r.swipe.velocity,[m,y]=r.swipe.distance,g=r.swipe.duration;if(n.elapsedTime<g){const w=Math.abs(a/n.timeDelta),v=Math.abs(l/n.timeDelta);w>f&&Math.abs(u)>m&&(n.swipe[0]=Math.sign(a)),v>h&&Math.abs(d)>y&&(n.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const n=this.config,r=n.device;n.pointerLock&&e.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Ale(e);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const n=eA[e.key];if(n){const r=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),r._delta=n(this.config.keyboardDisplacement,i),r._keyboardActive=!0,Ur.addTo(r._movement,r._delta),this.compute(e),this.emit()}}keyUp(e){e.key in eA&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const n=this.config.device;e(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(n,"change",this.pointerMove.bind(this)),e(n,"end",this.pointerUp.bind(this)),e(n,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Ale(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const L0=typeof window<"u"&&window.document&&window.document.createElement;function h8(){return L0&&"ontouchstart"in window}function Mle(){return h8()||L0&&window.navigator.maxTouchPoints>1}function Ble(){return L0&&"onpointerdown"in window}function Rle(){return L0&&"exitPointerLock"in window.document}function Ole(){try{return"constructor"in GestureEvent}catch{return!1}}const Ao={isBrowser:L0,gesture:Ole(),touch:h8(),touchscreen:Mle(),pointer:Ble(),pointerLock:Rle()},Dle=250,Lle=180,Fle=.5,$le=50,Ule=250,Vle=10,tA={mouse:0,touch:0,pen:8},Hle=ei(ei({},Cd),{},{device(t,e,{pointer:{touch:n=!1,lock:r=!1,mouse:i=!1}={}}){return this.pointerLock=r&&Ao.pointerLock,Ao.touch&&n?"touch":this.pointerLock?"mouse":Ao.pointer&&!i?"pointer":Ao.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&t?Dle:void 0,!(!Ao.touchscreen||n===!1))return t||(n!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:n=!0,buttons:r=1,keys:i=!0}={}}){return this.pointerButtons=r,this.keys=i,!this.pointerLock&&this.device==="pointer"&&n},threshold(t,e,{filterTaps:n=!1,tapsThreshold:r=3,axis:i=void 0}){const s=Ur.toVector(t,n?r:i?1:0);return this.filterTaps=n,this.tapsThreshold=r,s},swipe({velocity:t=Fle,distance:e=$le,duration:n=Ule}={}){return{velocity:this.transform(Ur.toVector(t)),distance:this.transform(Ur.toVector(e)),duration:n}},delay(t=0){switch(t){case!0:return Lle;case!1:return 0;default:return t}},axisThreshold(t){return t?ei(ei({},tA),t):tA},keyboardDisplacement(t=Vle){return t}});function p8(t){const[e,n]=t.overflow,[r,i]=t._delta,[s,o]=t._direction;(e<0&&r>0&&s<0||e>0&&r<0&&s>0)&&(t._movement[0]=t._movementBound[0]),(n<0&&i>0&&o<0||n>0&&i<0&&o>0)&&(t._movement[1]=t._movementBound[1])}const Gle=30,Wle=100;class qle extends d8{constructor(...e){super(...e),wi(this,"ingKey","pinching"),wi(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:n,lastOffset:r}=this.state;e==="wheel"?this.state.offset=Ur.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:e,lastOffset:n}=this.state;this.state.movement=[e[0]/n[0],e[1]-n[1]]}axisIntent(){const e=this.state,[n,r]=e._movement;if(!e.axis){const i=Math.abs(n)*Gle-Math.abs(r);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(s=>r.has(s))||r.size<2)return;this.start(e),n._touchIds=Array.from(r).slice(0,2);const i=YP(e,n._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const n=this.state,r=n._pointerEvents,i=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(o=>i.has(o))||(r.size<2&&r.set(e.pointerId,e),n._pointerEvents.size<2))return;this.start(e);const s=hC(...Array.from(r.values()));s&&this.pinchStart(e,s)}pinchStart(e,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const n=YP(e,this.state._touchIds);n&&this.pinchMove(e,n)}pointerMove(e){const n=this.state._pointerEvents;if(n.has(e.pointerId)&&n.set(e.pointerId,e),!this.state._active)return;const r=hC(...Array.from(n.values()));r&&this.pinchMove(e,r)}pinchMove(e,n){const r=this.state,i=r._values[1],s=n.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([n.distance,n.angle-360*o]),r.origin=n.origin,r.turns=o,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const n=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}n._pointerEvents.has(e.pointerId)&&n._pointerEvents.delete(e.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const n=this.state;n._active||(this.start(e),this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY];const r=n._movement;n._movement=[e.scale-1,e.rotation],n._delta=Ur.sub(n._movement,r),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>e[r]):!e[n])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const r=this.state;r._delta=[-u8(e)[1]/Wle*r.offset[0],0],Ur.addTo(r._movement,r._delta),p8(r),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const n=this.config.device;n&&(e(n,"start",this[n+"Start"].bind(this)),e(n,"change",this[n+"Move"].bind(this)),e(n,"end",this[n+"End"].bind(this)),e(n,"cancel",this[n+"End"].bind(this)),e("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const Kle=ei(ei({},f8),{},{device(t,e,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!Ao.touch&&Ao.gesture)return"gesture";if(Ao.touch&&r)return"touch";if(Ao.touchscreen){if(Ao.pointer)return"pointer";if(Ao.touch)return"touch"}},bounds(t,e,{scaleBounds:n={},angleBounds:r={}}){const i=o=>{const a=ZP(uv(n,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=ZP(uv(r,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(t,e,n){return this.lockDirection=n.axis==="lock",Ur.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});class Yle extends D0{constructor(...e){super(...e),wi(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(Ah(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const n=Ah(e),r=this.state;r._delta=Ur.sub(n,r._values),Ur.addTo(r._movement,r._delta),this.computeValues(n),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const Xle=ei(ei({},Cd),{},{mouseOnly:(t=!0)=>t});class Qle extends D0{constructor(...e){super(...e),wi(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const n=this.state,r=Cle(e);n._delta=Ur.sub(r,n._values),Ur.addTo(n._movement,n._delta),this.computeValues(r),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const Zle=Cd;class Jle extends D0{constructor(...e){super(...e),wi(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const n=this.state;n._delta=u8(e),Ur.addTo(n._movement,n._delta),p8(n),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const ece=Cd;class tce extends D0{constructor(...e){super(...e),wi(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(Ah(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=Ah(e);n._movement=n._delta=Ur.sub(r,n._values),this.computeValues(r),this.compute(e),n.delta=n.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const nce=ei(ei({},Cd),{},{mouseOnly:(t=!0)=>t}),VE=new Map,pC=new Map;function m8(t){VE.set(t.key,t.engine),pC.set(t.key,t.resolver)}const g8={key:"drag",engine:Ple,resolver:Hle},rce={key:"hover",engine:tce,resolver:nce},ice={key:"move",engine:Yle,resolver:Xle},sce={key:"pinch",engine:qle,resolver:Kle},oce={key:"scroll",engine:Qle,resolver:Zle},ace={key:"wheel",engine:Jle,resolver:ece};function lce(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}function cce(t,e){if(t==null)return{};var n=lce(t,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}const uce={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=Ao.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dce=["target","eventOptions","window","enabled","transform"];function by(t={},e){const n={};for(const[r,i]of Object.entries(e))switch(typeof i){case"function":n[r]=i.call(n,t[r],r,t);break;case"object":n[r]=by(t[r],i);break;case"boolean":i&&(n[r]=t[r]);break}return n}function fce(t,e,n={}){const r=t,{target:i,eventOptions:s,window:o,enabled:a,transform:l}=r,u=cce(r,dce);if(n.shared=by({target:i,eventOptions:s,window:o,enabled:a,transform:l},uce),e){const d=pC.get(e);n[e]=by(ei({shared:n.shared},u),d)}else for(const d in u){const f=pC.get(d);f&&(n[d]=by(ei({shared:n.shared},u[d]),f))}return n}class b8{constructor(e,n){wi(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=n}add(e,n,r,i,s){const o=this._listeners,a=xle(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},u=ei(ei({},l),s);e.addEventListener(a,i,u);const d=()=>{e.removeEventListener(a,i,u),o.delete(d)};return o.add(d),d}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class hce{constructor(){wi(this,"_timeouts",new Map)}add(e,n,r=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(n,r,...i))}remove(e){const n=this._timeouts.get(e);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class pce{constructor(e){wi(this,"gestures",new Set),wi(this,"_targetEventStore",new b8(this)),wi(this,"gestureEventStores",{}),wi(this,"gestureTimeoutStores",{}),wi(this,"handlers",{}),wi(this,"config",{}),wi(this,"pointerIds",new Set),wi(this,"touchIds",new Set),wi(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),mce(this,e)}setEventIds(e){if(Ex(e))return this.touchIds=new Set(Sle(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,n){this.handlers=e,this.nativeHandlers=n}applyConfig(e,n){this.config=fce(e,n,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const n=this.config.shared,r={};let i;if(!(n.target&&(i=n.target(),!i))){if(n.enabled){for(const o of this.gestures){const a=this.config[o],l=nA(r,a.eventOptions,!!i);if(a.enabled){const u=VE.get(o);new u(this,e,o).bind(l)}}const s=nA(r,n.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](ei(ei({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in r)r[s]=Nle(...r[s]);if(!i)return r;for(const s in r){const{device:o,capture:a,passive:l}=vle(s);this._targetEventStore.add(i,o,"",r[s],{capture:a,passive:l})}}}}function cf(t,e){t.gestures.add(e),t.gestureEventStores[e]=new b8(t,e),t.gestureTimeoutStores[e]=new hce}function mce(t,e){e.drag&&cf(t,"drag"),e.wheel&&cf(t,"wheel"),e.scroll&&cf(t,"scroll"),e.move&&cf(t,"move"),e.pinch&&cf(t,"pinch"),e.hover&&cf(t,"hover")}const nA=(t,e,n)=>(r,i,s,o={},a=!1)=>{var l,u;const d=(l=o.capture)!==null&&l!==void 0?l:e.capture,f=(u=o.passive)!==null&&u!==void 0?u:e.passive;let h=a?r:ble(r,i,d);n&&f&&(h+="Passive"),t[h]=t[h]||[],t[h].push(s)},gce=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function bce(t){const e={},n={},r=new Set;for(let i in t)gce.test(i)?(r.add(RegExp.lastMatch),n[i]=t[i]):e[i]=t[i];return[n,e,r]}function uf(t,e,n,r,i,s){if(!t.has(n)||!VE.has(r))return;const o=n+"Start",a=n+"End",l=u=>{let d;return u.first&&o in e&&e[o](u),n in e&&(d=e[n](u)),u.last&&a in e&&e[a](u),d};i[r]=l,s[r]=s[r]||{}}function yce(t,e){const[n,r,i]=bce(t),s={};return uf(i,n,"onDrag","drag",s,e),uf(i,n,"onWheel","wheel",s,e),uf(i,n,"onScroll","scroll",s,e),uf(i,n,"onPinch","pinch",s,e),uf(i,n,"onMove","move",s,e),uf(i,n,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:r}}function y8(t,e={},n,r){const i=mr.useMemo(()=>new pce(t),[]);if(i.applyHandlers(t,r),i.applyConfig(e,n),mr.useEffect(i.effect.bind(i)),mr.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function vr(t,e){return m8(g8),y8({drag:t},e||{},"drag")}function vce(t){return t.forEach(m8),function(n,r){const{handlers:i,nativeHandlers:s,config:o}=yce(n,r||{});return y8(i,o,void 0,s)}}function xce(t,e){return vce([g8,sce,oce,ace,ice,rce])(t,e||{})}const Nx=({topResizeBind:t,rightResizeBind:e,bottomResizeBind:n,leftResizeBind:r,topLeftResizeBind:i,topRightResizeBind:s,bottomRightResizeBind:o,bottomLeftResizeBind:a})=>c.jsxs(c.Fragment,{children:[t&&c.jsx("div",{className:"absolute inset-0 w-full h-10 lg:h-6 -translate-y-1/2 cursor-ns-resize touch-none",...t()}),e&&c.jsx("div",{className:"absolute right-0 top-0 w-10 lg:w-6 h-full translate-x-1/2 cursor-ew-resize touch-none",...e()}),n&&c.jsx("div",{className:"absolute bottom-0 left-0 w-full h-10 lg:h-6 translate-y-1/2 cursor-ns-resize touch-none",...n()}),r&&c.jsx("div",{className:"absolute inset-0 w-10 lg:w-6 h-full -translate-x-1/2 cursor-ew-resize touch-none",...r()}),i&&c.jsx("div",{className:"absolute top-0 left-0 size-10 lg:size-6 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize touch-none",...i()}),s&&c.jsx("div",{className:"absolute top-0 right-0 size-10 lg:size-6 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize touch-none",...s()}),o&&c.jsx("div",{className:"absolute bottom-0 right-0 size-10 lg:size-6 translate-x-1/2 translate-y-1/2 cursor-nwse-resize touch-none",...o()}),a&&c.jsx("div",{className:"absolute bottom-0 left-0 size-10 lg:size-6 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize touch-none",...a()})]}),Wl=()=>
710{const[t]=x.useState(()=>typeof navigator<"u"?navigator.userAgent.toLowerCase().includes("mac"):!1);return{hasCmdModifier:x.useCallback(n=>t?n.metaKey:n.ctrlKey,[t]),isMac:t}},wce={song:"border-zinc-400/60 bg-zinc-200/60 text-zinc-700 dark:border-zinc-500/80 dark:bg-zinc-800/80 dark:text-zinc-100",text:"border-yellow-400/70 bg-yellow-200/70 text-yellow-800 dark:border-yellow-500/80 dark:bg-yellow-900/70 dark:text-yellow-100",embed:"border-blue-400/70 bg-blue-200/70 text-blue-800 dark:border-blue-500/80 dark:bg-blue-900/70 dark:text-blue-100",media:"border-rose-400/70 bg-rose-200/70 text-rose-800 dark:border-rose-500/80 dark:bg-rose-900/70 dark:text-rose-100"},F0=({variant:t="song",className:e})=>c.jsx("span",{className:`inline-flex items-center rounded-full border p-1 ${wce[t]} ${e??""}`,title:"Shared with collaborators","aria-label":"Shared with collaborators",children:c.jsx(bx,{className:"size-3"})});function dv(t){return t===J.Song||t===J.TextNode||t===J.EmbeddingNode||t===J.VisualMediaNode}function Zf(t){switch(t.type){case J.Song:return`song:${t.id}`;case J.TextNode:return`text_node:${t.id}`;case J.EmbeddingNode:return`embedding_node:${t.id}`;case J.VisualMediaNode:return`visual_node:${t.id}`;default:return null}}function v8(t,e){var r;const n=(r=e[t])==null?void 0:r.toLowerCase();return!n||n==="owner"}function So(t,e,n){var d;const r=(d=e[t])==null?void 0:d.toLowerCase();if(r==="viewer"||r==="editor")return!0;const[i,s]=t.split(":"),o=parseInt(s,10);if(!i||Number.isNaN(o))return!1;const a=(n??[]).find(f=>f.object_type===i&&f.object_id===o),l=(a==null?void 0:a.members)??[],u=(a==null?void 0:a.pending_invites)??[];return l.length>0||u.length>0}function x8(t,e,n){const{getBloobsOverlappingWithPosition:r,maxBarExclusive:i}=n;if(r(t,e,1).length>0)return null;const o=r(t,{bar:e.bar,track:e.track-1},1),a=r(t,{bar:e.bar,track:e.track+1},1),l=r(t,{bar:e.bar-1,track:e.track},1),u=r(t,{bar:e.bar+1,track:e.track},1);let d,f,h;if(o.length>0){const S=o[0];d=e.bar-S.songPosition.bar,f=S.songPosition.bar+S.bars-e.bar-1,h=S.bars}else if(a.length>0){const S=a[0];d=e.bar-S.songPosition.bar,f=S.songPosition.bar+S.bars-e.bar-1,h=S.bars}else if(l.length>0){const S=l[0];d=0,f=S.bars,h=S.bars}else if(u.length>0){const S=u[0];d=S.bars,f=0,h=S.bars}else d=3,f=3,h=4;let m=1;for(;m<h;m++){const S=e.bar-m;if(S<0){m=d;break}const C={bar:S,track:e.track};if(r(t,C,m+1).length>0||m>d){m-=1;break}}let y=1;for(;y<h;y++){const S=e.bar+y;if(S>=i){y=f;break}const C={bar:S,track:e.track};if(r(t,C,y+1).length>0||y>f){y-=1;break}}const g={...e};let w=1,v=0;for(;w<h&&(m!==0||y!==0);)v%2===0?m>0&&(g.bar--,w++,m--):y>0&&(w++,y--),v++;return{position:g,bars:w}}const kce=({song:t,onSongResizingStart:e,onSongResizingStop:n})=>{const{isCaiObjectSelected:r,selectedCaiObjects:i}=Yn(),{selectCaiObject:s,deselectAllCaiObjects:o,deselectCaiObject:a,openImmersedSong:l}=cr(),{clientToCanvasPosition:u}=sl(),{generalSettings:d}=bi(),{getSongById:f,getBloobsOverlappingWithPosition:h,getSongName:m,tracks:y}=mn(),{addTracksToSong:g,removeTracksFromSongIfPossible:w,addBarsToSong:v,removeBarsFromSongIfPossible:S,addBloob:C,ensureTrackEntity:k}=Gn(),{commitToStore:N}=Ln(),{focusCaiChat:_}=di(),{isDarkMode:j}=Pn(),{hasCmdModifier:T}=Wl(),M=x.useMemo(()=>m(t.id),[m,t]),V=r(t),H=`song:${t.id}`,P=Vr(H),F=at(Te=>Te.domainRoleByChannel),I=at(Te=>Te.sharedByMe),R=So(H,F,I),U=t.bars*dn+Qi*2,A=t.tracks*bn+Is*2+fo,W=t.timeSignature.beatsPerBar,D=x.useRef(null),B=x.useCallback(Te=>{const ce=D.current;if(!ce)return 0;const se=ce.getBoundingClientRect(),ye=Te-se.left,ke=se.width/Math.max(1,t.bars),ze=ye/ke;return Math.max(0,Math.min(ze,t.bars-1e-6))},[t.bars]),L=x.useCallback(Te=>{const ce=D.current;if(!ce)return 0;const se=ce.getBoundingClientRect(),ye=Te-se.left,ke=se.width/Math.max(1,t.bars),ze=ye/ke;return Math.max(0,Math.min(ze,t.bars))},[t.bars]),$=x.useCallback((Te,ce)=>{const se=D.current;if(!se)return null;const ye=se.getBoundingClientRect(),ke=ye.width/Math.max(1,t.bars),ze=Te-ye.left;return F_(ze,ce,ke)},[t.bars]),q=x.useCallback(()=>{const Te=D.current;return Te?Te.getBoundingClientRect().width/t.bars/2:dn/2},[t.bars]),Z=x.useCallback(()=>{s(t)},[s,t]),{handlePointerDown:ie,handleDoubleClick:ge,activeLoopRegion:re}=UE({clientXToBar:B,clientXToExclusiveEndBar:L,hitTestEdge:$,getDragThresholdPx:q,songId:t.id,totalBars:t.bars,onPointerUp:Z}),Y=x.useMemo(()=>Array.from({length:t.bars}).map((Te,ce)=>c.jsxs("div",{className:"absolute top-0 bottom-0 border-l border-zinc-300/30 dark:border-zinc-700/30 f
710irst:border-l-0 flex items-center",style:{left:ce*dn,width:dn},children:[c.jsx("span",{className:"ml-[2px] text-[7px] font-semibold tabular-nums text-zinc-400 dark:text-zinc-500 leading-none",children:ce+1}),Array.from({length:W-1}).map((se,ye)=>c.jsx("div",{className:"absolute bottom-0 border-l border-zinc-300/20 dark:border-zinc-600/20",style:{left:(ye+1)/W*dn,height:4}},`sn-ruler-beat-${ye}`))]},`sn-bar-num-${ce}`)),[t.bars,W]),ne=x.useCallback((Te,ce)=>{ce.stopPropagation();const se=k(t.id,Te);N(),s({type:J.Track,id:se.id})},[t.id,k,N,s]),be=x.useCallback(Te=>{for(const ce of t.trackIds??[]){const se=y[ce];if(se&&se.trackIndex===Te)return se}},[t.trackIds,y]),we=x.useMemo(()=>Array.from({length:t.tracks}).map((Te,ce)=>{const se=be(ce),ye=se!==void 0&&r(se);return c.jsx("div",{className:`absolute flex items-center justify-center pointer-events-auto cursor-pointer select-none nodrag transition-colors duration-100 rounded-l ${ye?"bg-sky-500/20 dark:bg-sky-400/20":"hover:bg-zinc-400/20 dark:hover:bg-zinc-500/20"}`,style:{left:0,width:Qi,top:Is+ce*bn,height:bn},onClick:ke=>ne(ce,ke),title:`Track ${ce+1}`,children:c.jsx("span",{className:`text-[7px] font-semibold tabular-nums leading-none ${ye?"text-sky-600 dark:text-sky-300":"text-zinc-400 dark:text-zinc-500"}`,children:ce+1})},`sn-track-label-${ce}`)}),[t.tracks,be,r,ne]),te=x.useMemo(()=>Array.from({length:t.tracks}).map((Te,ce)=>c.jsx("div",{className:`absolute border-b border-zinc-300/20 dark:border-zinc-700/20 ${ce%2===1?"bg-zinc-500/5 dark:bg-zinc-400/5":""}`,style:{left:Qi,width:t.bars*dn,top:Is+ce*bn,height:bn},children:Array.from({length:t.bars}).map((se,ye)=>c.jsxs(mr.Fragment,{children:[c.jsx("div",{className:"absolute top-0 bottom-0 border-l border-zinc-300/20 dark:border-zinc-700/20",style:{left:ye*dn}}),Array.from({length:W-1}).map((ke,ze)=>c.jsx("div",{className:"absolute top-0 bottom-0 border-l border-zinc-300/10 dark:border-zinc-700/10",style:{left:ye*dn+(ze+1)/W*dn}},`sn-beat-${ze}`))]},`sn-bar-${ce}-${ye}`))},`sn-track-${ce}`)),[t.bars,t.tracks,W]),fe=x.useMemo(()=>V?j?It.zinc[50]:It.zinc[700]:j?It.zinc[600]:It.zinc[700],[V,j]),O=x.useMemo(()=>({boxShadow:V?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}),[V]),pe=x.useCallback(Te=>{i.some(se=>se.type===J.Bloob)&&o(),T(Te)?V?a(t):s(t,!0):s(t),Te.stopPropagation()},[o,a,T,V,s,i,t]),he=x.useCallback(Te=>{if(Te.stopPropagation(),!P)return;const ce={x:Te.clientX,y:Te.clientY},se=u(ce),ye=f(t.id),ke=yY(ye,se),ze=x8(t.id,ke,{getBloobsOverlappingWithPosition:h,maxBarExclusive:ye.bars});if(!ze)return;const qe=C(t.id,{instrument:d.defaultInstrument},ze.bars,ze.position,"Bloob "+t.nextInSongId);s({type:J.Bloob,id:qe}),_(),N()},[P,C,u,d.defaultInstrument,_,h,f,s,N,t.id,t.nextInSongId]),le=Xc({onClick:pe,onDoubleClick:he}),oe=x.useCallback(Te=>{Te.stopPropagation(),l(t.id)},[l,t.id]),Q=(Te,ce,se,ye)=>{if(!P)return;if(ce){e();return}else if(se){N(),n();return}const ke={x:ye[0],y:ye[1]},ze=u(ke),qe=f(t.id);if(Te.includes("top")){const Ze=qe.canvasPosition.y-ze.y;Ze>bn/2?g(qe.id,ao.Top,1):Ze<-1*(bn/2)&&w(qe.id,ao.Top,1)}if(Te.includes("right")){const ot=qe.canvasPosition.x+qe.bars*dn+Qi*2,Ze=ze.x-ot;Ze>dn/2?v(qe.id,Tr.Right,1):Ze<-1*(dn/2)&&S(qe.id,Tr.Right,1)}if(Te.includes("bottom")){const ot=qe.canvasPosition.y+qe.tracks*bn+Is*2+fo,Ze=ze.y-ot;Ze>bn/2?g(qe.id,ao.Bottom,1):Ze<-1*(bn/2)&&w(qe.id,ao.Bottom,1)}if(Te.includes("left")){const Ze=qe.canvasPosition.x-ze.x;Ze>dn/2?v(qe.id,Tr.Left,1):Ze<-1*(dn/2)&&S(qe.id,Tr.Left,1)}},de=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.Top,Te,ce,se)},{axis:"y",filterTaps:!0,preventDefault:!0}),Ne=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.Right,Te,ce,se)},{axis:"x",filterTaps:!0,preventDefault:!0}),Ce=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.Bottom,Te,ce,se)},{axis:"y",filterTaps:!0,preventDefault:!0}),Ae=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.Left,Te,ce,se)},{axis:"x",filterTaps:!0,preventDefault:!0}),Ue=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.TopLeft,Te,ce,se)},{filterTaps:!0,preventDefault:!0}),Se=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.TopRight,Te,ce,se)},{filterTaps:!0,preventDefault:!0}),ve=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.BottomRight,Te,ce,se)},{filterTaps:!0,preventDefault:!0}),je=vr(({first:Te,last:ce,xy:se})=>{Q(Xi.BottomLeft,Te,ce,se)},{filterTaps:!0,preventDefault:!0});return c.jsxs(c.Fragment,{children:[c.jsxs(et.div,{style:{width:U,height:A,borderColor:fe,touchAction:"none",...O},className:`border ${V?"border-2":"border"} box-border active:opacity-80 rounded-lg overflow-hidden relative cursor-pointer`,onClick:le.onSingle,onDoubleClick:le.onDouble,whileTap:{scale:.99},transition:{type:"spring",stiffness:400,damping:17,duration:.2},"aria-pressed":V,"aria-label":`Song: ${M}`,children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-400/90 via-zinc-500/90 to-zinc-600/90 dark:from-zinc-600/90 dark:via-zinc-700/90 dark:to-zinc-800/90 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-zinc-950/20 via-trans
710parent to-zinc-100/10 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-300/30 via-zinc-400/30 to-zinc-500/30 dark:from-zinc-500/30 dark:via-zinc-600/30 dark:to-zinc-700/30 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-zinc-100/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-zinc-950/10 to-transparent rounded-b-lg"}),c.jsxs("div",{className:"relative flex flex-col h-full bg-zinc-100/95 dark:bg-zinc-900/95 rounded-lg border border-zinc-200/50 dark:border-zinc-700/50",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-t-lg relative overflow-hidden",style:{height:`${fo}px`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-400/20 via-zinc-500/20 to-zinc-600/20 dark:from-zinc-600/20 dark:via-zinc-700/20 dark:to-zinc-800/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-zinc-100/40 to-transparent dark:from-zinc-100/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-300/30 via-zinc-400/30 to-zinc-500/30 dark:from-zinc-500/30 dark:via-zinc-600/30 dark:to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsxs("div",{className:"relative flex items-center gap-2 min-w-0 flex-1",children:[c.jsx(hx,{className:"size-3 text-zinc-700 dark:text-zinc-200 flex-shrink-0 drop-shadow-sm"}),c.jsx("span",{className:"text-sm font-semibold text-zinc-700 dark:text-zinc-200 truncate drop-shadow-sm",children:M})]}),c.jsxs("div",{className:"relative flex items-center gap-2 text-xs text-zinc-600 dark:text-zinc-400 flex-shrink-0",children:[R&&c.jsx(F0,{variant:"song"}),c.jsx("button",{type:"button",onClick:oe,className:"rounded p-1 hover:bg-zinc-200/60 dark:hover:bg-zinc-700/60 transition-colors",title:"Open immersed song view","aria-label":`Open immersed view for ${M}`,children:c.jsx(vD,{className:"size-3.5 text-zinc-700 dark:text-zinc-200"})})]})]}),c.jsxs("div",{className:"relative flex-1 overflow-hidden pointer-events-none",children:[c.jsxs("div",{ref:D,className:"absolute flex items-end select-none pointer-events-auto cursor-pointer z-10 nodrag",style:{left:Qi,top:0,width:t.bars*dn,height:Is,touchAction:"none"},onPointerDown:ie,onDoubleClick:ge,children:[Y,re&&c.jsx("div",{"aria-hidden":!0,className:"absolute top-0 bottom-0 z-10 bg-sky-400/20 border-l border-r border-sky-400/60 pointer-events-none",style:{left:re.startBar*dn,width:(re.endBar-re.startBar)*dn}})]}),we,te]})]})]}),c.jsx(Nx,{topResizeBind:de,rightResizeBind:Ne,bottomResizeBind:Ce,leftResizeBind:Ae,topLeftResizeBind:Ue,topRightResizeBind:Se,bottomRightResizeBind:ve,bottomLeftResizeBind:je})]})},w8=x.createContext(void 0),ts=()=>{const t=x.useContext(w8);if(!t)throw new Error("useBanner must be used within a BannerProvider");return t};var yk={},vk={},xk={},rA;function Sce(){return rA||(rA=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];if(typeof window<"u"){var a;typeof window.gtag>"u"&&(window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)}),(a=window).gtag.apply(a,s)}},n=e;t.default=n}(xk)),xk}var wk={},iA;function Cce(){return iA||(iA=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var e=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;function n(a){return a.toString().trim().replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,function(l,u,d){return u>0&&u+l.length!==d.length&&l.search(e)>-1&&d.charAt(u-2)!==":"&&(d.charAt(u+l.length)!=="-"||d.charAt(u-1)==="-")&&d.charAt(u-1).search(/[^\s-]/)<0?l.toLowerCase():l.substr(1).search(/[A-Z]|\../)>-1?l:l.charAt(0).toUpperCase()+l.substr(1)})}function r(a){return typeof a=="string"&&a.indexOf("@")!==-1}var i="REDACTED (Potential Email Address)";function s(a){return r(a)?(console.warn("This arg looks like an email address, redacting."),i):a}function o(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,d=a||"";return l&&(d=n(a)),u&&(d=s(d)),d}}(wk)),wk}var sA;function _ce(){return sA||(sA=1,function(t){Object.defineProperty(t,"__esMo
710dule",{value:!0}),t.default=t.GA4=void 0;var e=o(Sce()),n=o(Cce()),r=["eventCategory","eventAction","eventLabel","eventValue","hitType"],i=["title","location"],s=["page","hitType"];function o(I){return I&&I.__esModule?I:{default:I}}function a(I,R){if(I==null)return{};var U=l(I,R),A,W;if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(I);for(W=0;W<D.length;W++)A=D[W],!(R.indexOf(A)>=0)&&Object.prototype.propertyIsEnumerable.call(I,A)&&(U[A]=I[A])}return U}function l(I,R){if(I==null)return{};var U={},A=Object.keys(I),W,D;for(D=0;D<A.length;D++)W=A[D],!(R.indexOf(W)>=0)&&(U[W]=I[W]);return U}function u(I){"@babel/helpers - typeof";return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(R){return typeof R}:function(R){return R&&typeof Symbol=="function"&&R.constructor===Symbol&&R!==Symbol.prototype?"symbol":typeof R},u(I)}function d(I){return m(I)||h(I)||S(I)||f()}function f(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 711In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function h(I){if(typeof Symbol<"u"&&I[Symbol.iterator]!=null||I["@@iterator"]!=null)return Array.from(I)}function m(I){if(Array.isArray(I))return C(I)}function y(I,R){var U=Object.keys(I);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(I);R&&(A=A.filter(function(W){return Object.getOwnPropertyDescriptor(I,W).enumerable})),U.push.apply(U,A)}return U}function g(I){for(var R=1;R<arguments.length;R++){var U=arguments[R]!=null?arguments[R]:{};R%2?y(Object(U),!0).forEach(function(A){M(I,A,U[A])}):Object.getOwnPropertyDescriptors?Object.defineProperties(I,Object.getOwnPropertyDescriptors(U)):y(Object(U)).forEach(function(A){Object.defineProperty(I,A,Object.getOwnPropertyDescriptor(U,A))})}return I}function w(I,R){return N(I)||k(I,R)||S(I,R)||v()}function v(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 712In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function S(I,R){if(I){if(typeof I=="string")return C(I,R);var U=Object.prototype.toString.call(I).slice(8,-1);if(U==="Object"&&I.constructor&&(U=I.constructor.name),U==="Map"||U==="Set")return Array.from(I);if(U==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(U))return C(I,R)}}function C(I,R){(R==null||R>I.length)&&(R=I.length);for(var U=0,A=new Array(R);U<R;U++)A[U]=I[U];return A}function k(I,R){var U=I==null?null:typeof Symbol<"u"&&I[Symbol.iterator]||I["@@iterator"];if(U!=null){var A,W,D,B,L=[],$=!0,q=!1;try{if(D=(U=U.call(I)).next,R!==0)for(;!($=(A=D.call(U)).done)&&(L.push(A.value),L.length!==R);$=!0);}catch(Z){q=!0,W=Z}finally{try{if(!$&&U.return!=null&&(B=U.return(),Object(B)!==B))return}finally{if(q)throw W}}return L}}function N(I){if(Array.isArray(I))return I}function _(I,R){if(!(I instanceof R))throw new TypeError("Cannot call a class as a function")}function j(I,R){for(var U=0;U<R.length;U++){var A=R[U];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(I,V(A.key),A)}}function T(I,R,U){return R&&j(I.prototype,R),Object.defineProperty(I,"prototype",{writable:!1}),I}function M(I,R,U){return R=V(R),R in I?Object.defineProperty(I,R,{value:U,enumerable:!0,configurable:!0,writable:!0}):I[R]=U,I}function V(I){var R=H(I,"string");return u(R)==="symbol"?R:String(R)}function H(I,R){if(u(I)!=="object"||I===null)return I;var U=I[Symbol.toPrimitive];if(U!==void 0){var A=U.call(I,R);if(u(A)!=="object")return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(I)}var P=function(){function I(){var R=this;_(this,I),M(this,"reset",function(){R.isInitialized=!1,R._testMode=!1,R._currentMeasurementId,R._hasLoadedGA=!1,R._isQueuing=!1,R._queueGtag=[]}),M(this,"_gtag",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];R._testMode||R._isQueuing?R._queueGtag.push(A):e.default.apply(void 0,A)}),M(this,"_loadGA",function(U,A){var W=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"https://www.googletagmanager.com/gtag/js";if(!(typeof window>"u"||typeof document>"u")&&!R._hasLoadedGA){var D=document.createElement("script");D.async=!0,D.src="".concat(W,"?id=").concat(U),A&&D.setAttribute("nonce",A),document.body.appendChild(D),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},R._hasLoadedGA=!0}}
712),M(this,"_toGtagOptions",function(U){if(U){var A={cookieUpdate:"cookie_update",cookieExpires:"cookie_expires",cookieDomain:"cookie_domain",cookieFlags:"cookie_flags",userId:"user_id",clientId:"client_id",anonymizeIp:"anonymize_ip",contentGroup1:"content_group1",contentGroup2:"content_group2",contentGroup3:"content_group3",contentGroup4:"content_group4",contentGroup5:"content_group5",allowAdFeatures:"allow_google_signals",allowAdPersonalizationSignals:"allow_ad_personalization_signals",nonInteraction:"non_interaction",page:"page_path",hitCallback:"event_callback"},W=Object.entries(U).reduce(function(D,B){var L=w(B,2),$=L[0],q=L[1];return A[$]?D[A[$]]=q:D[$]=q,D},{});return W}}),M(this,"initialize",function(U){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!U)throw new Error("Require GA_MEASUREMENT_ID");var W=typeof U=="string"?[{trackingId:U}]:U;R._currentMeasurementId=W[0].trackingId;var D=A.gaOptions,B=A.gtagOptions,L=A.nonce,$=A.testMode,q=$===void 0?!1:$,Z=A.gtagUrl;if(R._testMode=q,q||R._loadGA(R._currentMeasurementId,L,Z),R.isInitialized||(R._gtag("js",new Date),W.forEach(function(re){var Y=g(g(g({},R._toGtagOptions(g(g({},D),re.gaOptions))),B),re.gtagOptions);Object.keys(Y).length?R._gtag("config",re.trackingId,Y):R._gtag("config",re.trackingId)})),R.isInitialized=!0,!q){var ie=d(R._queueGtag);for(R._queueGtag=[],R._isQueuing=!1;ie.length;){var ge=ie.shift();R._gtag.apply(R,d(ge)),ge[0]==="get"&&(R._isQueuing=!0)}}}),M(this,"set",function(U){if(!U){console.warn("`fieldsObject` is required in .set()");return}if(u(U)!=="object"){console.warn("Expected `fieldsObject` arg to be an Object");return}Object.keys(U).length===0&&console.warn("empty `fieldsObject` given to .set()"),R._gaCommand("set",U)}),M(this,"_gaCommandSendEvent",function(U,A,W,D,B){R._gtag("event",A,g(g({event_category:U,event_label:W,value:D},B&&{non_interaction:B.nonInteraction}),R._toGtagOptions(B)))}),M(this,"_gaCommandSendEventParameters",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];if(typeof A[0]=="string")R._gaCommandSendEvent.apply(R,d(A.slice(1)));else{var D=A[0],B=D.eventCategory,L=D.eventAction,$=D.eventLabel,q=D.eventValue;D.hitType;var Z=a(D,r);R._gaCommandSendEvent(B,L,$,q,Z)}}),M(this,"_gaCommandSendTiming",function(U,A,W,D){R._gtag("event","timing_complete",{name:A,value:W,event_category:U,event_label:D})}),M(this,"_gaCommandSendPageview",function(U,A){if(A&&Object.keys(A).length){var W=R._toGtagOptions(A),D=W.title,B=W.location,L=a(W,i);R._gtag("event","page_view",g(g(g(g({},U&&{page_path:U}),D&&{page_title:D}),B&&{page_location:B}),L))}else U?R._gtag("event","page_view",{page_path:U}):R._gtag("event","page_view")}),M(this,"_gaCommandSendPageviewParameters",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];if(typeof A[0]=="string")R._gaCommandSendPageview.apply(R,d(A.slice(1)));else{var D=A[0],B=D.page;D.hitType;var L=a(D,s);R._gaCommandSendPageview(B,L)}}),M(this,"_gaCommandSend",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];var D=typeof A[0]=="string"?A[0]:A[0].hitType;switch(D){case"event":R._gaCommandSendEventParameters.apply(R,A);break;case"pageview":R._gaCommandSendPageviewParameters.apply(R,A);break;case"timing":R._gaCommandSendTiming.apply(R,d(A.slice(1)));break;case"screenview":case"transaction":case"item":case"social":case"exception":console.warn("Unsupported send command: ".concat(D));break;default:console.warn("Send command doesn't exist: ".concat(D))}}),M(this,"_gaCommandSet",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];typeof A[0]=="string"&&(A[0]=M({},A[0],A[1])),R._gtag("set",R._toGtagOptions(A[0]))}),M(this,"_gaCommand",function(U){for(var A=arguments.length,W=new Array(A>1?A-1:0),D=1;D<A;D++)W[D-1]=arguments[D];switch(U){case"send":R._gaCommandSend.apply(R,W);break;case"set":R._gaCommandSet.apply(R,W);break;default:console.warn("Command doesn't exist: ".concat(U))}}),M(this,"ga",function(){for(var U=arguments.length,A=new Array(U),W=0;W<U;W++)A[W]=arguments[W];if(typeof A[0]=="string")R._gaCommand.apply(R,A);else{var D=A[0];R._gtag("get",R._currentMeasurementId,"client_id",function(B){R._isQueuing=!1;var L=R._queueGtag;for(D({get:function(Z){return Z==="clientId"?B:Z==="trackingId"?R._currentMeasurementId:Z==="apiVersion"?"1":void 0}});L.length;){var $=L.shift();R._gtag.apply(R,d($))}}),R._isQueuing=!0}return R.ga}),M(this,"event",function(U,A){if(typeof U=="string")R._gtag("event",U,R._toGtagOptions(A));else{var W=U.action,D=U.category,B=U.label,L=U.value,$=U.nonInteraction,q=U.transport;if(!D||!W){console.warn("args.category AND args.action are required in event()");return}var Z={hitType:"event",eventCategory:(0,n.default)(D),eventAction:(0,n.default)(W)};B&&(Z.eventLabel=(0,n.default)(B)),typeof L<"u"&&(typeof L!="number"?console.warn("Expected `args.value` arg to be a Number."):Z.eventValue=L),typeof $<"u"&&(typeof $!="boolean"?console.warn("`args.nonInteraction` must be a boolean."):Z.nonInteraction=$),typeof q<"u"&&(typeof q!="string"?console.warn("`args.transport` must be a string."):(["beacon","xhr","image"].indexOf(q)===-1&&console.warn("`args.transport` must be either one of these values: `beacon`, `xhr` or `image`"),Z.transport=q)),R._gaCommand("send",Z)}}),M(this,"send",function(U){R._gaCommand("send",U)}),this.reset()}return T(I,[{key:"gtag",value:function(){this._gtag.apply(this,arguments)}}]),I}();
712t.GA4=P;var F=new P;t.default=F}(vk)),vk}var oA;function Ece(){return oA||(oA=1,function(t){function e(a){"@babel/helpers - typeof";return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},e(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.ReactGAImplementation=void 0;var n=i(_ce());function r(a){if(typeof WeakMap!="function")return null;var l=new WeakMap,u=new WeakMap;return(r=function(f){return f?u:l})(a)}function i(a,l){if(a&&a.__esModule)return a;if(a===null||e(a)!=="object"&&typeof a!="function")return{default:a};var u=r(l);if(u&&u.has(a))return u.get(a);var d={},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in a)if(h!=="default"&&Object.prototype.hasOwnProperty.call(a,h)){var m=f?Object.getOwnPropertyDescriptor(a,h):null;m&&(m.get||m.set)?Object.defineProperty(d,h,m):d[h]=a[h]}return d.default=a,u&&u.set(a,d),d}var s=n.GA4;t.ReactGAImplementation=s;var o=n.default;t.default=o}(yk)),yk}Ece();const qs={USER_ACTIONS:"User Actions",SYSTEM_ACTIONS:"System Actions",SYSTEM_ERRORS:"System Errors",SYSTEM_TIMINGS:"System Timings"},Sr={DC_ATEB_TIME:"Double Click Audio and Text Edit Bloob Request Time",DC_TEB_TIME:"Double Click Text Edit Bloob Request Time",DC_AEB_TIME:"Double Click Audio Edit Bloob Request Time",DC_ATABS_TIME:"Double Click Audio and Text Add Bloob to Song Request Time",DC_TABS_TIME:"Double Click Text Add Bloob to Song Request Time",DC_AABS_TIME:"Double Click Audio Add Bloob to Song Request Time",DC_ATNBS_TIME:"Double Click Audio and Text New Bloob and Song Request Time",DC_TNBS_TIME:"Double Click Text New Bloob and Song Request Time",DC_ANBS_TIME:"Double Click Audio New Bloob and Song Request Time",CP_TEB_TIME:"Chat Prompt Text Edit Bloob Request Time",CP_AEB_TIME:"Chat Prompt Audio Edit Bloob Request Time",CP_TABS_TIME:"Chat Prompt Text Add Bloob to Song Request Time",CP_AABS_TIME:"Chat Prompt Audio Add Bloob to Song Request Time",CP_TNBS_TIME:"Chat Prompt Text New Bloob and Song Request Time",CP_ANBS_TIME:"Chat Prompt Audio New Bloob and Song Request Time",CP_TEXT_CONVO_TIME:"Chat Prompt Text Conversation Request Time",CP_AUD_CONVO_TIME:"Chat Prompt Audio Conversation Request Time",DEVELOP_BLOOB_ABOVE_TIME:"Develop Bloob Above Request Time",DEVELOP_BLOOB_AFTER_TIME:"Develop Bloob After Request Time",DEVELOP_BLOOB_BELOW_TIME:"Develop Bloob Below Request Time",DEVELOP_BLOOB_BEFORE_TIME:"Develop Bloob Before Request Time",DC_TES_TIME:"Double Click Text Edit Song Request Time",DC_AES_TIME:"Double Click Audio Edit Song Request Time",DC_ATES_TIME:"Double Click Audio and Text Edit Song Request Time",CP_TES_TIME:"Chat Prompt Text Edit Song Request Time",CP_AES_TIME:"Chat Prompt Audio Edit Song Request Time"},Jt={SIGN_IN:"Sign in",SIGN_OUT:"Sign out",CHAT_MIN:"Chatbox Minimized",CHAT_MAX:"Chatbox Maximized",CHAT_DEF:"Chatbox Reset to Default",SHOW_SONG_DETAILS:"Show Song Details",HIDE_SONG_DETAILS:"Hide Song Details",SHOW_BLOOB_DETAILS:"Show Bloob Details",HIDE_BLOOB_DETAILS:"Hide Bloob Details",UNDO:"Undo",REDO:"Redo",RESET:"Reset",CANVAS_DOUBLE_TAP:"Canvas Double Tap",VIEW_SONG_DETAILS:"View Song Details",VIEW_BLOOB_DETAILS:"View Bloob Details",CREATE_SONG:"Create Song",CREATE_BLOOB:"Create Bloob",MUTE:"Mute",UNMUTE:"Unmute",PAUSE:"Pause",PLAY_FROM_SONG:"Play from Song",DELETE_SONG:"Delete Song",RESIZE_SONG_SPACE_LEFT:"Resize Song Space Left",RESIZE_SONG_SPACE_RIGHT:"Resize Song Space Right",RESIZE_SONG_SPACE_TOP:"Resize Song Space Top",RESIZE_SONG_SPACE_BOTTOM:"Resize Song Space Bottom",DELETE_DETAILS_NOTE:"Delete Bloob Details Note",COPY_BLOOB:"Copy Bloob",PLAY_FROM_BLOOB:"Play from Bloob",DELETE_BLOOB:"Delete Bloob",SHIFT_BLOOB_UP:"Shift Bloob Up",SHIFT_BLOOB_DOWN:"Shift Bloob Down",SHIFT_BLOOB_LEFT:"Shift Bloob Left",SHIFT_BLOOB_RIGHT:"Shift Bloob Right",DEVELOP_BLOOB_ABOVE:"Develop Bloob Above",DEVELOP_BLOOB_AFTER:"Develop Bloob After",DEVELOP_BLOOB_BELOW:"Develop Bloob Below",DEVELOP_BLOOB_BEFORE:"Develop Bloob Before",DC_ATEB:"Double Click Audio and Text Edit Bloob Request",DC_TEB:"Double Click Text Edit Bloob Request",DC_AEB:"Double Click Audio Edit Bloob Request",CP_TEB:"Chat Prompt Text Edit Bloob Request",CP_AEB:"Chat Prompt Audio Edit Bloob Request",DC_ATABS:"Double Click Audio and Text Add Bloob to Song Request",DC_TABS:"Double Click Text Add Bloob to Song Request",DC_AABS:"Double Click Audio Add Bloob to Song Request",CP_TABS:"Chat Prompt Text Add Bloob to Song Request",CP_AABS:"Chat Prompt Audio Add Bloob to Song Request",DC_ATNBS:"Double Click Audio and Text New Bloob and Song Request",DC_TNBS:"Double Click Text New Bloob and Song Request",DC_ANBS:"Double Click Audio New Bloob and Song Request",CP_TNBS:"Chat Prompt Text New Bloob and Song Request",CP_ANBS:"Chat Prompt Audio New Bloob and Song Request",DC_TES:"Double Click Text Edit Song Request",DC_AES:"Double Click Audio Edit Song Request",DC_ATES:"Double Click Audio and Text Edit Song Request",CP_TES:"Chat Prompt Text Edit Song Request",CP_AES:"Chat Prompt Audio Edit Song Request",CP_AUD_CONVO:"Chat Prompt Audio Conversation Request",CP_TEXT_CONVO:"Chat Prompt Text Conversation Request",ADV_CHAT:"Advanced Chat Selected with request",CHAT_MIN_SENT:"Chat request sent from minimized chatbox",CHAT_MAX_SENT:"Chat request sent from maximized chatbox",CHAT_DEF_SENT:"Chat request sent from default chatbox",CHAT_NSC:"Chat request sent with no selected context",CHAT_BSC:"Chat request sent with bloob selected context",CHAT_SSC:"Chat request sent with song selected context"},Cr={DC_ATEB_ERROR:"Double Click Audio and Text Edit Bloob Error",DC_TEB_ERROR:"Double Click Text Edit Bloob Error",DC_AEB_ERROR:"Double Click Audio Edit Bloob Error",CP_TEB_ERROR:"Chat Prompt Text Edit Bloob Error",CP_AEB_ERROR:"Chat Prompt Audio Edit Bloob Error",DC_ATABS_ERROR:"Double Click Audio and Text Add Bloob to Song Error",DC_TABS_ERROR:"Double Click Text Add Bloob to Song Error",DC_AABS_ERROR:"Double Click Audio Add Bloob to Song Error",CP_TABS_ERROR:"Chat Prompt Text Add Bloob to Song Error",CP_AABS_ERROR:"Chat Prompt Audio Add Bloob to Song Error",DC_ATNBS_ERROR:"Double Click Audio and Text New Bloob and Song Error",DC_TNBS_ERROR:"Double Click Text New Bloob and Song Error",DC_ANBS_ERROR:"Double Click Audio New Bloob and Song Error",CP_TNBS_ERROR:"Chat Prompt Text New Bloob and Song Error",CP_ANBS_ERROR:"Chat Prompt Audio New Bloob and Song Error",DEVELOP_BLOOB_ABOVE_ERROR:"Develop Bloob Above Error",DEVELOP_BLOOB_AFTER_ERROR:"Develop Bloob After Error",DEVELOP_BLOOB_BELOW_ERROR:"Develop Bloob Below Error",DEVELOP_BLOOB_BEFORE_ERROR:"Develop Bloob Before Error",CP_TEXT_CONVO_ERROR:"Chat Prompt Text Conversation Error",CP_AUD_CONVO_ERROR:"Chat Prompt Audio Conversation Error",DC_TES_ERROR:"Double Click Text Edit Song Error",DC_AES_ERROR:"Double Click Audio Edit Song Error",DC_ATES_
712ERROR:"Double Click Audio and Text Edit Song Error",CP_TES_ERROR:"Chat Prompt Text Edit Song Error",CP_AES_ERROR:"Chat Prompt Audio Edit Song Error"},bo={AGENTIC_BLOOB_ACTS:"Agentic Bloob/Song Actions",USER_ACTION_ERRORS:"User Action Errors",MANUAL_BLOOB_ACTS:"Manual Bloob/Song Actions",MANUAL_SONG_ACTS:"Manual Song Actions",GENERAL_CHAT_ACTS:"General Chat Actions",CONVO_ACTS:"Conversation Actions",UI_ACTS:"UI Actions",AUTHENTICATION:"Authentication"},Nce={[Jt.DC_ATEB]:Sr.DC_ATEB_TIME,[Jt.DC_TEB]:Sr.DC_TEB_TIME,[Jt.DC_AEB]:Sr.DC_AEB_TIME,[Jt.DC_ATABS]:Sr.DC_ATABS_TIME,[Jt.DC_TABS]:Sr.DC_TABS_TIME,[Jt.DC_AABS]:Sr.DC_AABS_TIME,[Jt.DC_ATNBS]:Sr.DC_ATNBS_TIME,[Jt.DC_TNBS]:Sr.DC_TNBS_TIME,[Jt.DC_ANBS]:Sr.DC_ANBS_TIME,[Jt.CP_TEB]:Sr.CP_TEB_TIME,[Jt.CP_AEB]:Sr.CP_AEB_TIME,[Jt.CP_TABS]:Sr.CP_TABS_TIME,[Jt.CP_AABS]:Sr.CP_AABS_TIME,[Jt.CP_TNBS]:Sr.CP_TNBS_TIME,[Jt.CP_ANBS]:Sr.CP_ANBS_TIME,[Jt.DEVELOP_BLOOB_ABOVE]:Sr.DEVELOP_BLOOB_ABOVE_TIME,[Jt.DEVELOP_BLOOB_AFTER]:Sr.DEVELOP_BLOOB_AFTER_TIME,[Jt.DEVELOP_BLOOB_BELOW]:Sr.DEVELOP_BLOOB_BELOW_TIME,[Jt.DEVELOP_BLOOB_BEFORE]:Sr.DEVELOP_BLOOB_BEFORE_TIME,[Jt.CP_TEXT_CONVO]:Sr.CP_TEXT_CONVO_TIME,[Jt.CP_AUD_CONVO]:Sr.CP_AUD_CONVO_TIME,[Jt.DC_TES]:Sr.DC_TES_TIME,[Jt.DC_AES]:Sr.DC_AES_TIME,[Jt.DC_ATES]:Sr.DC_ATES_TIME,[Jt.CP_TES]:Sr.CP_TES_TIME,[Jt.CP_AES]:Sr.CP_AES_TIME},Ice={[Jt.DC_ATABS]:Cr.DC_ATABS_ERROR,[Jt.DC_TABS]:Cr.DC_TABS_ERROR,[Jt.DC_AABS]:Cr.DC_AABS_ERROR,[Jt.DC_ATNBS]:Cr.DC_ATNBS_ERROR,[Jt.DC_TNBS]:Cr.DC_TNBS_ERROR,[Jt.DC_ANBS]:Cr.DC_ANBS_ERROR,[Jt.DC_ATEB]:Cr.DC_ATEB_ERROR,[Jt.DC_TEB]:Cr.DC_TEB_ERROR,[Jt.DC_AEB]:Cr.DC_AEB_ERROR,[Jt.CP_TEB]:Cr.CP_TEB_ERROR,[Jt.CP_AEB]:Cr.CP_AEB_ERROR,[Jt.CP_TABS]:Cr.CP_TABS_ERROR,[Jt.CP_AABS]:Cr.CP_AABS_ERROR,[Jt.CP_TNBS]:Cr.CP_TNBS_ERROR,[Jt.CP_ANBS]:Cr.CP_ANBS_ERROR,[Jt.DEVELOP_BLOOB_ABOVE]:Cr.DEVELOP_BLOOB_ABOVE_ERROR,[Jt.DEVELOP_BLOOB_AFTER]:Cr.DEVELOP_BLOOB_AFTER_ERROR,[Jt.DEVELOP_BLOOB_BELOW]:Cr.DEVELOP_BLOOB_BELOW_ERROR,[Jt.DEVELOP_BLOOB_BEFORE]:Cr.DEVELOP_BLOOB_BEFORE_ERROR,[Jt.CP_TEXT_CONVO]:Cr.CP_TEXT_CONVO_ERROR,[Jt.CP_AUD_CONVO]:Cr.CP_AUD_CONVO_ERROR,[Jt.DC_TES]:Cr.DC_TES_ERROR,[Jt.DC_AES]:Cr.DC_AES_ERROR,[Jt.DC_ATES]:Cr.DC_ATES_ERROR,[Jt.CP_TES]:Cr.CP_TES_ERROR,[Jt.CP_AES]:Cr.CP_AES_ERROR};var gn=(t=>(t.Above="above",t.After="after",t.Below="below",t.Before="before",t))(gn||{});const jce=new Set(["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE"]),k8=t=>t?jce.has(t.toUpperCase()):!1,$0=async()=>{const{userCountryCode:t,setUserCountryCode:e,setShowUpgradeModal:n,setShowUnsupportedModal:r}=tl.getState();let i=t;if(!i)try{i=(await tr.get("/api/v0/subscriptions/country-code")).headers["X-User-Country"]||"Private",e(i)}catch{e("")}i&&k8(i)?r(!0):n(!0)};var Nr=(t=>(t.BASE="base",t.PRO="pro",t.KIPP_CAPITAL="kipp_capital",t))(Nr||{});const aA={base:0,pro:1,kipp_capital:1};function lA(t,e){return aA[t]>aA[e]}var S8=(t=>(t.ACTIVE="active",t.CANCELED="canceled",t.PAST_DUE="past_due",t.UNPAID="unpaid",t.TRIAL="trial",t.INCOMPLETE="incomplete",t.INCOMPLETE_EXPIRED="incomplete_expired",t))(S8||{});const mC={base:{plan:"base",name:"Base",price:{month:0,year:0},features:["48 Takes per month"],takes_limit:48},pro:{plan:"pro",name:"Pro",price:{month:13,year:110},features:["500 Takes per month"],takes_limit:500,popular:!0},kipp_capital:{plan:"kipp_capital",name:"KIPP Capital Pro",price:{month:26,year:0},features:["1100 Takes","Priority Support"],takes_limit:1100}},fc="/api/v0/subscriptions",Aa={async getUsageInfo(){var t;try{return(await tr.get(`${Yh.caiServerFastAPI}${fc}/usage/me`)).data}catch(e){if(((t=e.response)==null?void 0:t.status)===429){const n=e.response.data;throw new Error(n.message)}throw new Error("Failed to fetch usage information")}},async getSubscriptionDetails(t){var e;try{return(await tr.get(`${fc}/${t}`)).data}catch(n){if(((e=n.response)==null?void 0:e.status)===404)return{id:`sub_${t}`,user_id:t,plan:Nr.BASE,status:S8.ACTIVE,cancel_at_period_end:!1,interval:"month",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};throw new Error("Failed to fetch subscription details")}},async createCheckoutSession(t,e,n="month"){var r;try{const i=await tr.post(`${fc}/checkout?user_id=${t}&plan=${e}&interval=${n}`,{}),s=i.headers["x-user-country"]||null,o=s?!k8(s):!0;return{session:i.data,isSupported:o,countryCode:s}}catch(i){throw pr("Checkout session error:",((r=i.response)==null?void 0:r.data)||i.message),new Error("Failed to create checkout session")}},async cancelSubscription(t){var e;try{return(await tr.post(`${fc}/cancel`,{user_id:t})).data}catch(n){throw pr("Cancel subscription error:",((e=n.response)==null?void 0:e.data)||n.message),new Error("Failed to cancel subscription")}},async reactivateSubscription(t){var e;try{return(await tr.post(`${fc}/reactivate`,{user_id:t})).data}catch(n){throw pr("Reactivate subscription error:",((e=n.response)==null?void 0:e.data)||n.message),new Error("Failed to reactivate subscription")}},async createPaymentIntent(t,e){var n;try{return(await tr.post(`${fc}/payment-intent`,{user_id:t,plan:e})).data}catch(r){throw pr("Create payment intent error:",((n=r.response)==null?void 0:n.data)||r.message),new Error("Failed to create payment intent")}},async updateSubscription(t,e){var n;try{return(await tr.put(`${fc}/${t}`,e)).data}catch(r){throw pr("Update subscription error:",((n=r.response)==null?void 0:n.data)||r.message),new Error("Failed to update subscription")}},async checkKippCapitalEligibility(){var t;try{return(await tr.get(`${fc}/check-kipp-eligibility`)).data}catch(e){return pr("KIPP eligibility check error:",((t=e.response)==null?void 0:t.data)||e.message),{eligible:!1,email:void 0}}}},cA={subscription:null,usage:null,isKippCapitalEligible:!1,isCheckingEligibility:!1,isLoading:!1,isUpdating:!1,isProcessingPayment:!1,isReactivating:!1,isCanceling:!1,showUpgradeModal:!1,showUnsupportedModal:!1,userCountryCode:null,showUsageModal:!1,showSuccessModal:!1,error:null},tl=tO()(oee((t,e)=>({...cA,fetchUsage:async()=>{t({isLoading:!0,error:null});try{const n=await Aa.getUsageInfo();t({usage:n,isLoading:!1})}catch(n){const r=n instanceof Error?n.message:"Failed to fetch usage information";t({error:r,isLoading:!1})}}
712,fetchSubscription:async n=>{t({isLoading:!0,error:null});try{const r=await Aa.getSubscriptionDetails(n);t({subscription:r,isLoading:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to fetch subscription details";t({error:i,isLoading:!1})}},refreshSubscriptionData:async n=>{t({isLoading:!0,error:null});try{const[r,i]=await Promise.all([Aa.getUsageInfo(),Aa.getSubscriptionDetails(n)]);t({usage:r,subscription:i,isLoading:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to refresh subscription data";t({error:i,isLoading:!1})}},updateUsageFromHeader:n=>{t(r=>r.usage?{...r,usage:{...r.usage,takes_used:n}}:r)},createCheckoutSession:async(n,r,i)=>{t({isProcessingPayment:!0,error:null});try{const s=await Aa.createCheckoutSession(n,r,i);return t({isProcessingPayment:!1}),s}catch(s){const o=s instanceof Error?s.message:"Failed to create checkout session";throw t({error:o,isProcessingPayment:!1}),s}},handleSuccessfulSubscriptionUpgrade:async n=>{try{await e().refreshSubscriptionData(n)}catch{}},cancelSubscription:async n=>{t({isCanceling:!0,error:null});try{await Aa.cancelSubscription(n),await e().refreshSubscriptionData(n),t({isCanceling:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to cancel subscription";t({error:i,isCanceling:!1})}},reactivateSubscription:async n=>{t({isReactivating:!0,error:null});try{await Aa.reactivateSubscription(n),await e().refreshSubscriptionData(n),t({isReactivating:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to reactivate subscription";t({error:i,isReactivating:!1})}},createPaymentIntent:async(n,r)=>{t({isProcessingPayment:!0,error:null});try{const i=await Aa.createPaymentIntent(n,r);return t({isProcessingPayment:!1}),i}catch(i){const s=i instanceof Error?i.message:"Failed to create payment intent";throw t({error:s,isProcessingPayment:!1}),i}},updateSubscription:async(n,r)=>{t({isUpdating:!0,error:null});try{const i=await Aa.updateSubscription(n,r);t({subscription:i,isUpdating:!1}),await e().refreshSubscriptionData(n)}catch(i){const s=i instanceof Error?i.message:"Failed to update subscription";t({error:s,isUpdating:!1})}},checkKippCapitalEligibility:async()=>{t({isCheckingEligibility:!0});try{const n=await Aa.checkKippCapitalEligibility();t({isKippCapitalEligible:n.eligible,isCheckingEligibility:!1})}catch{t({isKippCapitalEligible:!1,isCheckingEligibility:!1})}},setShowUpgradeModal:n=>t({showUpgradeModal:n}),setShowUnsupportedModal:n=>t({showUnsupportedModal:n}),setUserCountryCode:n=>t({userCountryCode:n}),setShowUsageModal:n=>t({showUsageModal:n}),setShowSuccessModal:n=>t({showSuccessModal:n}),setError:n=>t({error:n}),clearError:()=>t({error:null}),reset:()=>t(cA)}))),Ix=()=>tl(t=>t.usage),Tce=()=>tl(t=>t.isKippCapitalEligible);var kk={exports:{}},Sk,uA;function zce(){if(uA)return Sk;uA=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Sk=t,Sk}var Ck,dA;function Pce(){if(dA)return Ck;dA=1;var t=zce();function e(){}function n(){}return n.resetWarningCache=e,Ck=function(){function r(o,a,l,u,d,f){if(f!==t){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Ck}var fA;function Ace(){return fA||(fA=1,kk.exports=Pce()()),kk.exports}var Mce=Ace();const df=Vo(Mce);function br(t){console.warn("[react-ga]",t)}function gC(t){"@babel/helpers - typeof";return gC=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},gC(t)}var Bce=["to","target"];function hA(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};
712e%2?hA(Object(n),!0).forEach(function(r){HE(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hA(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rce(t,e){if(t==null)return{};var n=Oce(t,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function Oce(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}function Dce(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Lce(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Fce(t,e,n){return e&&Lce(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function $ce(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&bC(t,e)}function bC(t,e){return bC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},bC(t,e)}function Uce(t){var e=Hce();return function(){var r=fv(t),i;if(e){var s=fv(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return Vce(this,i)}}function Vce(t,e){if(e&&(gC(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return C8(t)}function C8(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Hce(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fv(t){return fv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},fv(t)}function HE(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var mA="_blank",Gce=1,ud=function(t){$ce(n,t);var e=Uce(n);function n(){var r;Dce(this,n);for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];return r=e.call.apply(e,[this].concat(s)),HE(C8(r),"handleClick",function(a){var l=r.props,u=l.target,d=l.eventLabel,f=l.to,h=l.onClick,m=l.trackerNames,y={label:d},g=u!==mA,w=!(a.ctrlKey||a.shiftKey||a.metaKey||a.button===Gce);g&&w?(a.preventDefault(),n.trackLink(y,function(){window.location.href=f},m)):n.trackLink(y,function(){},m),h&&h(a)}),r}return Fce(n,[{key:"render",value:function(){var i=this.props,s=i.to,o=i.target,a=Rce(i,Bce),l=pA(pA({},a),{},{target:o,href:s,onClick:this.handleClick});return o===mA&&(l.rel="".concat(l.rel?l.rel:""," noopener noreferrer").trim()),delete l.eventLabel,delete l.trackerNames,mr.createElement("a",l)}}]),n}(x.Component);HE(ud,"trackLink",function(){br("ga tracking not enabled")});ud.propTypes={eventLabel:df.string.isRequired,target:df.string,to:df.string,onClick:df.func,trackerNames:df.arrayOf(df.string)};ud.defaultProps={target:null,to:null,onClick:null,trackerNames:null};function Wce(t){return typeof t=="string"&&t.indexOf("@")!==-1}var qce="REDACTED (Potential Email Address)";function Kce(t){return Wce(t)?(br("This arg looks like an email address, redacting."),qce):t}function jx(t){return t&&t.toString().replace(/^\s+|\s+$/g,"")}var Yce=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;function Xce(t){return jx(t).replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,function(e,n,r){return n>0&&n+e.length!==r.length&&e.search(Yce)>-1&&r.charAt(n-2)!==":"&&(r.charAt(n+e.length)!=="-"||r.charAt(n-1)==="-")&&r.charAt(n-1).search(/[^\s-]/)<0?e.toLowerCase():e.substr(1).search(/[A-Z]|\../)>-1?e:e.charAt(0).toUpperCase()+e.substr(1)})}function Qce(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=t||"";return e&&(r=Xce(t)),n&&(r=Kce(r)),r}function Zce(t){return t.substring(0,1)==="/"?t.substring(1):t}var gA=!1;
712function Jce(t){if(!gA){gA=!0;var e="https://www.google-analytics.com/analytics.js";t&&t.gaAddress?e=t.gaAddress:t&&t.debug&&(e="https://www.google-analytics.com/analytics_debug.js");var n=t&&t.onerror;(function(r,i,s,o,a,l,u){r.GoogleAnalyticsObject=a,r[a]=r[a]||function(){(r[a].q=r[a].q||[]).push(arguments)},r[a].l=1*new Date,l=i.createElement(s),u=i.getElementsByTagName(s)[0],l.async=1,l.src=o,l.onerror=n,u.parentNode.insertBefore(l,u)})(window,document,"script",e,"ga")}}function Fi(t){console.info("[react-ga]",t)}var _k=[];const hv={calls:_k,ga:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];_k.push([].concat(n))},resetCalls:function(){_k.length=0}};var eue=["category","action","label","value","nonInteraction","transport"];function tue(t,e){if(t==null)return{};var n=nue(t,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function nue(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}function bA(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function rue(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bA(Object(n),!0).forEach(function(r){iue(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bA(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iue(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r0(t){"@babel/helpers - typeof";return r0=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},r0(t)}function sue(t){return cue(t)||lue(t)||aue(t)||oue()}function oue(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 713In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aue(t,e){if(t){if(typeof t=="string")return yC(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yC(t,e)}}function lue(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function cue(t){if(Array.isArray(t))return yC(t)}function yC(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var _8=typeof window>"u"||typeof document>"u",fa=!1,E8=!0,N8=!1,I8=!0,j8=!0,Jf=function(){var e;return N8?hv.ga.apply(hv,arguments):_8?!1:window.ga?(e=window).ga.apply(e,arguments):br("ReactGA.initialize must be called first or GoogleAnalytics should be loaded manually")};function Oc(t){return Qce(t,E8,j8)}function Tx(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=n[0];if(typeof Jf=="function"){if(typeof i!="string"){br("ga command must be a string");return}(I8||!Array.isArray(t))&&Jf.apply(void 0,n),Array.isArray(t)&&t.forEach(function(s){Jf.apply(void 0,sue(["".concat(s,".").concat(i)].concat(n.slice(1))))})}}function yA(t,e){if(!t){br("gaTrackingID is required in initialize()");return}e&&(e.debug&&e.debug===!0&&(fa=!0),e.titleCase===!1&&(E8=!1),e.redactEmail===!1&&(j8=!1),e.useExistingGa)||(e&&e.gaOptions?Jf("create",t,e.gaOptions):Jf("create",t,"auto"))}function T8(t,e){return Array.isArray(t)?t.forEach(function(n){if(r0(n)!=="object"){br("All configs must be an object");return}yA(n.trackingId,n)}):yA(t,e),!0}function z8(t,e){if(e&&e.testMode===!0)N8=!0;else{if(_8)return;(!e||e.standardImplementation!==!0)&&Jce(e)}I8=e&&typeof e.alwaysSendToDefaultTracker=="boolean"?e.alwaysSendToDefaultTracker:!0,T8(t,e)}function Ns(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.length>0&&(Jf.apply(void 0,e),fa&&(Fi("called ga('arguments');"),Fi("with arguments: ".concat(JSON.stringify(e))))),window.ga}function P8(t,e){if(!t){br("`fieldsObject` is required in .set()");return}if(r0(t)!=="object"){br("Expected `fieldsObject` arg to be an Object");return}Object.keys(t).length===0&&br("empty `fieldsObject` given to .set()"),Tx(e,"set",t),fa&&(Fi("called ga('set', fieldsObject);"),Fi("with fieldsObject: ".concat(JSON.stringify(t))))}function ep(t,e){Tx(e,"send",t),fa&&(Fi("called ga('send', fieldObject);"),Fi("with fieldObject: ".concat(JSON.stringify(t))),Fi("with trackers: ".concat(JSON.stringify(e))))}function A8(t,e,n){if(!t){br("path is required in .pageview()");return}var r=jx(t);if(r===""){br("path cannot be an empty string in .pageview()");return}var i={};if(n&&(i.title=n),typeof Ns=="function"&&(Tx(e,"send",rue({hitType:"pageview",page:r},i)),fa)){Fi("called ga('send', 'pageview', path);");var s="";n&&(s=" and title: ".concat(n)),Fi("with path: ".concat(r).concat(s))}}function M8(t,e){if(!t){br("modalName is required in .modalview(modalName)");return}var n=Zce(jx(t));if(n===""){br("modalName cannot be an empty string or a single / in .modalview()");return}if(typeof Ns=="function"){var r="/modal/".concat(n);Tx(e,"send","pageview",r),fa&&(Fi("called ga('send', 'pageview', path);"),Fi("with path: ".concat(r)))}}function B8(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.category,n=t.variable,r=t.value,i=t.label,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(typeof Ns=="function"){if(!e||!n||typeof r!="number"){br("args.category, args.variable AND args.value are required in timing() AND args.value has to be a number");return}var o={hitType:"timing",timingCategory:Oc(e),timingVar:Oc(n),timingValue:r};
713i&&(o.timingLabel=Oc(i)),ep(o,s)}}function R8(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.category,n=t.action,r=t.label,i=t.value,s=t.nonInteraction,o=t.transport,a=tue(t,eue),l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(typeof Ns=="function"){if(!e||!n){br("args.category AND args.action are required in event()");return}var u={hitType:"event",eventCategory:Oc(e),eventAction:Oc(n)};r&&(u.eventLabel=Oc(r)),typeof i<"u"&&(typeof i!="number"?br("Expected `args.value` arg to be a Number."):u.eventValue=i),typeof s<"u"&&(typeof s!="boolean"?br("`args.nonInteraction` must be a boolean."):u.nonInteraction=s),typeof o<"u"&&(typeof o!="string"?br("`args.transport` must be a string."):(["beacon","xhr","image"].indexOf(o)===-1&&br("`args.transport` must be either one of these values: `beacon`, `xhr` or `image`"),u.transport=o)),Object.keys(a).filter(function(d){return d.substr(0,9)==="dimension"}).forEach(function(d){u[d]=a[d]}),Object.keys(a).filter(function(d){return d.substr(0,6)==="metric"}
713).forEach(function(d){u[d]=a[d]}),ep(u,l)}}function O8(t,e){var n=t.description,r=t.fatal;if(typeof Ns=="function"){var i={hitType:"exception"};n&&(i.exDescription=Oc(n)),typeof r<"u"&&(typeof r!="boolean"?br("`args.fatal` must be a boolean."):i.exFatal=r),ep(i,e)}}var D8={require:function(e,n,r){if(typeof Ns=="function"){if(!e){br("`name` is required in .require()");return}var i=jx(e);if(i===""){br("`name` cannot be an empty string in .require()");return}var s=r?"".concat(r,".require"):"require";if(n){if(r0(n)!=="object"){br("Expected `options` arg to be an Object");return}Object.keys(n).length===0&&br("Empty `options` given to .require()"),Ns(s,i,n),fa&&Fi("called ga('require', '".concat(i,"', ").concat(JSON.stringify(n)))}else Ns(s,i),fa&&Fi("called ga('require', '".concat(i,"');"))}},execute:function(e,n){for(var r,i,s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];if(o.length===1?r=o[0]:(i=o[0],r=o[1]),typeof Ns=="function")if(typeof e!="string")br("Expected `pluginName` arg to be a String.");else if(typeof n!="string")br("Expected `action` arg to be a String.");else{var l="".concat(e,":").concat(n);r=r||null,i&&r?(Ns(l,i,r),fa&&(Fi("called ga('".concat(l,"');")),Fi('actionType: "'.concat(i,'" with payload: ').concat(JSON.stringify(r))))):r?(Ns(l,r),fa&&(Fi("called ga('".concat(l,"');")),Fi("with payload: ".concat(JSON.stringify(r))))):(Ns(l),fa&&Fi("called ga('".concat(l,"');")))}}};function GE(t,e,n){if(typeof e!="function"){br("hitCallback function is required");return}if(typeof Ns=="function"){if(!t||!t.label){br("args.label is required in outboundLink()");return}var r={hitType:"event",eventCategory:"Outbound",eventAction:"Click",eventLabel:Oc(t.label)},i=!1,s=function(){i=!0,e()},o=setTimeout(s,250),a=function(){clearTimeout(o),i||e()};r.hitCallback=a,ep(r,n)}else setTimeout(e,0)}var uue=hv;const due={initialize:z8,ga:Ns,set:P8,send:ep,pageview:A8,modalview:M8,timing:B8,event:R8,exception:O8,plugin:D8,outboundLink:GE,testModeAPI:hv},fue=Object.freeze(Object.defineProperty({__proto__:null,addTrackers:T8,default:due,event:R8,exception:O8,ga:Ns,initialize:z8,modalview:M8,outboundLink:GE,pageview:A8,plugin:D8,send:ep,set:P8,testModeAPI:uue,timing:B8},Symbol.toStringTag,{value:"Module"}));function vA(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vA(Object(n),!0).forEach(function(r){hue(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vA(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hue(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}ud.origTrackLink=ud.trackLink;ud.trackLink=GE;var pue=ud;const Ji=xA(xA({},fue),{},{OutboundLink:pue}),L8=x.createContext(null),es=()=>{const t=x.useContext(L8);if(!t)throw new Error("useCaiAudio must be used within a CaiAudioContext");return t};class ti extends Error{constructor(n,r="AuthError"){super(n);Xt(this,"name");this.name=r}}const mue=async({username:t,password:e,email:n,firstName:r,lastName:i})=>{try{const{data:s,error:o}=await xr.auth.signUp({email:t,password:e,options:{data:{firstName:r||"",lastName:i||"",email:n}}});if(o){const a=o.message.toLowerCase();throw a.includes("user already registered")||a.includes("already exists")||a.includes("email address is already in use")||o.message==="User already registered"?new ti("An account with this email already exists. If you signed up with single sign-on (Google, Facebook, etc.), please use that method to sign in. Otherwise, please sign in with your email and password.","UsernameExistsException"):new ti("Sign up failed. Please try again.")}if(s!=null&&s.user&&(!s.user.identities||s.user.identities.length===0))throw new ti("An account with this email already exists. If you signed up with single sign-on (Google, Facebook, etc.), please use that method to sign in. Otherwise, please sign in with your email and password.","UsernameExistsException");return s}catch(s){throw s}},gue=async({username:t,confirmationCode:e})=>{try{const{data:n,error:r}=await xr.auth.verifyOtp({email:t,token:e,type:"email"});if(r)throw new ti(r.message);return n}catch(n){throw n}},vC=async({username:t,password:e})=>{try{const{error:n}=await xr.auth.signInWithPassword({email:t,password:e});if(n)throw n.message.includes("Invalid login credentials")?new ti("Invalid email or password. Please check your credentials and try again.","NotAuthorizedException"):n.message.includes("Email not confirmed")?new ti("User not confirmed","UserNotConfirmedException"):n.message.includes("Too many requests")?new ti("Account locked after too many attempts. Please try again later or reset your password.","NotAuthorizedException"):new ti(n.message);return{nextStep:{signInStep:"DONE"}}}catch(n){throw n}},Dp=async({provider:t})=>{try{let e;typeof t=="string"?e=t.toLowerCase():t.custom==="Discord"?e="discord":t.custom==="X"||t.custom==="Twitter"?e="twitter":t.custom==="Spotify"?e="spotify":e=t.custom.toLowerCase();const{data:n,error:r}=await xr.auth.signInWithOAuth({provider:e,options:{redirectTo:window.location.origin,queryParams:{prompt:"select_account"}}});if(r)throw new ti(r.message);return n}catch(e){throw e}},F8=async({username:t})=>{try{const{data:e,error:n}=await xr.auth.resetPasswordForEmail(t,{redirectTo:`${window.location.origin}/reset-password`});if(n)throw new ti(n.message);return e}catch(e){throw e}},$8=async({username:t,confirmationCode:e,newPassword:n})=>{try{const{data:r,error:i}=await xr.auth.verifyOtp({email:t,token:e,type:"recovery"});if(i)throw new ti(i.message);const{error:s}=await xr.auth.updateUser({password:n});if(s)throw new ti(s.message);return r}catch(r){throw r}},WE=async()=>{try{const{error:t}=await xr.auth.signOut();if(t)throw new ti(t.message)}catch(t){throw t}},bue=async t=>{try{const{data:e,error:n}=await xr.auth.updateUser({email:t});if(n)throw new ti(n.message||"Failed to request email change");return e}catch(e){throw e}},yue=async({firstName:t,lastName:e})=>{try{const{data:n,error:r}=await xr.auth.updateUser({data:{firstName:t.trim(),lastName:e.trim()}});if(r)throw new ti(r.message||"Failed to update profile");return n}catch(n){throw n}},dd=async()=>{try{const{data:{user:t}}=await xr.auth.getUser();return t}catch(t){throw t}},wA=async()=>{var t,e;try{const{data:{user:n}}=await xr.auth.getUser();if(!n)throw new ti("No user found");return{email:n.email,firstName:((t=n.user_metadata)==null?void 0:t.firstName)||"",lastName:((e=n.user_metadata)==null?void 0:e.lastName)||"",email_verified:n.email_confirmed_at?"true":"false"}}catch(n){throw n}},yy=async()=>{var t,e;try{const{data:{user:n}}=await xr.auth.getUser();if(!n)throw new ti("No user found");const r=((t=n.identities)==null?void 0:t.map(a=>a.provider))||[],i=r.includes("email"),s=r.some(a=>a!=="email"),o=((e=n.user_metadata)==null?void 0:e.has_password)===!0;return{hasEmailProvider:i||o,hasSocialProvider:s,onlySocialAuth:!i&&!o&&s}}catch{return{hasEmailProvider:!0,hasSocialProvider:!1,onlySocialAuth:!1}}},vue=async t=>{try{const{data:{user:e}}=await xr.auth.getUser();if(!(e!=null&&e.email))throw new ti("No user email found");const{error:n}=await xr.auth.updateUser({password:t,data:{...e.user_metadata,has_password:!0}});if(n)throw new ti(n.message);return{success:!0,needsConfirmation:!1}}catch(e){throw e}},xue=async({oldPassword:t,newPassword:e})=>{try{if((await yy()).onlySocialAuth)return await vue(e);const{data:{user:r}}=await xr.auth.getUser();if(!(r!=null&&r.email))throw new ti("No user email found");const{data:i,error:s}=await xr.auth.signInWithPassword({email:r.email,password:t});if(s||!i.user)throw new ti("Current password is incorrect","NotAuthorizedException");const{error:o}=await xr.auth.updateUser({password:e});if(o)throw new ti(o.message||"Failed to update password");return{success:!0,needsConfirmation:!1}}catch(n){throw n}},wue=async()=>{try{const{data:{session:t}}=await xr.auth.getSession();if(!t)throw new ti("No authentication session");const e=await fetch(`${Yh.caiServerFastAPI}/api/v0/auth/delete-user`,{method:"DELETE",headers:{Authorization:`Bearer ${t.access_token}`}});if(!e.ok){const n=await e.json().catch(()=>({detail:"Failed to delete account"}));throw new Error(n.detail||"Failed to delete account")}return await e.json()}catch(t){throw t}};class kue{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,n){this.keyToValue.set(e,n),this.valueToKey.set(n,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class U8{constructor(e){this.generateIdentifier=e,this.kv=new kue}register(e,n){this.kv.getByValue(e)||(n||(n=this.generateIdentifier(e)),this.kv.set(n,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class Sue extends U8{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,n){typeof n=="object"?(n.allowProps&&this.classToAllowedProps.set(e,n.allowProps),super.register(e,n.identifier)):super.register(e,n)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Cue(t){if("values"in Object)return Object.values(t);const e=[];for(const n in t)t.hasOwnProperty(n)&&e.push(t[n]);return e}function _ue(t,e){const n=Cue(t);if("find"in n)return n.find(e);const r=n;for(let i=0;i<r.length;i++){const s=r[i];if(e(s))return s}}function Mh(t,e){Object.entries(t).forEach(([n,r])=>e(r,n))}function vy(t,e){return t.indexOf(e)!==-1}function kA(t,e){for(let n=0;n<t.length;n++){const r=t[n];if(e(r))return r}}class Eue{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return _ue(this.transfomers,n=>n.isApplicable(e))}findByName(e){return this.transfomers[e]}}const Nue=t=>Object.prototype.toString.call(t).slice(8,-1),V8=t=>typeof t>"u",Iue=t=>t===null,i0=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,xC=t=>i0(t)&&Object.keys(t).length===0,Uc=t=>Array.isArray(t),jue=t=>typeof t=="string",Tue=t=>typeof t=="number"&&!isNaN(t),zue=t=>typeof t=="boolean",Pue=t=>t instanceof RegExp,s0=t=>t instanceof Map,o0=t=>t instanceof Set,H8=t=>Nue(t)==="Symbol",Aue=t=>t instanceof Date&&!isNaN(t.valueOf()),Mue=t=>t instanceof Error,SA=t=>typeof t=="number"&&isNaN(t),Bue=t=>zue(t)||Iue(t)||V8(t)||Tue(t)||jue(t)||H8(t),Rue=t=>typeof t=="bigint",Oue=t=>t===1/0||t===-1/0,Due=t=>ArrayBuffer.isView(t)&&!(t instanceof DataView),Lue=t=>t instanceof URL,G8=t=>t.replace(/\./g,"\\."),Ek=t=>t.map(String).map(G8).join("."),Em=t=>{const e=[];let n="";for(let i=0;i<t.length;i++){let s=t.charAt(i);if(s==="\\"&&t.charAt(i+1)==="."){n+=".",i++;continue}if(s==="."){e.push(n),n="";continue}n+=s}const r=n;return e.push(r),e};function Ma(t,e,n,r){return{isApplicable:t,annotation:e,transform:n,untransform:r}}const W8=[Ma(V8,"undefined",()=>null,()=>{}),Ma(Rue,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),Ma(Aue,"Date",t=>t.toISOString(),t=>new Date(t)),Ma(Mue,"Error",(t,e)=>{const n={name:t.name,message:t.message};return e.allowedErrorProps.forEach(r=>{n[r]=t[r]}),n},(t,e)=>{const n=new Error(t.message);return n.name=t.name,n.stack=t.stack,e.allowedErrorProps.forEach(r=>{n[r]=t[r]}),n}),Ma(Pue,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),n=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,n)}),Ma(o0,"set",t=>[...t.values()],t=>new Set(t)),Ma(s0,"map",t=>[...t.entries()],t=>new Map(t)),Ma(t=>SA(t)||Oue(t),"number",t=>SA(t)?"NaN":t>0?"Infinity":"-Infinity",Number),Ma(t=>t===0&&1/t===-1/0,"number",()=>"-0",Number),Ma(Lue,"URL",t=>t.toString(),t=>new URL(t))];function zx(t,e,n,r){return{isApplicable:t,annotation:e,transform:n,untransform:r}}const q8=zx((t,e)=>H8(t)?!!e.symbolRegistry.getIdentifier(t):!1,(t,e)=>["symbol",e.symbolRegistry.getIdentifier(t)],t=>t.description,(t,e,n)=>{const r=n.symbolRegistry.getValue(e[1]);
713if(!r)throw new Error("Trying to deserialize unknown symbol");return r}),Fue=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((t,e)=>(t[e.name]=e,t),{}),K8=zx(Due,t=>["typed-array",t.constructor.name],t=>[...t],(t,e)=>{const n=Fue[e[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(t)});function Y8(t,e){return t!=null&&t.constructor?!!e.classRegistry.getIdentifier(t.constructor):!1}const X8=zx(Y8,(t,e)=>["class",e.classRegistry.getIdentifier(t.constructor)],(t,e)=>{const n=e.classRegistry.getAllowedProps(t.constructor);if(!n)return{...t};const r={};return n.forEach(i=>{r[i]=t[i]}),r},(t,e,n)=>{const r=n.classRegistry.getValue(e[1]);if(!r)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(r.prototype),t)}),Q8=zx((t,e)=>!!e.customTransformerRegistry.findApplicable(t),(t,e)=>["custom",e.customTransformerRegistry.findApplicable(t).name],(t,e)=>e.customTransformerRegistry.findApplicable(t).serialize(t),(t,e,n)=>{const r=n.customTransformerRegistry.findByName(e[1]);if(!r)throw new Error("Trying to deserialize unknown custom value");return r.deserialize(t)}),$ue=[X8,q8,Q8,K8],CA=(t,e)=>{const n=kA($ue,i=>i.isApplicable(t,e));if(n)return{value:n.transform(t,e),type:n.annotation(t,e)};const r=kA(W8,i=>i.isApplicable(t,e));if(r)return{value:r.transform(t,e),type:r.annotation}},Z8={};W8.forEach(t=>{Z8[t.annotation]=t});const Uue=(t,e,n)=>{if(Uc(e))switch(e[0]){case"symbol":return q8.untransform(t,e,n);case"class":return X8.untransform(t,e,n);case"custom":return Q8.untransform(t,e,n);case"typed-array":return K8.untransform(t,e,n);default:throw new Error("Unknown transformation: "+e)}else{const r=Z8[e];if(!r)throw new Error("Unknown transformation: "+e);return r.untransform(t,n)}},Uf=(t,e)=>{if(e>t.size)throw new Error("index out of bounds");const n=t.keys();for(;e>0;)n.next(),e--;return n.next().value};function J8(t){if(vy(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(vy(t,"prototype"))throw new Error("prototype is not allowed as a property");if(vy(t,"constructor"))throw new Error("constructor is not allowed as a property")}const Vue=(t,e)=>{J8(e);for(let n=0;n<e.length;n++){const r=e[n];if(o0(t))t=Uf(t,+r);else if(s0(t)){const i=+r,s=+e[++n]==0?"key":"value",o=Uf(t,i);switch(s){case"key":t=o;break;case"value":t=t.get(o);break}}else t=t[r]}return t},wC=(t,e,n)=>{if(J8(e),e.length===0)return n(t);let r=t;for(let s=0;s<e.length-1;s++){const o=e[s];if(Uc(r)){const a=+o;r=r[a]}else if(i0(r))r=r[o];else if(o0(r)){const a=+o;r=Uf(r,a)}else if(s0(r)){if(s===e.length-2)break;const l=+o,u=+e[++s]==0?"key":"value",d=Uf(r,l);switch(u){case"key":r=d;break;case"value":r=r.get(d);break}}}const i=e[e.length-1];if(Uc(r)?r[+i]=n(r[+i]):i0(r)&&(r[i]=n(r[i])),o0(r)){const s=Uf(r,+i),o=n(s);s!==o&&(r.delete(s),r.add(o))}if(s0(r)){const s=+e[e.length-2],o=Uf(r,s);switch(+i==0?"key":"value"){case"key":{const l=n(o);r.set(l,r.get(o)),l!==o&&r.delete(o);break}case"value":{r.set(o,n(r.get(o)));break}}}return t};function kC(t,e,n=[]){if(!t)return;if(!Uc(t)){Mh(t,(s,o)=>kC(s,e,[...n,...Em(o)]));return}const[r,i]=t;i&&Mh(i,(s,o)=>{kC(s,e,[...n,...Em(o)])}),e(r,n)}function Hue(t,e,n){return kC(e,(r,i)=>{t=wC(t,i,s=>Uue(s,r,n))}),t}function Gue(t,e){function n(r,i){const s=Vue(t,Em(i));r.map(Em).forEach(o=>{t=wC(t,o,()=>s)})}if(Uc(e)){const[r,i]=e;r.forEach(s=>{t=wC(t,Em(s),()=>t)}),i&&Mh(i,n)}else Mh(e,n);return t}const Wue=(t,e)=>i0(t)||Uc(t)||s0(t)||o0(t)||Y8(t,e);function que(t,e,n){const r=n.get(t);r?r.push(e):n.set(t,[e])}function Kue(t,e){const n={};let r;return t.forEach(i=>{if(i.length<=1)return;e||(i=i.map(a=>a.map(String)).sort((a,l)=>a.length-l.length));const[s,...o]=i;s.length===0?r=o.map(Ek):n[Ek(s)]=o.map(Ek)}),r?xC(n)?[r]:[r,n]:xC(n)?void 0:n}const eL=(t,e,n,r,i=[],s=[],o=new Map)=>{const a=Bue(t);if(!a){que(t,i,e);const m=o.get(t);if(m)return r?{transformedValue:null}:m}if(!Wue(t,n)){const m=CA(t,n),y=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:t};return a||o.set(t,y),y}if(vy(s,t))return{transformedValue:null};const l=CA(t,n),u=(l==null?void 0:l.value)??t,d=Uc(u)?[]:{},f={};Mh(u,(m,y)=>{if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Detected property ${y}. This is a prototype pollution risk, please remove it from your object.`);const g=eL(m,e,n,r,[...i,y],[...s,t],o);d[y]=g.transformedValue,Uc(g.annotations)?f[y]=g.annotations:i0(g.annotations)&&Mh(g.annotations,(w,v)=>{f[G8(y)+"."+v]=w})});const h=xC(f)?{transformedValue:d,annotations:l?[l.type]:void 0}:{transformedValue:d,annotations:l?[l.type,f]:f};return a||o.set(t,h),h};function tL(t){return Object.prototype.toString.call(t).slice(8,-1)}function _A(t){return tL(t)==="Array"}function Yue(t){if(tL(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}function Xue(t,e,n,r,i){const s={}.propertyIsEnumerable.call(r,e)?"enumerable":"nonenumerable";s==="enumerable"&&(t[e]=n),i&&s==="nonenumerable"&&Object.defineProperty(t,e,{value:n,enumerable:!1,writable:!0,configurable:!0})}function SC(t,e={}){if(_A(t))return t.map(i=>SC(i,e));if(!Yue(t))return t;const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertySymbols(t);return[...n,...r].reduce((i,s)=>{if(_A(e.props)&&!e.props.includes(s))return i;const o=t[s],a=SC(o,e);return Xue(i,s,a,t,e.nonenumerable),i},{})}class Jn{constructor({dedupe:e=!1}={}){this.classRegistry=new Sue,this.symbolRegistry=new U8(n=>n.description??""),this.customTransformerRegistry=new Eue,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const n=new Map,r=eL(e,n,this,this.dedupe),i={json:r.transformedValue};r.annotations&&(i.meta={...i.meta,values:r.annotations});const s=Kue(n,this.dedupe);return s&&(i.meta={...i.meta,referentialEqualities:s}),i}deserialize(e){const{json:n,meta:r}=e;let i=SC(n);return r!=null&&r.values&&(i=Hue(i,r.values,this)),r!=null&&r.referentialEqualities&&(i=Gue(i,r.referentialEqualities)),i}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,n){this.classRegistry.register(e,n)}registerSymbol(e,n){this.symbolRegistry.register(e,n)}registerCustom(e,n){this.customTransformerRegistry.register({name:n,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}Jn.defaultInstance=new Jn;Jn.serialize=Jn.defaultInstance.serialize.bind(Jn.defaultInstance);Jn.deserialize=Jn.defaultInstance.deserialize.bind(Jn.defaultInstance);Jn.stringify=Jn.defaultInstance.stringify.bind(Jn.defaultInstance);Jn.parse=Jn.defaultInstance.parse.bind(Jn.defaultInstance);Jn.registerClass=Jn.defaultInstance.registerClass.bind(Jn.defaultInstance);Jn.registerSymbol=Jn.defaultInstance.registerSymbol.bind(Jn.defaultInstance);Jn.registerCustom=Jn.defaultInstance.registerCustom.bind(Jn.defaultInstance);Jn.allowErrorProps=Jn.defaultInstance.allowErrorProps.bind(Jn.defaultInstance);Jn.serialize;Jn.deserialize;Jn.stringify;Jn.parse;Jn.registerClass;Jn.registerCustom;Jn.registerSymbol;Jn.allowErrorProps;const jf=t=>t instanceof Set?Array.from(t).map(jf):t instanceof Map?Object.fromEntries(Array.from(t.entries()).map(([e,n])=>[jf(e),jf(n)])):Array.isArray(t)?t.map(jf):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,jf(n)])):t,Que=t=>{try{return JSON.parse(t)}catch{return Jn.parse(t).state}},_d=()=>{const{allInstrumentNames:t,getRender:e,getInstrumentId:n}=cx(),{audioFiles:r,getAudioFileData:i}=mn(),s=async()=>{const l=await jl.storage.getItem(jl.name);if(l!=null&&typeof l=="object"&&"state"in l&&l.state){const u=jf(l.state);return JSON.stringify(u,null,2)}return"{}"};return{retrieveStorage:s,downloadStorageFile:async l=>{const u=await s(),d=Object.fromEntries(await Promise.all(t.map(async S=>{const C=n(S),k=await e(S);return[C,k]}))),f=Object.fromEntries(await Promise.all(Object.keys(r).map(async S=>{const C=Number(S),k=await i(C),N=k?k.map(_=>Array.from(_)):null;return[C,N]}))),h=JSON.stringify({store:u,generatedInstruments:d,audioFiles:f}),m=new Blob([h],{type:"text/plain"}),y=URL.createObjectURL(m),g=document.createElement("a");g.href=y;const w=`project-${new Date().toISOString()}`,v=l||w;g.download=`${v}.cai`,g.click(),URL.revokeObjectURL(y)},replaceStorageFile:async l=>{const u=JSON.parse(l);await jn.clear();const d=Que(u.store);await jl.storage.setItem(jl.name,{state:d});const f=u.generatedInstruments??{},h=u.audioFiles??{};await Promise.all(Object.keys(f).map(async m=>{const y=Number(m),g=f[y];await iD(y,g)})),await Promise.all(Object.keys(h).map(async m=>{const y=Number(m),g=h[y];if(!g)return;const w=g.map(v=>new Float32Array(v));await RS(y,w,1)})),await new Promise(m=>setTimeout(m,1100)),await at.persist.rehydrate()}}};
713class qu extends Error{constructor(e,n,r){super(e),this.originalError=n,this.statusCode=r,this.name="ApiError"}get userMessage(){return this.statusCode===499?"Request Cancelled":this.message?this.message:"Error processing request"}}const U0=()=>{const{addBloob:t,addNotes:e,addSong:n,addAudioBloob:r,addMidiBloob:i,updateBloobDetails:s,updateSongDetails:o,deleteNotes:a,deleteBloob:l,organizeBloobs:u}=Gn(),{getBloobsOverlappingWithPosition:d,getBloobsInSongForRequest:f,getSongById:h,getBloobById:m,getNoteById:y}=mn(),{allInstrumentNames:g}=cx(),{addInstrument:w}=nE(),{commitToStore:v}=Ln(),{selectedCaiObjects:S}=Yn(),{selectCaiObject:C}=cr(),{addThread:k,addUserPromptAndResponse:N,objectHasThreads:_,getThreadForObject:j}=xd(),{updateUsageFromHeader:T}=tl(),{loadBloobAudio:M}=es(),{retrieveStorage:V}=_d(),H=at(Y=>Y.setDisplayRequestProgression),P=(Y,ne)=>null,F=(Y,ne,be)=>{const we={bar:0,track:0};switch(Y){case gn.Above:for(we.bar=ne.songPosition.bar,we.track=ne.songPosition.track-1;d(ne.songId,we,ne.bars).length>0;)we.track--;break;case gn.After:for(we.bar=ne.songPosition.bar+ne.bars,we.track=ne.songPosition.track;d(ne.songId,we,ne.bars).length>0;)we.track++;break;case gn.Below:for(we.bar=ne.songPosition.bar,we.track=ne.songPosition.track+1;d(ne.songId,we,ne.bars).length>0;)we.track++;break;case gn.Before:for(we.bar=ne.songPosition.bar-be.bars,we.track=ne.songPosition.track;d(ne.songId,we,ne.bars).length>0;)we.track++;break}return we},I=async(Y,ne,be)=>{Y.data.bloobs.forEach(fe=>{const O=F(be,ne,fe),pe=t(ne.songId,{instrument:fe.instrument},fe.bars,O,fe.label);if(ln(fe)&&fe.notes){const he=fe.notes.map(le=>({pitch:le.pitch,velocity:le.velocity,startBeat:le.startBeat,durationInBeats:le.durationInBeats}));e(pe,he)}M(pe)}),v()},R=async(Y,ne)=>{const be=ne===gn.Above?Jt.DEVELOP_BLOOB_ABOVE:ne===gn.After?Jt.DEVELOP_BLOOB_AFTER:ne===gn.Below?Jt.DEVELOP_BLOOB_BELOW:Jt.DEVELOP_BLOOB_BEFORE;try{const we=performance.now(),te=h(Y.songId),fe={song:te,bloobs:f(te.id),developBloobId:Y.id,developType:ne},O=await uy("songs/develop_from_bloob",fe);await I(O,Y,ne);const pe=performance.now();Ji.timing({category:qs.SYSTEM_TIMINGS,variable:Nce[be],value:pe-we}),Ji.event({category:qs.USER_ACTIONS,action:be,label:bo.AGENTIC_BLOOB_ACTS}),re(O)}catch(we){throw Ji.event({category:qs.USER_ACTIONS,action:Ice[be],label:bo.USER_ACTION_ERRORS}),we}},U=async Y=>{const ne=Y.data,be=[...g,...yh(),...yh().map(te=>$l(te))];let we=ne.name;if(be.includes(ne.name)){let te=1;for(we=we+" "+te;be.includes(we);)te++,we=we+" "+te}return await w(we,ne.render),v(),we},A=async Y=>{const be=await uy("instrument/generate_instrument",{descriptor:Y});return await U(be)},W=async(Y,ne,be={},we=!1)=>{try{let te;if(we){const pe=await V();try{te=JSON.parse(pe)}catch(he){pr("Failed to parse store data for feedback:",he),te={error:"Failed to parse store data"}}}const fe={user_id:Y,description:ne,exported_store_data:te,metadata:be};return(await tr.post(`${Yh.caiServerFastAPI}/api/v0/feedback`,fe)).data}catch{throw new Error("Failed to submit feedback. Please try again.")}},D=async(Y,ne)=>{const be=[];return Y.forEach(async we=>{const te=we.song,fe=we.bloobs,O=n(te.key,te.bpm,te.timeSignature,ne,te.label);fe.forEach(pe=>{const he=t(O,{instrument:pe.instrument},pe.bars,pe.songPosition,pe.label,pe.melodicRole,pe.metadata,pe.metadataOutdated??!1,null,pe.midiConversion);if(ln(pe)&&pe.notes){const le=pe.notes.map(oe=>({pitch:oe.pitch,velocity:oe.velocity,startBeat:oe.startBeat,durationInBeats:oe.durationInBeats}));e(he,le)}M(he)}),u(O),be.push(O)}),be},B=Y=>{Y.forEach(ne=>{h(ne.id)&&o(ne.id,{key:ne.key,bpm:ne.bpm,timeSignature:ne.timeSignature,canvasPosition:ne.canvasPosition,label:ne.label})})},L=Y=>{Y&&Y.bloobIds.forEach(ne=>{l(ne)})},$=async Y=>{Y.forEach(ne=>{const be=ne.bloobs,we=ne.songId;be.filter(te=>te.bloobType!=="Audio").forEach(te=>{let fe=te.id;te.id!==void 0&&te.id!==null?s(te.id,{songPosition:te.songPosition,bars:te.bars,label:te.label,instrument:te.instrument,melodicRole:te.melodicRole,metadata:te.metadata,metadataOutdated:!1}):fe=i(we,te.instrument,te.bars,te.songPosition,te.label,te.melodicRole,te.metadata,te.metadataOutdated??!1);const O=m(fe);if(ln(O)){const pe=Array.from(O.noteIds);a(pe,fe)}if(te.notes&&te.notes.length>0){const pe=te.notes.map(he=>({pitch:he.pitch,velocity:he.velocity,startBeat:he.startBeat,durationInBeats:he.durationInBeats}));e(fe,pe)}}),be.filter(te=>te.bloobType==="Audio").forEach(te=>{let fe=te.id;fe?s(fe,{songPosition:te.songPosition,bars:te.bars,label:te.label,melodicRole:te.melodicRole,metadata:te.metadata,midiConversion:te.midiConversion}):fe=r(we,te.audioFileId,te.bars,te.songPosition,te.label,te.melodicRole,te.metadata,te.metadataOutdated??!1,void 0,te.midiConversion)})})},q=async(Y,ne,be,we,te,fe,O,pe)=>{try{if(ne)return await ie(Y,{messages:[]},we,te,fe,O,ne,pe)}catch(he){throw he}},Z=(Y,ne)=>{const be=D(Y.createSongResponses,ne);return $(Y.updateBloobsInSongResponses),B(Y.editSongsResponse.songs),L(Y.deleteBloobResponse),be},ie=async(Y,ne,be,we,te,fe,O,pe)=>{var oe,Q,de;const he=await dd(),le={message:Y.message,songsWereSelected:Y.songsWereSelected,songsContext:Y.songsContext,specifiedBloobsContext:Y.specifiedBloobsContext,songIdToBloobsContext:Y.songIdToBloobsContext,audioFileIdToAudioData:Y.audioFileIdToAudioData,chatHistory:ne||{messages:[]}
713,advancedChat:O,specifiedSongId:be,timestamp:Y.timestamp,requestMetadata:{userId:he.id}};try{const Ne=typeof Y.message=="string"?Y.message:"",Ce=P(Ne,be),Ae=Ce||await uy("chat",le,{signal:pe.signal});Y.message=te?Ae.data.userMessage??"":(oe=Ae.data.userMessage)!=null&&oe.trim()?`@cai ${Ae.data.userMessage.trim()}`:"@cai";const Ue=await Z(Ae.data,fe);return(Ue.length!==0?Ue.map(ve=>({objectType:"song",objectId:ve})):ge()).forEach(({objectType:ve,objectId:je})=>{var Te,ce;if(!_(ve,je))k(ve,je,Y,Ae.data.chatResponse,{authorId:he==null?void 0:he.id,authorDisplayName:(he==null?void 0:he.email)??((Te=he==null?void 0:he.user_metadata)==null?void 0:Te.firstName)??"User",transcribedFromAudio:!te,inReplyToId:Y.inReplyToId});else{const se=j(ve,je);se&&N(se.id,Y,Ae.data.chatResponse,{authorId:he==null?void 0:he.id,authorDisplayName:(he==null?void 0:he.email)??((ce=he==null?void 0:he.user_metadata)==null?void 0:ce.firstName)??"User",transcribedFromAudio:!te,inReplyToId:Y.inReplyToId})}}),Ue.length!=0&&C({id:Ue[0],type:J.Song}),v(),re(Ae),{response:Ae.data.chatResponse,routeActions:Ae.data.routeActions}}catch(Ne){H(!1);const Ce=(Q=Ne==null?void 0:Ne.response)==null?void 0:Q.status,Ae=(de=Ne==null?void 0:Ne.response)==null?void 0:de.data;if(Ce===429&&Ae!=null){let Ue="You have 3 agentic requests in progress. Please wait for one to finish.";try{const Se=typeof Ae=="string"?JSON.parse(Ae):Ae;Se!=null&&Se.message&&(Ue=Se.message)}catch{}throw new qu(Ue,Ne,429)}throw Ne}},ge=()=>{if(S.length!==1)return[{objectType:"global",objectId:0}];const Y=S[0];switch(Y.type){case J.Bloob:return[{objectType:"song",objectId:m(Y.id).songId}];case J.Note:{const ne=y(Y.id).bloobId;return[{objectType:"song",objectId:m(ne).songId}]}case J.Song:return[{objectType:"song",objectId:Y.id}];case J.TextNode:return[{objectType:"text",objectId:Y.id}];case J.EmbeddingNode:return[{objectType:"embedding",objectId:Y.id}];case J.VisualMediaNode:return[{objectType:"visual",objectId:Y.id}];default:return[{objectType:"global",objectId:0}]}},re=Y=>{const ne=Y.headers["x-total-takes-used"];if(Y.headers["x-non-completion-takes-quota-exhausted"]==="true"&&$0(),ne){const we=parseInt(ne,10);isNaN(we)||T(we)}};return{handleDevelopBloob:R,handleGenerateInstrument:A,handleCaiAgentRequest:q,handleFeedbackSubmission:W}},Zue=28,Nk=[{label:"¼",value:.25},{label:"½",value:.5},{label:"1",value:1},{label:"2",value:2},{label:"4",value:4}],nL=({bloobId:t,setIsBeingDeveloped:e,layoutBarWidth:n,layoutTrackHeight:r})=>{const{getBloobById:i,getBloobsOverlappingWithPosition:s,getNotesInBloob:o,getSongById:a,noteDetails:l}=mn(),{duplicateBloob:u,updateBloobDetails:d,expandSongAsNecessary:f,addNotes:h,updateNoteDetails:m,deleteBloob:y,addAudioBloob:g}=Gn(),{commitToStore:w}=Ln(),{showBanner:v}=ts(),{handleDevelopBloob:S}=U0(),{selectCaiObject:C}=cr(),{generalSettings:k}=bi(),{setExpansionAmount:N}=il(),_=i(t),j=En(_),{getCurrentAudioContext:T}=es(),{getAudioFileById:M,getAudioFileData:V}=mn(),{addAudioFile:H}=Gn(),{isMobile:P}=Hn(),F=n??dn,I=r??bn,R=F,U=Math.max(22,Math.round(Zue/bn*I)),W=at(ce=>Object.keys(ce.inFlightAgentRequests??{}).length)<3,D=at(ce=>ce.addInFlightRequest),B=at(ce=>ce.removeInFlightRequest),L=x.useCallback(async ce=>{const se=M(ce),ye=await V(ce),ke=ye.length,ze=ye[0].length*2,qe=T().createBuffer(ke,ze,se.sampleRate);for(let Ze=0;Ze<ke;Ze++){const _t=ye[Ze],tt=qe.getChannelData(Ze);tt.set(_t,0),tt.set(_t,ye[Ze].length)}return await H(se.fileName+" (duplicated)",qe)},[H,M,V,T]),$=x.useCallback(async(ce,se)=>{try{const ye=await L(ce.audioFileId),ke={...ce.songPosition};se===gn.Before&&(ke.bar=ce.songPosition.bar-ce.bars);const ze=g(ce.songId,ye,ce.bars*2,ke,ce.label,ce.melodicRole,ce.metadata,ce.metadataOutdated,void 0,ce.midiConversion),qe=ce.id;return C({type:J.Bloob,id:ze}),y(qe),f(ce.songId),w(),ze}catch{return v("Failed to extend audio bloob"),null}},[L,g,C,y,f,w,v]),q=s(_.songId,{bar:_.songPosition.bar,track:_.songPosition.track+1},_.bars).length>0,Z=s(_.songId,{bar:_.songPosition.bar+_.bars,track:_.songPosition.track},1).length>0,ie=s(_.songId,{bar:_.songPosition.bar-_.bars,track:_.songPosition.track},_.bars).length>
7130,[ge,re]=x.useState(null),[Y,ne]=x.useState(null),[be,we]=x.useState(!1),[te,fe]=x.useState(!1),[O,pe]=x.useState(null),he=x.useCallback((ce,se=k.expansionAmount)=>{try{if(j){if(ce==="expand")d(t,{bars:_.bars+se,songPosition:{bar:_.songPosition.bar-se,track:_.songPosition.track}});else if(ce==="retract"){const ye=Math.max(.25,_.bars-se),ke=_.bars-ye;d(t,{bars:ye,songPosition:{bar:_.songPosition.bar+ke,track:_.songPosition.track}})}}else{const ye=o(t),ze=a(_.songId).timeSignature.beatsPerBar,qe=se*ze;if(ce==="expand")d(t,{bars:_.bars+se,songPosition:{bar:_.songPosition.bar-se,track:_.songPosition.track}}),ye.forEach(ot=>{const Ze=l[ot.noteDetailsHash];Ze&&m(ot.id,{newStartBeat:Ze.startBeat+qe})});else if(ce==="retract"){const ot=Math.max(.25,_.bars-se),Ze=_.bars-ot,_t=Ze*ze;d(t,{bars:ot,songPosition:{bar:_.songPosition.bar+Ze,track:_.songPosition.track}}),ye.forEach(tt=>{const gt=l[tt.noteDetailsHash];gt&&m(tt.id,{newStartBeat:gt.startBeat-_t})})}}f(_.songId),w()}catch{v("There was an issue with left expansion")}},[j,t,_.bars,_.songId,_.songPosition,o,a,d,m,f,w,v,k.expansionAmount]),le=x.useCallback((ce,se=k.expansionAmount)=>{try{if(ce==="expand")d(t,{bars:_.bars+se});else if(ce==="retract"){const ye=Math.max(.25,_.bars-se);d(t,{bars:ye})}f(_.songId),w()}catch{v("There was an issue with right expansion")}},[t,_.bars,_.songId,d,f,w,v,k.expansionAmount]),oe=x.useCallback(async(ce,se,ye)=>{try{if(ce.stopPropagation(),be)if(ye){if(j){if(j&&(se===gn.Before||se===gn.After)){const ke=await $(_,se);ke&&C({type:J.Bloob,id:ke})}}else{const ke=o(t);if(se===gn.After){d(t,{bars:_.bars*2});const ze=_.bars*a(_.songId).timeSignature.beatsPerBar,qe=ke.map(ot=>{const Ze=l[ot.noteDetailsHash];return Ze?{pitch:Ze.pitch,velocity:Ze.velocity,startBeat:Ze.startBeat+ze,durationInBeats:Ze.durationInBeats}:null}).filter(ot=>ot!==null);h(t,qe)}else if(se===gn.Before){const ze=_.bars*a(_.songId).timeSignature.beatsPerBar;ke.forEach(ot=>{const Ze=l[ot.noteDetailsHash];Ze&&m(ot.id,{newStartBeat:Ze.startBeat+ze})});const qe=ke.map(ot=>{const Ze=l[ot.noteDetailsHash];return Ze?{pitch:Ze.pitch,velocity:Ze.velocity,startBeat:Ze.startBeat,durationInBeats:Ze.durationInBeats}:null}).filter(ot=>ot!==null);d(t,{bars:_.bars*2,songPosition:{bar:_.songPosition.bar-_.bars,track:_.songPosition.track}}),h(t,qe)}}f(_.songId),w()}else{if(!W){v("Maximum number of requests in flight. Please wait for one to finish.");return}const ke=crypto.randomUUID(),ze=new AbortController;D(ke,"song",_.songId,ze),re(se),e(!0);try{await S(_,se),setTimeout(()=>{try{const qe=a(_.songId);let ot=null;if(se===gn.After){const Ze=_.songPosition.bar+_.bars,_t=_.songPosition.track;Array.from(qe.bloobIds).forEach(tt=>{const gt=i(tt);gt.songPosition.bar===Ze&>.songPosition.track===_t&&(ot=tt)})}else if(se===gn.Before){const Ze=Math.max(0,_.songPosition.bar-_.bars),_t=_.songPosition.track;Array.from(qe.bloobIds).forEach(tt=>{const gt=i(tt);gt.songPosition.bar===Ze&>.songPosition.track===_t&&(ot=tt)})}if(ot!==null){const Ze=o(ot);if(se===gn.After){d(t,{bars:_.bars*2});const _t=_.bars*a(_.songId).timeSignature.beatsPerBar,tt=Ze.map(gt=>{const dt=l[gt.noteDetailsHash];return dt?{pitch:dt.pitch,velocity:dt.velocity,startBeat:dt.startBeat+_t,durationInBeats:dt.durationInBeats}:null}).filter(gt=>gt!==null);h(t,tt)}else if(se===gn.Before){const _t=o(t),tt=_.bars*a(_.songId).timeSignature.beatsPerBar;_t.forEach(dt=>{const wt=l[dt.noteDetailsHash];wt&&m(dt.id,{newStartBeat:wt.startBeat+tt})});const gt=Ze.map(dt=>{const wt=l[dt.noteDetailsHash];return wt?{pitch:wt.pitch,velocity:wt.velocity,startBeat:wt.startBeat,durationInBeats:wt.durationInBeats}:null}).filter(dt=>dt!==null);d(t,{bars:_.bars*2,songPosition:{bar:_.songPosition.bar-_.bars,track:_.songPosition.track}}),h(t,gt)}y(ot),f(_.songId),w(),e(!1),re(null)}}catch(qe){v("There was an issue developing the bloob"),pr("Error handling AI extension:",qe),e(!1),re(null)}finally{B(ke)}},500)}catch(qe){v("There was an issue developing the bloob"),pr("Error developing bloob:",qe),e(!1),re(null),B(ke)}}else if(ye){let ke;switch(se){case gn.Below:ke={..._.songPosition,track:_.songPosition.track+1};break;case gn.Before:ke={..._.songPosition,bar:_.songPosition.bar-_.bars};break;case gn.After:ke={..._.songPosition,bar:_.songPosition.bar+_.bars};break;default:ke={..._.songPosition}}const ze=u(t,ke);d(ze,{songPosition:ke}),f(_.songId),w()}else{if(!W){v("Maximum number of requests in flight. Please wait for one to finish.");return}const ke=crypto.randomUUID(),ze=new AbortController;D(ke,"song",_.songId,ze),re(se),e(!0);try{await S(_,se)}finally{B(ke),e(!1),re(null)}}}catch{v("There was an issue developing the bloob"),e(!1),re(null)}finally{ne(null)}},[be,j,f,_,w,o,t,d,a,h,m,$,C,W,D,B,e,S,i,y,v,u]),Q=x.useCallback((ce,se,ye)=>{ce.stopPropagation(),we(se),ne(ye),fe(!1),pe(null)},[]),de=x.useCallback((ce,se,ye)=>{ce.stopPropagation(),se===gn.Before?he(ye):se===gn.After&&le(ye)},[he,le]),Ne=x.useCallback((ce,se)=>{ce.stopPropagation(),fe(!0),pe(se)},[]),Ce=x.useCallback((ce,se)=>{ce.stopPropagation(),N(se),fe(!1),O&&Y&&(Y===gn.Before?he(O,se):Y===gn.After&&le(O,se))},[O,Y,he,le,N]),Ae=x.useMemo(()=>{const ce=_.bars*F;return[{id:`right-copy-${t}`,type:gn.After,show:!Z,isCopy:!0,icon:c.jsx(Do,{size:16,className:"text-zinc-200"}),position:{x:ce,y:0,width:R,height:I},ariaLabel:`Copy bloob ${gn.After}`},{id:`right-ai-${t}`,type:gn.After,show:!Z,isCopy:!1,icon:c.jsx(uo,{size:16,className:"text-zinc-200"}),position:{x:ce+R,y:0,width:R,height:I},ariaLabel:`Generate AI bloob ${gn.After}`},{id:`bottom-copy-${t}`,type:gn.Below,show:!q,isCopy:!0,icon:c.jsx(Do,{size:16,className:"text-zinc-200"}),position:{x:0,y:I,width:ce/2,height:U},ariaLabel:`Copy bloob ${gn.Below}`},{id:`bottom-ai-${t}`,type:gn.Below,show:!q,isCopy:!1,icon:c.jsx(uo,{size:16,className:"text-zinc-200"}),position:{x:ce/2,y:I,width:ce/2,height:U},ariaLabel:`Generate AI bloob ${gn.Below}`},{id:`left-copy-${t}`,type:gn.Before,show:!ie,isCopy:!0,icon:c.jsx(Do,{size:16,className:"text-zinc-200"}),position:{x:-R*2,y:0,width:R,height:I},ariaLabel:`Copy bloob ${gn.Before}`},{id:`left-ai-${t}`,type:gn.Before,show:!ie,isCopy:!1,icon:c.jsx(uo,{size:16,className:"text-zinc-200"}),position:{x:-R,y:0,width:R,height:I},ariaLabel:`Generate AI bloob ${gn.Before}`}].filter(ye=>ye.show)},[_.bars,t,U,R,q,ie,Z,F,I]),Ue=x.useMemo(()=>
713{const ce={[gn.Above]:[],[gn.Below]:[],[gn.Before]:[],[gn.After]:[]};return Ae.forEach(se=>{ce[se.type].push(se)}),ce},[Ae]),Se=(ce,se)=>c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ce.position.x,top:ce.position.y,width:ce.position.width,height:ce.position.height},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 714 w-full h-full rounded-lg flex items-center justify-center 715 ${se?"animate-pulse":"hover:shadow-glow"} 716 bg-zinc-700/80 border border-zinc-600/80 717 transition-all duration-200 718 `,onClick:ye=>oe(ye,ce.type,ce.isCopy),disabled:se,"aria-label":ce.ariaLabel,title:ce.ariaLabel,children:ce.icon})},ce.id),ve=ce=>{const se=_.bars*F,ye=R,ke=ye*Nk.length;let ze={x:0,y:0};switch(ce){case gn.After:ze={x:se,y:0};break;case gn.Before:ze={x:-ke,y:0};break}return(ce===gn.Before?[...Nk].reverse():Nk).map((ot,Ze)=>c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ze.x+Ze*ye,top:ze.y,width:ye,height:I},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{delay:Ze*.05},children:c.jsx("button",{className:` 719 w-full h-full rounded-lg flex items-center justify-center 720 bg-zinc-700/80 border border-zinc-600/80 721 hover:shadow-glow hover:bg-zinc-600/80 722 transition-all duration-200 723 text-sm font-medium text-zinc-200 724 `,onClick:_t=>Ce(_t,ot.value),"aria-label":`Select ${ot.label} bar${ot.value!==1?"s":""}`,title:`${ot.label} bar${ot.value!==1?"s":""}`,children:ot.label})},`amount-${ot.value}-${ce}-${t}`))},je=ce=>{const se=_.bars*F;let ye={x:0,y:0,width:0,height:0},ke={x:0,y:0,width:0,height:0},ze={x:0,y:0,width:0,height:0};switch(ce){case gn.After:ke={x:se,y:0,width:R,height:I},ye={x:se+R,y:0,width:R,height:I},ze={x:se+R*2,y:0,width:R,height:I};break;
724case gn.Before:ze={x:-R*3,y:0,width:R,height:I},ye={x:-R*2,y:0,width:R,height:I},ke={x:-R,y:0,width:R,height:I};break}return c.jsxs(c.Fragment,{children:[c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ye.x,top:ye.y,width:ye.width,height:ye.height},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 725 w-full h-full rounded-lg 726 flex items-center justify-center 727 bg-zinc-700/80 border border-zinc-600/80 728 hover:shadow-glow 729 transition-all duration-200 730 `,onClick:qe=>de(qe,ce,"expand"),"aria-label":`Expand bloob ${ce}`,title:`Expand bloob ${ce} by ${k.expansionAmount} bar${k.expansionAmount!==1?"s":""}`,children:ce===gn.After?c.jsx(pi,{size:16,className:"text-zinc-200"}):c.jsx(Sh,{size:16,className:"text-zinc-200"})})},`expand-${ce}-${t}`),c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ke.x,top:ke.y,width:ke.width,height:ke.height},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 731 w-full h-full rounded-lg 732 flex items-center justify-center 733 bg-zinc-700/80 border border-zinc-600/80 734 hover:shadow-glow 735 transition-all duration-200 736 `,onClick:qe=>de(qe,ce,"retract"),"aria-label":`Retract bloob ${ce}`,title:`Retract bloob ${ce} by ${k.expansionAmount} bar${k.expansionAmount!==1?"s":""}`,children:ce===gn.After?c.jsx(Sh,{size:16,className:"text-zinc-200"}):c.jsx(pi,{size:16,className:"text-zinc-200"})})},`retract-${ce}-${t}`),c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ze.x,top:ze.y,width:ze.width,height:ze.height},initial:{opacity:0}
736,animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 737 w-full h-full rounded-lg 738 flex items-center justify-center 739 bg-zinc-700/80 border border-zinc-600/80 740 hover:shadow-glow 741 transition-all duration-200 742 `,onClick:qe=>Ne(qe,"expand"),"aria-label":"Edit expansion amount",title:`Current: ${k.expansionAmount} bar${k.expansionAmount!==1?"s":""} - Click to change`,children:c.jsx(Ine,{size:16,className:"text-zinc-200"})})},`edit-${ce}-${t}`)]})},Te=ce=>{const se=_.bars*F;let ye={x:0,y:0,width:0,height:0},ke={x:0,y:0,width:0,height:0};switch(ce){case gn.After:{const ze=P?R:0;ke={x:se,y:0,width:R,height:I},ye={x:se+ze,y:0,width:R,height:I};break}case gn.Before:{const ze=P?R:0;ye={x:-R-ze,y:0,width:R,height:I},ke={x:-R,y:0,width:R,height:I};break}case gn.Below:ye={x:0,y:I,width:se,height:U};break}return c.jsxs(c.Fragment,{children:[c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ye.x,top:ye.y,width:ye.width,height:ye.height},initial:{opacity:0}
742,animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 743 w-full h-full rounded-lg 744 flex items-center justify-center 745 bg-zinc-700/80 border border-zinc-600/80 746 hover:shadow-glow 747 transition-all duration-200 748 `,onClick:ze=>Q(ze,!1,ce),"aria-label":`Create new bloob ${ce}`,title:`Create new bloob ${ce}`,children:c.jsx(Yf,{size:16,className:"text-zinc-200"})})},`create-${ce}-${t}`),P&&(ce===gn.After||ce===gn.Before)&&c.jsx(et.div,{className:"absolute overflow-visible",style:{left:ke.x,top:ke.y,width:ke.width,height:ke.height},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:c.jsx("button",{className:` 749 w-full h-full rounded-lg 750 flex items-center justify-center 751 bg-zinc-700/80 border border-zinc-600/80 752 hover:shadow-glow 753 transition-all duration-200 754 `,onClick:ze=>Q(ze,!0,ce),"aria-label":`Extend bloob ${ce}`,title:`Extend bloob ${ce}`,children:ce===gn.After?c.jsx(tte,{size:16,className:"text-zinc-200"}):c.jsx(Jee,{size:16,className:"text-zinc-200"})})},`extend-${ce}-${t}`)]})};return c.jsx(c.Fragment,{children:Object.entries(Ue).map(([ce,se])=>{if(se.length===0)return null;const ye=ce,ke=Y===ye,ze=ge===ye;return ge!==null&&ge!==ye?null:c.jsx(Vn,{children:ke||ze?te&&(ye===gn.Before||ye===gn.After)?ve(ye):be&&(ye===gn.Before||ye===gn.After)?je(ye):se.filter(qe=>j?qe.isCopy:!0).map(qe=>Se(qe,ze&&!qe.isCopy)):Te(ye)},`handle-group-${ye}`)})})};function V0({onShortPress:t,onLongPress:e,longPressThreshold:n=500,moveCancelThreshold:r=12}){const i=x.useRef(null),s=x.useRef(!1),o=x.useRef(null),a=()=>{i.current&&(clearTimeout(i.current),i.current=null)};return{bind:xce({onPointerDown:u=>{if(!e&&!t)return;s.current=!1;const d=u.event;if(o.current={x:d.clientX,y:d.clientY},!e){o.current=null;return}i.current=window.setTimeout(()=>{s.current=!0,e==null||e(u.event),i.current=null},n)},onPointerMove:u=>{if(i.current===null||o.current===null)return;const d=u.event,f=d.clientX-o.current.x,h=d.clientY-o.current.y;f*f+h*h>r*r&&(a(),o.current=null)},onPointerUp:u=>{o.current=null,a(),s.current||t==null||t(u.event)},onPointerCancel:()=>{o.current=null,a()}},{eventOptions:{passive:!1}})}}const rL=x.createContext(null),Lo=()=>{const t=x.useContext(rL);if(!t)throw new Error("useBloobRecording must be used within a BloobRecordingProvider");return t},Jue=2,EA=2,Sb=18,NA=127,Ik=12,ff=3.5,IA=["#f97316","#22c55e","#3b82f6","#14b8a6","#a855f7","#06b6d4","#facc15"];function jk(t){let e=0;for(let r=0;r<t.length;r+=1)e=e*31+t.charCodeAt(r)|0;const n=Math.abs(e)%IA.length;return IA[n]}const ede=({bloob:t,shouldShowDevelopHandles:e})=>{const{isCaiObjectSelected:n,selectedCaiObjects:r}=Yn(),{selectCaiObject:i}=cr(),{songs:s,getNotesInBloob:o,getBloobById:a,getBloobsInSong:l,getSongById:u,getBloobsOverlappingWithPosition:d,getAudioFileData:f,getBloobName:h,isAudioFileAvailable:m,fetchingAudioFiles:y,getAudioFileById:g,noteDetails:w}=mn(),{addBarsToBloobIfPossible:v,removeBarsFromBloob:S,setLoopBars:C,updateBloobDetails:k}=Gn(),{commitToStore:N}=Ln(),{showBloobDetails:_}=Xs(),{appearanceSettings:j}=bi(),{isDarkMode:T,showVolumeAutomation:M}=Pn(),{clientToCanvasPosition:V}=sl(),[H,P]=x.useState(null),[F,I]=x.useState(!1),R=at(kt=>kt.awaitingResponse),[U,A]=x.useState(null),[W,D]=x.useState(!1),B=mr.useRef(!1),L=x.useMemo(()=>s[t.songId]!==void 0,[t.songId,s]),$=n(t),q="url('/cursors/loop-refresh-cursor.svg') 6 6, pointer",Z=En(t),ie=ln(t),ge=x.useMemo(()=>Gh(t),[t]),re=x.useMemo(()=>h(t.id),[t,h]),Y=wd(t.songId),ne=Vr(`song:${t.songId}`),{showMobileInspector:be}=Br(),{isMobile:we}=Hn(),te=x.useCallback(()=>{i(t),be()},[t,i,be]),{bind:fe}=V0({onLongPress:we?te:void 0}),O=fe(),pe=x.useMemo(()=>(Y==null?void 0:Y.hasSoloedBloobs)||!1,[Y]),{recordingBloobId:he}=Lo(),le=x.useMemo(()=>he===t.id,[t.id,he]),{currentUserId:oe}=iE(),Q=sE(t.songId),de=x.useMemo(()=>Object.values(Q).filter(kt=>kt.userId!==oe&&(kt.bloobId??null)===t.id),[Q,oe,t.id]),[Ne,Ce]=x.use
754State(!1),Ae=x.useMemo(()=>{if(!Z)return!1;const kt=t;return(y instanceof Set?y:new Set(Array.isArray(y)?y:[])).has(kt.audioFileId)},[Z,t,y]);x.useEffect(()=>{if(!Z){A(null),B.current=!1;return}let kt=!0,rt=null;const Tt=async()=>{if(!kt||!Z)return;const Mt=t;try{const Rt=await m(Mt.audioFileId);if(!kt)return;A(Ct=>Rt===Ct?Ct:(Rt&&!Ct&&!B.current&&(B.current=!0,setTimeout(()=>{const Gt=g(Mt.audioFileId);Gt&&Gt.instrument&&ai(async()=>{const{getBloobColor:Lt}=await Promise.resolve().then(()=>LY);return{getBloobColor:Lt}},void 0).then(({getBloobColor:Lt})=>{const $t=Lt(Gt.instrument),Qt=a(Mt.id);Qt&&Qt.color!==$t&&ai(async()=>{const{useCaiStore:Ye}=await Promise.resolve().then(()=>Sl);return{useCaiStore:Ye}},void 0).then(({useCaiStore:Ye})=>{Ye.setState(bt=>{bt.bloobs[Mt.id]&&(bt.bloobs[Mt.id].color=$t)})})}),W||f(Mt.audioFileId).then(Lt=>{if(!kt)return;const $t=Mt.audioClipStartInSeconds??0;let Qt=Lt;if($t>0&&Lt&&Lt.length>0){const bt=g(Mt.audioFileId),Ie=(bt==null?void 0:bt.sampleRate)??44100,it=Math.min(Lt[0].length,Math.round($t*Ie));Qt=Lt.map(ct=>ct.subarray(it))}const Ye=$y(Qt);P(Ye),D(!0)}).catch(Lt=>{pr("Error loading waveform data",Lt)})},0)),Rt))}catch{}};return Tt(),rt=setInterval(()=>{Tt()},500),()=>{kt=!1,rt&&clearInterval(rt)}},[Z,t.id]);const Ue=x.useMemo(()=>L?Z&&U===!1?It.zinc[600]:ge||t.muted||pe&&!t.soloed?It.zinc[700]:t.color:It.zinc[700],[L,t.color,t.muted,t.soloed,ge,pe,Z,U]),Se=x.useMemo(()=>de.length===0?null:jk(de[0].userId),[de]),ve=x.useMemo(()=>d(t.songId,t.songPosition,t.bars).some(rt=>rt.id!==t.id),[d,t.songId,t.songPosition,t.bars,t.id]),je=x.useMemo(()=>le||ve?It.red[500]:Se||($?T?It.zinc[50]:It.zinc[800]:Ue),[le,ve,Se,$,T,Ue]),Te=x.useMemo(()=>({boxShadow:$?T?"0 0 5px rgba(255, 255, 255, 0.4)":"0 0 5px rgba(0, 0, 0, 0.6)":"none"}),[$,T]),ce=x.useMemo(()=>(Y&&r.forEach(kt=>{if(kt.type===J.Song){if(uO(kt,Y))return!0}else if(kt.type===J.Bloob){const rt=a(kt.id);if(!rt)return;if(rt.songId===Y.id)return!0}}),!1),[r,Y,a]);x.useEffect(()=>{D(!1),P(null),B.current=!1},[t.id]);const se=ln(t)?t.noteIds.size:0,ye=x.useMemo(()=>{if(ge||!Y||!ie)return null;const kt=o(t.id);if(!kt||kt.length===0)return null;const rt=kt.map(ct=>{const Ut=w[ct.noteDetailsHash];if(!Ut)return null;const Et=H_(Ut.pitch);return Et===null?null:{n:ct,noteDetailsObj:Ut,m:Et}}).filter(ct=>ct!==null);if(rt.length===0)return null;let Tt=Math.min(...rt.map(ct=>ct.m)),Mt=Math.max(...rt.map(ct=>ct.m));Tt=Math.max(0,Tt-Ik),Mt=Math.min(NA,Mt+Ik);const Rt=Mt-Tt,Ct=t.bars*dn,Gt=bn-Ik-2,Lt=Gt*.65,$t=(Gt-Lt)/2,Qt=t.bars*Y.timeSignature.beatsPerBar,Ye=t.loopContentBars,bt=Ye?Ye*Y.timeSignature.beatsPerBar:Qt,Ie=[],it=Ye&&Ye>0?Math.ceil(t.bars/Ye):1;for(let ct=0;ct<it;ct++){const Ut=ct*bt,Et=ct>0;for(let yn=0;yn<rt.length;yn++){const{n:nn,noteDetailsObj:rr,m:xn}=rt[yn],Bn=rr.startBeat+Ut;if(Bn>=Qt||Ye&&rr.startBeat>=bt)continue;const dr=Bn/Qt*Ct,gr=(Math.min(Qt,Bn+rr.durationInBeats)-Bn)/Qt*Ct,on=Math.max(EA,gr),Fn=(Mt-xn)/Rt*Lt+$t,Xn=rr.velocity/NA*.8+.2;Ie.push(c.jsx("div",{className:"absolute rounded-sm",style:{left:Number.isNaN(dr)?0:dr,top:Number.isNaN(Fn)?0:Fn,width:Number.isNaN(on)?EA:on,height:Jue,opacity:Et?Xn*.5:Xn,backgroundColor:Et?"rgba(255,255,255,0.55)":"rgba(255,255,255,0.9)"}},`mini-note-${ct}-${yn}-${nn.id??yn}-${t.id}`))}}if(Ye&&Ye>0&&t.bars>Ye)for(let ct=Ye;ct<t.bars;ct+=Ye){const Ut=ct/t.bars*Ct;Ie.push(c.jsx("div",{className:"absolute top-0 bottom-0",style:{left:Ut,width:1,background:"repeating-linear-gradient(to bottom, rgba(255,255,255,0.4) 0px, rgba(255,255,255,0.4) 3px, transparent 3px, transparent 6px)"}},`loop-line-${ct}`))}return Ie},[ge,Y,ie,o,t.id,t.bars,t.loopContentBars,se,w]),ke=x.useMemo(()=>{if(!Z||!Y)return null;if(!H)return c.jsx("div",{className:"absolute inset-0 pt-[14px] px-0 pb-1 flex items-center overflow-hidden",children:c.jsxs("svg",{width:"100%",height:"28",viewBox:"0 0 100 28",preserveAspectRatio:"none",children:[c.jsx("rect",{x:"0",y:"0",width:"100%",height:"28",fill:"rgba(0,0,0,0.1)",rx:"2"}),c.jsx("line",{x1:"0",y1:"14",x2:"100%",y2:"14",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"})]})});const kt=(Rt,Ct,Gt)=>{const $t=9.333333333333334,Qt=Gt-Ct;let Ye="";Rt.forEach((bt,Ie)=>{const it=Ct+Ie/Rt.length*Qt,ct=$t-bt*$t*.95;Ie===0?Ye+=`M ${it},${$t} L ${it},${ct}`:Ye+=` L ${it},${ct}`});for(let bt=Rt.length-1;bt>=0;bt--){const Ie=Ct+bt/Rt.length*Qt,it=$t+Rt[bt]*$t*.95;Ye+=` L ${Ie},${it}`}return Ye+=" Z",Ye},rt=t.loopContentBars,Tt=rt&&rt>0?Math.ceil(t.bars/rt):1,Mt=rt?rt/t.bars:1;return c.jsx("div",{className:"absolute inset-0 pt-[14px] px-0 pb-1 flex items-center overflow-hidden",children:c.jsxs("svg",{width:"100%",height:"28",viewBox:"0 0 100 28",preserveAspectRatio:"none",children:[c.jsx("rect",{x:"0",y:"0",width:"100%",height:"28",fill:"rgba(0,0,0,0.0
754)",rx:"2"}),c.jsx("line",{x1:"0",y1:"14",x2:"100%",y2:"14",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"}),Array.from({length:Tt}).map((Rt,Ct)=>{const Gt=Ct*Mt*100,Lt=Math.min((Ct+1)*Mt*100,100),$t=Ct>0;return c.jsx("path",{d:kt(H,Gt,Lt),fill:$t?"rgba(255,255,255,0.45)":"rgba(255,255,255,0.8)",stroke:$t?"rgba(255,255,255,0.45)":"rgba(255,255,255,0.8)",strokeWidth:"0.75"},`wf-${Ct}`)}),rt&&rt>0&&t.bars>rt&&Array.from({length:Math.floor(t.bars/rt)},(Rt,Ct)=>(Ct+1)*Mt*100).filter(Rt=>Rt<100).map(Rt=>c.jsx("line",{x1:Rt,y1:"0",x2:Rt,y2:"28",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"},`wf-loop-${Rt}`))]})})},[Z,Y,H,t.loopContentBars,t.bars]),ze=x.useMemo(()=>{const kt=t.volumeAutomation;if(!M||!kt||kt.length===0)return null;const rt=t.bars*dn,Tt=bn,Mt=[...kt].sort(($t,Qt)=>$t.bar-Qt.bar),Rt=$t=>$t/t.bars*rt,Ct=$t=>(1-$t)*Tt,Gt=Mt.map($t=>`${Rt($t.bar)},${Ct($t.value)}`),Lt=[`${Rt(Mt[0].bar)},${Tt}`,...Gt,`${Rt(Mt[Mt.length-1].bar)},${Tt}`].join(" ");return c.jsxs("svg",{className:"absolute inset-0 z-[2] pointer-events-none",width:rt,height:Tt,viewBox:`0 0 ${rt} ${Tt}`,preserveAspectRatio:"none",children:[c.jsx("polygon",{points:Lt,fill:"rgba(255,255,255,0.10)"}),c.jsx("polyline",{points:Gt.join(" "),fill:"none",stroke:"rgba(255,255,255,0.5)",strokeWidth:1.5,strokeLinejoin:"round"})]})},[M,t.volumeAutomation,t.bars]),qe=x.useCallback(kt=>{kt.stopPropagation(),i(t)},[t,i]),ot=x.useCallback(kt=>{kt.stopPropagation(),i(t),_(t.id)},[t,i,_]),Ze=Xc({onClick:qe,onDoubleClick:ot}),_t=.25,tt=vr(({first:kt,last:rt,xy:Tt})=>{if(!ne||kt)return;if(rt){N();return}const Mt=V({x:Tt[0],y:Tt[1]}),Rt=u(t.songId),Ct=a(t.id);if(!Ct)return;const Gt=Rt.canvasPosition.x+Qi+Ct.songPosition.bar*dn,Lt=Mt.x-Gt;Lt>dn/2?S(t.id,Tr.Left,1):Lt<-30/2&&v(t.id,Tr.Left,1)},{axis:"x",filterTaps:!0,preventDefault:!0}),gt=vr(({first:kt,last:rt,xy:Tt})=>{if(!ne||kt)return;if(rt){N();return}const Mt=V({x:Tt[0],y:Tt[1]}),Rt=u(t.songId),Ct=a(t.id);if(!Ct)return;const Gt=Rt.canvasPosition.x+Qi,Lt=Math.max(_t,(Mt.x-Gt)/dn-Ct.songPosition.bar);if(Lt!==Ct.bars&&!d(Ct.songId,Ct.songPosition,Lt).some(Qt=>Qt.id!==Ct.id)){const Qt=Ct.loopContentBars!=null&&Lt<=Ct.loopContentBars;k(t.id,{bars:Lt,...Qt?{loopContentBars:null}:{}})}},{axis:"x",filterTaps:!0,preventDefault:!0}),dt=vr(({first:kt,last:rt,xy:Tt})=>{if(!ne||kt)return;if(rt){N();return}const Mt=V({x:Tt[0],y:Tt[1]}),Rt=u(t.songId),Ct=a(t.id);if(!Ct)return;const Gt=Rt.canvasPosition.x+Qi,Lt=Math.max(_t,(Mt.x-Gt)/dn-Ct.songPosition.bar);C(t.id,Lt)},{axis:"x",filterTaps:!0,preventDefault:!0}),wt=x.useMemo(()=>ne?ge?!1:R?F:$&&e:!1,[ne,e,ge,R,F,$]),Dt=t.songPosition.track,Kt=t.songId,rn=at(x.useCallback(kt=>kt.getBloobsInSong(Kt).filter(rt=>rt.songPosition.track===Dt).map(rt=>`${rt.id}:${rt.songPosition.bar}:${rt.bars}`).sort().join("|"),[Kt,Dt])),{hasLeftNeighbor:pn,hasRightNeighbor:cn}=x.useMemo(()=>{const rt=l(t.songId).filter(Ct=>Ct.id!==t.id&&Ct.songPosition.track===t.songPosition.track),Tt=t.songPosition.bar+t.bars,Mt=rt.some(Ct=>Math.abs(Ct.songPosition.bar+Ct.bars-t.songPosition.bar)<1e-9),Rt=rt.some(Ct=>Math.abs(Ct.songPosition.bar-Tt)<1e-9);return{hasLeftNeighbor:Mt,hasRightNeighbor:Rt}},[t.id,t.songPosition.bar,t.songPosition.track,t.bars,t.songId,l,rn]);return L?c.jsxs(c.Fragment,{children:[c.jsxs(et.div,{style:{width:t.bars*dn,height:bn,backgroundColor:Ue,borderColor:je,borderRadius:`${pn?ff:8}px ${cn?ff:8}px ${cn?ff:8}px ${pn?ff:8}px`,...Te},className:`border ${le&&"animate-glowingRedBorder"} box-border text-zinc-50 flex items-start relative overflow-hidden drag-handle transition-[width,height] duration-100 ${ne?"cursor-grab":"cursor-default"}`,title:$?`${re} (click to open details)`:re,onPointerDown:kt=>{var rt;(rt=O.onPointerDown)==null||rt.call(O,kt)},onPointerMove:O.onPointerMove,onPointerUp:O.onPointerUp,onPointerCancel:O.onPointerCancel,onClick:Ze.onSingle,onDoubleClick:Ze.onDouble,onMouseEnter:()=>{de.length>0&&Ce(!0)},onMouseLeave:()=>{Ce(!1)},whileTap:{scale:.98},animate:Ae?{opacity:[.7,1,.7]}:{},transition:Ae?{duration:2,repeat:1/0,ease:"easeInOut"}:{type:"spring",stiffness:400,damping:17,duration:.2},children:[c.jsxs("div",{className:"absolute top-0 left-0 px-2 py-1 flex items-center w-full overflow-hidden",style:{maxHeight:Sb,backgroundColor:`color-mix(in srgb, ${Ue} 80%, #000000 20%)40`,borderBottom:`1px solid color-mix(in srgb, ${Ue} 70%, #000000 30%)50`,borderTopLeftRadius:pn?ff:8,borderTopRightRadius:cn?ff:8},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/10 via-black/5 to-black/10",style:{backgroundColor:`color-mix(in srgb, ${Ue} 85%, #000000 15%)`,opacity:.4}}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/15 to-black/10",style:{backgroundColor:`color-mix(in srgb, ${Ue} 80%, #000000 20%)`,opacity:.3}}),c.jsx("div",{className:"absolute inset-0",style:{backgroundColor:`color-mix(in srgb, ${Ue} 75%, #000000 25%)60`,backgroundImage:`linear-gradient(135deg, color-mix(in srgb, ${Ue} 70%, #000000 30%)70 0%, color-mix(in srgb, ${Ue} 85%, #000000 15%)40 50%, color-mix(in srgb, ${Ue} 70%, #000000 30%)70 100%)`}}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent"}),c.jsxs("div",{className:"relative flex items-center w-full gap-1",children:[ve&&c.jsx("span",{title:"Overlapping bloob",children:c.jsx(z0,{className:"size-3 text-red-500 drop-shadow-sm flex-shrink-0","aria-label":"Overlap warning"})}),c.jsx("span",{className:`text-xs font-semibold overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0 drop-shadow-sm text-white dark:text-zinc-100 ${ge?"opacity-50":""}`,children:re}),de.length>0&&c.jsxs("div",{className:"flex items-center gap-0.5 mr-1",children:[de.slice(0,3).map(kt=>c.jsx("div",{className:"w-2 h-2 rounded-full border border-black/40",style:{backgroundColor:jk(kt.userId)},title:kt.name||kt.email||kt.userId}
754,kt.userId)),de.length>3&&c.jsxs("span",{className:"text-[10px] text-white/80 dark:text-zinc-200 ml-0.5",children:["+",de.length-3]})]}),c.jsxs("div",{className:"flex items-center flex-shrink-0 gap-1",children:[t.muted&&c.jsx(Ih,{className:"size-3 drop-shadow-sm"}),t.soloed&&c.jsx(Eh,{className:"size-3 drop-shadow-sm"})]}),c.jsx("div",{className:"text-xs opacity-70 drop-shadow-sm text-white/80 dark:text-zinc-200",children:ce&&j.showBloobIds&&t.inSongId})]})]}),c.jsxs("div",{className:"absolute inset-x-0 bottom-0 top-4 px-1 pb-1",children:[!ge&&ye,Z&&ke]}),ze]}),Ne&&de.length>0&&c.jsxs("div",{className:"absolute -top-6 left-1/2 -translate-x-1/2 z-50 px-2 py-1 rounded-full shadow-md border text-[10px] flex items-center gap-1 max-w-[220px]",style:{backgroundColor:T?"rgba(24,24,27,0.98)":"rgba(250,250,250,0.98)",borderColor:T?It.zinc[700]:It.zinc[300]},onMouseEnter:kt=>{kt.stopPropagation(),de.length>0&&Ce(!0)},onMouseLeave:kt=>{kt.stopPropagation(),Ce(!1)},children:[de.slice(0,3).map(kt=>c.jsx("div",{className:"w-2 h-2 rounded-full border border-black/40 flex-shrink-0",style:{backgroundColor:jk(kt.userId)}},kt.userId)),c.jsxs("span",{className:`truncate ${T?"text-zinc-100":"text-zinc-800"}`,children:[de.slice(0,2).map(kt=>kt.name||kt.email||kt.userId).join(", "),de.length>2&&` +${de.length-2}`]})]}),wt?c.jsx(nL,{bloobId:t.id,setIsBeingDeveloped:I}):null,ne&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute inset-0 h-full w-6 -translate-x-1/2 z-[2] cursor-ew-resize touch-none",...tt()}),c.jsx("div",{className:"absolute right-0 top-0 translate-x-1/2 z-[2] w-4 touch-none",style:{height:Sb,cursor:q},title:"Drag to loop",...dt()}),c.jsx("div",{className:"absolute right-0 translate-x-1/2 z-[2] w-6 cursor-ew-resize touch-none",style:{top:Sb,height:`calc(100% - ${Sb}px)`},...gt()})]})]}):null},tde=({bars:t})=>c.jsx("div",{style:{width:t*dn,height:bn},className:"border-2 border-zinc-400 dark:border-zinc-500 rounded-lg h-100 w-100"}),jA=dn*4,TA=bn*3,qE=t=>{if(![J.EmbeddingNode,J.TextNode,J.VisualMediaNode].includes(t.type))throw new Error("node resizing can only be used with embedding, text, and visual media nodes");const{selectCaiObject:e}=cr(),{commitToStore:n}=Ln(),{clientToCanvasPosition:r}=sl(),{getEmbeddingNodeById:i,getTextNodeById:s,getVisualMediaNodeById:o}=mn(),{updateEmbeddingNode:a,updateTextNode:l,updateVisualMediaNode:u}=Gn(),d=x.useCallback(()=>{switch(t.type){case J.EmbeddingNode:return i(t.id);case J.TextNode:return s(t.id);case J.VisualMediaNode:return o(t.id)}}
754,[t.id,t.type,i,s,o]),f=x.useCallback(N=>{switch(t.type){case J.EmbeddingNode:return a(t.id,N);case J.TextNode:return l(t.id,N);case J.VisualMediaNode:return u(t.id,N)}},[t.id,t.type,a,l,u]),h=(N,_,j,T)=>{if(_){e(t);return}else if(j){n();return}const M={x:T[0],y:T[1]},V=r(M),H=d();if(N.includes("top")){const F=H.canvasPosition.y-V.y;if(F>bn/2){const I=H.height+bn,R={x:H.canvasPosition.x,y:H.canvasPosition.y-bn};f({height:I,canvasPosition:R})}else if(F<-1*(bn/2)){const I=H.height-bn;if(I>=TA){const R={x:H.canvasPosition.x,y:H.canvasPosition.y+bn};f({height:I,canvasPosition:R})}}}if(N.includes("right")){const P=H.canvasPosition.x+H.width,F=V.x-P;if(F>dn/2){const I=H.width+dn;f({width:I})}else if(F<-1*(dn/2)){const I=H.width-dn;I>=jA&&f({width:I})}}if(N.includes("bottom")){const P=H.canvasPosition.y+H.height,F=V.y-P;if(F>bn/2){const I=H.height+bn;f({height:I})}else if(F<-1*(bn/2)){const I=H.height-bn;I>=TA&&f({height:I})}}if(N.includes("left")){const F=H.canvasPosition.x-V.x;if(F>dn/2){const I=H.width+dn,R={x:H.canvasPosition.x-dn,y:H.canvasPosition.y};f({width:I,canvasPosition:R})}else if(F<-1*(dn/2)){const I=H.width-dn,R={x:H.canvasPosition.x+dn,y:H.canvasPosition.y};I>=jA&&f({width:I,canvasPosition:R})}}},m=vr(({first:N,last:_,xy:j})=>{h(Xi.Top,N,_,j)},{axis:"y",filterTaps:!0,preventDefault:!0}),y=vr(({first:N,last:_,xy:j})=>{h(Xi.Right,N,_,j)},{axis:"x",filterTaps:!0,preventDefault:!0}),g=vr(({first:N,last:_,xy:j})=>{h(Xi.Bottom,N,_,j)},{axis:"y",filterTaps:!0,preventDefault:!0}),w=vr(({first:N,last:_,xy:j})=>{h(Xi.Left,N,_,j)},{axis:"x",filterTaps:!0,preventDefault:!0}),v=vr(({first:N,last:_,xy:j})=>{h(Xi.TopLeft,N,_,j)},{filterTaps:!0,preventDefault:!0}),S=vr(({first:N,last:_,xy:j})=>{h(Xi.TopRight,N,_,j)},{filterTaps:!0,preventDefault:!0}),C=vr(({first:N,last:_,xy:j})=>{h(Xi.BottomRight,N,_,j)},{filterTaps:!0,preventDefault:!0}),k=vr(({first:N,last:_,xy:j})=>{h(Xi.BottomLeft,N,_,j)},{filterTaps:!0,preventDefault:!0});return{topResizeBind:m,rightResizeBind:y,bottomResizeBind:g,leftResizeBind:w,topLeftResizeBind:v,topRightResizeBind:S,bottomRightResizeBind:C,bottomLeftResizeBind:k}},zA=bn,nde=({textNode:t})=>{const{isCaiObjectSelected:e,selectedCaiObjects:n}=Yn(),{selectCaiObject:r,deselectAllCaiObjects:i,deselectCaiObject:s}=cr(),{updateTextNode:o}=Gn(),{getTextNodeName:a}=mn(),{commitToStore:l}=Ln(),{isDarkMode:u}=Pn(),{hasCmdModifier:d}=Wl(),f=`text_node:${t.id}`,h=Vr(f),m=at(re=>re.domainRoleByChannel),y=at(re=>re.sharedByMe),g=So(f,m,y),[w,v]=x.useState(!1),[S,C]=x.useState(t.content||""),k=x.useRef(null),N=t.width||D_,_=t.height||L_,j=x.useMemo(()=>a(t.id),[a,t]),T=e(t);x.useEffect(()=>{C(t.content||"")},[t.content]),x.useEffect(()=>{if(w&&k.current){k.current.innerHTML!==S&&(k.current.innerHTML=S||""),k.current.focus();const re=document.createRange(),Y=window.getSelection();k.current.childNodes.length>0?(re.selectNodeContents(k.current),re.collapse(!1)):(re.setStart(k.current,0),re.collapse(!0)),Y==null||Y.removeAllRanges(),Y==null||Y.addRange(re)}},[S,w]);const M=x.useCallback(()=>{if(!h){v(!1);return}let re=S;k.current&&(re=k.current.innerHTML),re!==t.content&&(o(t.id,{content:re}),l()),v(!1)},[h,S,t.content,t.id,o,l]),V=x.useCallback(re=>{const Y=window.getSelection();if(!Y||Y.rangeCount===0)return;Y.getRangeAt(0).collapsed,document.execCommand(re,!1)},[]),H=x.useCallback(()=>{if(!k.current)return;const re=k.current.innerHTML;C(re)},[]),P=x.useCallback(re=>{const Y=re.metaKey||re.ctrlKey;if(Y&&!re.shiftKey)switch(re.key.toLowerCase()){case"b":re.preventDefault(),V("bold");return;case"i":re.preventDefault(),V("italic");return;case"u":re.preventDefault(),V("underline");return}if(Y&&re.shiftKey&&re.key.toLowerCase()==="x"){re.preventDefault(),V("strikeThrough");return}re.key==="Escape"?(k.current&&(k.current.innerHTML=t.content||""),C(t.content||""),v(!1)):re.key==="Enter"&&Y&&(re.preventDefault(),M())},[t.content,M,V]),F=x.useCallback(re=>{n.some(ne=>ne.type===J.Bloob)&&i(),d(re)?T?s(t):r(t,!0):r(t),re.stopPropagation()},[i,s,d,T,r,n,t]),I=x.useCallback(re=>{re.stopPropagation(),r(t),h&&v(!0)},[t,r,h]),R=Xc({onClick:F,onDoubleClick:I}),U=x.useMemo(()=>{var we;if(!S)return"";const re=document.createElement("div");re.innerHTML=S;const Y=((we=re.textContent)==null?void 0:we.length)||0,ne=Math.ceil(Y/50),be=Math.floor((_-zA-24)/20);if(ne>be){const te=re.textContent||"",fe=be*50;if(te.length>fe)return te.substring(0,fe)+"..."}return S},[S,_]),A=x.useMemo(()=>T?u?It.zinc[50]:It.zinc[700]:"transparent",[T,u]),W=x.useMemo(()=>({boxShadow:T?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}),[T]),{topResizeBind:D,rightResizeBind:B,bottomResizeBind:L,leftResizeBind:$,topRightResizeBind:q,bottomRightResizeBind:Z,bottomLeftResizeBind:ie,topLeftResizeBind:ge}=qE(t);return c.jsxs(c.Fragment,{children:[c.jsxs(et.div,{style:{width:N,height:_,borderColor:A,touchAction:"none",...W},className:`border box-border rounded-lg flex flex-col relative overflow-hidden ${w?"":"drag-handle"} cursor-pointer active:opacity-80 transition-opacity duration-150`,onClick:R.onSingle,onDoubleClick:R.onDouble,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:17,duration:.2},"aria-pressed":T,"aria-label":`Notes: ${S||"Empty"}`,children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-400/90 via-orange-400/90 to-red-400/90 dark:from-yellow-500/90 dark:via-orange-500/90 dark:to-red-500/90 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-trans
754parent to-white/10 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-300/30 via-orange-300/30 to-red-300/30 dark:from-yellow-600/30 dark:via-orange-600/30 dark:to-red-600/30 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-white/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-black/10 to-transparent rounded-b-lg"}),c.jsxs("div",{className:"relative flex flex-col h-full bg-white/95 dark:bg-zinc-900/95 rounded-lg border border-yellow-200/50 dark:border-yellow-700/50",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 rounded-t-lg relative overflow-hidden",style:{height:`${zA}px`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-yellow-400/20 via-orange-400/20 to-red-400/20 dark:from-yellow-500/20 dark:via-orange-500/20 dark:to-red-500/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-yellow-300/30 via-orange-300/30 to-red-300/30 dark:from-yellow-600/30 dark:via-orange-600/30 dark:to-red-600/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-yellow-200/80 to-transparent dark:via-yellow-600/80"}),c.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[c.jsx(Tl,{className:"size-4 text-yellow-700 dark:text-yellow-300 drop-shadow-sm"}),c.jsx("span",{className:"text-sm font-semibold text-yellow-800 dark:text-yellow-200 truncate drop-shadow-sm",children:j})]}),g&&c.jsx(F0,{variant:"text",className:"relative z-10"})]}),c.jsx("div",{className:"flex-1 p-3 overflow-hidden",children:w?c.jsx("div",{ref:k,contentEditable:!0,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",onInput:H,onKeyDown:P,onBlur:M,className:"w-full h-full resize-none border-none outline-none bg-transparent text-sm text-yellow-900 dark:text-yellow-100 overflow-auto",style:{userSelect:"text",direction:"ltr"},onMouseDown:re=>re.stopPropagation(),onTouchStart:re=>re.stopPropagation(),suppressContentEditableWarning:!0}):c.jsx(c.Fragment,{children:U?c.jsx("div",{className:"w-full h-full text-sm text-yellow-900 dark:text-yellow-100 overflow-hidden space-y-1",dangerouslySetInnerHTML:{__html:U}}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-yellow-600 dark:text-yellow-400",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"text-sm mb-2",children:h?"Click to add notes...":"Empty note"}),c.jsx($i,{className:"size-4 mx-auto"})]})})})})]}),T&&c.jsx("div",{className:"absolute inset-0 border rounded-lg pointer-events-none",style:{borderColor:u?It.zinc[50]:It.zinc[700]},"aria-hidden":"true"})]}),h&&c.jsx(Nx,{topResizeBind:D,rightResizeBind:B,bottomResizeBind:L,leftResizeBind:$,topLeftResizeBind:ge,topRightResizeBind:q,bottomRightResizeBind:Z,bottomLeftResizeBind:ie})]})},rde=bn,ide=({embeddingNode:t})=>{const{isCaiObjectSelected:e,selectedCaiObjects:n}=Yn(),{selectCaiObject:r,deselectAllCaiObjects:i,deselectCaiObject:s}=cr(),{updateEmbeddingNode:o}=Gn(),{getEmbeddingNodeName:a}=mn(),{commitToStore:l}=Ln(),{isDarkMode:u}=Pn(),{hasCmdModifier:d}=Wl(),f=`embedding_node:${t.id}`,h=Vr(f),m=at(O=>O.domainRoleByChannel),y=at(O=>O.sharedByMe),g=So(f,m,y),[w,v]=x.useState(!1),[S,C]=x.useState(t.url||""),[k,N]=x.useState(!1),_=x.useRef(null),j=x.useMemo(()=>{const O=navigator.userAgent,pe=/Safari/.test(O)&&!/Chrome/.test(O),he=/Chrome/.test(O),le=/Firefox/.test(O);return{isSafari:pe,isChrome:he,isFirefox:le,supportsCredentialless:he||le}},[]),T=t.width||M_,M=t.height||B_,V=e(t);x.useEffect(()=>{C(t.url||""),N(!1)},[t.url]),x.useEffect(()=>{w&&_.current&&(_.current.focus(),_.current.setSelectionRange(S.length,S.length))},[w,S]);const H=x.useCallback(O=>{n.some(he=>he.type===J.Bloob)&&i(),d(O)?V?s(t):r(t,!0):r(t),O.stopPropagation()},[n,d,i,V,s,t,r]),P=x.useCallback(O=>{O.stopPropagation(),r(t),h&&v(!0)},[t,r,h]),F=Xc({onClick:H,onDoubleClick:P}),I=x.useCallback(O=>{C(O.target.value)},[]),R=x.useCallback(()=>
754{if(!h){v(!1);return}o(t.id,{url:S}),l(),v(!1)},[h,t.id,S,o,l]),U=x.useCallback(O=>{O.key==="Escape"?(C(t.url||""),v(!1)):O.key==="Enter"&&(O.preventDefault(),R())},[t.url,R]),{embedType:A,embedId:W,isValidUrl:D}=x.useMemo(()=>{if(!S)return{embedType:null,embedId:null,isValidUrl:!1};const O=S.match(/spotify\.com\/track\/([a-zA-Z0-9]+)/),pe=S.match(/spotify\.com\/playlist\/([a-zA-Z0-9]+)/),he=S.match(/spotify\.com\/album\/([a-zA-Z0-9]+)/);if(pe)return{embedType:"spotify-playlist",embedId:pe[1],isValidUrl:!0};if(he)return{embedType:"spotify-album",embedId:he[1],isValidUrl:!0};if(O)return{embedType:"spotify",embedId:O[1],isValidUrl:!0};const le=S.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)/),oe=S.match(/youtube\.com\/(?:watch\?.*list=|playlist\?list=)([a-zA-Z0-9_-]+)/);if(oe)return{embedType:"youtube-playlist",embedId:oe[1],isValidUrl:!0};if(le)return{embedType:"youtube",embedId:le[1],isValidUrl:!0};if(S.match(/soundcloud\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/))return{embedType:"soundcloud",embedId:S,isValidUrl:!0};const de=S.match(/music\.apple\.com\/([a-z]{2}\/)?song\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/),Ne=S.match(/music\.apple\.com\/([a-z]{2}\/)?album\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/);if(S.match(/music\.apple\.com\/([a-z]{2}\/)?playlist\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/))return{embedType:"apple-playlist",embedId:S,isValidUrl:!0};if(Ne)return{embedType:"apple-album",embedId:S,isValidUrl:!0};if(de)return{embedType:"apple",embedId:S,isValidUrl:!0};if(S.match(/([a-zA-Z0-9_-]+)\.bandcamp\.com/))return{embedType:"bandcamp",embedId:S,isValidUrl:!0};if(S.match(/tidal\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/))return{embedType:"tidal",embedId:S,isValidUrl:!0};const Se=["deezer.com","music.amazon.com","pandora.com"];if(Se.some(je=>S.includes(je))){const je=Se.find(ce=>S.includes(ce));return{embedType:(je==null?void 0:je.split(".")[0])||"music",embedId:S,isValidUrl:!0}}return{embedType:null,embedId:null,isValidUrl:!1}},[S]),B=()=>{N(!0)},L=x.useCallback(()=>{if(!D||!W)return c.jsx("div",{className:"w-full h-full flex items-center justify-center text-blue-600 dark:text-blue-400",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"text-sm mb-2",children:h?"Double click to embed YouTube or streaming link.":"No content embedded"}),c.jsx(US,{className:"size-4 mx-auto"})]})});if(j.isSafari||k)return c.jsx("div",{className:"w-full h-full flex items-center justify-center text-blue-600 dark:text-blue-400",children:c.jsx("div",{className:"p-3 bg-orange-50 dark:bg-orange-900/20 rounded-lg border border-orange-200 dark:border-orange-800",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"text-sm text-orange-700 dark:text-orange-300 mb-2",children:"Embedding unsupported on this browser"}),c.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 underline px-1.5 py-1 rounded-md transition-colors",onClick:pe=>pe.stopPropagation(),children:[c.jsx(Ka,{className:"size-3"}),"Open Link"]})]})})});const O={width:"100%",height:"100%",frameBorder:"0",className:"rounded-lg",onError:B};return A==="spotify"?c.jsx("iframe",{credentialless:"",src:`https://open.spotify.com/embed/track/${W}?utm_source=generator`,allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy",...O}):A==="spotify-playlist"?c.jsx("iframe",{credentialless:"",src:`https://open.spotify.com/embed/playlist/${W}?utm_source=generator`,allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy",...O}):A==="spotify-album"?c.jsx("iframe",{credentialless:"",src:`https://open.spotify.com/embed/album/${W}?utm_source=generator`,allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy",...O}):A==="youtube"?c.jsx("iframe",{credentialless:"",src:`https://www.youtube.com/embed/${W}`,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,...O}
754):A==="youtube-playlist"?c.jsx("iframe",{credentialless:"",src:`https://www.youtube.com/embed/videoseries?list=${W}`,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,...O}):A==="soundcloud"?c.jsx("iframe",{credentialless:"",src:`https://w.soundcloud.com/player/?url=${encodeURIComponent(W)}&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true`,allow:"autoplay",...O}):A==="apple"?c.jsx("iframe",{credentialless:"",src:`https://embed.music.apple.com${new URL(W).pathname}`,sandbox:"allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation",...O}):A==="apple-playlist"?c.jsx("iframe",{credentialless:"",src:`https://embed.music.apple.com${new URL(W).pathname}`,sandbox:"allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation",...O}):A==="apple-album"?c.jsx("iframe",{credentialless:"",src:`https://embed.music.apple.com${new URL(W).pathname}`,sandbox:"allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation",...O}):A==="bandcamp"?c.jsx("iframe",{credentialless:"",src:W,...O}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-blue-600 dark:text-blue-400",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Mn,{className:"size-8 mx-auto mb-3"}),c.jsxs("p",{className:"text-sm mb-3 capitalize",children:[A," Link Detected"]}),c.jsxs("a",{href:W,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors",onClick:pe=>pe.stopPropagation(),children:[c.jsx(Ch,{className:"size-4"}),"Open in ",A==null?void 0:A.charAt(0).toUpperCase(),A==null?void 0:A.slice(1)]})]})})},[D,W,A,j.isSafari,k,S,B]),$=x.useCallback(()=>A==="spotify"?c.jsx(Mn,{className:"size-3"}):A==="spotify-playlist"?c.jsx(Mn,{className:"size-3"}):A==="spotify-album"?c.jsx(Mn,{className:"size-3"}):A==="youtube"?c.jsx(ka,{className:"size-3"}):A==="youtube-playlist"?c.jsx(ka,{className:"size-3"}):A==="soundcloud"?c.jsx(Mn,{className:"size-3"}):A==="apple"?c.jsx(Mn,{className:"size-3"}):A==="apple-playlist"?c.jsx(Mn,{className:"size-3"}):A==="apple-album"?c.jsx(Mn,{className:"size-3"}):A==="bandcamp"?c.jsx(Mn,{className:"size-3"}):A==="tidal"?c.jsx(Mn,{className:"size-3"}):A==="deezer"?c.jsx(Mn,{className:"size-3"}):A==="music"?c.jsx(Mn,{className:"size-3"}):A==="pandora"?c.jsx(Mn,{className:"size-3"}):c.jsx(Ka,{className:"size-3"}),[A]),q=x.useMemo(()=>V?u?It.zinc[50]:It.zinc[700]:"transparent",[V,u]),Z=x.useMemo(()=>({boxShadow:V?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}),[V]),{topResizeBind:ie,rightResizeBind:ge,bottomResizeBind:re,leftResizeBind:Y,topLeftResizeBind:ne,topRightResizeBind:be,bottomRightResizeBind:we,bottomLeftResizeBind:te}=qE(t),fe=x.useMemo(()=>a(t.id),[a,t]);return c.jsxs(c.Fragment,{children:[c.jsxs(et.div,{style:{width:T,height:M,borderColor:q,touchAction:"none",...Z},className:"border-2 box-border rounded-lg flex flex-col relative overflow-hidden drag-handle cursor-pointer",onClick:F.onSingle,onDoubleClick:F.onDouble,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:17,duration:.2},"aria-pressed":V,"aria-label":`Embed: ${A||"Empty"}`,children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-400/90 via-purple-400/90 to-indigo-400/90 dark:from-blue-500/90 dark:via-purple-500/90 dark:to-indigo-500/90 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-white/10 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-300/30 via-purple-300/30 to-indigo-300/30 dark:from-blue-600/30 dark:via-purple-600/30 dark:to-indigo-600/30 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-white/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-black/10 to-transparent roun
754ded-b-lg"}),c.jsxs("div",{className:"relative flex flex-col h-full bg-white/95 dark:bg-zinc-900/95 rounded-lg border border-blue-200/50 dark:border-blue-700/50",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 rounded-t-lg relative overflow-hidden",style:{height:`${rde}px`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-blue-400/20 via-purple-400/20 to-indigo-400/20 dark:from-blue-500/20 dark:via-purple-500/20 dark:to-indigo-500/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-blue-300/30 via-purple-300/30 to-indigo-300/30 dark:from-blue-600/30 dark:via-purple-600/30 dark:to-indigo-600/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-blue-200/80 to-transparent dark:via-blue-600/80"}),c.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-2 w-full",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[$(),c.jsx("span",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 truncate drop-shadow-sm",children:fe}),j.isSafari&&c.jsx(z0,{className:"size-3 text-orange-500 drop-shadow-sm"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[g&&c.jsx(F0,{variant:"embed",className:"relative z-10 mr-1"}),S&&D&&c.jsx("a",{href:S,target:"_blank",rel:"noopener noreferrer",onClick:O=>O.stopPropagation(),className:"relative p-1.5 rounded bg-white/20 dark:bg-white/10 backdrop-blur-sm border border-white/30 dark:border-white/20 hover:bg-white/30 dark:hover:bg-white/20 transition-colors",title:"Open in new tab",children:c.jsx(Ch,{className:"size-3 text-blue-600 dark:text-blue-400 drop-shadow-sm"})})]})]})]}),w&&c.jsx("div",{className:"p-2 bg-blue-50 dark:bg-blue-900/50 border-b border-blue-200 dark:border-blue-700",children:c.jsx("input",{ref:_,type:"text",value:S,onChange:I,onBlur:R,onKeyDown:U,className:"w-full px-3 py-2 text-sm border border-blue-300 dark:border-blue-600 rounded bg-white dark:bg-blue-800 text-blue-900 dark:text-blue-100",placeholder:"Paste Spotify or YouTube URL..."})}),c.jsx("div",{className:"flex-1 p-3 overflow-hidden",children:!w&&c.jsx("div",{className:"w-full h-full overflow-hidden rounded-lg",children:L()})})]})]}),h&&c.jsx(Nx,{topResizeBind:ie,rightResizeBind:ge,bottomResizeBind:re,leftResizeBind:Y,topLeftResizeBind:ne,topRightResizeBind:be,bottomRightResizeBind:we,bottomLeftResizeBind:te})]})};let cm={};const CC=new Set,sde=()=>{const t={...cm};CC.forEach(e=>e(t))},KE=()=>{const{getAllVisualMediaNodes:t}=mn(),[e,n]=x.useState(()=>({...cm}));x.useEffect(()=>{const o=a=>{n(a)};return CC.add(o),n({...cm}),()=>{CC.delete(o)}},[]);const r=x.useCallback((o,a)=>{cm={...cm,[o]:a},sde()},[]),i=x.useCallback(o=>{var f;const a=Object.values(t()).find(h=>h&&h.id===o);if(!((f=a==null?void 0:a.mediaData)!=null&&f.startsWith("data:video/")))return;const l=e[o]||!1,u=document.querySelectorAll("video");let d=null;for(const h of u)if(h.src===a.mediaData){d=h;break}d&&(l?d.pause():d.play().catch(()=>{}))},[t,e]),s=x.useCallback(o=>{r(o,!1)},[r]);return{visualMediaPlayStates:e,handleVisualMediaPlayPause:i,updateVisualMediaPlayState:r,resetVisualMediaState:s}},ode=bn,ade=({visualMediaNode:t})=>{const{isCaiObjectSelected:e,selectedCaiObjects:n}=Yn(),{selectCaiObject:r,deselectAllCaiObjects:i,deselectCaiObject:s}=cr(),{updateVisualMediaNode:o}=Gn(),{getVisualMediaNodeName:a}=mn(),{commitToStore:l}=Ln(),{isDarkMode:u}=Pn(),{hasCmdModifier:d}=Wl(),f=`visual_node:${t.id}`,h=Vr(f),m=at(fe=>fe.domainRoleByChannel),y=at(fe=>fe.sharedByMe),g=So(f,m,y),[w,v]=x.useState(!1),S=x.useRef(null),C=x.useRef(null),{visualMediaPlayStates:k,updateVisualMediaPlayState:N}=KE(),_=t.width||R_,j=t.height||O_,T=e(t),M=x.useMemo(()=>t.mediaData?t.mediaData.startsWith("data:video/"):!1,[t.mediaData]),V=x.useMemo(()=>k[t.id]||!1,[k,t.id]),H=x.useMemo(()=>T?u?It.zinc[50]:It.zinc[700]:"transparent",[T,u]),P=x.useMemo(()=>({boxShadow:T?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}),[T]),F=x.useCallback(fe=>{n.some(pe=>pe.type===J.Bloob)&&i(),d(fe)?T?s(t):r(t,!0):r(t),fe.stopPropagation()},[n,d,T,t,r,i,s]),I=x.useCallback(()=>{var fe;r(t),h&&((fe=S.current)==null||fe.click())},[t,r,h]),R=Xc({onClick:F,onDoubleClick:I}),U=x.useCallback(fe=>
754{if(!h||!fe||fe.length===0)return;const O=fe[0],pe=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml"],he=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],le=pe.includes(O.type)||O.name.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i),oe=he.includes(O.type)||O.name.match(/\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)$/i);if(le||oe){const Q=new FileReader;Q.onload=de=>{var Ce;const Ne=(Ce=de.target)==null?void 0:Ce.result;o(t.id,{mediaData:Ne}),l()},Q.readAsDataURL(O)}else alert("Please select a supported image or video file (Images: JPG, PNG, GIF, WebP, BMP, SVG | Videos: MP4, WebM, OGG, AVI, MOV, WMV, FLV, MKV)")},[h,t.id,o,l]),A=x.useCallback(fe=>{U(fe.target.files)},[U]),W=x.useCallback(fe=>{fe.preventDefault(),v(!0)},[]),D=x.useCallback(fe=>{fe.preventDefault(),v(!1)},[]),B=x.useCallback(fe=>{fe.preventDefault(),v(!1),h&&U(fe.dataTransfer.files)},[h,U]),L=x.useCallback(()=>{var fe;h&&((fe=S.current)==null||fe.click())},[h]),$=x.useCallback(()=>{o(t.id,{mediaData:""}),l()},[t.id,o,l]),q=x.useCallback(fe=>{if(fe.stopPropagation(),M&&C.current){const O=C.current;V?O.pause():O.play().catch(pe=>{})}},[M,V]);x.useEffect(()=>{const fe=C.current;if(!fe)return;const O=()=>{N(t.id,!1)},pe=()=>{N(t.id,!0)},he=()=>{N(t.id,!1)},le=()=>{fe.currentTime=0},oe=()=>{fe.paused&&fe.currentTime===0&&(fe.style.opacity="0.99",setTimeout(()=>{fe.style.opacity="1"},10))};return fe.addEventListener("pause",O),fe.addEventListener("play",pe),fe.addEventListener("ended",he),fe.addEventListener("loadedmetadata",le),fe.addEventListener("seeked",oe),fe.readyState>=1&&le(),()=>{fe.removeEventListener("pause",O),fe.removeEventListener("play",pe),fe.removeEventListener("ended",he),fe.removeEventListener("loadedmetadata",le),fe.removeEventListener("seeked",oe)}},[t.id,t.mediaData]);const{topResizeBind:Z,rightResizeBind:ie,bottomResizeBind:ge,leftResizeBind:re,topLeftResizeBind:Y,topRightResizeBind:ne,bottomRightResizeBind:be,bottomLeftResizeBind:we}=qE(t),te=x.useMemo(()=>a(t.id),[a,t]);return c.jsxs(c.Fragment,{children:[c.jsxs(et.div,{style:{width:_,height:j,borderColor:H,touchAction:"none",...P},className:"border-2 box-border rounded-lg flex flex-col relative overflow-hidden drag-handle cursor-pointer",onClick:R.onSingle,onDoubleClick:R.onDouble,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:17,duration:.2},"aria-pressed":T,"aria-label":`Visual Media: ${t.mediaData?M?"Contains video":"Contains image":"Empty"}`,children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-400/90 via-rose-400/90 to-red-600/90 dark:from-red-500/90 dark:via-rose-500/90 dark:to-red-700/90 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-white/10 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-300/30 via-rose-300/30 to-red-500/30 dark:from-red-600/30 dark:via-rose-600/30 dark:to-red-800/30 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-white/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-black/10 to-transparent rounded-b-lg"}),c.jsxs("div",{className:"relative flex flex-col h-full bg-white/95 dark:bg-zinc-900/95 rounded-lg border border-red-200/50 dark:border-red-700/50",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 rounded-t-lg relative overflow-hidden",style:{height:`${ode}px`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-red-400/20 via-rose-400/20 to-red-600/20 dark:from-red-500/20 dark:via-rose-500/20 dark:to-red-700/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-red-300/30 via-rose-300/30 to-red-500/30 dark:from-red-600/30 dark:via-rose-600/30 dark:to-red-800/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-red-200/80 to-transparent dark:via-red-600/80"}),c.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-2 w-full",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[M?c.jsx(Ul,{className:"size-3 text-red-700 dark:text-red-300 drop-shadow-sm"}):c.jsx(Gs,{className:"size-3 text-red-700 dark:text-red-300 drop-shadow-sm"}),c.jsx("span",{className:"text-sm font-semibold text-red-800 dark:text-red-200 truncate drop-shadow-sm",children:te})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[g&&c.jsx(F0,{variant:"media",className:"relative z-10 mr-1"}),t.mediaData&&c.jsx("a",{href:t.mediaData,target:"_blank",rel:"noopener noreferrer",onClick:fe=>fe.stopPropagation(),className:"relative p-1.5 rounded bg-white/20 dark:bg-white/10 backdrop-blur-sm border border-white/30 dark:border-white/20 hover:bg-white/30 dark:hover:bg-white/20 transition-colors",title:"Open media in new tab",children:c.jsx(Ch,{className:"size-3 text-red-600 dark:text-red-400 drop-shadow-sm"})})]})]})]}),c.jsx("div",{className:"flex-1 p-3 overflow-hidden",children:t.mediaData?c.jsx("div",{className:"w-full h-full overflow-hidden rounded-lg relative",children:M?c.jsxs(c.Fragment,{children:[c.jsx("video",{ref:C,src:t.mediaData,className:"w-full h-full object-contain",onError:$,controls:!1,muted:!1,loop:!0,preload:"metadata",playsInl
754ine:!0,style:{backgroundColor:"black",minHeight:"100%",minWidth:"100%"}}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsx("button",{onClick:q,className:"bg-black bg-opacity-50 text-white p-3 rounded-full hover:bg-opacity-70 transition-all",children:V?c.jsx(Zm,{className:"size-6"}):c.jsx(ka,{className:"size-6"})})})]}):c.jsx("img",{src:t.mediaData,alt:te,className:"w-full h-full object-contain",onError:$})}):c.jsx("div",{onClick:L,onDragOver:W,onDragLeave:D,onDrop:B,className:`w-full h-full flex items-center justify-center border-2 border-dashed rounded-lg transition-colors cursor-pointer ${w?"border-red-500 bg-red-100 dark:bg-red-900/20":"border-red-300 dark:border-red-600 hover:border-red-400 dark:hover:border-red-500 hover:bg-red-50 dark:hover:bg-red-900/10"}`,children:c.jsx("div",{className:"text-center text-red-600 dark:text-red-400",children:w?c.jsxs(c.Fragment,{children:[c.jsx(gx,{className:"size-6 mx-auto mb-2"}),c.jsx("p",{className:"text-sm",children:"Drop media here"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-center gap-1 mb-2",children:[c.jsx(Gs,{className:"size-5"}),c.jsx(Ul,{className:"size-5"})]}),c.jsx("p",{className:"text-sm",children:h?"Click to upload image or video":"No media uploaded"})]})})})})]}),c.jsx("input",{ref:S,type:"file",accept:"image/*,video/*",onChange:A,className:"hidden"})]}),h&&c.jsx(Nx,{topResizeBind:Z,rightResizeBind:ie,bottomResizeBind:ge,leftResizeBind:re,topLeftResizeBind:Y,topRightResizeBind:ne,bottomRightResizeBind:be,bottomLeftResizeBind:we})]})},lde=({onCaiObjectDragStart:t,onCaiObjectDrag:e,onCaiObjectDragStop:n,dragCanvasOffset:r,ghostBloob:i,copyBloobId:s,onCanvasClick:o,onCanvasDoubleClick:a,shouldShowBloobDevelopHandles:l,isSongResizing:u,onSongResizingStart:d,onSongResizingStop:f})=>{const{isDarkMode:h}=Pn(),{caiPrimary:m}=oE(),{songs:y,bloobs:g,textNodes:w,embeddingNodes:v,visualMediaNodes:S,getSongById:C,getBloobById:k,getTextNodeById:N,getEmbeddingNodeById:_,getVisualMediaNodeById:j}=mn(),{isCaiObjectSelected:T,selectedCaiObjects:M,dragMode:V}=Yn(),H=x.useCallback(()=>{o()},[o]),{clientToCanvasPosition:P}=sl(),{isMobile:F}=Hn(),I=x.useCallback(te=>{const fe={x:te.clientX,y:te.clientY},O=P(fe);a(O)},[a,P]),R=Xc({onClick:H,onDoubleClick:I}),U=x.useCallback((te,fe)=>{t(te,fe.data.caiObject)},[t]),A=x.useCallback((te,fe,O)=>{const he=O[0].position;e(te,he)},[e]),W=x.useCallback(()=>{n()},[n]),D=x.useCallback((te,fe=null)=>({type:J.Song,id:`${J.Song}-${te.id}`,position:fe?Ua(te.canvasPosition,fe):te.canvasPosition,data:{song:te,caiObject:{type:J.Song,id:te.id},onSongResizingStart:d,onSongResizingStop:f},style:{zIndex:1},measured:{width:Yv(te.bars),height:$_(te.tracks)}}),[d,f]),B=x.useCallback((te,fe=null)=>{if(!(te!=null&&te.songPosition))return null;const O={x:te.songPosition.bar*dn+Qi,y:te.songPosition.track*bn+Is+fo},pe=fe?Ua(O,fe):O;return{type:J.Bloob,id:`${J.Bloob}-${te.id}`,parentId:`${J.Song}-${te.songId}`,extent:"parent",position:pe,dragHandle:".drag-handle",data:{bloob:te,caiObject:{type:J.Bloob,id:te.id},shouldShowBloobDevelopHandles:l},style:{zIndex:1},measured:{width:te.bars*dn,height:bn}}},[l]),L=x.useCallback(()=>i?{type:"ghost bloob",id:"ghost bloob",parentId:`${J.Song}-${i.songId}`,extent:"parent",position:{x:i.songPosition.bar*dn+Qi,y:i.songPosition.track*bn+Is+fo},data:{bars:i.bars},measured:{width:i.bars*dn,height:bn}}:null,[i]),$=x.useMemo(()=>i?[L()]:[],[i,L]),q=x.useCallback((te,fe=null)=>({type:J.TextNode,id:`${J.TextNode}-${te.id}`,position:fe?Ua(te.canvasPosition,fe):te.canvasPosition,dragHandle:".drag-handle",data:{textNode:te,caiObject:{type:J.TextNode,id:te.id}},measured:{width:dn*4,height:bn*3}}),[]),Z=x.useCallback((te,fe=null)=>({type:J.EmbeddingNode,id:`${J.EmbeddingNode}-${te.id}`,position:fe?Ua(te.canvasPosition,fe):te.canvasPosition,dragHandle:".drag-handle",data:{embeddingNode:te,caiObject:{type:J.EmbeddingNode,id:te.id}},measured:{width:dn*5,height:bn*4}}),[]),ie=x.useCallback((te,fe=null)=>({type:J.VisualMediaNode,id:`${J.VisualMediaNode}-${te.id}`,position:fe?Ua(te.canvasPosition,fe):te.canvasPosition,dragHandle:".drag-handle",data:{visualMediaNode:te,caiObject:{type:J.VisualMediaNode,id:te.id}},measured:{width:dn*6,height:bn*5}}),[]),ge=x.useMemo(()=>{const te=[];
754return Object.values(y).forEach(fe=>{if(T(fe))return;const O=D(fe);te.push(O),fe.bloobIds.forEach(pe=>{const he=g[pe];if(!he||T(he))return;const le=B(he);le&&te.push(le)})}),Object.values(w).forEach(fe=>{if(T(fe))return;const O=q(fe);te.push(O)}),Object.values(v).forEach(fe=>{if(T(fe))return;const O=Z(fe);te.push(O)}),Object.values(S).forEach(fe=>{if(T(fe))return;const O=ie(fe);te.push(O)}),te},[y,w,v,S,T,D,g,B,q,Z,ie]),re=x.useMemo(()=>{if(s===null)return[];const te=k(s),fe=B(te);return!fe||!(te!=null&&te.songPosition)?[]:(fe.id=`${J.Bloob}-${te.id}-copy`,[fe])},[s,k,B]),Y=x.useMemo(()=>{const te=[];return M.forEach(fe=>{switch(fe.type){case J.Song:{const O=C(fe.id),pe=D(O,r);te.push(pe),(O.bloobIds instanceof Set?O.bloobIds:Array.from(O.bloobIds||[])).forEach(le=>{const oe=k(le);if(!oe)return;const Q=B(oe);Q&&te.push(Q)});break}case J.Bloob:{const O=k(fe.id),pe=B(O,r);pe&&te.push(pe);break}case J.TextNode:{const O=N(fe.id),pe=q(O,r);te.push(pe);break}case J.EmbeddingNode:{const O=_(fe.id),pe=Z(O,r);te.push(pe);break}case J.VisualMediaNode:{const O=j(fe.id),pe=ie(O,r);te.push(pe);break}case J.Track:break;default:throw new Error("unallowed node type")}}),te},[M,C,D,r,k,B,N,q,_,Z,j,ie]),ne=x.useMemo(()=>[...ge,...$,...re,...Y],[re,Y,$,ge]),be=x.useCallback(te=>{switch(te.type){case J.Bloob:return te.data.bloob.color;case J.Song:return It.zinc[700]+"40";case J.TextNode:return It.yellow[200];case J.EmbeddingNode:return It.blue[200];case J.VisualMediaNode:return It.red[200];case"ghost bloob":return"";default:throw new Error("unallowed node type")}},[]),we=x.useMemo(()=>({[J.Song]:te=>c.jsx(kce,{song:te.data.song,onSongResizingStart:te.data.onSongResizingStart,onSongResizingStop:te.data.onSongResizingStop}),[J.Bloob]:te=>c.jsx(ede,{bloob:te.data.bloob,shouldShowDevelopHandles:te.data.shouldShowBloobDevelopHandles}),"ghost bloob":te=>c.jsx(tde,{bars:te.data.bars}),[J.TextNode]:te=>c.jsx(nde,{textNode:te.data.textNode}),[J.EmbeddingNode]:te=>c.jsx(ide,{embeddingNode:te.data.embeddingNode}),[J.VisualMediaNode]:te=>c.jsx(ade,{visualMediaNode:te.data.visualMediaNode})}),[]);return c.jsxs(z_,{className:"relative",nodes:ne,nodeTypes:we,noDragClassName:"nodrag",selectNodesOnDrag:!1,elementsSelectable:!1,onNodeDragStart:U,onNodeDrag:A,onNodeDragStop:W,onClick:R.onSingle,onDoubleClick:R.onDouble,style:{touchAction:"manipulation"},tabIndex:0,proOptions:{hideAttribution:!0},panOnDrag:F&&V===Hs.MOVE&&!u,panOnScroll:!0,zoomOnScroll:!1,zoomOnDoubleClick:!1,zoomOnPinch:!0,deleteKeyCode:null,disableKeyboardA11y:!0,translateExtent:[[0,0],[pT.bars*dn,pT.tracks*bn]],"aria-label":"Canvas",children:[c.jsx(gK,{bgColor:m,color:h?It.zinc[700]:It.zinc[400],patternClassName:"opacity-70",variant:Al.Dots,gap:A_,size:bY}),!F&&c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{position:"absolute",bottom:135,right:10,zIndex:50},children:c.jsx(ule,{})}),c.jsx(BK,{pannable:!0,inversePan:!0,bgColor:m,maskColor:(h?It.zinc[800]:It.zinc[200])+"80",maskStrokeColor:h?It.zinc[500]:It.zinc[300],nodeColor:te=>be(te),position:"bottom-right",zoomable:!1,style:{width:140,height:100,bottom:10,right:10,border:"1px solid "+(h?It.zinc[600]:It.zinc[400]),borderRadius:"6px",opacity:.8,transition:"opacity 0.2s ease-in-out",boxShadow:h?"0 4px 6px rgba(0, 0, 0, 0.2)":"0 4px 6px rgba(0, 0, 0, 0.1)"},onMouseEnter:te=>{te.currentTarget.style.opacity="1"},onMouseLeave:te=>{te.currentTarget.style.opacity="0.8"}})]})]})};function Px(){return typeof window<"u"}function tp(t){return iL(t)?(t.nodeName||"").toLowerCase():"#document"}function yo(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ol(t){var e;return(e=(iL(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function iL(t){return Px()?t instanceof Node||t instanceof yo(t).Node:!1}function Fr(t){return Px()?t instanceof Element||t instanceof yo(t).Element:!1}function Sa(t){return Px()?t instanceof HTMLElement||t instanceof yo(t).HTMLElement:!1}function _C(t){return!Px()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof yo(t).ShadowRoot}function H0(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Fo(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function cde(t){return["table","td","th"].includes(tp(t))}function Ax(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function YE(t){const e=Mx(),n=Fr(t)?Fo(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function ude(t){let e=Hl(t);for(;Sa(e)&&!Ol(e);){if(YE(e))return e;if(Ax(e))return null;e=Hl(e)}return null}function Mx(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ol(t){return["html","body","#document"].includes(tp(t))}function Fo(t){return yo(t).getComputedStyle(t)}function Bx(t){return Fr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Hl(t){if(tp(t)==="html")return t;const e=t.assignedSlot||t.parentNode||_C(t)&&t.host||ol(t);return _C(e)?e.host:e}function sL(t){const e=Hl(t);return Ol(e)?t.ownerDocument?t.ownerDocument.body:t.body:Sa(e)&&H0(e)?e:sL(e)}function Dc(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=sL(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=yo(i);if(s){const a=EC(o);
vendor: 4,213 bytes, lines 754-757
754return e.concat(o,o.visualViewport||[],H0(i)?i:[],a&&n?Dc(a):[])}return e.concat(i,Dc(i,[],n))}function EC(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function dde(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function td(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&_C(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function fde(){return/apple/i.test(navigator.vendor)}function NC(t,e){const n=["mouse","pen"];return n.push("",void 0),n.includes(t)}function hde(t){return"nativeEvent"in t}function pde(t){return t.matches("html,body")}function zl(t){return(t==null?void 0:t.ownerDocument)||document}function Tk(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function Tf(t){return"composedPath"in t?t.composedPath()[0]:t.target}const Bh=Math.min,lo=Math.max,pv=Math.round,Cb=Math.floor,Za=t=>({x:t,y:t}),mde={left:"right",right:"left",bottom:"top",top:"bottom"},gde={start:"end",end:"start"};function PA(t,e,n){return lo(t,Bh(e,n))}function G0(t,e){return typeof t=="function"?t(e):t}function Vc(t){return t.split("-")[0]}function W0(t){return t.split("-")[1]}function oL(t){return t==="x"?"y":"x"}function aL(t){return t==="y"?"height":"width"}function fd(t){return["top","bottom"].includes(Vc(t))?"y":"x"}function lL(t){return oL(fd(t))}function bde(t,e,n){n===void 0&&(n=!1);const r=W0(t),i=lL(t),s=aL(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=mv(o)),[o,mv(o)]}function yde(t){const e=mv(t);return[IC(t),e,IC(e)]}function IC(t){return t.replace(/start|end/g,e=>gde[e])}function vde(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function xde(t,e,n,r){const i=W0(t);let s=vde(Vc(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(IC)))),s}function mv(t){return t.replace(/left|right|bottom|top/g,e=>mde[e])}function wde(t){return{top:0,right:0,bottom:0,left:0,...t}}function kde(t){return typeof t!="number"?wde(t):{top:t,right:t,bottom:t,left:t}}function gv(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}/*! 755* tabbable 6.2.0 756* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE 757*/var Sde=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],jC=Sde.join(","),cL=typeof Element>"u",a0=cL?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,bv=!cL&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},yv=function t(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),s=i===""||i==="true",o=s||n&&e&&t(e.parentNode);return o},Cde=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},_de=function(e,n,r){if(yv(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(jC));return n&&a0.call(e,jC)&&i.unshift(e),i=i.filter(r),i},Ede=function t(e,n,r){for(var i=[],s=Array.from(e);s.length;){var o=s.shift();if(!yv(o,!1))if(o.tagName==="SLOT"){var a=o.assignedElements(),l=a.length?a:o.children,u=t(l,!0,r);r.flatten?i.push.apply(i,u):i.push({scopeParent:o,candidates:u})}else{var d=a0.call(o,jC);d&&r.filter(o)&&(n||!e.includes(o))&&i.push(o);var f=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),h=!yv(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o
vendor: 3,433 bytes, line 757
757));if(f&&h){var m=t(f===!0?o.children:f.children,!0,r);r.flatten?i.push.apply(i,m):i.push({scopeParent:o,candidates:m})}else s.unshift.apply(s,o.children)}}return i},uL=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},dL=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Cde(e))&&!uL(e)?0:e.tabIndex},Nde=function(e,n){var r=dL(e);return r<0&&n&&!uL(e)?0:r},Ide=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},fL=function(e){return e.tagName==="INPUT"},jde=function(e){return fL(e)&&e.type==="hidden"},Tde=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},zde=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},Pde=function(e){if(!e.name)return!0;var n=e.form||bv(e),r=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var s=zde(i,e.form);return!s||s===e},Ade=function(e){return fL(e)&&e.type==="radio"},Mde=function(e){return Ade(e)&&!Pde(e)},Bde=function(e){var n,r=e&&bv(e),i=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==e){var o,a,l;for(s=!!((o=i)!==null&&o!==void 0&&(a=o.ownerDocument)!==null&&a!==void 0&&a.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!s&&i;){var u,d,f;r=bv(i),i=(u=r)===null||u===void 0?void 0:u.host,s=!!((d=i)!==null&&d!==void 0&&(f=d.ownerDocument)!==null&&f!==void 0&&f.contains(i))}}return s},AA=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},Rde=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(getComputedStyle(e).visibility==="hidden")return!0;var s=a0.call(e,"details>summary:first-of-type"),o=s?e.parentElement:e;if(a0.call(o,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof i=="function"){for(var a=e;e;){var l=e.parentElement,u=bv(e);if(l&&!l.shadowRoot&&i(l)===!0)return AA(e);e.assignedSlot?e=e.assignedSlot:!l&&u!==e.ownerDocument?e=u.host:e=l}e=a}if(Bde(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return AA(e);return!1},Ode=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return a0.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},Dde=function(e,n){return!(n.disabled||yv(n)||jde(n)||Rde(n,e)||Tde(n)||Ode(n))},MA=function(e,n){return!(Mde(n)||dL(n)<0||!Dde(e,n))},Lde=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Fde=function t(e){var n=[],r=[];return e.forEach(function(i,s){var o=!!i.scopeParent,a=o?i.scopeParent:i,l=Nde(a,o),u=o?t(i.candidates):a;l===0?o?n.push.apply(n,u):n.push(a):r.push({documentOrder:s,tabIndex:l,item:i,isScope:o,content:u})}),r.sort(Ide).reduce(function(i,s){return s.isScope?i.push.apply(i,s.content):i.push(s.content),i},[]).concat(n)}
vendor: 4,174 bytes, line 757
757,hL=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Ede([e],n.includeContainer,{filter:MA.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Lde}):r=_de(e,n.includeContainer,MA.bind(null,n)),Fde(r)};function BA(t,e,n){let{reference:r,floating:i}=t;const s=fd(e),o=lL(e),a=aL(o),l=Vc(e),u=s==="y",d=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:d,y:r.y-i.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}switch(W0(e)){case"start":m[o]-=h*(n&&u?-1:1);break;case"end":m[o]+=h*(n&&u?-1:1);break}return m}const $de=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:f}=BA(u,r,l),h=r,m={},y=0;for(let g=0;g<a.length;g++){const{name:w,fn:v}=a[g],{x:S,y:C,data:k,reset:N}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:u,platform:o,elements:{reference:t,floating:e}});d=S??d,f=C??f,m={...m,[w]:{...m[w],...k}},N&&y<=50&&(y++,typeof N=="object"&&(N.placement&&(h=N.placement),N.rects&&(u=N.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):N.rects),{x:d,y:f}=BA(u,h,l)),g=-1)}return{x:d,y:f,placement:h,strategy:i,middlewareData:m}};async function XE(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=G0(e,t),y=kde(m),w=a[h?f==="floating"?"reference":"floating":f],v=gv(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),S=f==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},N=gv(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:C,strategy:l}):S);return{top:(v.top-N.top+y.top)/k.y,bottom:(N.bottom-v.bottom+y.bottom)/k.y,left:(v.left-N.left+y.left)/k.x,right:(N.right-v.right+y.right)/k.x}}const Ude=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:u}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0,...w}=G0(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Vc(i),S=fd(a),C=Vc(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),N=h||(C||!g?[mv(a)]:yde(a)),_=y!=="none";!h&&_&&N.push(...xde(a,g,y,k));const j=[a,...N],T=await XE(e,w),M=[];let V=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(T[v]),f){const I=bde(i,o,k);M.push(T[I[0]],T[I[1]])}if(V=[...V,{placement:i,overflows:M}],!M.every(I=>I<=0)){var H,P;const I=(((H=s.flip)==null?void 0:H.index)||0)+1,R=j[I];if(R)return{data:{index:I,overflows:V},reset:{placement:R}};let U=(P=V.filter(A=>A.overflows[0]<=0).sort((A,W)=>A.overflows[1]-W.overflows[1])[0])==null?void 0:P.placement;if(!U)switch(m){case"bestFit":{var F;const A=(F=V.filter(W=>{if(_){const D=fd(W.placement);return D===S||D==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(D=>D>0).reduce((D,B)=>D+B,0)]).sort((W,D)=>W[1]-D[1])[0])==null?void 0:F[0];A&&(U=A);break}case"initialPlacement":U=a;break}if(i!==U)return{reset:{placement:U}}}return{}}}};async function Vde(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Vc(n),a=W0(n),l=fd(n)==="y",u=["left","top"].includes(o)?-1:1,d=s&&l?-1:1,f=G0(e,t);let{mainAxis:h,crossAxis:m,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}
vendor: 2,491 bytes, line 757
757:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof y=="number"&&(m=a==="end"?y*-1:y),l?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const Hde=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await Vde(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},Gde=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:w=>{let{x:v,y:S}=w;return{x:v,y:S}}},...l}=G0(t,e),u={x:n,y:r},d=await XE(e,l),f=fd(Vc(i)),h=oL(f);let m=u[h],y=u[f];if(s){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",S=m+d[w],C=m-d[v];m=PA(S,m,C)}if(o){const w=f==="y"?"top":"left",v=f==="y"?"bottom":"right",S=y+d[w],C=y-d[v];y=PA(S,y,C)}const g=a.fn({...e,[h]:m,[f]:y});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:s,[f]:o}}}}}},Wde=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...u}=G0(t,e),d=await XE(e,u),f=Vc(i),h=W0(i),m=fd(i)==="y",{width:y,height:g}=s.floating;let w,v;f==="top"||f==="bottom"?(w=f,v=h===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,w=h==="end"?"top":"bottom");const S=g-d.top-d.bottom,C=y-d.left-d.right,k=Bh(g-d[w],S),N=Bh(y-d[v],C),_=!e.middlewareData.shift;let j=k,T=N;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(T=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(j=S),_&&!h){const V=lo(d.left,0),H=lo(d.right,0),P=lo(d.top,0),F=lo(d.bottom,0);m?T=y-2*(V!==0||H!==0?V+H:lo(d.left,d.right)):j=g-2*(P!==0||F!==0?P+F:lo(d.top,d.bottom))}await l({...e,availableWidth:T,availableHeight:j});const M=await o.getDimensions(a.floating);return y!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function pL(t){const e=Fo(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Sa(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=pv(n)!==s||pv(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function QE(t){return Fr(t)?t:t.contextElement}function eh(t){const e=QE(t);if(!Sa(e))return Za(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=pL(e);let o=(s?pv(n.width):n.width)/r,a=(s?pv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const qde=Za(0);function mL(t){const e=yo(t);
vendor: 6,627 bytes, line 757
757return!Mx()||!e.visualViewport?qde:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Kde(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==yo(t)?!1:e}function hd(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=QE(t);let o=Za(1);e&&(r?Fr(r)&&(o=eh(r)):o=eh(t));const a=Kde(s,n,r)?mL(s):Za(0);let l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,d=i.width/o.x,f=i.height/o.y;if(s){const h=yo(s),m=r&&Fr(r)?yo(r):r;let y=h,g=EC(y);for(;g&&r&&m!==y;){const w=eh(g),v=g.getBoundingClientRect(),S=Fo(g),C=v.left+(g.clientLeft+parseFloat(S.paddingLeft))*w.x,k=v.top+(g.clientTop+parseFloat(S.paddingTop))*w.y;l*=w.x,u*=w.y,d*=w.x,f*=w.y,l+=C,u+=k,y=yo(g),g=EC(y)}}return gv({width:d,height:f,x:l,y:u})}function ZE(t,e){const n=Bx(t).scrollLeft;return e?e.left+n:hd(ol(t)).left+n}function gL(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:ZE(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function Yde(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=ol(r),a=e?Ax(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Za(1);const d=Za(0),f=Sa(r);if((f||!f&&!s)&&((tp(r)!=="body"||H0(o))&&(l=Bx(r)),Sa(r))){const m=hd(r);u=eh(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=o&&!f&&!s?gL(o,l,!0):Za(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Xde(t){return Array.from(t.getClientRects())}function Qde(t){const e=ol(t),n=Bx(t),r=t.ownerDocument.body,i=lo(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=lo(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+ZE(t);const a=-n.scrollTop;return Fo(r).direction==="rtl"&&(o+=lo(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function Zde(t,e){const n=yo(t),r=ol(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=Mx();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function Jde(t,e){const n=hd(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Sa(t)?eh(t):Za(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,u=r*s.y;return{width:o,height:a,x:l,y:u}}function RA(t,e,n){let r;if(e==="viewport")r=Zde(t,n);else if(e==="document")r=Qde(ol(t));else if(Fr(e))r=Jde(e,n);else{const i=mL(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return gv(r)}function bL(t,e){const n=Hl(t);return n===e||!Fr(n)||Ol(n)?!1:Fo(n).position==="fixed"||bL(n,e)}function efe(t,e){const n=e.get(t);if(n)return n;let r=Dc(t,[],!1).filter(a=>Fr(a)&&tp(a)!=="body"),i=null;const s=Fo(t).position==="fixed";let o=s?Hl(t):t;for(;Fr(o)&&!Ol(o);){const a=Fo(o),l=YE(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||H0(o)&&!l&&bL(t,o))?r=r.filter(d=>d!==o):i=a,o=Hl(o)}return e.set(t,r),r}function tfe(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Ax(e)?[]:efe(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((u,d)=>{const f=RA(e,d,i);return u.top=lo(f.top,u.top),u.right=Bh(f.right,u.right),u.bottom=Bh(f.bottom,u.bottom),u.left=lo(f.left,u.left),u},RA(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function nfe(t){const{width:e,height:n}=pL(t);return{width:e,height:n}}function rfe(t,e,n){const r=Sa(e),i=ol(e),s=n==="fixed",o=hd(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Za(0);if(r||!r&&!s)if((tp(e)!=="body"||H0(i))&&(a=Bx(e)),r){const h=hd(e,!0,s,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&(l.x=ZE(i));const u=i&&!r&&!s?gL(i,a):Za(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function zk(t){return Fo(t).position==="static"}function OA(t,e){if(!Sa(t)||Fo(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ol(t)===n&&(n=n.ownerDocument.body),n}function yL(t,e){const n=yo(t);if(Ax(t))return n;if(!Sa(t)){let i=Hl(t);for(;i&&!Ol(i);){if(Fr(i)&&!zk(i))return i;i=Hl(i)}return n}let r=OA(t,e);for(;r&&cde(r)&&zk(r);)r=OA(r,e);return r&&Ol(r)&&zk(r)&&!YE(r)?n:r||ude(t)||n}const ife=async function(t){const e=this.getOffsetParent||yL,n=this.getDimensions,r=await n(t.floating);return{reference:rfe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sfe(t){return Fo(t).direction==="rtl"}const ofe={convertOffsetParentRelativeRectToViewportRelativeRect:Yde,getDocumentElement:ol,getClippingRect:tfe,getOffsetParent:yL,getElementRects:ife,getClientRects:Xde,getDimensions:nfe,getScale:eh,isElement:Fr,isRTL:sfe};function vL(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function afe(t,e){let n=null,r;const i=ol(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=t.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||e(),!h||!m)return;const y=Cb(f),g=Cb(i.clientWidth-(d+h)),w=Cb(i.clientHeight-(f+m)),v=Cb(d),C={rootMargin:-y+"px "+-g+"px "+-w+"px "+-v+"px",threshold:lo(0,Bh(1,l))||1};let k=!0;function N(_){const j=_[0].intersectionRatio;if(j!==l){if(!k)return o();j?o(!1,j):r=setTimeout(()=>{o(!1,1e-7)},1e3)}j===1&&!vL(u,t.getBoundingClientRect())&&o(),k=!1}try{n=new IntersectionObserver(N,{...C,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,C)}n.observe(t)}return o(!0),s}function xL(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=QE(t),d=i||s?[...u?Dc(u):[],...Dc(e)]:[];d.forEach(v=>{i&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?afe(u,n):null;let h=-1,m=null;o&&(m=new ResizeObserver(v=>{let[S]=v;S&&S.target===u&&m&&(m.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=m)==null||C.observe(e)})),n()}),u&&!l&&m.observe(u),m.observe(e));let y,g=l?hd(t):null;l&&w();function w(){const v=hd(t);g&&!vL(g,v)&&n(),g=v,y=requestAnimationFrame(w)}return n(),()=>{var v;d.forEach(S=>{i&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),f==null||f(),(v=m)==null||v.disconnect(),m=null,l&&cancelAnimationFrame(y)}}const lfe=Hde,cfe=Gde,ufe=Ude,dfe=Wde,ffe=(t,e,n)=>{const r=new Map,i={platform:ofe,...n},s={...i.platform,_c:r};return $de(t,e,{...i,platform:s})};var xy=typeof document<"u"?x.useLayoutEffect:x.useEffect;function vv(t,e){if(t===e)return!0;
757if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!vv(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!vv(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function wL(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function DA(t,e){const n=wL(t);return Math.round(e*n)/n}function Pk(t){const e=x.useRef(t);return xy(()=>{e.current=t}),e}function hfe(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:u}=t,[d,f]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,m]=x.useState(r);vv(h,r)||m(r);const[y,g]=x.useState(null),[w,v]=x.useState(null),S=x.useCallback(W=>{W!==_.current&&(_.current=W,g(W))},[]),C=x.useCallback(W=>{W!==j.current&&(j.current=W,v(W))},[]),k=s||y,N=o||w,_=x.useRef(null),j=x.useRef(null),T=x.useRef(d),M=l!=null,V=Pk(l),H=Pk(i),P=Pk(u),F=x.useCallback(()=>{if(!_.current||!j.current)return;const W={placement:e,strategy:n,middleware:h};H.current&&(W.platform=H.current),ffe(_.current,j.current,W).then(D=>{const B={...D,isPositioned:P.current!==!1};I.current&&!vv(T.current,B)&&(T.current=B,Vh.flushSync(()=>{f(B)}))})},[h,e,n,H,P]);xy(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(W=>({...W,isPositioned:!1})))},[u]);const I=x.useRef(!1);xy(()=>(I.current=!0,()=>{I.current=!1}),[]),xy(()=>{if(k&&(_.current=k),N&&(j.current=N),k&&N){if(V.current)return V.current(k,N,F);F()}},[k,N,F,V,M]);const R=x.useMemo(()=>({reference:_,floating:j,setReference:S,setFloating:C}),[S,C]),U=x.useMemo(()=>({reference:k,floating:N}),[k,N]),A=x.useMemo(()=>{const W={position:n,left:0,top:0};if(!U.floating)return W;const D=DA(U.floating,d.x),B=DA(U.floating,d.y);return a?{...W,transform:"translate("+D+"px, "+B+"px)",...wL(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:B}},[n,a,U.floating,d.x,d.y]);return x.useMemo(()=>({...d,update:F,refs:R,elements:U,floatingStyles:A}),[d,F,R,U,A])}const kL=(t,e)=>({...lfe(t),options:[t,e]}),pfe=(t,e)=>({...cfe(t),options:[t,e]}),mfe=(t,e)=>({...ufe(t),options:[t,e]}),gfe=(t,e)=>({...dfe(t),options:[t,e]}),SL={...T$},bfe=SL.useInsertionEffect,yfe=bfe||(t=>t());function El(t){const e=x.useRef(()=>{});return yfe(()=>{e.current=t}),x.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}var Ja=typeof document<"u"?x.useLayoutEffect:x.useEffect;let LA=!1,vfe=0;const FA=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+vfe++;function xfe(){const[t,e]=x.useState(()=>LA?FA():void 0);return Ja(()=>{t==null&&e(FA())},[]),x.useEffect(()=>{LA=!0},[]),t}const wfe=SL.useId,Rx=wfe||xfe;function kfe(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.set(e,[...t.get(e)||[],n])},off(e,n){var r;t.set(e,((r=t.get(e))==null?void 0:r.filter(i=>i!==n))||[])}}}const Sfe=x.createContext(null),Cfe=x.createContext(null),JE=()=>{var t;return((t=x.useContext(Sfe))==null?void 0:t.id)||null},eN=()=>x.useContext(Cfe);function Ox(t){return"data-floating-ui-"+t}function ea(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}function Ak(t){const e=x.useRef(t);return Ja(()=>{e.current=t}),e}const $A=Ox("safe-polygon");function Mk(t,e,n){return n&&!NC(n)?0:typeof t=="number"?t:t==null?void 0:t[e]}function _fe(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:i,events:s,elements:o}=t,{enabled:a=!0,delay:l=0,handleClose:u=null,mouseOnly:d=!1,restMs:f=0,move:h=!0}=e,m=eN(),y=JE(),g=Ak(u),w=Ak(l),v=Ak(n),S=x.useRef(),C=x.useRef(-1),k=x.useRef(),N=x.useRef(-1),_=x.useRef(!0),j=x.useRef(!1),T=x.useRef(()=>{}),M=x.useRef(!1),V=x.useCallback(()=>{var A;const W=(A=i.current.openEvent)==null?void 0:A.type;return(W==null?void 0:W.includes("mouse"))&&W!=="mousedown"},[i]);x.useEffect(()=>{if(!a)return;function A(W){let{open:D}=W;D||(ea(C),ea(N),_.current=!0,M.current=!1)}return s.on("openchange",A),()=>{s.off("openchange",A)}},[a,s]),x.useEffect(()=>{if(!a||!g.current||!n)return;function A(D){V()&&r(!1,D,"hover")}const W=zl(o.floating).documentElement;return W.addEventListener("mouseleave",A),()=>{W.removeEventListener("mouseleave",A)}},[o.floating,n,r,a,g,V]);const H=x.useCallback(function(A,W,D){W===void 0&&(W=!0),D===void 0&&(D="hover");
757const B=Mk(w.current,"close",S.current);B&&!k.current?(ea(C),C.current=window.setTimeout(()=>r(!1,A,D),B)):W&&(ea(C),r(!1,A,D))},[w,r]),P=El(()=>{T.current(),k.current=void 0}),F=El(()=>{if(j.current){const A=zl(o.floating).body;A.style.pointerEvents="",A.removeAttribute($A),j.current=!1}}),I=El(()=>i.current.openEvent?["click","mousedown"].includes(i.current.openEvent.type):!1);x.useEffect(()=>{if(!a)return;function A(L){if(ea(C),_.current=!1,d&&!NC(S.current)||f>0&&!Mk(w.current,"open"))return;const $=Mk(w.current,"open",S.current);$?C.current=window.setTimeout(()=>{v.current||r(!0,L,"hover")},$):n||r(!0,L,"hover")}function W(L){if(I())return;T.current();const $=zl(o.floating);if(ea(N),M.current=!1,g.current&&i.current.floatingContext){n||ea(C),k.current=g.current({...i.current.floatingContext,tree:m,x:L.clientX,y:L.clientY,onClose(){F(),P(),I()||H(L,!0,"safe-polygon")}});const Z=k.current;$.addEventListener("mousemove",Z),T.current=()=>{$.removeEventListener("mousemove",Z)};return}(S.current==="touch"?!td(o.floating,L.relatedTarget):!0)&&H(L)}function D(L){I()||i.current.floatingContext&&(g.current==null||g.current({...i.current.floatingContext,tree:m,x:L.clientX,y:L.clientY,onClose(){F(),P(),I()||H(L)}})(L))}if(Fr(o.domReference)){var B;const L=o.domReference;return n&&L.addEventListener("mouseleave",D),(B=o.floating)==null||B.addEventListener("mouseleave",D),h&&L.addEventListener("mousemove",A,{once:!0}),L.addEventListener("mouseenter",A),L.addEventListener("mouseleave",W),()=>{var $;n&&L.removeEventListener("mouseleave",D),($=o.floating)==null||$.removeEventListener("mouseleave",D),h&&L.removeEventListener("mousemove",A),L.removeEventListener("mouseenter",A),L.removeEventListener("mouseleave",W)}}},[o,a,t,d,f,h,H,P,F,r,n,v,m,w,g,i,I]),Ja(()=>{var A;if(a&&n&&(A=g.current)!=null&&A.__options.blockPointerEvents&&V()){j.current=!0;const D=o.floating;if(Fr(o.domReference)&&D){var W;const B=zl(o.floating).body;B.setAttribute($A,"");const L=o.domReference,$=m==null||(W=m.nodesRef.current.find(q=>q.id===y))==null||(W=W.context)==null?void 0:W.elements.floating;return $&&($.style.pointerEvents=""),B.style.pointerEvents="none",L.style.pointerEvents="auto",D.style.pointerEvents="auto",()=>{B.style.pointerEvents="",L.style.pointerEvents="",D.style.pointerEvents=""}}}},[a,n,y,o,m,g,V]),Ja(()=>{n||(S.current=void 0,M.current=!1,P(),F())},[n,P,F]),x.useEffect(()=>()=>{P(),ea(C),ea(N),F()},[a,o.domReference,P,F]);const R=x.useMemo(()=>{function A(W){S.current=W.pointerType}return{onPointerDown:A,onPointerEnter:A,onMouseMove(W){const{nativeEvent:D}=W;function B(){!_.current&&!v.current&&r(!0,D,"hover")}d&&!NC(S.current)||n||f===0||M.current&&W.movementX**2+W.movementY**2<2||(ea(N),S.current==="touch"?B():(M.current=!0,N.current=window.setTimeout(B,f)))}}},[d,r,n,v,f]),U=x.useMemo(()=>({onMouseEnter(){ea(C)},onMouseLeave(A){I()||H(A.nativeEvent,!1)}}),[H,I]);return x.useMemo(()=>a?{reference:R,floating:U}:{},[a,R,U])}function wy(t,e){let n=t.filter(i=>{var s;return i.parentId===e&&((s=i.context)==null?void 0:s.open)}),r=n;for(;r.length;)r=t.filter(i=>{var s;return(s=r)==null?void 0:s.some(o=>{var a;return i.parentId===o.id&&((a=i.context)==null?void 0:a.open)})}),n=n.concat(r);return n}const CL=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function _L(t,e){const n=hL(t,CL());e==="prev"&&n.reverse();const r=n.indexOf(dde(zl(t)));return n.slice(r+1)[0]}function Efe(t){return _L(zl(t).body,"next")||t}function Nfe(t){return _L(zl(t).body,"prev")||t}function Bk(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!td(n,r)}function Ife(t){hL(t,CL()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function UA(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const EL={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},VA=x.forwardRef(function(e,n){const[r,i]=x.useState();Ja(()=>{fde()&&i("button")},[]);const s={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Ox("focus-guard")]:"",style:EL};return c.jsx("span",{...e,...s})}),NL=x.createContext(null),HA=Ox("portal");function jfe(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Rx(),i=zfe(),[s,o]=x.useState(null),a=x.useRef(null);return Ja(()=>()=>{s==null||s.remove(),queueMicrotask(()=>{a.current=null})},[s]),Ja(()=>
757{if(!r||a.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(HA,""),l.appendChild(u),a.current=u,o(u)},[e,r]),Ja(()=>{if(n===null||!r||a.current)return;let l=n||(i==null?void 0:i.portalNode);l&&!Fr(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const d=document.createElement("div");d.id=r,d.setAttribute(HA,""),l=u||l,l.appendChild(d),a.current=d,o(d)},[e,n,r,i]),s}function Tfe(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,s=jfe({id:n,root:r}),[o,a]=x.useState(null),l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),f=x.useRef(null),h=o==null?void 0:o.modal,m=o==null?void 0:o.open,y=!!o&&!o.modal&&o.open&&i&&!!(r||s);return x.useEffect(()=>{if(!s||!i||h)return;function g(w){s&&Bk(w)&&(w.type==="focusin"?UA:Ife)(s)}return s.addEventListener("focusin",g,!0),s.addEventListener("focusout",g,!0),()=>{s.removeEventListener("focusin",g,!0),s.removeEventListener("focusout",g,!0)}},[s,i,h]),x.useEffect(()=>{s&&(m||UA(s))},[m,s]),c.jsxs(NL.Provider,{value:x.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:d,afterInsideRef:f,portalNode:s,setFocusManagerState:a}),[i,s]),children:[y&&s&&c.jsx(VA,{"data-type":"outside",ref:l,onFocus:g=>{if(Bk(g,s)){var w;(w=d.current)==null||w.focus()}else{const v=o?o.domReference:null,S=Nfe(v);S==null||S.focus()}}}),y&&s&&c.jsx("span",{"aria-owns":s.id,style:EL}),s&&Vh.createPortal(e,s),y&&s&&c.jsx(VA,{"data-type":"outside",ref:u,onFocus:g=>{if(Bk(g,s)){var w;(w=f.current)==null||w.focus()}else{const v=o?o.domReference:null,S=Efe(v);S==null||S.focus(),o!=null&&o.closeOnFocusOut&&(o==null||o.onOpenChange(!1,g.nativeEvent,"focus-out"))}}})]})}const zfe=()=>x.useContext(NL),Pfe="data-floating-ui-focusable",Afe={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Mfe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},GA=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t==null?void 0:t.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t==null?void 0:t.outsidePress)!=null?n:!0}};function Bfe(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:s}=t,{enabled:o=!0,escapeKey:a=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:d=!1,referencePressEvent:f="pointerdown",ancestorScroll:h=!1,bubbles:m,capture:y}=e,g=eN(),w=El(typeof l=="function"?l:()=>!1),v=typeof l=="function"?w:l,S=x.useRef(!1),C=x.useRef(!1),{escapeKey:k,outsidePress:N}=GA(m),{escapeKey:_,outsidePress:j}=GA(y),T=x.useRef(!1),M=El(R=>{var U;if(!n||!o||!a||R.key!=="Escape"||T.current)return;const A=(U=s.current.floatingContext)==null?void 0:U.nodeId,W=g?wy(g.nodesRef.current,A):[];if(!k&&(R.stopPropagation(),W.length>0)){let D=!0;if(W.forEach(B=>{var L;if((L=B.context)!=null&&L.open&&!B.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}r(!1,hde(R)?R.nativeEvent:R,"escape-key")}),V=El(R=>{var U;const A=()=>{var W;M(R),(W=Tf(R))==null||W.removeEventListener("keydown",A)};(U=Tf(R))==null||U.addEventListener("keydown",A)}),H=El(R=>{var U;const A=S.current;S.current=!1;const W=C.current;if(C.current=!1,u==="click"&&W||A||typeof v=="function"&&!v(R))return;const D=Tf(R),B="["+Ox("inert")+"]",L=zl(i.floating).querySelectorAll(B);let $=Fr(D)?D:null;for(;$&&!Ol($);){const ge=Hl($);if(Ol(ge)||!Fr(ge))break;$=ge}if(L.length&&Fr(D)&&!pde(D)&&!td(D,i.floating)&&Array.from(L).every(ge=>!td($,ge)))return;if(Sa(D)&&I){const ge=Ol(D),re=Fo(D),Y=/auto|scroll/,ne=ge||Y.test(re.overflowX),be=ge||Y.test(re.overflowY),we=ne&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,te=be&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,fe=re.direction==="rtl",O=te&&(fe?R.offsetX<=D.offsetWidth-D.clientWidth:R.offsetX>D.clientWidth),pe=we&&R.offsetY>D.clientHeight;if(O||pe)return}const q=(U=s.current.floatingContext)==null?void 0:U.nodeId,Z=g&&wy(g.nodesRef.current,q).some(ge=>{var re;return Tk(R,(re=ge.context)==null?void 0:re.elements.floating)});if(Tk(R,i.floating)||Tk(R,i.domReference)||Z)return;const ie=g?wy(g.nodesRef.current,q):[];if(ie.length>0){let ge=!0;if(ie.forEach(re=>{var Y;if((Y=re.context)!=null&&Y.open&&!re.context.dataRef.current.__outsidePressBubbles){ge=!1;return}}),!ge)return}r(!1,R,"outside-press")}),P=El(R=>{var U;const A=()=>{var W;H(R),(W=Tf(R))==null||W.removeEventListener(u,A)};(U=Tf(R))==null||U.addEventListener(u,A)});x.useEffect(()=>{if(!n||!o)return;s.current.__escapeKeyBubbles=k,s.current.__outsidePressBubbles=N;let R=-1;function U(L){r(!1,L,"ancestor-scroll")}function A(){window.clearTimeout(R),T.current=!0}function W(){R=window.setTimeout(()=>{T.current=!1},Mx()?5:0)}const D=zl(i.floating);a&&(D.addEventListener("keydown",_?V:M,_),D.addEventListener("compositionstart",A),D.addEventListener("compositionend",W)),v&&D.addEventListener(u,j?P:H,j);let B=[];return h&&(Fr(i.domReference)&&(B=Dc(i.domReference)),Fr(i.floating)&&(B=B.concat(Dc(i.floating))),!Fr(i.reference)&&i.reference&&i.reference.contextElement&&(B=B.concat(Dc(i.reference.contextElement)))),B=B.filter(L=>{var $;
757return L!==(($=D.defaultView)==null?void 0:$.visualViewport)}),B.forEach(L=>{L.addEventListener("scroll",U,{passive:!0})}),()=>{a&&(D.removeEventListener("keydown",_?V:M,_),D.removeEventListener("compositionstart",A),D.removeEventListener("compositionend",W)),v&&D.removeEventListener(u,j?P:H,j),B.forEach(L=>{L.removeEventListener("scroll",U)}),window.clearTimeout(R)}},[s,i,a,v,u,n,r,h,o,k,N,M,_,V,H,j,P]),x.useEffect(()=>{S.current=!1},[v,u]);const F=x.useMemo(()=>({onKeyDown:M,...d&&{[Afe[f]]:R=>{r(!1,R.nativeEvent,"reference-press")},...f!=="click"&&{onClick(R){r(!1,R.nativeEvent,"reference-press")}}}}),[M,r,d,f]),I=x.useMemo(()=>({onKeyDown:M,onMouseDown(){C.current=!0},onMouseUp(){C.current=!0},[Mfe[u]]:()=>{S.current=!0}}),[M,u]);return x.useMemo(()=>o?{reference:F,floating:I}:{},[o,F,I])}function Rfe(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=Rx(),s=x.useRef({}),[o]=x.useState(()=>kfe()),a=JE()!=null,[l,u]=x.useState(r.reference),d=El((m,y,g)=>{s.current.openEvent=m?y:void 0,o.emit("openchange",{open:m,event:y,reason:g,nested:a}),n==null||n(m,y,g)}),f=x.useMemo(()=>({setPositionReference:u}),[]),h=x.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return x.useMemo(()=>({dataRef:s,open:e,onOpenChange:d,elements:h,events:o,floatingId:i,refs:f}),[e,d,h,o,i,f])}function IL(t){t===void 0&&(t={});const{nodeId:e}=t,n=Rfe({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[s,o]=x.useState(null),[a,l]=x.useState(null),d=(i==null?void 0:i.domReference)||s,f=x.useRef(null),h=eN();Ja(()=>{d&&(f.current=d)},[d]);const m=hfe({...t,elements:{...i,...a&&{reference:a}}}),y=x.useCallback(C=>{const k=Fr(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),getClientRects:()=>C.getClientRects(),contextElement:C}:C;l(k),m.refs.setReference(k)},[m.refs]),g=x.useCallback(C=>{(Fr(C)||C===null)&&(f.current=C,o(C)),(Fr(m.refs.reference.current)||m.refs.reference.current===null||C!==null&&!Fr(C))&&m.refs.setReference(C)},[m.refs]),w=x.useMemo(()=>({...m.refs,setReference:g,setPositionReference:y,domReference:f}),[m.refs,g,y]),v=x.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),S=x.useMemo(()=>({...m,...r,refs:w,elements:v,nodeId:e}),[m,w,v,e,r]);return Ja(()=>{r.dataRef.current.floatingContext=S;const C=h==null?void 0:h.nodesRef.current.find(k=>k.id===e);C&&(C.context=S)}),x.useMemo(()=>({...m,context:S,refs:w,elements:v}),[m,w,v,S])}const WA="active",qA="selected";function Rk(t,e,n){const r=new Map,i=n==="item";let s=t;if(i&&t){const{[WA]:o,[qA]:a,...l}=t;s=l}return{...n==="floating"&&{tabIndex:-1,[Pfe]:""},...s,...e.map(o=>{const a=o?o[n]:null;return typeof a=="function"?t?a(t):null:a}).concat(t).reduce((o,a)=>(a&&Object.entries(a).forEach(l=>{let[u,d]=l;if(!(i&&[WA,qA].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),o[u]=function(){for(var h,m=arguments.length,y=new Array(m),g=0;g<m;g++)y[g]=arguments[g];return(h=r.get(u))==null?void 0:h.map(w=>w(...y)).find(w=>w!==void 0)}}}else o[u]=d}),o),{})}}function Ofe(t){t===void 0&&(t=[]);const e=t.map(a=>a==null?void 0:a.reference),n=t.map(a=>a==null?void 0:a.floating),r=t.map(a=>a==null?void 0:a.item),i=x.useCallback(a=>Rk(a,t,"reference"),e),s=x.useCallback(a=>Rk(a,t,"floating"),n),o=x.useCallback(a=>Rk(a,t,"item"),r);return x.useMemo(()=>({getReferenceProps:i,getFloatingProps:s,getItemProps:o}),[i,s,o])}const Dfe=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Lfe(t,e){var n;e===void 0&&(e={});const{open:r,floatingId:i}=t,{enabled:s=!0,role:o="dialog"}=e,a=(n=Dfe.get(o))!=null?n:o,l=Rx(),d=JE()!=null,f=x.useMemo(()=>a==="tooltip"||o==="label"?{["aria-"+(o==="label"?"labelledby":"describedby")]:r?i:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":a==="alertdialog"?"dialog":a,"aria-controls":r?i:void 0,...a==="listbox"&&{role:"combobox"},...a==="menu"&&{id:l},...a==="menu"&&d&&{role:"menuitem"},...o==="select"&&{"aria-autocomplete":"none"},...o==="combobox"&&{"aria-autocomplete":"list"}},[a,i,d,r,l,o]),h=x.useMemo(()=>{const y={id:i,...a&&{role:a}};return a==="tooltip"||o==="label"?y:{...y,...a==="menu"&&{"aria-labelledby":l}}},[a,i,l,o]),m=x.useCallback(y=>{let{active:g,selected:w}=y;const v={role:"option",...g&&{id:i+"-option"}};switch(o){case"select":return{...v,"aria-selected":g&&w};case"combobox":return{...v,...g&&{"aria-selected":!0}}}return{}},[i,o]);return x.useMemo(()=>s?{reference:f,floating:h,item:m}:{},[s,f,h,m])}function KA(t,e){const[n,r]=t;let i=!1;const s=e.length;for(let o=0,a=s-1;o<s;a=o++){const[l,u]=e[o]||[0,0],[d,f]=e[a]||[0,0];u>=r!=f>=r&&n<=(d-l)*(r-u)/(f-u)+l&&(i=!i)}return i}function Ffe(t,e){return t[0]>=e.x&&t[0]<=e.x+e.width&&t[1]>=e.y&&t[1]<=e.y+e.height}function $fe(t){t===void 0&&(t={});const{buffer:e=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=t;let i,s=!1,o=null,a=null,l=performance.now();function u(f,h){const m=performance.now(),y=m-l;if(o===null||a===null||y===0)return o=f,a=h,l=m,null;const g=f-o,w=h-a,S=Math.sqrt(g*g+w*w)/y;return o=f,a=h,l=m,S}const d=f=>{let{x:h,y:m,placement:y,elements:g,onClose:w,nodeId:v,tree:S}
757=f;return function(k){function N(){clearTimeout(i),w()}if(clearTimeout(i),!g.domReference||!g.floating||y==null||h==null||m==null)return;const{clientX:_,clientY:j}=k,T=[_,j],M=Tf(k),V=k.type==="mouseleave",H=td(g.floating,M),P=td(g.domReference,M),F=g.domReference.getBoundingClientRect(),I=g.floating.getBoundingClientRect(),R=y.split("-")[0],U=h>I.right-I.width/2,A=m>I.bottom-I.height/2,W=Ffe(T,F),D=I.width>F.width,B=I.height>F.height,L=(D?F:I).left,$=(D?F:I).right,q=(B?F:I).top,Z=(B?F:I).bottom;if(H&&(s=!0,!V))return;if(P&&(s=!1),P&&!V){s=!0;return}if(V&&Fr(k.relatedTarget)&&td(g.floating,k.relatedTarget)||S&&wy(S.nodesRef.current,v).some(re=>{let{context:Y}=re;return Y==null?void 0:Y.open}))return;if(R==="top"&&m>=F.bottom-1||R==="bottom"&&m<=F.top+1||R==="left"&&h>=F.right-1||R==="right"&&h<=F.left+1)return N();let ie=[];switch(R){case"top":ie=[[L,F.top+1],[L,I.bottom-1],[$,I.bottom-1],[$,F.top+1]];break;case"bottom":ie=[[L,I.top+1],[L,F.bottom-1],[$,F.bottom-1],[$,I.top+1]];break;case"left":ie=[[I.right-1,Z],[I.right-1,q],[F.left+1,q],[F.left+1,Z]];break;case"right":ie=[[F.right-1,Z],[F.right-1,q],[I.left+1,q],[I.left+1,Z]];break}function ge(re){let[Y,ne]=re;switch(R){case"top":{const be=[D?Y+e/2:U?Y+e*4:Y-e*4,ne+e+1],we=[D?Y-e/2:U?Y+e*4:Y-e*4,ne+e+1],te=[[I.left,U||D?I.bottom-e:I.top],[I.right,U?D?I.bottom-e:I.top:I.bottom-e]];return[be,we,...te]}case"bottom":{const be=[D?Y+e/2:U?Y+e*4:Y-e*4,ne-e],we=[D?Y-e/2:U?Y+e*4:Y-e*4,ne-e],te=[[I.left,U||D?I.top+e:I.bottom],[I.right,U?D?I.top+e:I.bottom:I.top+e]];return[be,we,...te]}case"left":{const be=[Y+e+1,B?ne+e/2:A?ne+e*4:ne-e*4],we=[Y+e+1,B?ne-e/2:A?ne+e*4:ne-e*4];return[...[[A||B?I.right-e:I.left,I.top],[A?B?I.right-e:I.left:I.right-e,I.bottom]],be,we]}case"right":{const be=[Y-e,B?ne+e/2:A?ne+e*4:ne-e*4],we=[Y-e,B?ne-e/2:A?ne+e*4:ne-e*4],te=[[A||B?I.left+e:I.right,I.top],[A?B?I.left+e:I.right:I.left+e,I.bottom]];return[be,we,...te]}}}if(!KA([_,j],ie)){if(s&&!W)return N();if(!V&&r){const re=u(k.clientX,k.clientY);if(re!==null&&re<.1)return N()}KA([_,j],ge([h,m]))?!s&&r&&(i=window.setTimeout(N,40)):N()}}};return d.__options={blockPointerEvents:n},d}const Ufe=(t,e,n,r=!1)=>{const i=x.useCallback(s=>{const o=t.some(a=>a.current&&a.current.contains(s.target));e&&!o&&(n(s),r&&s.stopPropagation())},[e,t,n,r]);x.useEffect(()=>(e?document.addEventListener("click",i,{capture:!0}):document.removeEventListener("click",i,{capture:!0}),()=>{document.removeEventListener("click",i,{capture:!0})}),[e,i])},Vfe=30,tN=({placeholder:t="Describe an instrument...",currentInstrumentDisplay:e,borderColorClassName:n="border-zinc-700 dark:border-zinc-500",arrowColorClassName:r="text-zinc-700 dark:text-zinc-500",title:i="Instrument",children:s})=>{const{isMobile:o}=Hn(),[a,l]=x.useState(!1),[u,d]=x.useState(""),h=(o?5:8)*Vfe+6,{refs:m,floatingStyles:y,update:g}=IL({open:a,placement:"bottom-start",middleware:[kL(4),mfe(),pfe({padding:8}),gfe({apply({rects:M,availableHeight:V,elements:H}){Object.assign(H.floating.style,{width:`${M.reference.width}px`,maxHeight:`${Math.min(V-16,h+80)}px`})}})],whileElementsMounted:xL}),w=x.useRef(null),v=x.useRef(null),S=x.useRef(null);Ufe([v,S],a,()=>{l(!1)},!0),x.useEffect(()=>{d(a?"":e)},[a,e]),x.useEffect(()=>{a&&g&&g()},[a,g]);const C=x.useCallback(M=>{var V;M.preventDefault(),M.stopPropagation(),a?(V=w.current)==null||V.focus():(l(!0),d(""),setTimeout(()=>{var H;(H=w.current)==null||H.focus()},0))},[a]),k=x.useCallback(M=>{d(M.target.value)},[]),N=x.useCallback(M=>{var V;M.key==="Escape"&&(l(!1),(V=w.current)==null||V.blur()),o||M.stopPropagation()},[o]),_=x.useCallback(()=>{l(!1)},[]),j=mr.cloneElement(s,{searchValue:u,onClose:_,maxHeight:h}),T=a?c.jsx("div",{ref:M=>{m.setFloating(M),S.current!==M&&(S.current=M)},style:{...y,zIndex:51,pointerEvents:"auto"},className:"mt-1",onClick:M=>M.stopPropagation(),children:c.jsx("div",{className:"bg-zinc-100 dark:bg-zinc-800 rounded-md border border-zinc-300 dark:border-zinc-500 overflow-hidden",children:j})}):null;return c.jsxs("div",{ref:v,className:"w-full relative",children:[c.jsxs("button",{ref:m.setReference,className:`bg-transparent w-full px-2 py-1 border rounded-md flex items-center justify-between ${n}`,onClick:C,title:i,type:"button",children:[c.jsx("input",{ref:w,type:"text",placeholder:t,className:"bg-transparent cursor-pointer text-zinc-700 dark:text-zinc-200 outline-none flex-1 min-w-0",value:u,onChange:k,onKeyDown:N,autoComplete:"off"}),c.jsx("div",{className:"flex-shrink-0 ml-1",children:a?c.jsx(j0,{className:`${r}`,size:16}):c.jsx(Vi,{className:`${r}`,size:16})})]}),T&&Vh.createPortal(T,document.body)]})},jL=({searchValue:t="",onClose:e,onSelectInstrument:n,maxHeight:r=200})=>{var W;const[i,s]=x.useState("Built-In"),[o,a]=x.useState(null),[l,u]=x.useState(!1),[d,f]=x.use
757State(0),h=x.useRef(t),m=x.useRef(null),{allInstrumentNames:y}=cx(),{deleteInstrument:g}=nE(),{handleGenerateInstrument:w}=U0(),{showBanner:v}=ts(),{commitToStore:S}=Ln(),{bloobs:C}=mn();x.useEffect(()=>{if(!l){f(0);return}const D=Date.now(),B=47e3,L=setInterval(()=>{const $=Date.now()-D,q=Math.min($/B*100,95);f(q),q>=95&&clearInterval(L)},50);return()=>clearInterval(L)},[l]);const k=x.useMemo(()=>i==="Built-In"?yh().filter(D=>D.toLowerCase().includes(t.toLowerCase())).map(D=>({name:$l(D),value:D})):y.filter(D=>D.toLowerCase().includes(t.toLowerCase())).map(D=>({name:D,value:D})),[t,i,y]),N=((W=k[0])==null?void 0:W.value)||null;x.useEffect(()=>{m.current!==N&&(m.current=N,a(N))},[N]),x.useEffect(()=>{const D=t.trim(),B=h.current.trim();if(h.current=t,D===B||!D)return;const L=yh().filter(q=>q.toLowerCase().includes(D.toLowerCase())),$=y.filter(q=>q.toLowerCase().includes(D.toLowerCase()));L.length===0&&$.length>0?s("Generated"):L.length>0&&$.length===0?s("Built-In"):L.length===0&&$.length===0&&s("Generated")},[t,y]);const _=x.useCallback(async D=>{n==null||n(D),e==null||e()},[n,e]),j=x.useCallback(async(D,B)=>{if(D.stopPropagation(),Object.values(C).filter($=>ln($)&&$.instrument===B).length>0){v("Cannot delete Instrument! Instrument is in use by this or other bloobs");return}else await g(B),S()},[C,g,S,v]),T=x.useCallback(async()=>{const D=t.trim();if(D===""){v("Please enter a descriptor");return}else if(y.includes(D)){v("A generated instrument with this name already exists, please try something else");return}u(!0);try{const B=await w(D);f(100),await _(B),setTimeout(()=>{f(0),u(!1)},500)}catch{v("Failed to generate instrument, please try again"),u(!1),f(0)}},[t,y,v,w,_]),M=t.trim().length>0,V=M&&k.length===0,H=M&&(V||i==="Generated")&&!l,P=l,F=i==="Generated"&&!M&&k.length===0,I=y.filter(D=>D.toLowerCase().includes(t.toLowerCase())),R=M&&I.length===0,U=R?"Generate":"Generated",A=l||R;return c.jsxs("div",{className:"flex flex-col",style:{position:"relative"},children:[c.jsx("style",{children:` 758 @keyframes gradientShift { 759 0% { 760 background-position: 100% 50%; 761 } 762 50% { 763 background-position: 0% 50%; 764 } 765 100% { 766 background-position: 100% 50%; 767 } 768 } 769 `}),c.jsxs("div",{className:"flex border-b border-zinc-300 dark:border-zinc-500",style:{position:"relative"},children:[c.jsx("button",{className:`flex-1 text-zinc-700 dark:text-zinc-200 py-1.5 text-sm font-medium transition-colors ${i==="Built-In"?"bg-zinc-200 dark:bg-zinc-700":"hover:bg-zinc-100 dark:hover:bg-zinc-800"}`,onClick:D=>{D.preventDefault(),D.stopPropagation(),s("Built-In")},type:"button",style:{position:"relative",pointerEvents:"auto"},children:"Built-In"}),c.jsx("button",{className:`flex-1 py-1.5 text-sm font-medium transition-colors ${i==="Generated"?"bg-zinc-200 dark:bg-zinc-700":"hover:bg-zinc-100 dark:hover:bg-zinc-800"} flex items-center justify-center`,onClick:D=>{D.preventDefault(),D.stopPropagation(),s("Generated")},type:"button",style:{position:"relative",pointerEvents:"auto"},children:c.jsx("span",{className:"bg-clip-text text-transparent",style:{backgroundImage:A?"linear-gradient(90deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 50%, rgb(125, 195, 131) 100%)":"linear-gradient(90deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 100%)",backgroundSize:A?"200% 100%":"100% 100%",backgroundPosition:"0% 50%",animation:A?"gradientShift 10s ease infinite":"none"},children:U})})]}),F&&c.jsxs("div",{className:"relative m-3 p-5 rounded-lg border-2 border-transparent",children:[c.jsx("div",{className:"absolute inset-0 rounded-lg opacity-60",style:{background:"linear-gradient(135deg, #10b981 0%, #06b6d4 100%)",padding:"1.5px",WebkitMask:"linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",WebkitMaskComposite:"xor",maskComposite:"exclude"}}),c.jsxs("div",{className:"relative text-center",children:[c.jsx("div",{className:"flex justify-center mb-2.5",children:c.jsx(KS,{className:"size-7 text-emerald-600 dark:text-emerald-400"})}),c.jsx("p",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-200 mb-1.5",children:"Create Custom Instruments"}),c.jsx("p",{className:"text-xs text-zinc-600 dark:text-zinc-400 leading-relaxed",children:"Type a description above to generate"})]})]}),c.jsx("div",{className:"overflow-y-auto overscroll-none",style:{maxHeight:`${r-40}px`,position:"relative"},children:k.length>0?k.map(D=>c.jsxs("div",{className:`flex items-center px-3 py-1.5 cursor-pointer transition-colors hover:bg-zinc-200 dark:hover:bg-zinc-700 ${o===D.value?"bg-zinc-200 dark:bg-zinc-700":""}`,onMouseEnter:()=>a(D.value),onClick:()=>
769_(D.value),children:[c.jsx("span",{className:"text-zinc-700 dark:text-zinc-200 truncate flex-1",children:$l(D.value)}),i==="Generated"&&c.jsx(cre,{size:14,className:"text-zinc-500 dark:text-zinc-400 hover:text-red-500 dark:hover:text-red-400 cursor-pointer ml-2 flex-shrink-0",onClick:async B=>await j(B,D.value)})]},`${ci(D.value)}-${D.value}`)):!F&&!H&&!P&&c.jsx("div",{className:"px-3 py-2 text-zinc-500 dark:text-zinc-400 text-sm",children:M?`No instruments found matching ${t}`:i==="Generated"?"No generated instruments":"No built-in instruments"})}),H&&c.jsx("div",{className:"p-2.5",children:c.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{padding:"1.5px"},children:[c.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(45deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 33%, rgb(248, 194, 145) 66%, rgb(125, 195, 131) 100%)",backgroundSize:"300% 100%",backgroundPosition:"0% 50%"}}),c.jsxs("button",{onClick:D=>{D.preventDefault(),D.stopPropagation(),T()},className:"relative w-full px-3 py-2.5 text-sm rounded-md bg-zinc-100 dark:bg-zinc-800 text-zinc-700 dark:text-zinc-200 hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors flex items-center justify-center gap-2 font-medium",style:{pointerEvents:"auto"},children:[c.jsxs("span",{children:["Generate ",t]}),c.jsx(KS,{size:14})]})]})}),P&&c.jsx("div",{className:"p-2.5",children:c.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{padding:"1.5px"},children:[c.jsx("div",{className:"absolute inset-0 bg-zinc-200 dark:bg-zinc-700"}),c.jsx("div",{className:"absolute inset-y-0 left-0 transition-all duration-300 ease-out",style:{width:`${d}%`,background:"linear-gradient(45deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 33%, rgb(248, 194, 145) 66%, rgb(125, 195, 131) 100%)",backgroundSize:"300% 100%",backgroundPosition:"0% 50%"}}),c.jsxs("div",{className:"relative w-full px-3 py-2.5 text-sm rounded-md bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center gap-2",children:[c.jsx(Da,{className:"size-4 text-caiGreen animate-spin"}),c.jsxs("span",{className:"text-zinc-700 dark:text-zinc-200 font-medium",children:["Generating ",t,"..."]})]})]})})]})},TC=({bloobId:t,borderColorClassName:e="border-zinc-700 dark:border-zinc-500",arrowColorClassName:n="text-zinc-700 dark:text-zinc-500"})=>{const{loadBloobAudio:r}=es(),{updateBloobDetails:i}=Gn(),{commitToStore:s}=Ln(),o=qc(t),a=(o==null?void 0:o.instrument)||"",l=$l(a),u=x.useCallback(async d=>{d!==(o==null?void 0:o.instrument)&&(i(t,{instrument:d}),await r(t),s())},[o==null?void 0:o.instrument,t,s,r,i]);return c.jsx(tN,{currentInstrument:a,currentInstrumentDisplay:l,borderColorClassName:e,arrowColorClassName:n,title:"Instrument",children:c.jsx(jL,{onSelectInstrument:u})})};function zC(t,e){return zC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},zC(t,e)}function Hfe(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,zC(t,e)}function Ok(t){return t&&t.stopPropagation&&t.stopPropagation(),t&&t.preventDefault&&t.preventDefault(),!1}function Dk(t){return t==null?[]:Array.isArray(t)?t.slice():[t]}function _b(t){return t!==null&&t.length===1?t[0]:t.slice()}function Eb(t){Object.keys(t).forEach(e=>{typeof document<"u"&&document.addEventListener(e,t[e],!1)})}function pu(t,e){return PC(function(n,r){let i=n;return i<=r.min&&(i=r.min),i>=r.max&&(i=r.max),i}(t,e),e)}function PC(t,e){const n=(t-e.min)%e.step;let r=t-n;return 2*Math.abs(n)>=e.step&&(r+=n>0?e.step:-e.step),parseFloat(r.toFixed(5))}let AC=function(t){function e(r){var i;(i=t.call(this,r)||this).onKeyUp=()=>{i.onEnd()},i.onMouseUp=()=>{i.onEnd(i.getMouseEventMap())},i.onTouchEnd=a=>{a.preventDefault(),i.onEnd(i.getTouchEventMap())},i.onBlur=()=>{i.setState({index:-1},i.onEnd(i.getKeyDownEventMap()))},i.onMouseMove=a=>{i.setState({pending:!0});const l=i.getMousePosition(a),u=i.getDiffPosition(l[0]),d=i.getValueFromPosition(u);i.move(d)},i.onTouchMove=a=>{if(a.touches.length>1)return;i.setState({pending:!0});const l=i.getTouchPosition(a);if(i.isScrolling===void 0){const f=l[0]-i.startPosition[0],h=l[1]-i.startPosition[1];i.isScrolling=Math.abs(h)>Math.abs(f)}if(i.isScrolling)return void i.setState({index:-1});const u=i.getDiffPosition(l[0]),d=i.getValueFromPosition(u);i.move(d)},i.onKeyDown=a=>{if(!(a.ctrlKey||a.shiftKey||a.altKey||a.metaKey))switch(i.setState({pen
769ding:!0}),a.key){case"ArrowLeft":case"ArrowDown":case"Left":case"Down":a.preventDefault(),i.moveDownByStep();break;case"ArrowRight":case"ArrowUp":case"Right":case"Up":a.preventDefault(),i.moveUpByStep();break;case"Home":a.preventDefault(),i.move(i.props.min);break;case"End":a.preventDefault(),i.move(i.props.max);break;case"PageDown":a.preventDefault(),i.moveDownByStep(i.props.pageFn(i.props.step));break;case"PageUp":a.preventDefault(),i.moveUpByStep(i.props.pageFn(i.props.step))}},i.onSliderMouseDown=a=>{if(!i.props.disabled&&a.button!==2){if(i.setState({pending:!0}),!i.props.snapDragDisabled){const l=i.getMousePosition(a);i.forceValueFromPosition(l[0],u=>{i.start(u,l[0]),Eb(i.getMouseEventMap())})}Ok(a)}},i.onSliderClick=a=>{if(!i.props.disabled&&i.props.onSliderClick&&!i.hasMoved){const l=i.getMousePosition(a),u=pu(i.calcValue(i.calcOffsetFromPosition(l[0])),i.props);i.props.onSliderClick(u)}},i.createOnKeyDown=a=>l=>{i.props.disabled||(i.start(a),Eb(i.getKeyDownEventMap()),Ok(l))},i.createOnMouseDown=a=>l=>{if(i.props.disabled||l.button===2)return;i.setState({pending:!0});const u=i.getMousePosition(l);i.start(a,u[0]),Eb(i.getMouseEventMap()),Ok(l)},i.createOnTouchStart=a=>l=>{if(i.props.disabled||l.touches.length>1)return;i.setState({pending:!0});const u=i.getTouchPosition(l);i.startPosition=u,i.isScrolling=void 0,i.start(a,u[0]),Eb(i.getTouchEventMap()),function(d){d.stopPropagation&&d.stopPropagation()}(l)},i.handleResize=()=>{const a=window.setTimeout(()=>{i.pendingResizeTimeouts.shift(),i.resize()},0);i.pendingResizeTimeouts.push(a)},i.renderThumb=(a,l)=>{const u=i.props.thumbClassName+" "+i.props.thumbClassName+"-"+l+" "+(i.state.index===l?i.props.thumbActiveClassName:""),d={ref:h=>{i["thumb"+l]=h},key:i.props.thumbClassName+"-"+l,className:u,style:a,onMouseDown:i.createOnMouseDown(l),onTouchStart:i.createOnTouchStart(l),onFocus:i.createOnKeyDown(l),tabIndex:0,role:"slider","aria-orientation":i.props.orientation,"aria-valuenow":i.state.value[l],"aria-valuemin":i.props.min,"aria-valuemax":i.props.max,"aria-label":Array.isArray(i.props.ariaLabel)?i.props.ariaLabel[l]:i.props.ariaLabel,"aria-labelledby":Array.isArray(i.props.ariaLabelledby)?i.props.ariaLabelledby[l]:i.props.ariaLabelledby,"aria-disabled":i.props.disabled},f={index:l,value:_b(i.state.value),valueNow:i.state.value[l]};return i.props.ariaValuetext&&(d["aria-valuetext"]=typeof i.props.ariaValuetext=="string"?i.props.ariaValuetext:i.props.ariaValuetext(f)),i.props.renderThumb(d,f)},i.renderTrack=(a,l,u)=>{const d={key:i.props.trackClassName+"-"+a,className:i.props.trackClassName+" "+i.props.trackClassName+"-"+a,style:i.buildTrackStyle(l,i.state.upperBound-u)},f={index:a,value:_b(i.state.value)};return i.props.renderTrack(d,f)};let s=Dk(r.value);s.length||(s=Dk(r.defaultValue)),i.pendingResizeTimeouts=[];const o=[];for(let a=0;a<s.length;a+=1)s[a]=pu(s[a],r),o.push(a);return i.resizeObserver=null,i.resizeElementRef=mr.createRef(),i.state={index:-1,upperBound:0,sliderLength:0,value:s,zIndices:o},i}Hfe(e,t);var n=e.prototype;return n.componentDidMount=function(){typeof window<"u"&&(this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.resizeElementRef.current),this.resize())},e.getDerivedStateFromProps=function(r,i){const s=Dk(r.value);return s.length?i.pending?null:{value:s.map(o=>pu(o,r))}:null},n.componentDidUpdate=function(){this.state.upperBound===0&&this.resize()},n.componentWillUnmount=function(){this.clearPendingResizeTimeouts(),this.resizeObserver&&this.resizeObserver.disconnect()}
769,n.onEnd=function(r){r&&function(i){Object.keys(i).forEach(s=>{typeof document<"u"&&document.removeEventListener(s,i[s],!1)})}(r),this.hasMoved&&this.fireChangeEvent("onAfterChange"),this.setState({pending:!1}),this.hasMoved=!1},n.getValue=function(){return _b(this.state.value)},n.getClosestIndex=function(r){let i=Number.MAX_VALUE,s=-1;const{value:o}=this.state,a=o.length;for(let l=0;l<a;l+=1){const u=this.calcOffset(o[l]),d=Math.abs(r-u);d<i&&(i=d,s=l)}return s},n.getMousePosition=function(r){return[r["page"+this.axisKey()],r["page"+this.orthogonalAxisKey()]]},n.getTouchPosition=function(r){const i=r.touches[0];return[i["page"+this.axisKey()],i["page"+this.orthogonalAxisKey()]]},n.getKeyDownEventMap=function(){return{keydown:this.onKeyDown,keyup:this.onKeyUp,focusout:this.onBlur}},n.getMouseEventMap=function(){return{mousemove:this.onMouseMove,mouseup:this.onMouseUp}},n.getTouchEventMap=function(){return{touchmove:this.onTouchMove,touchend:this.onTouchEnd}},n.getValueFromPosition=function(r){const i=r/(this.state.sliderLength-this.state.thumbSize)*(this.props.max-this.props.min);return pu(this.state.startValue+i,this.props)},n.getDiffPosition=function(r){let i=r-this.state.startPosition;return this.props.invert&&(i*=-1),i},n.resize=function(){const{slider:r,thumb0:i}=this;if(!r||!i)return;const s=this.sizeKey(),o=r.getBoundingClientRect(),a=r[s],l=o[this.posMaxKey()],u=o[this.posMinKey()],d=i.getBoundingClientRect()[s.replace("client","").toLowerCase()],f=a-d,h=Math.abs(l-u);this.state.upperBound===f&&this.state.sliderLength===h&&this.state.thumbSize===d||this.setState({upperBound:f,sliderLength:h,thumbSize:d})},n.calcOffset=function(r){const i=this.props.max-this.props.min;return i===0?0:(r-this.props.min)/i*this.state.upperBound},n.calcValue=function(r){return r/this.state.upperBound*(this.props.max-this.props.min)+this.props.min},n.calcOffsetFromPosition=function(r){const{slider:i}=this,s=i.getBoundingClientRect(),o=s[this.posMaxKey()],a=s[this.posMinKey()];let l=r-(window["page"+this.axisKey()+"Offset"]+(this.props.invert?o:a));return this.props.invert&&(l=this.state.sliderLength-l),l-=this.state.thumbSize/2,l},n.forceValueFromPosition=function(r,i){const s=this.calcOffsetFromPosition(r),o=this.getClosestIndex(s),a=pu(this.calcValue(s),this.props),l=this.state.value.slice();l[o]=a;for(let u=0;u<l.length-1;u+=1)if(l[u+1]-l[u]<this.props.minDistance)return;this.fireChangeEvent("onBeforeChange"),this.hasMoved=!0,this.setState({value:l},()=>{i(o),this.fireChangeEvent("onChange")})},n.clearPendingResizeTimeouts=function(){do{const r=this.pendingResizeTimeouts.shift();clearTimeout(r)}while(this.pendingResizeTimeouts.length)},n.start=function(r,i){const s=this["thumb"+r];s&&s.focus();const{zIndices:o}=this.state;o.splice(o.indexOf(r),1),o.push(r),this.setState(a=>({startValue:a.value[r],startPosition:i!==void 0?i:a.startPosition,index:r,zIndices:o}))},n.moveUpByStep=function(r){r===void 0&&(r=this.props.step);const i=this.state.value[this.state.index],s=pu(this.props.invert&&this.props.orientation==="horizontal"?i-r:i+r,this.props);
769this.move(Math.min(s,this.props.max))},n.moveDownByStep=function(r){r===void 0&&(r=this.props.step);const i=this.state.value[this.state.index],s=pu(this.props.invert&&this.props.orientation==="horizontal"?i+r:i-r,this.props);this.move(Math.max(s,this.props.min))},n.move=function(r){const i=this.state.value.slice(),{index:s}=this.state,{length:o}=i,a=i[s];if(r===a)return;this.hasMoved||this.fireChangeEvent("onBeforeChange"),this.hasMoved=!0;const{pearling:l,max:u,min:d,minDistance:f}=this.props;if(!l){if(s>0){const h=i[s-1];r<h+f&&(r=h+f)}if(s<o-1){const h=i[s+1];r>h-f&&(r=h-f)}}i[s]=r,l&&o>1&&(r>a?(this.pushSucceeding(i,f,s),function(h,m,y,g){for(let w=0;w<h;w+=1){const v=g-w*y;m[h-1-w]>v&&(m[h-1-w]=v)}}(o,i,f,u)):r<a&&(this.pushPreceding(i,f,s),function(h,m,y,g){for(let w=0;w<h;w+=1){const v=g+w*y;m[w]<v&&(m[w]=v)}}(o,i,f,d))),this.setState({value:i},this.fireChangeEvent.bind(this,"onChange"))},n.pushSucceeding=function(r,i,s){let o,a;for(o=s,a=r[o]+i;r[o+1]!==null&&a>r[o+1];o+=1,a=r[o]+i)r[o+1]=PC(a,this.props)},n.pushPreceding=function(r,i,s){for(let o=s,a=r[o]-i;r[o-1]!==null&&a<r[o-1];o-=1,a=r[o]-i)r[o-1]=PC(a,this.props)},n.axisKey=function(){return this.props.orientation==="vertical"?"Y":"X"},n.orthogonalAxisKey=function(){return this.props.orientation==="vertical"?"X":"Y"},n.posMinKey=function(){return this.props.orientation==="vertical"?this.props.invert?"bottom":"top":this.props.invert?"right":"left"},n.posMaxKey=function(){return this.props.orientation==="vertical"?this.props.invert?"top":"bottom":this.props.invert?"left":"right"},n.sizeKey=function(){return this.props.orientation==="vertical"?"clientHeight":"clientWidth"},n.fireChangeEvent=function(r){this.props[r]&&this.props[r](_b(this.state.value),this.state.index)},n.buildThumbStyle=function(r,i){const s={position:"absolute",touchAction:"none",willChange:this.state.index>=0?this.posMinKey():void 0,zIndex:this.state.zIndices.indexOf(i)+1};return s[this.posMinKey()]=r+"px",s},n.buildTrackStyle=function(r,i){const s={position:"absolute",willChange:this.state.index>=0?this.posMinKey()+","+this.posMaxKey():void 0};return s[this.posMinKey()]=r,s[this.posMaxKey()]=i,s},n.buildMarkStyle=function(r){var i;return(i={position:"absolute"})[this.posMinKey()]=r,i},n.renderThumbs=function(r){const{length:i}=r,s=[];for(let a=0;a<i;a+=1)s[a]=this.buildThumbStyle(r[a],a);const o=[];for(let a=0;a<i;a+=1)o[a]=this.renderThumb(s[a],a);return o},n.renderTracks=function(r){const i=[],s=r.length-1;i.push(this.renderTrack(0,0,r[0]));for(let o=0;o<s;o+=1)i.push(this.renderTrack(o+1,r[o],r[o+1]));return i.push(this.renderTrack(s+1,r[s],this.state.upperBound)),i},n.renderMarks=function(){let{marks:r}=this.props;const i=this.props.max-this.props.min+1;return typeof r=="boolean"?r=Array.from({length:i}).map((s,o)=>o):typeof r=="number"&&(r=Array.from({length:i}).map((s,o)=>o).filter(s=>s%r==0)),r.map(parseFloat).sort((s,o)=>s-o).map(s=>{const o=this.calcOffset(s),a={key:s,className:this.props.markClassName,style:this.buildMarkStyle(o)};return this.props.renderMark(a)})},n.render=function(){const r=[],{value:i}=this.state,s=i.length;for(let u=0;u<s;u+=1)r[u]=this.calcOffset(i[u],u);const o=this.props.withTracks?this.renderTracks(r):null,a=this.renderThumbs(r),l=this.props.marks?this.renderMarks():null;return mr.createElement("div",{ref:u=>{this.slider=u,this.resizeElementRef.current=u},style:{position:"relative"},className:this.props.className+(this.props.disabled?" disabled":""),onMouseDown:this.onSliderMouseDown,onClick:this.onSliderClick},o,a,l)},e}(mr.Component);AC.displayName="ReactSlider",AC.defaultProps={min:0,max:100,step:1,pageFn:t=>10*t,minDistance:0,defaultValue:0,orientation:"horizontal",className:"slider",thumbClassName:"thumb",thumbActiveClassName:"active",trackClassName:"track",markClassName:"mark",withTracks:!0,pearling:!1,disabled:!1,snapDragDisabled:!1,invert:!1,marks:[],renderThumb:t=>mr.createElement("div",t),renderTrack:t=>mr.createElement("div",t),renderMark:t=>mr.createElement("span",t)};var TL=AC;const _s=({min:t,max:e,step:n=1,value:r,renderValue:i=g=>g.toString(),adjustUserEnteredValue:s=g=>g,onChange:o,onAfterChange:a=()=>{},doubleClickValue:l,label:u,valueOnThumb:d=!1,title:f="",id:h="slider",labelAlign:m="center",showLabelColumn:y=!0})=>{const[g,w]=x.useState(r),[v,S]=x.useState(!1),[C,k]=x.useState(!1),[N,_]=x.useState(i(r)),j=x.useRef(null),T=x.useRef(null),M=x.useRef(null);x.useEffect(()=>{C||(w(r),_(i(r)))},[r,C,i]);const V=x.useCallback(()=>{S(!0),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{S(!1)},2e3)},[]),H=x.useCallback(re=>{const Y=Math.max(t,Math.min(e,re)),ne=Math.round(Y/n)*n,be=Math.max(t,Math.min(e,ne));w(be),C||_(i(be)),o(be),V()},[t,e,n,o,i,V,C]),P=x.useCallback(()=>{k(!0),_(i(g)),j.current&&clearTimeout(j.current),S(!0),setTimeout(()=>{T.current&&(T.current.focus(),T.current.select())},0)},[g,i]),F=x.useCallback(re=>{_(re.target.value)},[]),I=x.useCallback(()=>{const re=Number(N);let Y;if(isNaN(re)||N.trim()==="")Y=r;else{const ne=s(re),be=Math.max(t,Math.min(e,ne)),we=Math.round(be/n)*n;Y=Math.max(t,Math.min(e,we))}w(Y),_(i(Y)),Y!==r&&o(Y),a(),k(!1),V()},[N,r,s,t,e,n,i,o,a,V]),R=x.useCallback(()=>{I()},[I]),U=x.useCallback(re=>{var Y,ne;re.key==="Enter"?(re.preventDefault(),I(),(Y=T.current)==null||Y.blur()):re.key==="Escape"&&(re.preventDefault(),w(r),_(i(r)),k(!1),(ne=T.current)==null||ne.blur(),V())},[I,r,i,V]),A=x.useCallback(re=>{if(!M.current||C)return;const Y=M.current.getBoundingClientRect(),ne=re.touches[0],we=Math.max(0,Math.min(ne.clientX-Y.left,Y.width))/Y.width,te=t+we*(e-t),fe=Math.round(te/n)*n,O=Math.max(t,Math.min(e,fe));O!==g&&H(O)}
769,[H,t,e,n,g,C]),W=x.useCallback(re=>{C||(document.body.style.overflow="hidden",A(re),V())},[A,V,C]),D=x.useCallback(re=>{C||A(re)},[A,C]),B=x.useCallback(()=>{C||(document.body.style.overflow="",a())},[a,C]),L=x.useCallback(()=>{C||(S(!0),j.current&&clearTimeout(j.current))},[C]),$=x.useCallback(()=>{C||V()},[V,C]);x.useEffect(()=>()=>{j.current&&clearTimeout(j.current),document.body.style.overflow=""},[]);const q=m==="left"?"text-left":"text-center",Z=m==="left"?"justify-start text-left":"justify-center text-center",ie=m==="left"?"text-left":"text-center",ge=c.jsx("div",{ref:M,className:"w-full min-w-0 h-8 flex items-center cursor-pointer touch-none select-none",onTouchStart:W,onTouchMove:D,onTouchEnd:B,onTouchCancel:B,onMouseDown:L,onMouseUp:$,children:c.jsx(TL,{min:t,max:e,step:n,value:g,onChange:H,onAfterChange:a,className:"flex items-center py-3 w-full h-full",renderThumb:re=>{const{key:Y,...ne}=re;return c.jsx("div",{...ne,style:{...ne.style,touchAction:"none"},id:`${h}-thumb`,"aria-label":`${u||f} slider thumb`,title:f,className:`bg-zinc-700 dark:bg-zinc-100 text-zinc-100 dark:text-zinc-800 flex items-center justify-center rounded-full cursor-pointer hover:scale-110 transition-transform shrink-0 overflow-hidden ${d?"h-7 w-7 min-w-[1.75rem] max-w-[1.75rem] px-0.5 text-[7px] font-semibold tabular-nums leading-none":"size-5 text-xs min-w-5 max-w-5"}`,onMouseDown:L,onMouseUp:$,onDoubleClick:()=>{l!==void 0&&!C&&(H(l),a())},children:d?c.jsx("span",{className:"block w-full min-w-0 max-w-full truncate text-center leading-none",children:i(g)}):null},Y)},renderTrack:(re,Y)=>{const{key:ne,...be}=re;return c.jsx("div",{...be,style:{...be.style,touchAction:"none"},id:`${h}-track-${Y.index}`,"aria-label":`${u||f} slider track ${Y.index}`,title:f,className:`h-2 rounded-full ${Y.index===0&&Number(Y.value)>t?"bg-zinc-700 dark:bg-zinc-300":"bg-zinc-300 dark:bg-zinc-500"}`},ne)}})});return y?c.jsxs("div",{className:"flex gap-2 items-center w-full min-w-0",children:[c.jsx("div",{className:`w-[40px] shrink-0 min-w-0 overflow-hidden ${q}`,children:C||!u?c.jsx("div",{className:"h-full w-full min-w-0 max-w-[40px] overflow-hidden",children:c.jsx("input",{ref:T,type:"text",inputMode:"numeric",maxLength:12,className:`box-border w-full min-w-0 max-w-full h-full bg-transparent ${ie} text-xs text-zinc-700 dark:text-zinc-100 outline-none p-0 m-0 border-none`,value:N,onChange:F,onBlur:R,onKeyDown:U})}):d&&u?c.jsx("div",{className:`text-zinc-700 dark:text-zinc-100 h-full min-w-0 max-w-full flex items-center ${Z} text-xs font-medium cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap`,onClick:P,title:f||"Click to edit",children:u}):c.jsx(Vn,{mode:"wait",initial:!1,children:c.jsx(et.div,{initial:{opacity:0}
769,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`text-zinc-700 dark:text-zinc-100 cursor-pointer h-full min-w-0 max-w-full flex items-center ${Z} text-xs overflow-hidden`,onClick:P,title:v?"Click to edit":f,children:c.jsx("span",{className:`block w-full min-w-0 truncate ${m==="left"?"text-left":"text-center"}`,children:v?i(g):u})},v?"value":"label")})}),ge]}):ge},Cs=x.forwardRef(({children:t,onClick:e=()=>{},bind:n=void 0,disabled:r=!1,tooltipId:i},s)=>c.jsx("button",{ref:s,className:`border border-zinc-700 dark:border-zinc-500 py-1 rounded-md flex-1 ${r?"opacity-50 cursor-not-allowed":"hover:bg-zinc-200 dark:hover:bg-zinc-700"}`,onClick:r?void 0:e,disabled:r,...i&&{"data-tooltip-id":i},...n&&n(),children:t}));Cs.displayName="InspectorButton";const Gfe=({searchValue:t="",onClose:e,onSelectInstrument:n,maxHeight:r=200})=>{const[i,s]=x.useState([]),[o,a]=x.useState(null);x.useEffect(()=>{var h;const f=rO.map(m=>({name:m.split(" ").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join(" "),value:m})).filter(m=>m.name.toLowerCase().includes(t.toLowerCase()));s(f),a(((h=f[0])==null?void 0:h.value)||null)},[t]);const l=x.useCallback(d=>{n==null||n(d.value),e==null||e()},[n,e]),u=x.useCallback(()=>{t.trim()&&(n==null||n(t.trim()),e==null||e())},[t,n,e]);return c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{className:"overflow-y-auto overscroll-none",style:{maxHeight:`${r}px`},children:[i.map(d=>c.jsx("div",{className:`flex items-center px-3 py-1 cursor-pointer transition-colors hover:bg-zinc-200 dark:hover:bg-zinc-700 ${o===d.value?"bg-zinc-200 dark:bg-zinc-700":""}`,onMouseEnter:()=>a(d.value),onClick:()=>l(d),children:c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100 truncate",children:d.name})},d.value)),i.length===0&&t&&c.jsxs("div",{className:"px-3 py-2 text-zinc-500 dark:text-zinc-400 text-sm",children:['No built-in instruments found matching "',t,'"']})]}),t&&c.jsx("div",{className:"border-t border-zinc-300 dark:border-zinc-600 bg-zinc-50 dark:bg-zinc-900",children:c.jsx("div",{className:"p-3",children:c.jsxs("button",{onClick:u,className:"w-full px-3 py-2 text-sm rounded transition-colors bg-caiGreen text-white hover:bg-caiGreen/90",children:['Create "',t,'"']})})})]})},Wfe=({audioFileId:t,initialValue:e})=>{const{getAudioFileById:n}=mn(),{updateAudioFileDetails:r}=Gn(),{commitToStore:i}=Ln(),s=n(t),o=e||(s==null?void 0:s.instrument)||qm,a=x.useCallback(u=>u===qm?"Select Instrument":u.split(" ").map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join(" "),[]),l=x.useCallback(async u=>{u!==(s==null?void 0:s.instrument)&&(r(t,{newInstrument:u}),i())},[s==null?void 0:s.instrument,t,r,i]);return c.jsx(tN,{currentInstrument:o,currentInstrumentDisplay:a(o),title:"Instrument Type",children:c.jsx(Gfe,{onSelectInstrument:l})})};var cs=(t=>(t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t[t.NoDevices=2]="NoDevices",t))(cs||{}),la=(t=>(t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t))(la||{}),ca=(t=>(t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t))(ca||{});const zL=()=>{const{isRecording:t}=Lo(),{setSource:e}=rE(),{recordingSettings:n}=bi(),{setSnapToGrid:r,setSnapToKey:i,setGridDivision:s}=il(),{recordingSourcesStatus:o,currentSource:a}=Lo(),[l,u]=x.useState(!1),d=x.useRef(null),f=x.useMemo(()=>o.midiInstrument===cs.Enabled,[o.midiInstrument]),h=x.useMemo(()=>o.voice2Midi===la.Enabled,[o.voice2Midi]),m=x.useMemo(()=>o.audio===ca.Enabled,[o.audio]),y=x.useMemo(()=>{switch(o.midiInstrument){case cs.Enabled:return"Record with a MIDI instrument";case cs.NoDevices:return"No MIDI devices detected";case cs.Disabled:return"Select a Song or MIDI Bloob to record with a MIDI instrument"}},[o.midiInstrument]),g=x.useMemo(()=>{switch(o.voice2Midi){case la.Enabled:return"Record MIDI by singing or humming into Cai";case la.Disabled:return"Select a Song or MIDI Bloob to record with Voice 2 Midi"}},[o.voice2Midi]),w=x.useMemo(()=>{switch(o.audio){case ca.Enabled:return"Record sound directly from your microphone";case ca.Disabled:return"Select anything other than a MIDI Bloob to record Audio"}},[o.audio]);return t?null:c.jsxs("div",{className:"p-2 space-y-2",children:[c.jsx("h1",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-100",children:"Recording Source"}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("label",{className:`flex items-center space-x-2 ${f?"cursor-pointer":"cursor-default"}`,children:[c.jsx("input",{type:"radio",name:"source",value:"midi",checked:a===zr.MidiInstrument,onChange:()=>e(zr.MidiInstrument),disabled:!f,className:"text-cai-primary focus:ring-cai-primary [&:checked]:accent-caiBlue disabled:opacity-50 disabled:cursor-not-allowed"}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:`text-sm text-zinc-700 dark:text-zinc-100 ${f?"":"op
769acity-50"}`,children:"MIDI Instrument"}),c.jsx("span",{className:`text-xs text-zinc-500 dark:text-zinc-400 ${f?"":"opacity-50"}`,children:y})]})]}),c.jsxs("label",{className:`flex items-center space-x-2 ${h?"cursor-pointer":"cursor-default"} `,children:[c.jsx("input",{type:"radio",name:"source",value:"voice",checked:a===zr.VoiceToMidi,onChange:()=>e(zr.VoiceToMidi),className:"text-cai-primary focus:ring-cai-primary [&:checked]:accent-caiBlue disabled:opacity-50 disabled:cursor-not-allowed",disabled:!h}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:`text-sm text-zinc-700 dark:text-zinc-100 ${h?"":"opacity-50"}`,children:"Voice to MIDI"}),c.jsx("span",{className:`text-xs text-zinc-500 dark:text-zinc-400 ${h?"":"opacity-50"}`,children:g})]})]}),c.jsxs("label",{className:`flex items-center space-x-2 ${m?"cursor-pointer":"cursor-default"}`,children:[c.jsx("input",{type:"radio",name:"source",value:"audio",checked:a===zr.Audio,onChange:()=>e(zr.Audio),className:"text-cai-primary focus:ring-cai-primary [&:checked]:accent-caiBlue disabled:opacity-50 disabled:cursor-not-allowed",disabled:!m}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:`text-sm text-zinc-700 dark:text-zinc-100 ${m?"":"opacity-50"}`,children:"Audio"}),c.jsx("span",{className:`text-xs text-zinc-500 dark:text-zinc-400 ${m?"":"opacity-50"}`,children:w})]})]})]}),a!==zr.Audio&&c.jsx("div",{className:"pt-2 border-t border-zinc-800",children:c.jsxs("div",{className:"space-y-2",children:[c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-100",children:"Snap to Grid"}),c.jsxs("div",{className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${n.snapToGrid?"bg-caiBlue":"bg-zinc-200 dark:bg-zinc-700"}`,children:[c.jsx("input",{type:"checkbox",checked:n.snapToGrid,onChange:v=>r(v.target.checked),className:"peer sr-only"}),c.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition ${n.snapToGrid?"translate-x-4":"translate-x-1"}`})]})]}),n.snapToGrid&&c.jsxs("div",{ref:d,className:"relative",children:[c.jsxs("button",{onClick:v=>{v.preventDefault(),u(!l)},className:"flex items-center justify-between w-full px-3 py-1.5 rounded-lg border transition-colors bg-zinc-100 dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-800 dark:text-zinc-200 hover:bg-zinc-200 dark:hover:bg-zinc-700 select-none",children:[c.jsx("span",{className:"text-sm truncate",children:n.gridDivision}),c.jsx(Vi,{size:16,className:`ml-2 transition-transform duration-300 ${l?"rotate-180":""}`})]}),l&&c.jsx("div",{className:"absolute z-50 mt-1 rounded-lg overflow-hidden shadow-lg border w-full bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700",children:Object.values(Hu).map(v=>c.jsxs("div",{className:`px-3 py-1.5 cursor-pointer flex items-center justify-between text-sm select-none ${v===n.gridDivision?"bg-caiBlue-100 dark:bg-caiBlue-900/40 text-caiBlue-800 dark:text-caiBlue-200":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-700 dark:text-zinc-200"}`,onClick:S=>{S.preventDefault(),s(v),u(!1)},children:[c.jsx("span",{children:v}),v===n.gridDivision&&c.jsx(Ml,{size:14,className:"text-caiBlue-600 dark:text-caiBlue-300"})]},v))})]}),a===zr.VoiceToMidi&&c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-100",children:"Snap to Key"}),c.jsxs("div",{className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${n.snapToKey?"bg-caiBlue":"bg-zinc-200 dark:bg-zinc-700"}`,children:[c.jsx("input",{type:"checkbox",checked:n.snapToKey,onChange:v=>i(v.target.checked),className:"peer sr-only"}),c.jsx("span",{className:`inline-block size-4 transform rounded-full bg-white shadow-sm transition ${n.snapToKey?"translate-x-4":"translate-x-1"}`})]})]})]})})]})},xv=({hoverTriggerRef:t,positionAnchorRef:e,disabled:n=!1,placement:r="right-start",mainAxisOffset:i=8})=>{const{isRecording:s}=Lo(),[o,a]=x.useState(!1),{refs:l,floatingStyles:u,context:d}=IL({open:o&&!n,onOpenChange:a,placement:r,middleware:[kL({mainAxis:i,crossAxis:0})],whileElementsMounted:xL});x.useEffect(()=>{t.current&&l.setReference(t.current),e.current&&l.setPositionReference(e.current)},[t,e,l]);const f=_fe(d,{handleClose:$fe(),delay:{open:500,close:500}}),h=Bfe(d),m=Lfe(d),{getFloatingProps:y}=Ofe([f,h,m]),g=Rx();
769return s||!o||n?null:c.jsx(Tfe,{id:"record-details-portal",children:c.jsx("div",{ref:l.setFloating,style:{...u,zIndex:51},"aria-labelledby":g,...y(),className:"bg-glass border-glass opacity-100 rounded-md w-56 p-2",children:c.jsx(zL,{})})})},qfe=()=>{const{closeMobileRecordDetails:t}=Br();return c.jsx(Wr,{onClose:t,children:c.jsx("div",{className:"bg-glass border-glass p-2",children:c.jsx(zL,{})})})},Kfe=({bloobId:t})=>{const[e,n]=x.useState(""),[r,i]=x.useState(!1),[s,o]=x.useState(0),a=x.useRef(null),{handleGenerateInstrument:l}=U0(),{showBanner:u}=ts(),{updateBloobDetails:d}=Gn(),{commitToStore:f}=Ln(),{loadBloobAudio:h}=es();x.useEffect(()=>{if(!r){o(0);return}const g=Date.now(),w=47e3,v=setInterval(()=>{const S=Date.now()-g,C=Math.min(S/w*100,95);o(C),C>=95&&clearInterval(v)},50);return()=>clearInterval(v)},[r]);const m=x.useCallback(async g=>{g.preventDefault();const w=e.trim();if(!w){u("Please enter an instrument description");return}i(!0);try{const v=await l(w);o(100),d(t,{instrument:v}),await h(t),f(),u(`Generated "${v}"`),n(""),setTimeout(()=>{o(0),i(!1)},500)}catch{u("Failed to generate instrument. Please try again."),i(!1),o(0)}},[e,t,l,d,f,u,h]),y=x.useCallback(g=>{g.key==="Enter"&&(g.preventDefault(),m(g))},[m]);return c.jsxs("div",{children:[c.jsx("style",{children:` 770 @keyframes gradientShift { 771 0% { 772 background-position: 0% 50%; 773 } 774 50% { 775 background-position: 100% 50%; 776 } 777 100% { 778 background-position: 0% 50%; 779 } 780 } 781 782 .gradient-placeholder::placeholder { 783 background: linear-gradient(90deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 100%); 784 background-size: 200% 100%; 785 background-clip: text; 786 -webkit-background-clip: text; 787 -webkit-text-fill-color: transparent; 788 background-position: 0% 50%; 789 } 790 791 .gradient-placeholder.animating::placeholder { 792 animation: gradientShift 10s ease infinite; 793 } 794 `}),c.jsx("form",{onSubmit:m,className:"relative",children:c.jsxs("div",{className:"relative rounded-md overflow-hidden",style:{padding:"1.5px"},children:[c.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(45deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 33%, rgb(248, 194, 145) 66%, rgb(125, 195, 131) 100%)",backgroundSize:"300% 100%",backgroundPosition:"0% 50%",opacity:.6}}),c.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1.5 bg-zinc-50 dark:bg-zinc-800 rounded-md",children:[c.jsx(KS,{className:"flex-shrink-0 text-zinc-500 dark:text-zinc-400",size:16}),c.jsxs("div",{className:"relative flex-1 rounded-sm overflow-hidden",children:[r&&c.jsx("div",{className:"absolute inset-y-0 left-0 transition-all duration-300 ease-out",style:{width:`${s}%`,background:"linear-gradient(45deg, rgb(125, 195, 131) 0%, rgb(107, 136, 204) 33%, rgb(248, 194, 145) 66%, rgb(125, 195, 131) 100%)",backgroundSize:"300% 100%",backgroundPosition:"0% 50%"}}),c.jsx("input",{ref:a,type:"text",value:e,onChange:g=>n(g.target.value),onKeyDown:y,disabled:r,placeholder:"Generate instrument...",className:`gradient-placeholder ${r?"animating":""} relative w-full bg-transparent text-zinc-700 dark:text-zinc-200 outline-none text-sm disabled:opacity-50`,autoComplete:"off"})]}),r&&c.jsx("div",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center",children:c.jsx(et.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:c.jsx(Da,{className:"text-caiGreen animate-spin",size:16})})})]})]})})]})},MC=({bloobId:t,containerRef:e})=>{var ce,se,ye;const n=qc(t),r=n?`song:${n.songId}`:"",i=Vr(r),{isMobile:s}=Hn(),{getAudioFileById:o,findOpenSongPositionNear:a,getBloobsOverlappingWithPosition:l,getBloobName:u}=mn(),{updateBloobDetails:d,deleteBloob:f,updateAudioFileDetails:h,duplicateBloob:m,extendBloob:y}=Gn(),{commitToStore:g}=Ln(),{selectCaiObject:w,deselectAllCaiObjects:v}=cr(),{showBloobDetails:S}=Xs(),{showVolumeAutomation:C}
794=Pn(),{closeMobileInspector:k,showMobileRecordDetails:N,toggleVolumeAutomation:_}=Br(),[j,T]=x.useState(!1),M=x.useMemo(()=>u(n.id),[n,u]),[V,H]=x.useState(M),P=x.useRef(null),{isRecording:F}=Lo(),{togglePlayStop:I,isPlaying:R}=zs(),{showBanner:U}=ts(),{loadBloobAudio:A}=es(),W=x.useRef(null),[D,B]=x.useState(!1),[L,$]=x.useState(""),[q,Z]=x.useState(!1),[ie,ge]=x.useState(""),re=n&&ln(n),be=n&&ln(n)&&ci(n.instrument)!==$r.BuiltInDrumMachine;x.useEffect(()=>{T(!1),H(M)},[n,M]),x.useEffect(()=>{j&&P.current&&P.current.focus()},[j]);const we=x.useCallback(()=>{k(),S(t)},[t,k,S]),te=x.useCallback(()=>{if(!n)return;const ke=a(n.songId,n.songPosition,n.bars??1);if(ke==null)return;const ze=m(t,ke);w({type:J.Bloob,id:ze},!0),k(),g()},[n,t,k,g,m,a,w]),fe=x.useCallback(()=>{if(!n)return;const ke={bar:n.songPosition.bar+n.bars,track:n.songPosition.track},ze={bar:n.songPosition.bar-n.bars,track:n.songPosition.track},qe=l(n.songId,ke,1),ot=l(n.songId,ze,1);if(qe.length>0&&ot.length>0){U("Not enough space on either side of the bloob to extend it");return}qe.length===0?y(t,Qy.Right):ot.length===0&&y(t,Qy.Left),A(t),k(),g()},[n,t,k,g,y,l,A,U]),O=x.useCallback(()=>{n&&(f(t),v(),k(),g())},[t,n,f,g,v,k]),pe=x.useCallback(ke=>{H(ke.target.value)},[]),he=x.useCallback(()=>{if(!n)return;const ke=V.trim();ke!==M&&(ke===""?H(M):(d(t,{label:ke}),g()),T(!1))},[n,V,M,d,t,g]),le=x.useCallback(ke=>{d(t,{volume:ke})},[t,d]),oe=x.useMemo(()=>G2(n.volume,Ss),[n.volume]),Q=x.useCallback(()=>{var ke;!C&&!((ke=n==null?void 0:n.volumeAutomation)!=null&&ke.length)&&(d(t,{volumeAutomation:[{bar:0,value:1},{bar:n.bars,value:1}]}),g()),_()},[C,n,t,_,d,g]),de=x.useCallback(()=>{n&&(d(t,{muted:!n.muted}),g())},[t,d,g,n]),Ne=x.useCallback(()=>{n&&(d(t,{soloed:!n.soloed}),g())},[t,d,g,n]),Ce=x.useCallback(()=>{n&&(k(),I(!0))},[n,k,I]),Ae=x.useCallback(()=>{N()},[N]),{bind:Ue}=V0({onShortPress:Ce,onLongPress:s?Ae:Ce}),Se=x.useCallback(ke=>{$(ke.target.value)},[]),ve=x.useCallback(()=>{if(!n||!En(n))return;const ke=L.trim();if(ke){const ze=/^([A-G][#b]?)\s*(.*)$/i,qe=ke.match(ze);if(qe){const ot=qe[1].charAt(0).toUpperCase()+qe[1].slice(1).toLowerCase(),Ze=qe[2];let _t="";Ze==="m"||Ze.toLowerCase().includes("min")||Ze.toLowerCase().includes("minor")?_t="Minor":_t="Major";const tt={chroma:ot,quality:_t};h(n.audioFileId,{newOriginalKey:tt}),g()}}B(!1)},[n,L,h,g]),je=x.useCallback(ke=>{ge(ke.target.value)},[]),Te=x.useCallback(()=>{if(!n||!En(n))return;const ke=parseInt(ie);!isNaN(ke)&&ke>0&&ke<=300&&(h(n.audioFileId,{newOriginalBpm:ke}),g()),Z(!1)},[n,ie,h,g]);return n?c.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[!i&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"text-xl rounded-lg flex items-center justify-between gap-1",children:[c.jsx("input",{ref:P,type:"text",id:`bloob-header-${t}`,name:`bloob-header-${t}`,value:V,onChange:pe,onBlur:he,onKeyDown:ke=>{ke.key==="Enter"&&ke.currentTarget.blur()},onClick:()=>i&&T(!0),readOnly:!i,className:`bg-transparent underline underline-offset-4 decoration-4 text-cai-secondary outline-none w-full ${i?"cursor-pointer":"cursor-default"} ${j?"cursor-text":"overflow-hidden text-ellipsis whitespace-nowrap"}`,style:{textDecorationColor:n.color}}),i&&c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded",onClick:O,title:"Delete Bloob",children:c.jsx(js,{className:"size-6 text-red-500 dark:text-red-500"})})]}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-full flex items-center gap-2",children:c.jsx(_s,{min:Ss,max:0,step:.1,value:oe,renderValue:ke=>ke<=Ss?"-inf":`${ke.toFixed(1)}`,onChange:ke=>le(Q4(ke,Ss)),onAfterChange:g,title:"Volume (dB)",label:c.jsx(Ya,{className:"size-5 text-cai-secondary"}),id:`bloob-volume-${t}`,doubleClickValue:0})}),re?c.jsx(TC,{bloobId:t}):c.jsx(Wfe,{audioFileId:n.audioFileId}),be&&c.jsx(Kfe,{bloobId:t}),c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx(Cs,{onClick:de,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Ih,{className:`size-4 ${n.muted?"text-cai-secondary":"text-zinc-300 dark:text-zinc-500"}`}),c.jsx("span",{className:"text-cai-secondary",children:n.muted?"Unmute":"Mute"})]})}),c.jsx(Cs,{onClick:Ne,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Eh,{className:`size-4 ${n.soloed?"text-cai-secondary":"text-zinc-300 dark:text-zinc-500"}`}),c.jsx("span",{className:"text-cai-secondary",children:n.soloed?"Unsolo":"Solo"})]})})]}),(re||n&&En(n))&&c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx(Cs,{onClick:we,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Mn,{className:"size-4 text-cai-secondary"}),c.jsx("span",{className:"text-cai-secondary",children:"Details"})]})}),c.jsx(Cs,{ref:W,bind:Ue,disabled:R&&!F,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[F?c.jsx(nv,{className:"size-4 text-red-500 fill-red-500"}):c.jsx(ld,{className:`size-4 ${R&&!F?"text-red-300 fill-red-300":"text-red-500 fill-red-500"}`}),c.jsx("span",{className:`text-cai-secondary ${R&&!F?"opacity-50":""}`,children:F?"Stop":"Record"})]})}),!s&&c.jsx(xv,{hoverTriggerRef:W,positionAnchorRef:e,disabled:R&&!F})]}),En(n)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx(Cs,{onClick:()=>B(!0),children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Mn,{className:"size-4 text-cai-secondary"}),D?c.jsx("input",{type:"text",value:L,onChange:Se,onBlur:ve,onKeyDown:ke=>{ke.key==="Enter"&&ke.currentTarget.blur()},className:"bg-transparent text-cai-secondary outline-none text-center",style:{width:"6c
794h"},autoFocus:!0}):c.jsx("span",{className:"text-cai-secondary text-center",style:{minWidth:"6ch"},children:((se=(ce=o(n.audioFileId))==null?void 0:ce.originalKey)==null?void 0:se.chroma)||"Set Key"})]})}),c.jsx(Cs,{onClick:()=>Z(!0),children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(ore,{className:"size-4 text-cai-secondary"}),q?c.jsx("input",{type:"text",value:ie,onChange:je,onBlur:Te,onKeyDown:ke=>{ke.key==="Enter"&&ke.currentTarget.blur()},className:"bg-transparent text-cai-secondary outline-none text-center",style:{width:"4ch"},autoFocus:!0}):c.jsx("span",{className:"text-cai-secondary text-center",style:{minWidth:"4ch"},children:((ye=o(n.audioFileId))==null?void 0:ye.originalBpm)||"Set BPM"})]})})]}),c.jsx("div",{className:"flex items-center gap-3 w-full",children:c.jsx(Cs,{onClick:Ce,disabled:R&&!F,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[F?c.jsx(nv,{className:"size-4 text-red-500 fill-red-500"}):c.jsx(ld,{className:`size-4 ${R&&!F?"text-red-300 fill-red-300":"text-red-500 fill-red-500"}`}),c.jsx("span",{className:`text-cai-secondary ${R&&!F?"opacity-50":""}`,children:F?"Stop Recording":"Record New Audio"})]})})})]}),c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx(Cs,{onClick:fe,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(mD,{className:"size-4 text-cai-secondary"}),c.jsx("span",{className:"text-cai-secondary",children:"Extend"})]})}),c.jsx(Cs,{onClick:te,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{className:"size-4 text-cai-secondary"}),c.jsx("span",{className:"text-cai-secondary",children:"Copy"})]})})]}),c.jsxs("button",{onClick:Q,className:"w-full flex items-center justify-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium transition-colors bg-zinc-100 dark:bg-zinc-800 text-cai-secondary hover:bg-zinc-200 dark:hover:bg-zinc-700",title:C?"Hide volume automation (A)":"Show volume automation (A)",children:[c.jsx(Qee,{className:"size-3.5 shrink-0"}),c.jsx("span",{children:C?"Editing Automation":"Volume Automation"})]})]})]}):null},al=({isOpen:t,onClose:e,onConfirm:n,title:r,message:i,confirmText:s="Confirm",isDangerous:o=!1})=>{const{isDarkMode:a}=Pn();return x.useEffect(()=>{if(!t)return;const l=u=>{u.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,e]),t?Vh.createPortal(c.jsx(Vn,{children:t&&c.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[100] p-4",children:c.jsx(et.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"},className:`relative max-w-md w-full rounded-2xl shadow-2xl border ${a?"bg-gradient-to-br from-zinc-900/100 to-zinc-600/25 backdrop-blur-sm border-zinc-700":"bg-gradient-to-br from-zinc-200/100 to-zinc-100/25 backdrop-blur-sm border-zinc-300"}`,children:c.jsxs("div",{className:"p-6",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h3",{className:`text-lg font-semibold ${a?"text-zinc-100":"text-zinc-900"}`,children:r}),c.jsx("button",{onClick:e,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${a?"hover:bg-white":"hover:bg-black"}`,children:c.jsx(nr,{size:18})})]}),c.jsx("p",{className:`text-sm mb-6 ${a?"text-zinc-300":"text-zinc-600"}`,children:i}),c.jsxs("div",{className:"flex gap-3 justify-end",children:[c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:e,className:`px-4 py-2 rounded-lg border transition-colors ${a?"bg-gradient-to-br from-zinc-800/80 to-zinc-700/50 backdrop-blur-sm border-zinc-600 text-zinc-200 hover:bg-zinc-700/50":"bg-gradient-to-br from-zinc-100/80 to-zinc-200/50 backdrop-blur-sm border-zinc-300 text-zinc-700 hover:bg-zinc-200/50"}`,children:"Cancel"}),c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:n,className:`px-4 py-2 rounded-lg font-medium transition-colors ${o?"bg-red-600 hover:bg-red-700 text-white":"bg-gradient-to-r from-caiGreen to-caiBlue hover:from-caiGreen/90 hover:to-caiBlue/90 text-white"}`,children:s})]})]})})})}),document.body):null},Yfe=({song:t,canEdit:e,setBpm:n,commitToStore:r})=>
794{const[i,s]=x.useState(!1),[o,a]=x.useState(String(t.bpm)),l=x.useRef(null);x.useEffect(()=>{i||a(String(t.bpm))},[t.bpm,i]),x.useEffect(()=>{i&&l.current&&(l.current.focus(),l.current.select())},[i]);const u=x.useCallback(()=>{const f=o.replace(/\D/g,""),h=parseInt(f,10);if(!isNaN(h)){const m=Math.min(300,Math.max(30,h));n(m),r()}s(!1)},[o,n,r]),d=x.useCallback(f=>{f.key==="Enter"?(f.preventDefault(),u()):f.key==="Escape"&&(a(String(t.bpm)),s(!1))},[u,t.bpm]);return c.jsxs("div",{className:"flex flex-col items-center shrink-0 w-12 max-w-[3rem] min-w-0 overflow-hidden",style:{pointerEvents:e?"auto":"none",opacity:e?1:.8},children:[i?c.jsx("input",{ref:l,type:"text",inputMode:"numeric",id:`song-bpm-text-${t.id}`,value:o,onChange:f=>a(f.target.value.replace(/\D/g,"").slice(0,3)),onBlur:u,onKeyDown:d,className:"box-border w-full min-w-0 max-w-full text-center text-sm font-semibold tabular-nums bg-transparent outline-none text-zinc-800 dark:text-zinc-100 border-b border-zinc-400/50 dark:border-zinc-500/50","aria-label":"BPM"}):c.jsx("button",{type:"button",onClick:()=>e&&s(!0),className:"text-sm font-semibold tabular-nums text-zinc-800 dark:text-zinc-100 min-h-[1.25rem] px-0.5 rounded hover:bg-zinc-200/50 dark:hover:bg-zinc-700/50",children:t.bpm}),c.jsx("span",{className:"text-[10px] text-zinc-500 dark:text-zinc-400 mt-0.5",children:"bpm"})]})},BC=({songId:t,variant:e="default"})=>{const n=wd(t),{updateSongDetails:r}=Gn(),{commitToStore:i}=Ln(),s=Vr(`song:${t}`),o=x.useCallback(l=>{r(t,{bpm:l})},[t,r]);if(!n)return null;if(e==="compactText")return c.jsx(Yfe,{song:n,canEdit:s,setBpm:o,commitToStore:i});if(e==="modal")return c.jsx("div",{className:"w-full min-w-0 overflow-hidden",style:{pointerEvents:s?"auto":"none",opacity:s?1:.8},children:c.jsx(_s,{label:"BPM",id:`song-bpm-modal-${t}`,min:30,max:300,value:n.bpm,doubleClickValue:120,valueOnThumb:!0,showLabelColumn:!1,onChange:o,onAfterChange:i})});const a=c.jsx("div",{style:{pointerEvents:s?"auto":"none",opacity:s?1:.8},children:c.jsx(_s,{label:"BPM",id:`song-bpm-${t}`,min:30,max:300,value:n.bpm,doubleClickValue:120,valueOnThumb:!0,onChange:o,onAfterChange:i})});return e==="compact"?c.jsx("div",{className:"min-w-[7.5rem] max-w-[11rem] w-[10rem] shrink-0",children:a}):a},RC=({songId:t,variant:e="default",align:n="center"})=>{var T;const r=wd(t),{updateSongDetails:i,transposeBloobs:s}=Gn(),{commitToStore:o}=Ln(),{showBanner:a}=ts(),l=Vr(`song:${t}`),[u,d]=x.useState(!1),[f,h]=x.useState(((T=r==null?void 0:r.key)==null?void 0:T.chroma)||"C"),[m,y]=x.useState(""),g=x.useRef(null),w=x.useMemo(()=>r?Array.from(r.bloobIds).length>0:!1,[r]),v=x.useMemo(()=>{if(!r)return[];switch(r.key.quality){case"Major":return["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B"];case"Minor":return["C","C#","D","D#","Eb","E","F","F#","G","G#","Ab","A","A#","Bb","B"];default:return[]}},[r]);x.useEffect(()=>{var M;h(((M=r==null?void 0:r.key)==null?void 0:M.chroma)||"C")},[r]),x.useEffect(()=>{u&&g.current&&(g.current.focus(),g.current.select())},[u]);const S=x.useCallback(()=>{l&&d(!0)},[l]),C=x.useCallback(M=>{h(M.target.value.slice(0,2))},[]),k=x.useCallback(()=>{if(!r)return;const M=f.charAt(0).toUpperCase()+f.slice(1);if(v.includes(M)){const V=Array.from(r.bloobIds);s(V,r.key.chroma,M),i(t,{key:{chroma:M,quality:r.key.quality}}),o()}else h(r.key.chroma);d(!1)},[f,r,t,s,i,o,v]),N=x.useCallback(()=>{r&&(w?(a("Cannot change key quality when there are bloobs in the song"),y("animate-shake"),setTimeout(()=>{y("")},500)):(y("animate-fade-scale"),setTimeout(()=>{const M=r.key.quality==="Major"?"Minor":"Major";i(t,{key:{chroma:r.key.chroma,quality:M}}),o(),y("")},300)))},[o,a,r,t,i,w]);if(!r)return null;const _=e==="compact",j=n==="start";return c.jsxs("div",{className:`flex flex-col ${j?"items-start":"items-center"} ${_?"shrink-0":"flex-1"}`,children:[c.jsx("div",{className:`flex items-center ${j?"justify-start":"justify-center"}`,style:_?void 0:{height:"48px"},children:u?c.jsx("input",{ref:g,type:"text",id:`song-key-${t}`,name:`song-key-${t}`,value:f,onChange:C,onBlur:k,onKeyDown:M=>{M.key==="Enter"&&M.currentTarget.blur()},className:`bg-transparent ${j?"text-left":"text-center"} text-zinc-700 dark:text-zinc-100 outline-none ${_?"text-base w-12":"text-4xl w-16"}`,style:{margin:0,padding:0}}):c.jsx("div",{className:`${j?"text-left":"text-center"}
794 ${l?"cursor-pointer":"cursor-default"} ${_?"text-base font-semibold w-10":"text-4xl w-16"}`,onClick:S,title:l?"Click to edit key":void 0,style:{lineHeight:1,margin:0,padding:0},children:r.key.chroma})}),c.jsx("button",{type:"button",className:`${m} ${_?"text-[10px] mt-0.5":"text-sm"} ${j?"text-left":""}`,onClick:l?N:void 0,title:l?"Click to change key quality":void 0,disabled:!l,children:r.key.quality})]})},Xfe=({songId:t})=>{const{getSongName:e}=mn(),n=`song:${t}`,r=Vr(n),i=N0(n),s=I0(n),o=at(ne=>ne.domainRoleByChannel),a=at(ne=>ne.sharedByMe),l=So(n,o,a),{updateSongDetails:u,deleteSong:d,organizeBloobs:f,duplicateSong:h}=Gn(),{selectCaiObject:m,deselectAllCaiObjects:y}=cr(),{commitToStore:g}=Ln(),w=wd(t),[v,S]=x.useState(!1),C=x.useMemo(()=>e(w.id),[w,e]),[k,N]=x.useState(C),[_,j]=x.useState(!1),[T,M]=x.useState(""),[V,H]=x.useState(""),P=x.useRef(null),F=x.useRef(null),{isPlaying:I,togglePlayStop:R}=zs(),{showBanner:U}=ts(),{closeMobileInspector:A}=Br(),W=x.useMemo(()=>w?Array.from(w.bloobIds).length>0:!1,[w]);x.useEffect(()=>{S(!1),N(C),M(w?`${w.timeSignature.beatsPerBar}/${w.timeSignature.beatDuration}`:"4/4"),j(!1)},[w,C]),x.useEffect(()=>{v&&P.current&&P.current.focus()},[v]),x.useEffect(()=>{_&&F.current&&(F.current.focus(),F.current.select())},[_]);const D=x.useCallback(ne=>{N(ne.target.value)},[]),B=x.useCallback(()=>{if(!w)return;const ne=Ro(w.canvasPosition),be=h(w.id,ne);m({type:J.Song,id:be}),A(),g()},[w,h,m,g,A]),[L,$]=x.useState(!1),q=x.useCallback(()=>{w&&(I&&R(),d(t),y(),A(),g(),$(!1))},[w,I,d,t,y,A,g,R]),Z=x.useCallback(()=>{if(!w)return;const ne=k.trim();ne!==C&&(ne===""?N(C):(u(t,{label:k.trim()}),g()),S(!1))},[w,k,C,u,t,g]),ie=x.useCallback(()=>{W?(U("Cannot change time signature when there are bloobs in the song"),H("animate-shake"),setTimeout(()=>{H("")},500)):j(!0)},[U,W]),ge=x.useCallback(ne=>{M(ne.target.value)},[]),re=x.useCallback(()=>{if(!w)return;const ne=T.split("/");if(ne.length===2){const be=parseInt(ne[0],10),we=parseInt(ne[1],10),te=Math.max(1,Math.min(16,be)),fe=[1,2,4,8,16].includes(we)?we:4;!isNaN(te)&&!isNaN(fe)?((te!==w.timeSignature.beatsPerBar||fe!==w.timeSignature.beatDuration)&&(u(t,{timeSignature:{beatsPerBar:te,beatDuration:fe}}),g()),M(`${te}/${fe}`)):M(`${w.timeSignature.beatsPerBar}/${w.timeSignature.beatDuration}`)}else M(`${w.timeSignature.beatsPerBar}/${w.timeSignature.beatDuration}`);j(!1)},[w,t,T,u,g]),Y=x.useCallback(()=>{w&&(f(t),A(),g())},[w,f,t,g,A]);return w?c.jsxs("div",{className:"flex flex-col gap-2",children:[!r&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"flex items-center justify-between gap-1",children:[c.jsx("input",{ref:P,type:"text",id:`song-header-${t}`,name:`song-header-${t}`,value:k,onChange:D,onBlur:Z,onKeyDown:ne=>{ne.key==="Enter"&&ne.currentTarget.blur()},onClick:()=>r&&S(!0),readOnly:!r,className:`bg-transparent text-xl underline underline-offset-4 decoration-4 decoration-zinc-400 dark:decoration-zinc-500 text-zinc-700 dark:text-zinc-100 outline-none w-full ${r?"cursor-pointer":"cursor-default"} ${v?"":"overflow-hidden text-ellipsis whitespace-nowrap"}`}),i?c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded ml-2",onClick:()=>$(!0),title:"Delete Song",children:c.jsx(js,{className:"size-6 text-red-500 dark:text-red-500"})}):null]}),c.jsx(BC,{songId:t}),c.jsxs("div",{className:"flex items-center w-full justify-around text-zinc-700 dark:text-zinc-100",children:[c.jsx("div",{className:`flex-1 flex justify-center items-center gap-1 text-4xl ${r?"cursor-pointer":"cursor-default"} ${V}`,title:r?"Click to edit time signature":void 0,onClick:r?ie:void 0,children:_?c.jsx("input",{ref:F,type:"text",id:`song-time-signature-${t}`,name:`song-time-signature-${t}`,value:T,onChange:ge,onBlur:re,onKeyDown:ne=>{ne.key==="Enter"&&ne.currentTarget.blur()},className:"bg-transparent text-center text-4xl w-20 text-zinc-700 dark:text-zinc-100 outline-none",placeholder:"4/4"}):c.jsxs(c.Fragment,{children:[c.jsx("sup",{children:w.timeSignature.beatsPerBar}),c.jsx("span",{className:"text-2xl",children:"/"}),c.jsx("sub",{children:w.timeSignature.beatDuration})]})}),c.jsx("div",{className:"w-px h-12 bg-zinc-300 dark:bg-zinc-600"}),c.jsx(RC,{songId:t})]}),c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[r&&c.jsx(Cs,{onClick:Y,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(dre,{className:"size-4 text-zinc-700 dark:text-zinc-100"}),c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100",children:"Organize"})]})}),s&&c.jsx(Cs,{onClick:B,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{
794className:"size-4 text-zinc-700 dark:text-zinc-100"}),c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100",children:"Copy"})]})})]}),c.jsx(al,{isOpen:L,onClose:()=>$(!1),onConfirm:q,title:"Delete Song",message:`Are you sure you want to delete "${C}"? This will permanently remove the song and all its bloobs.${l?" This object is currently shared with collaborators.":""}`,confirmText:"Delete Song",isDangerous:!0})]}):null},Lk=({title:t,enabled:e,onToggle:n,canEdit:r,children:i})=>c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:t}),c.jsx("button",{type:"button",onClick:r?n:void 0,className:`w-8 h-4 rounded-full transition-colors duration-150 p-0.5 flex items-center overflow-hidden ${r?"cursor-pointer":"opacity-50 cursor-not-allowed"} ${e?"bg-sky-500/80":"bg-zinc-300 dark:bg-zinc-600"} ${e?"justify-end":"justify-start"}`,title:e?`Disable ${t}`:`Enable ${t}`,children:c.jsx("span",{className:"w-3 h-3 rounded-full bg-white shadow-sm"})})]}),e&&i]}),OC=({trackId:t,showSongTitle:e=!0,showTrackName:n=!0,showTrackMixControls:r=!0})=>{const{tracks:i,bloobs:s,getSongById:o}=mn(),{updateTrackEffects:a,updateTrackName:l,updateBloobDetails:u,setTrackInstrumentLock:d}=Gn(),{commitToStore:f}=Ln(),h=i[t],m=h?o(h.songId):null,y=h?`song:${h.songId}`:"",g=Vr(y),w=(h==null?void 0:h.effects)??null,v=(h==null?void 0:h.name)||`Track ${((h==null?void 0:h.trackIndex)??0)+1}`,S=(h==null?void 0:h.instrumentLock)||"",[C,k]=x.useState(!1),[N,_]=x.useState(v),j=x.useRef(null);x.useEffect(()=>{_(v),k(!1)},[v]),x.useEffect(()=>{C&&j.current&&(j.current.focus(),j.current.select())},[C]);const T=x.useCallback(()=>{const U=N.trim();U&&U!==v?(l(t,U),f()):_(v),k(!1)},[N,v,t,l,f]),M=x.useMemo(()=>!e||!m?"":m.label||`Song ${m.id}`,[m,e]),V=x.useMemo(()=>!m||!h?[]:Array.from(m.bloobIds).map(U=>s[U]).filter(U=>U!==void 0&&U.songPosition.track===h.trackIndex),[m,h,s]),H=x.useMemo(()=>V.length>0&&V.every(U=>U.muted),[V]),P=x.useMemo(()=>V.length>0&&V.every(U=>U.soloed),[V]),F=x.useCallback(()=>{if(!g)return;const U=!H;V.forEach(A=>{A.muted!==U&&u(A.id,{muted:U})}),f()},[g,H,V,u,f]),I=x.useCallback(()=>{if(!g)return;const U=!P;V.forEach(A=>{A.soloed!==U&&u(A.id,{soloed:U})}),f()},[g,P,V,u,f]),R=x.useCallback(U=>{!g||!h||(a(t,U),f())},[g,h,t,a,f]);return!h||!w?null:c.jsxs("div",{className:"flex flex-col gap-3",children:[!g&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),(e||n)&&c.jsxs("div",{children:[e&&M?c.jsx("div",{className:"text-xs text-zinc-400 dark:text-zinc-500 truncate",children:M}):null,n&&(C?c.jsx("input",{ref:j,type:"text",value:N,onChange:U=>_(U.target.value),onBlur:T,onKeyDown:U=>{U.key==="Enter"&&U.currentTarget.blur(),U.key==="Escape"&&(_(v),k(!1))},className:"bg-transparent text-lg font-semibold text-zinc-700 dark:text-zinc-100 outline-none w-full"}):c.jsx("div",{className:`text-lg font-semibold text-zinc-700 dark:text-zinc-100 truncate ${g?"cursor-pointer":""}`,onClick:()=>g&&k(!0),title:g?"Click to rename":v,children:v}))]}),c.jsx("div",{className:"w-full h-px bg-zinc-200 dark:bg-zinc-700"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:"Instrument Lock"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:`flex-1 min-w-0 ${g?"":"pointer-events-none opacity-60"}`,children:c.jsx(tN,{currentInstrument:S,currentInstrumentDisplay:S?$l(S):"No Lock",title:"Instrument Lock",children:c.jsx(jL,{onSelectInstrument:U=>{g&&(d(h.id,U),f())}})})}),c.jsx("button",{type:"button",disabled:!g||!S,onClick:()=>{d(h.id,null),f()},className:`shrink-0 flex h-7 w-7 items-center justify-center rounded border transition-colors ${!g||!S?"cursor-not-allowed border-zinc-300 dark:border-zinc-700 text-zinc-400 opacity-50":"border-zinc-400 dark:border-zinc-600 text-zinc-600 dark:text-zinc-300 hover:bg-zinc-200 dark:hover:bg-zinc-700"}`,title:"Clear instrument lock","aria-label":"Clear instrument lock",children:c.jsx(nr,{className:"size-3.5",strokeWidth:2.25})})]})]}),c.jsx("div",{className:"w-full h-px bg-zinc-200 dark:bg-zinc-700"}),r&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",onClick:F,disabled:!g,className:`flex-1 h-7 rounded text-xs font-semibold transition-colors ${g?H?"bg-red-500/90 text-white":"bg-zinc-300/70 dark:bg-zinc-600/50 text-zinc-700 dark:text-zinc-200 hover:bg-zinc-400/60 dark:hover:bg-zinc-500/50":"opacity-50 cursor-not-allowed bg-zinc-300/50 dark:bg-zinc-700/50 text-zinc-500"}`,title:H?"Unmute track":"Mute track",children:"Mute"}),c.jsx("button",{type:"button",onClick:I,disabled:!g,className:`flex-1 h-7 rounded text-xs font-semibold transition-colors ${g?P?"bg-amber-400/90 text-zinc-900":"bg-zinc-300/70 dark:bg-zinc-600/50 text-zinc-700 dark:text-zinc-200 hover:bg-zinc-400/60 dark:hover:bg-zinc-500/50":"opacity-50 cursor-not-allowed bg-zinc-300/50 dark:bg-zinc-700/50 text-zinc-500"}`,title:P?"Unsolo track":"Solo track",children:"Solo"})]}),c.jsx("div",{className:"w-full h-px bg-zinc-200 dark:bg-zinc-700"})]}),c.jsxs(Lk,{title:"EQ",enabled:w.eq.enabled,canEdit:g,onToggle:()=>R({eq:{...w.eq,enabled:!w.eq.enabled}}),children:[c.jsx(_s,{id:`track-${t}-eq-low`,min:-12,max:12,step:.5,value:w.eq.lowGain,doubleClickValue:0,onChange:U=>R({eq:{...w.eq,lowGain:U}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Low"}),renderValue:U=>`${U>0?"+":""}${U}dB`,title:"Low shelf gain",labelAlign:"left"}),c.jsx(_s,{id:`track-${t}-eq-mid`,min:-12,max:12,step:.5,value:w.eq.midGain,doubleClickValue:0,onChange:U=>R({eq:{...w.eq,midGain:U}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Mid"}),renderValue:U=>`${U>0?"+":""}${U}dB`,title:"Mid peaking gain",labelAlign:"left"}),c.jsx(_s,{id:`track-${t}-eq-high`,min:-12,max:12,step:.5,value:w.eq.highGain,doubleClickValue:0,onChange:U=>R({eq:{...w.eq,highGain:U}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"High"}),renderValue:U=>`${U>0?"+":""}${U}dB`,title:"High shelf gain",labelAlign:"left"})]}),c.jsx("div",{className:"w-full h-px bg-zinc-200 dark:bg-zinc-700"}),c.jsxs(Lk,{title:"Compressor",enabled:w.compressor.enabled,canEdit:g,onToggle:()=>R({compressor:{...w.compressor,enabled:!w.compressor.enabled}}),children:[c.jsx(_s,{id:`track-${t}-comp-threshold`,min:-60,max:0,step:1,value:w.compressor.threshold,doubleClickValue:-24,onChange:U=>R({compressor:{...w.compressor,threshold:U}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Thr"}),renderValue:U=>`${U}dB`,title:"Threshold",labelAlign:"left"}),c.jsx(_s,{id:`track-${t}-comp-ratio`,min:1,max:20,step:.5,value:w.compressor.ratio,doubleClickValue:4,onChange:U=>R({compressor:{...w.compressor,ratio:U}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Ratio"}),renderValue:U=>`${U}:1`,title:"Ratio",labelAlign:"left"}),c.jsx(_s,{id:`track-${t}-comp-attack`,min:0,max:100,step:1,value:Math.round(w.compressor.attack*1e3),doubleClickValue:3,onCh
794ange:U=>R({compressor:{...w.compressor,attack:U/1e3}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Atk"}),renderValue:U=>`${U}ms`,title:"Attack",labelAlign:"left"}),c.jsx(_s,{id:`track-${t}-comp-release`,min:10,max:1e3,step:10,value:Math.round(w.compressor.release*1e3),doubleClickValue:250,onChange:U=>R({compressor:{...w.compressor,release:U/1e3}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Rel"}),renderValue:U=>`${U}ms`,title:"Release",labelAlign:"left"})]}),c.jsx("div",{className:"w-full h-px bg-zinc-200 dark:bg-zinc-700"}),c.jsx(Lk,{title:"Reverb",enabled:w.reverb.enabled,canEdit:g,onToggle:()=>R({reverb:{...w.reverb,enabled:!w.reverb.enabled}}),children:c.jsx(_s,{id:`track-${t}-reverb-send`,min:0,max:100,step:1,value:Math.round(w.reverb.send*100),doubleClickValue:0,onChange:U=>R({reverb:{...w.reverb,send:U/100}}),onAfterChange:f,label:c.jsx("span",{className:"text-[10px]",children:"Send"}),renderValue:U=>`${U}%`,title:"Reverb send level",labelAlign:"left"})})]})},Qfe=({textNode:t})=>{const{getTextNodeName:e}=mn(),n=`text_node:${t.id}`,r=Vr(n),i=N0(n),s=I0(n),o=at(F=>F.domainRoleByChannel),a=at(F=>F.sharedByMe),l=So(n,o,a),{updateTextNode:u,deleteTextNode:d,duplicateTextNode:f}=Gn(),{selectCaiObject:h,deselectAllCaiObjects:m}=cr(),{commitToStore:y}=Ln(),{closeMobileInspector:g}=Br(),[w,v]=x.useState(!1),S=x.useMemo(()=>e(t.id),[t,e]),[C,k]=x.useState(S),[N,_]=x.useState(!1),j=x.useRef(null),T=x.useMemo(()=>{const F=(t==null?void 0:t.content)||"";if(!F.trim())return 0;const I=document.createElement("div");I.innerHTML=F;const R=I.querySelectorAll("br").length,U=I.querySelectorAll("div, p, h1, h2, h3, h4, h5, h6, li").length;return(I.textContent||I.innerText||"").trim()?1+R+Math.max(0,U-1):0},[t==null?void 0:t.content]),M=x.useCallback(F=>{k(F.target.value)},[]),V=x.useCallback(()=>{if(!t)return;const F=C.trim();F!==S&&(F===""?k(S):(u(t.id,{label:F}),y()),v(!1))},[t,C,S,u,y]),H=x.useCallback(()=>{if(!t)return;const F=Ro(t.canvasPosition),I=f(t.id,F);h({type:J.TextNode,id:I}),g(),y()},[t,f,h,y,g]),P=x.useCallback(()=>{t&&(d(t.id),m(),g(),y(),_(!1))},[t,d,m,y,g]);return x.useEffect(()=>{v(!1),k(S)},[t,S]),x.useEffect(()=>{w&&j.current&&j.current.focus()},[w]),t?c.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[!r&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"text-xl rounded-lg flex items-center justify-between gap-1",children:[c.jsx("input",{ref:j,type:"text",id:`notes-node-header-${t.id}`,name:`notes-node-header-${t.id}`,value:C,onChange:M,onBlur:V,onKeyDown:F=>{F.key==="Enter"&&F.currentTarget.blur()},onClick:()=>r&&v(!0),readOnly:!r,className:`bg-transparent underline underline-offset-4 decoration-4 decoration-yellow-500 text-cai-secondary outline-none w-full ${r?"cursor-pointer":"cursor-default"} ${w?"cursor-text":"overflow-hidden text-ellipsis whitespace-nowrap"}`}),i&&c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded",onClick:()=>_(!0),title:"Delete Notes",children:c.jsx(js,{className:"size-6 text-red-500 dark:text-red-500"})})]}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-cai-secondary",children:[c.jsx(Tl,{className:"size-4"}),c.jsx("span",{children:"Notes"}),T>0&&c.jsxs("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:["(",T," line",T!==1?"s":"",")"]})]}),c.jsx("div",{className:"w-full",children:c.jsx("div",{className:"w-full p-3 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-gradient-to-r from-yellow-50 to-orange-50 dark:from-yellow-900/20 dark:to-orange-900/20 min-h-[60px]",children:t.content&&t.content.trim()?c.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:[c.jsx("div",{className:"font-medium mb-1 opacity-75",children:"Preview:"}),c.jsx("div",{className:"overflow-hidden max-h-16 leading-relaxed",dangerouslySetInnerHTML:{__html:t.content},style:{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"}}),T>3&&c.jsxs("div",{className:"text-xs mt-2 opacity-60",children:["+",T-3," more line",T-3!==1?"s":""]})]}):c.jsx("div",{className:"flex items-center justify-center h-full text-yellow-600 dark:text-yellow-400",children:c.jsxs("div",{className:"text-center",children:[c.jsx($i,{className:"size-4 mx-auto mb-1"}),c.jsx("p",{className:"text-xs",children:"Empty note"})]})})})}),c.jsx("div",{className:"text-xs text-center text-zinc-500 dark:text-zinc-400",children:"Double-click the node to edit content"}),c.jsx("div",{className:"flex justify-center items-center gap-2 w-full",children:s&&c.jsx(Cs,{onClick:H,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{
794className:"size-4 text-zinc-700 dark:text-zinc-100"}),c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100",children:"Copy"})]})})}),c.jsx(al,{isOpen:N,onClose:()=>_(!1),onConfirm:P,title:"Delete Notes",message:`Are you sure you want to delete "${S}"? This will permanently remove this note.${l?" This object is currently shared with collaborators.":""}`,confirmText:"Delete Notes",isDangerous:!0})]}):null},Zfe=({embeddingNode:t})=>{const{getEmbeddingNodeName:e}=mn(),n=`embedding_node:${t.id}`,r=Vr(n),i=N0(n),s=I0(n),o=at(ne=>ne.domainRoleByChannel),a=at(ne=>ne.sharedByMe),l=So(n,o,a),{updateEmbeddingNode:u,deleteEmbeddingNode:d,duplicateEmbeddingNode:f}=Gn(),{selectCaiObject:h,deselectAllCaiObjects:m}=cr(),{commitToStore:y}=Ln(),{closeMobileInspector:g}=Br(),[w,v]=x.useState(!1),S=x.useMemo(()=>e(t.id),[t,e]),[C,k]=x.useState(S),[N,_]=x.useState(null),[j,T]=x.useState(!1),[M,V]=x.useState((t==null?void 0:t.url)||""),[H,P]=x.useState(!1),F=x.useRef(null),I=x.useRef(null),{embedType:R,embedId:U,isValidUrl:A}=x.useMemo(()=>{const ne=(t==null?void 0:t.url)||"";if(!ne)return{embedType:null,embedId:null,isValidUrl:!1};const be=ne.match(/spotify\.com\/track\/([a-zA-Z0-9]+)/),we=ne.match(/spotify\.com\/playlist\/([a-zA-Z0-9]+)/),te=ne.match(/spotify\.com\/album\/([a-zA-Z0-9]+)/);if(be)return{embedType:"Spotify",embedId:be[1],isValidUrl:!0};if(we)return{embedType:"Spotify",embedId:we[1],isValidUrl:!0};if(te)return{embedType:"Spotify",embedId:te[1],isValidUrl:!0};const fe=ne.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)/);if(fe)return{embedType:"YouTube",embedId:fe[1],isValidUrl:!0};if(ne.match(/soundcloud\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/))return{embedType:"SoundCloud",embedId:ne,isValidUrl:!0};if(ne.match(/music\.apple\.com\/([a-z]{2}\/)?([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/))return{embedType:"Apple Music",embedId:ne,isValidUrl:!0};if(ne.match(/([a-zA-Z0-9_-]+)\.bandcamp\.com/))return{embedType:"Bandcamp",embedId:ne,isValidUrl:!0};const le=ne.match(/vimeo\.com\/(\d+)/);return le?{embedType:"Vimeo",embedId:le[1],isValidUrl:!0}:ne.match(/tidal\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/)?{embedType:"Tidal",embedId:ne,isValidUrl:!0}:ne.match(/deezer\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/)?{embedType:"Deezer",embedId:ne,isValidUrl:!0}:ne.match(/music\.amazon\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)/)?{embedType:"Amazon Music",embedId:ne,isValidUrl:!0}:{embedType:null,isValidUrl:!1}},[t==null?void 0:t.url]),W=x.useCallback(ne=>{k(ne.target.value)},[]),D=x.useCallback(()=>{if(!t)return;const ne=C.trim();ne!==S&&(ne===""?k(S):(u(t.id,{label:ne}),y()),v(!1))},[t,C,S,u,y]),B=x.useCallback(()=>{if(!t)return;const ne=Ro(t.canvasPosition),be=f(t.id,ne);h({type:J.EmbeddingNode,id:be}),g(),y()},[t,f,h,y,g]),L=x.useCallback(()=>{t&&(d(t.id),m(),g(),y(),P(!1))},[t,d,m,y,g]),$=x.useCallback(()=>{t!=null&&t.url&&A&&window.open(t.url,"_blank","noopener,noreferrer")},[t==null?void 0:t.url,A]),q=x.useCallback(()=>{r&&(T(!0),V((t==null?void 0:t.url)||""))},[r,t==null?void 0:t.url]),Z=x.useCallback(ne=>{V(ne.target.value)},[]),ie=x.useCallback(()=>{if(!t)return;const ne=M.trim();u(t.id,{url:ne}),y(),T(!1)},[t,M,u,y]),ge=x.useCallback(ne=>{ne.key==="Enter"?(ne.preventDefault(),ie()):ne.key==="Escape"&&(V((t==null?void 0:t.url)||""),T(!1))},[ie,t==null?void 0:t.url]),re=x.useCallback(()=>{switch(R){case"Spotify":return{icon:c.jsx(Mn,{className:"size-8 text-green-600"}),bgColor:"from-green-100 to-green-50 dark:from-green-900/30 dark:to-green-800/20",borderColor:"border-green-200 dark:border-green-700",textColor:"text-green-700 dark:text-green-300"};case"YouTube":return{icon:c.jsx(ka,{className:"size-8 text-red-600"}),bgColor:"from-red-100 to-red-50 dark:from-red-900/30 dark:to-red-800/20",borderColor:"border-red-200 dark:border-red-700",textColor:"text-red-700 dark:text-red-300"};case"SoundCloud":return{icon:c.jsx(Mn,{className:"size-8 text-orange-600"}),bgColor:"from-orange-100 to-orange-50 dark:from-orange-900/30 dark:to-orange-800/20",borderColor:"border-orange-200 dark:border-orange-700",textColor:"text-orange-700 dark:text-orange-300"};case"Apple Music":return{icon:c.jsx(Mn,{className:"size-8 text-gray-700"}),bgColor:"from-gray-100 to-gray-50 dark:from-gray-800/30 dark:to-gray-700/20",borderColor:"border-gray-200 dark:border-gray-600",textColor:"text-gray-700 dark:text-gray-300"};case"Bandcamp":return{icon:c.jsx(Mn,{className:"size-8 text-cyan-600"}),bgColor:"from-cyan-100 to-cyan-50 dark:from-cyan-900/30 dark:to-cyan-800/20",borderColor:"border-cyan-200 dark:border-cyan-700",textColor:"text-cyan-700 dark:text-cyan-300"};case"Vimeo":return{icon:c.jsx(ka,{className:"size-8 text-blue-600"}),bgColor:"from-blue-100 to-blue-50 dark:from-blue-900/30 dark:to-blue-800/20",borderColor:"border-blue-200 dark:border-blue-700",textColor:"text-blue-700 dark:text-blue-300"};case"Tidal":return{icon:c.jsx(Mn,{className:"size-8 text-black dark:text-white"}),bgColor:"from-gray-100 to-gray-50 dark:from-gray-900/30 dark:to-gray-800/20",borderColor:"border-gray-200 dark:border-gray-700",textColor:"text-gray-700 dark:text-gray-300"};case"Deezer":return{icon:c.jsx(Mn,{className:"size-8 text-purple-600"}),bgColor:"from-purple-100 to-purple-50 dark:from-purple-900/30 dark:to-purple-800/20",borderColor:"border-purple-200 dark:border-purple-700",textColor:"text-purple-700 dark:text-purple-300"};case"Amazon Music":return{icon:c.jsx(Mn,{className:"size-8 text-blue-600"}),bgColor:"from-blue-100 to-blue-50 dark:from-blue-900/30 dark:to-blue-800/20",borderColor:"border-blue-200 dark:border-blue-700",textColor:"text-blue-700 dark:text-blue-300"};default:return{icon:c.jsx(Mn,{className:"size-8 text-blue-600"}),bgColor:"from-blue-100 to-blue-50 dark:from-blue-900/30 dark:to-blue-800/20",borderColor:"border-blue-200 dark:border-blue-700",textColor:"text-blue-700 dark:text-blue-300"}}},[R]),Y=x.useCallback(()=>
794{if(!A||!U)return c.jsx("div",{className:"w-full h-32 border border-zinc-300 dark:border-zinc-600 rounded-lg flex items-center justify-center text-zinc-500 dark:text-zinc-400 bg-zinc-50 dark:bg-zinc-800",children:c.jsxs("div",{className:"text-center",children:[c.jsx(US,{className:"size-4 mx-auto mb-1"}),c.jsx("p",{className:"text-xs",children:"No content"})]})});if(N)return c.jsx("div",{className:"relative group",children:c.jsx("div",{className:"w-full h-32 border border-zinc-300 dark:border-zinc-600 rounded-lg overflow-hidden bg-zinc-100 dark:bg-zinc-800 bg-cover bg-center",style:{backgroundImage:`url(${N})`},children:c.jsx("div",{className:"w-full h-full bg-black bg-opacity-30 flex items-end justify-center pb-2",children:c.jsx("button",{onClick:q,className:"px-3 py-2 bg-white text-black rounded-md text-sm font-medium hover:bg-gray-100 transition-colors opacity-0 group-hover:opacity-100",children:"Change Link"})})})});const ne=re();return c.jsx("div",{className:"relative group",children:c.jsx("div",{className:`w-full h-32 border ${ne.borderColor} rounded-lg bg-gradient-to-r ${ne.bgColor} flex items-center justify-center`,children:c.jsxs("div",{className:"relative h-full w-full",children:[c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"flex items-center justify-center mb-2",children:ne.icon}),c.jsx("p",{className:`text-xs font-medium ${ne.textColor}`,children:R})]})}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center mt-20",children:c.jsx("button",{onClick:q,className:"px-3 py-2 bg-white text-black rounded-md text-sm font-medium hover:bg-gray-100 transition-colors opacity-0 group-hover:opacity-100 z-10",children:"Change Link"})})]})})})},[A,U,R,N,re,q]);return x.useEffect(()=>{v(!1),k(S),V((t==null?void 0:t.url)||"")},[t.label,t==null?void 0:t.url,t.id,S]),x.useEffect(()=>{w&&F.current&&F.current.focus()},[w]),x.useEffect(()=>{j&&I.current&&(I.current.focus(),I.current.select())},[j]),x.useEffect(()=>{if(!A||!U){_(null);return}(async()=>{var be;try{switch(R){case"YouTube":{const we=`https://img.youtube.com/vi/${U}/hqdefault.jpg`;_(we);break}case"Vimeo":try{const we=await fetch(`https://vimeo.com/api/v2/video/${U}.json`);if(we.ok){const te=await we.json();(be=te[0])!=null&&be.thumbnail_large&&_(te[0].thumbnail_large)}}catch(we){ar("Vimeo thumbnail fetch failed:",we),_(null)}break;case"Spotify":_(null);break;case"SoundCloud":try{const we=`https://soundcloud.com/oembed?format=json&url=${encodeURIComponent(U)}`,te=await fetch(we);if(te.ok){const fe=await te.json();fe.thumbnail_url&&_(fe.thumbnail_url)}}catch(we){ar("SoundCloud thumbnail fetch failed:",we),_(null)}break;default:_(null);break}}catch{_(null)}})()},[R,U,A]),t?c.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[!r&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"text-xl rounded-lg flex items-center justify-between gap-1",children:[c.jsx("input",{ref:F,type:"text",id:`embedding-node-header-${t.id}`,name:`embedding-node-header-${t.id}`,value:C,onChange:W,onBlur:D,onKeyDown:ne=>{ne.key==="Enter"&&ne.currentTarget.blur()},onClick:()=>r&&v(!0),readOnly:!r,className:`bg-transparent underline underline-offset-4 decoration-4 decoration-blue-500 text-cai-secondary outline-none w-full ${r?"cursor-pointer":"cursor-default"} ${w?"cursor-text":"overflow-hidden text-ellipsis whitespace-nowrap"}`}),i&&c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded",onClick:()=>P(!0),title:"Delete Embedding",children:c.jsx(js,{className:"size-6 text-red-500 dark:text-red-500"})})]}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-cai-secondary",children:[c.jsx(US,{className:"size-4"}),c.jsx("span",{children:R||"Link"}),t.url&&A&&c.jsx("button",{onClick:$,className:"p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors",title:"Open link",children:c.jsx(Ch,{className:"size-3"})})]}),j&&c.jsx("div",{className:"w-full",children:c.jsx("input",{ref:I,type:"text",value:M,onChange:Z,onBlur:ie,onKeyDown:ge,className:"w-full px-3 py-2 text-sm border border-blue-300 dark:border-blue-600 rounded bg-white dark:bg-blue-800 text-blue-900 dark:text-blue-100",placeholder:"Paste YouTube, Spotify, or streaming URL..."})}),c.jsx("div",{className:"w-full",children:Y()}),c.jsx("div",{className:"text-xs text-center text-zinc-500 dark:text-zinc-400",children:t.url?A?`${R} content ready`:"Invalid URL format":"Double-click to add URL"}),c.jsx("div",{className:"flex justify-center items-center gap-2 w-full",children:s&&c.jsx(Cs,{onClick:B,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{
794className:"size-4 text-zinc-700 dark:text-zinc-100"}),c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100",children:"Copy"})]})})}),c.jsx(al,{isOpen:H,onClose:()=>P(!1),onConfirm:L,title:"Delete Embedding",message:`Are you sure you want to delete "${S}"? This will permanently remove this embedded content.${l?" This object is currently shared with collaborators.":""}`,confirmText:"Delete Embedding",isDangerous:!0})]}):null},Jfe=({visualMediaNode:t})=>{const{getVisualMediaNodeName:e}=mn(),n=`visual_node:${t.id}`,r=Vr(n),i=N0(n),s=I0(n),o=at(Y=>Y.domainRoleByChannel),a=at(Y=>Y.sharedByMe),l=So(n,o,a),{updateVisualMediaNode:u,deleteVisualMediaNode:d,duplicateVisualMediaNode:f}=Gn(),{selectCaiObject:h,deselectAllCaiObjects:m}=cr(),{commitToStore:y}=Ln(),{closeMobileInspector:g}=Br(),[w,v]=x.useState(!1),S=x.useMemo(()=>e(t.id),[t,e]),[C,k]=x.useState(S),[N,_]=x.useState(!1),[j,T]=x.useState(!1),[M,V]=x.useState(!1),H=x.useRef(null),P=x.useRef(null),F=x.useRef(null),I=x.useMemo(()=>t!=null&&t.mediaData?t.mediaData.startsWith("data:video/"):!1,[t==null?void 0:t.mediaData]),R=x.useCallback(()=>{if(!t)return;const Y=C.trim();Y!==S&&(Y===""?k(S):(u(t.id,{label:Y}),y()),v(!1))},[t,C,S,u,y]),U=x.useCallback(()=>{if(!t)return;const Y=Ro(t.canvasPosition),ne=f(t.id,Y);h({type:J.VisualMediaNode,id:ne}),g(),y()},[t,f,h,y,g]),A=x.useCallback(()=>{t&&(d(t.id),m(),g(),y(),V(!1))},[t,d,m,y,g]),W=x.useCallback(Y=>{if(!Y||Y.length===0)return;const ne=Y[0],be=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml"],we=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],te=be.includes(ne.type)||ne.name.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i),fe=we.includes(ne.type)||ne.name.match(/\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)$/i);if(te||fe){const O=new FileReader;O.onload=pe=>{var le;const he=(le=pe.target)==null?void 0:le.result;u(t.id,{mediaData:he}),y()},O.readAsDataURL(ne)}else alert("Please select a supported image or video file (Images: JPG, PNG, GIF, WebP, BMP, SVG | Videos: MP4, WebM, OGG, AVI, MOV, WMV, FLV, MKV)")},[t.id,u,y]),D=x.useCallback(Y=>{W(Y.target.files)},[W]),B=x.useCallback(Y=>{Y.preventDefault(),_(!0)},[]),L=x.useCallback(Y=>{Y.preventDefault(),_(!1)},[]),$=x.useCallback(Y=>{Y.preventDefault(),_(!1),W(Y.dataTransfer.files)},[W]),q=x.useCallback(()=>{var Y;(Y=P.current)==null||Y.click()},[]),Z=x.useCallback(()=>{t!=null&&t.mediaData&&window.open(t.mediaData,"_blank","noopener,noreferrer")},[t==null?void 0:t.mediaData]),ie=x.useCallback(()=>{u(t.id,{mediaData:""}),y()},[t.id,u,y]),ge=x.useCallback(()=>{F.current&&(j?F.current.pause():F.current.play(),T(!j))},[j]);x.useEffect(()=>{v(!1),k(S)},[t,S]),x.useEffect(()=>{w&&H.current&&H.current.focus()},[w]);const re=x.useCallback(Y=>{k(Y.target.value)},[]);return t?c.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[!r&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"text-xl rounded-lg flex items-center justify-between gap-1",children:[c.jsx("input",{ref:H,type:"text",id:`visual-media-node-header-${t.id}`,name:`visual-media-node-header-${t.id}`,value:C,onChange:re,onBlur:R,onKeyDown:Y=>{Y.key==="Enter"&&Y.currentTarget.blur()},onClick:()=>r&&v(!0),readOnly:!r,className:`bg-transparent underline underline-offset-4 decoration-4 decoration-rose-500 text-cai-secondary outline-none w-full ${r?"cursor-pointer":"cursor-default"} ${w?"cursor-text":"overflow-hidden text-ellipsis whitespace-nowrap"}`}),i&&c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded",onClick:()=>V(!0),title:"Delete Visual Media",children:c.jsx(js,{className:"size-6 text-red-500 dark:text-red-500"})})]}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-cai-secondary",children:[I?c.jsx(Ul,{className:"size-4"}):c.jsx(Gs,{className:"size-4"}),c.jsx("span",{children:I?"Video":"Image"}),t.mediaData&&c.jsx("button",{onClick:Z,className:"p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors",title:"Open media",children:c.jsx(Ch,{className:"size-3"})})]}),c.jsx("div",{className:"w-full",children:t.mediaData?c.jsxs("div",{className:"relative group",children:[I?c.jsxs(c.Fragment,{children:[c.jsx("video",{ref:F,src:t.mediaData,className:"w-full h-32 object-cover rounded-lg border border-zinc-300 dark:border-zinc-600",onError:ie,muted:!0,loop:!0}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsx("button",{onClick:ge,className:"bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-70 transition-all opacity-0 group-hover:opacity-100",children:j?c.jsx(Zm,{className:"size-4"}):c.jsx(ka,{className:"size-4"})})})]}):c.jsx("img",{src:t.mediaData,alt:C,className:"w-full h-32 object-cover rounded-lg border border-zinc-300 dark:border-zinc-600",onError:ie}),c.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity rounded-lg flex items-end justify-center pb-2",children:r&&c.jsx("button",{onClick:q,className:"px-3 py-2 bg-white text-black rounded-md text-sm font-medium hover:bg-gray-100 transition-colors",children:"Change Media"})})]}):c.jsx("div",{onClick:r?q:void 0,onDragOver:r?B:void 0,onDragLeave:r?L:void 0,onDrop:r?$:void 0,className:`w-full h-32 border-2 border-dashed rounded-lg flex items-center justify-center transition-colors ${r?"cursor-pointer":"cursor-default"}
794 ${N?"border-rose-500 bg-rose-100 dark:bg-rose-900/20":"border-zinc-300 dark:border-zinc-600 hover:border-rose-400 dark:hover:border-rose-500"}`,children:c.jsx("div",{className:"text-center text-rose-600 dark:text-rose-400",children:N?c.jsxs(c.Fragment,{children:[c.jsx(gx,{className:"size-6 mx-auto mb-2"}),c.jsx("p",{className:"text-sm",children:"Drop media here"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-center gap-1 mb-2",children:[c.jsx(Gs,{className:"size-5"}),c.jsx(Ul,{className:"size-5"})]}),c.jsx("p",{className:"text-sm",children:"Upload image or video"})]})})})}),c.jsx("div",{className:"text-xs text-center text-zinc-500 dark:text-zinc-400",children:t.mediaData?`${I?"Video":"Image"} loaded successfully`:"Double-click to add media"}),c.jsx("div",{className:"flex justify-center items-center gap-2 w-full",children:s&&c.jsx(Cs,{onClick:U,children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{className:"size-4 text-zinc-700 dark:text-zinc-100"}),c.jsx("span",{className:"text-zinc-700 dark:text-zinc-100",children:"Copy"})]})})}),c.jsx("input",{ref:P,type:"file",accept:"image/*,video/*",onChange:D,className:"hidden"}),c.jsx(al,{isOpen:M,onClose:()=>V(!1),onConfirm:A,title:"Delete Visual Media",message:`Are you sure you want to delete "${S}"? This will permanently remove this visual media object.${l?" This object is currently shared with collaborators.":""}`,confirmText:"Delete Media",isDangerous:!0})]}):null},ehe=()=>{const{selectedSingleCaiObject:t}=Yn(),{getTextNodeById:e,getEmbeddingNodeById:n,getVisualMediaNodeById:r,songs:i,bloobs:s,tracks:o,textNodes:a,embeddingNodes:l,visualMediaNodes:u}=mn(),{deselectCaiObjects:d}=cr(),[f,h]=x.useState(!1),{mobileInspectorOpen:m}=Pn(),{closeMobileInspector:y}=Br(),{isMobile:g}=Hn(),w=x.useRef(null),v=x.useMemo(()=>g?{bottom:"calc(1rem + 60px + 8.5rem)",left:"1rem"}:{top:"1rem",left:"1rem"},[g]),S=x.useMemo(()=>{if(!t)return!1;switch(t.type){case J.Bloob:return s[t.id]!==void 0;case J.Song:return i[t.id]!==void 0;case J.Track:return o[t.id]!==void 0;case J.TextNode:return a[t.id]!==void 0;case J.EmbeddingNode:return l[t.id]!==void 0;case J.VisualMediaNode:return u[t.id]!==void 0;default:return!0}},[t,s,i,o,a,l,u]);x.useEffect(()=>{t&&!S&&d([t])},[t,S,d]);const C=x.useMemo(()=>{if(!t||!S)return null;switch(t.type){case J.Bloob:return c.jsx(MC,{bloobId:t.id,containerRef:w});case J.Song:return c.jsx(Xfe,{songId:t.id});case J.Track:return c.jsx(OC,{trackId:t.id});case J.TextNode:{const k=e(t.id);return c.jsx(Qfe,{textNode:k})}case J.EmbeddingNode:{const k=n(t.id);return c.jsx(Zfe,{embeddingNode:k})}case J.VisualMediaNode:{const k=r(t.id);return c.jsx(Jfe,{visualMediaNode:k})}default:return null}},[t,S,e,n,r]);if(x.useEffect(()=>{h(!!t)},[t]),!t||!S)return null;if(g&&m)return c.jsx(Wr,{onClose:y,children:c.jsx("div",{className:"p-4 bg-glass border-glass",children:C})});if(!g)return c.jsx("div",{ref:w,className:`absolute w-56 transition-transform duration-300 ease-in-out z-45 ${f?"translate-x-0":"-translate-x-[110%]"}`,style:v,children:c.jsx("div",{className:"bg-glass border-glass py-2 px-3 rounded-lg",children:c.jsx(Vn,{children:c.jsx(et.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:C},t==null?void 0:t.type)})})})},PL=x.createContext({playheadPosition:null}),Dx=()=>{const t=x.useContext(PL);if(!t)throw new Error("usePlayhead must be used within a PlayheadProvider");return t},the=({dragCanvasOffset:t})=>{const{playheadPosition:e}=Dx(),{timelineCursorBar:n,timelineCursorSongId:r}=Yn(),{isPlaying:i}=zs();return i&&e?c.jsx(Fk,{songId:e.songId,bar:e.bar,dragCanvasOffset:t,mode:"moving"}):n!==null&&r!==null?c.jsx(Fk,{songId:r,bar:n,dragCanvasOffset:t,mode:"static"}):e?c.jsx(Fk,{songId:e.songId,bar:e.bar,dragCanvasOffset:t,mode:"static"}):null},Fk=({songId:t,bar:e,dragCanvasOffset:n,mode:r})=>{const{isRecording:i}=Lo(),{isCaiObjectSelected:s}=Yn(),o=wd(t),a=x.useMemo(()=>o!=null&&o.tracks?o.tracks*bn+Is*2:0,[o==null?void 0:o.tracks]),l=x.useMemo(()=>
vendor: 12,284 bytes, lines 794-805
794n&&s(o)?Ua(o.canvasPosition,n):o.canvasPosition,[n,s,o]);if(!o||typeof o.bars!="number"||typeof o.tracks!="number")return null;const u=r==="moving",d=l.x+Qi+e*dn,f=l.y+fo,h=i?"bg-red-500":u?"bg-zinc-500 dark:bg-white":"bg-zinc-400 dark:bg-white";return c.jsx(O3,{children:c.jsx("div",{style:{left:d,top:f,height:a},className:`absolute z-10 w-0.5 -translate-x-1/2 pointer-events-none ${h}`,"data-testid":`song-${o.id}-playhead`,"aria-hidden":"true",children:!u&&!i&&c.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[4px] border-r-[4px] border-t-[5px] border-l-transparent border-r-transparent border-t-zinc-400 dark:border-t-white"})})})};var $k={exports:{}};/*! 795 796JSZip v3.10.1 - A JavaScript class for generating and reading zip files 797<http://stuartk.com/jszip> 798 799(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com> 800Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. 801 802JSZip uses the library pako released under the MIT license : 803https://github.com/nodeca/pako/blob/main/LICENSE 804*/var YA;function nhe(){return YA||(YA=1,function(t,e){(function(n){t.exports=n()})(function(){return function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof Tc=="function"&&Tc;if(!d&&f)return f(u,!0);if(a)return a(u,!0);var h=new Error("Cannot find module '"+u+"'");throw h.code="MODULE_NOT_FOUND",h}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(y){var g=r[u][1][y];return o(g||y)},m,m.exports,n,r,i,s)}return i[u].exports}for(var a=typeof Tc=="function"&&Tc,l=0;l<s.length;l++)o(s[l]);return o}({1:[function(n,r,i){var s=n("./utils"),o=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var u,d,f,h,m,y,g,w=[],v=0,S=l.length,C=S,k=s.getTypeOf(l)!=="string";v<l.length;)C=S-v,f=k?(u=l[v++],d=v<S?l[v++]:0,v<S?l[v++]:0):(u=l.charCodeAt(v++),d=v<S?l.charCodeAt(v++):0,v<S?l.charCodeAt(v++):0),h=u>>2,m=(3&u)<<4|d>>4,y=1<C?(15&d)<<2|f>>6:64,g=2<C?63&f:64,w.push(a.charAt(h)+a.charAt(m)+a.charAt(y)+a.charAt(g));return w.join("")},i.decode=function(l){var u,d,f,h,m,y,g=0,w=0,v="data:";if(l.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var S,C=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&C--,l.charAt(l.length-2)===a.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|C):new Array(0|C);g<l.length;)u=a.indexOf(l.charAt(g++))<<2|(h=a.indexOf(l.charAt(g++)))>>4,d=(15&h)<<4|(m=a.indexOf(l.charAt(g++)))>>2,f=(3&m)<<6|(y=a.indexOf(l.charAt(g++))),S[w++]=u,m!==64&&(S[w++]=d),y!==64&&(S[w++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),o=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function u(d,f,h,m,y){this.compressedSize=d,this.uncompressedSize=f,this.crc32=h,this.compression=m,this.compressedContent=y}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,h){return d.pipe(new a).pipe(new l("uncompressedSize")).pipe(f.compressWorker(h)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),o=function(){for(var a,l=[],u=0;u<256;u++){a=u;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(u,d,f,h){var m=o,y=h+f;u^=-1;for(var g=h;g<y;g++)u=u>>>8^m[255&(u^d[g])];return-1^u}(0|l,a,a.length,0):function(u,d,f,h){var m=o,y=h+f;u^=-1;for(var g=h;g<y;g++)u=u>>>8^m[255&(u^d.charCodeAt(g))];return-1^u}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(f,h){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,this.meta={}}i.magic="\b\0",a.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(h){f.push({data:h,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,y){var g,w="";for(g=0;g<y;g++)w+=String.fromCharCode(255&m),m>>>=8;return w}function o(m,y,g,w,v,S){var C,k,N=m.file,_=m.compression,j=S!==u.utf8encode,T=a.transformTo("string",S(N.name)),M=a.transformTo("string",u.utf8encode(N.name)),V=N.comment,H=a.transformTo("string",S(V)),P=a.transformTo("string",u.utf8encode(V)),F=M.length!==N.name.length,I=P.length!==V.length,R="",U="",A="",W=N.dir,D=N.date,B={crc32:0,compressedSize:0,uncompressedSize:0};y&&!g||(B.crc32=m.crc32,B.compressedSize=m.compressedSize,B.uncompressedSize=m.uncompressedSize);var L=0;y&&(L|=8),j||!F&&!I||(L|=2048);var $=0,q=0;W&&($|=16),v==="UNIX"?(q=798,$|=function(ie,ge){var re=ie;return ie||(re=ge?16893:33204),(65535&re)<<16}(N.unixPermissions,W)):(q=20,$|=function(ie){return 63&(ie||0)}(N.dosPermissions)),C=D.getUTCHours(),C<<=6,C|=D.getUTCMinutes(),C<<=5,C|=D.getUTCSeconds()/2,k=D.getUTCFullYear()-1980,k<<=4,k|=D.getUTCMonth()+1,k<<=5,k|=D.getUTCDate(),F&&(U=s(1,1)+s(d(T),4)+M,R+="up"+s(U.length,2)+U),I&&(A=s(1,1)+s(d(H),4)+P,R+="uc"+s(A.length,2)+A);var Z="";return Z+=` 805\0`,Z+=s(L,2),Z+=_.magic,Z+=s(C,2),Z+=s(k,2),Z+=s(B.crc32,4),Z+=s(B.compressedSize,4),Z+=s(B.uncompressedSize,4),Z+=s(T.length,2),Z+=s(R.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Z+T+R,dirRecord:f.CENTRAL_FILE_HEADER+s(q,2)+Z+s(H.length,2)+"\0\0\0\0"+s($,4)+s(w,4)+T+R+H}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function h(m,y,g,w){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=g,this.encodeFileName=w,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(h,l),h.prototype.push=function(m){var y=m.meta.percent||0,g=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(y+100*(g-w-1))/g:100}}))},h.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var y=this.streamFiles&&!m.file.dir;if(y){var g=o(m,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(m){this.accumulate=!1;var y=this.streamFiles&&!m.file.dir,g=o(m,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),y)this.push({data:function(w){return f.DATA_DESCRIPTOR+s(w.crc32,4)+s(w.compressedSize,4)+s(w.uncompressedSize,4)}(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var m=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var g=this.bytesWritten-m,w=function(v,S,C,k,N){var _=a.transformTo("string",N(k));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(v,2)+s(v,2)+s(S,4)+s(C,4)+s(_.length,2)+_}(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:w,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(m){this._sources.push(m);var y=this;return m.on("data",function(g){y.processChunk(g)}),m.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),m.on("error",function(g){y.error(g)}),this},h.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(m){var y=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var g=0;g<y.length;g++)try{y[g].error(m)}catch{}return!0},h.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,y=0;y<m.length;y++)m[y].lock()},r.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(a,l,u){var d=new o(l.streamFiles,u,l.platform,l.encodeFileName),f=0;try{a.forEach(function(h,m){f++;var y=function(S,C){var k=S||C,N=s[k];if(!N)throw new Error(k+" is not a valid compression method !");return N}(m.options.compression,l.compression),g=m.options.compressionOptions||l.compressionOptions||{},w=m.dir,v=m.date;m._compressWorker(y,g).withStreamInfo("file",{name:h,dir:w,date:v,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(h){d.error(h)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var a in this)typeof this[a]!="function"&&(o[a]=this[a]);return o}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(o,a){return new s().loadAsync(o,a)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),o=n("./external"),a=n("./utf8"),l=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(h){return new o.Promise(function(m,y){var g=h.decompressed.getContentWorker().pipe(new u);g.on("error",function(w){y(w)}).on("end",function(){g.streamInfo.crc32!==h.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(h,m){var y=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),d.isNode&&d.isStream(h)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip f
805ile",h,!0,m.optimizedBinaryString,m.base64).then(function(g){var w=new l(m);return w.load(g),w}).then(function(g){var w=[o.Promise.resolve(g)],v=g.files;if(m.checkCRC32)for(var S=0;S<v.length;S++)w.push(f(v[S]));return o.Promise.all(w)}).then(function(g){for(var w=g.shift(),v=w.files,S=0;S<v.length;S++){var C=v[S],k=C.fileNameStr,N=s.resolve(C.fileNameStr);y.file(N,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:m.createFolders}),C.dir||(y.file(N).unsafeOriginalName=k)}return w.zipComment.length&&(y.comment=w.zipComment),y})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),o=n("../stream/GenericWorker");function a(l,u){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(a,o),a.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function o(a,l,u){s.call(this,l),this._helper=a;var d=this;a.on("data",function(f,h){d.push(f)||d._helper.pause(),u&&u(h)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(N,_,j){var T,M=a.getTypeOf(_),V=a.extend(j||{},d);V.date=V.date||new Date,V.compression!==null&&(V.compression=V.compression.toUpperCase()),typeof V.unixPermissions=="string"&&(V.unixPermissions=parseInt(V.unixPermissions,8)),V.unixPermissions&&16384&V.unixPermissions&&(V.dir=!0),V.dosPermissions&&16&V.dosPermissions&&(V.dir=!0),V.dir&&(N=v(N)),V.createFolders&&(T=w(N))&&S.call(this,T,!0);var H=M==="string"&&V.binary===!1&&V.base64===!1;j&&j.binary!==void 0||(V.binary=!H),(_ instanceof f&&_.uncompressedSize===0||V.dir||!_||_.length===0)&&(V.base64=!1,V.binary=!0,_="",V.compression="STORE",M="string");var P=null;P=_ instanceof f||_ instanceof l?_:y.isNode&&y.isStream(_)?new g(N,_):a.prepareContent(N,_,V.binary,V.optimizedBinaryString,V.base64);var F=new h(N,P,V);this.files[N]=F}var o=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),h=n("./zipObject"),m=n("./generate"),y=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),w=function(N){N.slice(-1)==="/"&&(N=N.substring(0,N.length-1));var _=N.lastIndexOf("/");return 0<_?N.substring(0,_):""},v=function(N){return N.slice(-1)!=="/"&&(N+="/"),N},S=function(N,_){return _=_!==void 0?_:d.createFolders,N=v(N),this.files[N]||s.call(this,N,null,{dir:!0,createFolders:_}),this.files[N]};function C(N){return Object.prototype.toString.call(N)==="[object RegExp]"}var k={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(N){var _,j,T;for(_ in this.files)T=this.files[_],(j=_.slice(this.root.length,_.length))&&_.slice(0,this.root.length)===this.root&&N(j,T)},filter:function(N){var _=[];return this.forEach(function(j,T){N(j,T)&&_.push(T)}),_},file:function(N,_,j){if(arguments.length!==1)return N=this.root+N,s.call(this,N,_,j),this;if(C(N)){var T=N;return this.filter(function(V,H){return!H.dir&&T.test(V)})}var M=this.files[this.root+N];return M&&!M.dir?M:null},folder:function(N){if(!N)return this;if(C(N))return this.filter(function(M,V){return V.dir&&N.test(M)});var _=this.root+N,j=S.call(this,_),T=this.clone();return T.root=j.name,T},remove:function(N){N=this.root+N;var _=this.files[N];if(_||(N.slice(-1)!=="/"&&(N+="/"),_=this.files[N]),_&&!_.dir)delete this.files[N];else for(var j=this.filter(function(M,V){return V.name.slice(0,N.length)===N}),T=0;T<j.length;T++)delete this.files[j[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")}
vendor: 22,011 bytes, line 805
805,generateInternalStream:function(N){var _,j={};try{if((j=a.extend(N||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=j.type.toLowerCase(),j.compression=j.compression.toUpperCase(),j.type==="binarystring"&&(j.type="string"),!j.type)throw new Error("No output type specified.");a.checkSupport(j.type),j.platform!=="darwin"&&j.platform!=="freebsd"&&j.platform!=="linux"&&j.platform!=="sunos"||(j.platform="UNIX"),j.platform==="win32"&&(j.platform="DOS");var T=j.comment||this.comment||"";_=m.generateWorker(this,j,T)}catch(M){(_=new l("error")).error(M)}return new u(_,j.type||"string",j.mimeType)},generateAsync:function(N,_){return this.generateInternalStream(N).accumulate(_)},generateNodeStream:function(N,_){return(N=N||{}).type||(N.type="nodebuffer"),this.generateInternalStream(N).toNodejsStream(_)}};r.exports=k},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function o(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===l&&this.data[h+1]===u&&this.data[h+2]===d&&this.data[h+3]===f)return h-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),h=this.readData(4);return l===h[0]&&u===h[1]&&d===h[2]&&f===h[3]},o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,u=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function o(a){s.call(this,a)}n("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function o(a){s.call(this,a)}n("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function o(a){s.call(this,a)}n("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),o=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var h=s.getTypeOf(f);return s.checkSupport(h),h!=="string"||o.uint8array?h==="nodebuffer"?new u(f):o.uint8array?new d(s.transformTo("uint8array",f)):new a(s.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK��",i.CENTRAL_FILE_HEADER="PK��",i.CENTRAL_DIRECTORY_END="PK��",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK�\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK��",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),o=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),o=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}o.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function a(l){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),o=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(y,g){return new d.Promise(function(w,v){var S=[],C=y._internalType,k=y._outputType,N=y._mimeType;y.on("data",function(_,j){S.push(_),g&&g(j)}).on("error",function(_){S=[],v(_)}).on("end",function(){try{var _=function(j,T,M){switch(j){case"blob":return s.newBlob(s.transformTo("arraybuffer",T),M);case"base64":return l.encode(T);default:return s.transformTo(j,T)}}(k,function(j,T){var M,V=0,H=null,P=0;for(M=0;M<T.length;M++)P+=T[M].length;switch(j){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(H=new Uint8Array(P),M=0;M<T.length;M++)H.set(T[M],V),V+=T[M].length;return H;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+j+"'")}}(C,S),N);w(_)}catch(j){v(j)}S=[]}).resume()})}function m(y,g,w){var v=g;switch(g){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=g,this._mimeType=w,s.checkSupport(v),this._worker=y.pipe(new o(v)),y.lock()}catch(S){this._worker=new a("error"),this._worker.error(S)}}m.prototype={accumulate:function(y){return h(this,y)},on:function(y,g){var w=this;return y==="data"?this._worker.on(y,function(v){g.call(w,v.data,v.meta)}):this._worker.on(y,function(){s.delay(g,arguments,w)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},y)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),o=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function h(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?a.newBufferFrom(m,"utf-8"):function(y){var g,w,v,S,C,k=y.length,N=0;for(S=0;S<k;S++)(64512&(w=y.charCodeAt(S)))==55296&&S+1<k&&(64512&(v=y.charCodeAt(S+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),S++),N+=w<128?1:w<2048?2:w<65536?3:4;for(g=o.uint8array?new Uint8Array(N):new Array(N),S=C=0;C<N;S++)(64512&(w=y.charCodeAt(S)))==55296&&S+1<k&&(64512&(v=y.charCodeAt(S+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),S++),w<128?g[C++]=w:(w<2048?g[C++]=192|w>>>6:(w<65536?g[C++]=224|w>>>12:(g[C++]=240|w>>>18,g[C++]=128|w>>>12&63),g[C++]=128|w>>>6&63),g[C++]=128|63&w);return g}(m)},i.utf8decode=function(m){return o.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):function(y){var g,w,v,S,C=y.length,k=new Array(2*C);for(g=w=0;g<C;)if((v=y[g++])<128)k[w++]=v;else if(4<(S=u[v]))k[w++]=65533,g+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&g<C;)v=v<<6|63&y[g++],S--;1<S?k[w++]=65533:v<65536?k[w++]=v:(v-=65536,k[w++]=55296|v>>10&1023,k[w++]=56320|1023&v)}return k.length!==w&&(k.subarray?k=k.subarray(0,w):k.length=w),s.applyFromCharCode(k)}(m=s.transformTo(o.uint8array?"uint8array":"array",m))},s.inherits(f,l),f.prototype.processChunk=function(m){var y=s.transformTo(o.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var g=y;(y=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),y.set(g,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var w=function(S,C){var k;for((C=C||S.length)>S.length&&(C=S.length),k=C-1;0<=k&&(192&S[k])==128;)k--;return k<0||k===0?C:k+u[S[k]]>C?k:C}(y),v=y;w!==y.length&&(o.uint8array?(v=y.subarray(0,w),this.leftOver=y.subarray(w,y.length)):(v=y.slice(0,w),this.leftOver=y.slice(w,y.length))),this.push({data:i.utf8decode(v),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,s.inherits(h,l),h.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=n("./support"),o=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function u(g){return g}function d(g,w){for(var v=0;v<g.length;++v)w[v]=255&g.charCodeAt(v);return w}n("setimmediate"),i.newBlob=function(g,w){i.checkSupport("blob");try{return new Blob([g],{type:w})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(g),v.getBlob(w)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,w,v){var S=[],C=0,k=g.length;if(k<=v)return String.fromCharCode.apply(null,g);for(;C<k;)w==="array"||w==="nodebuffer"?S.push(String.fromCharCode.apply(null,g.slice(C,Math.min(C+v,k)))):S.push(String.fromCharCode.apply(null,g.subarray(C,Math.min(C+v,k)))),C+=v;return S.join("")},stringifyByChar:function(g){for(var w="",v=0;v<g.length;v++)w+=String.fromCharCode(g[v]);return w},applyCanBeUsed:{uint8array:function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}}()}};function h(g){var w=65536,v=i.getTypeOf(g),S=!0;if(v==="uint8array"?S=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<w;)try{return f.stringifyByChunk(g,v,w)}catch{w=Math.floor(w/2)}return f.stringifyByChar(g)}function m(g,w){for(var v=0;v<g.length;v++)w[v]=g[v];return w}i.applyFromCharCode=h;var y={};y.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return y.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,a.allocBuffer(g.length))}},y.array={string:h,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(g)}},y.arraybuffer={string:function(g){return h(new Uint8Array(g))},array:function(g){return m(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(new Uint8Array(g))}},y.uint8array={string:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return a.newBufferFrom(g)}},y.nodebuffer={string:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return y.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:u},i.transformTo=function(g,w){if(w=w||"",!g)return w;i.checkSupport(g);var v=i.getTypeOf(w);return y[v][g](w)},i.resolve=function(g){for(var w=g.split("/"),v=[],S=0;S<w.length;S++){var C=w[S];C==="."||C===""&&S!==0&&S!==w.length-1||(C===".."?v.pop():v.push(C))}return v.join("/")},i.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(g)?"nodebuffer":s.uint8array&&g instanceof Uint8Array?"uint8array":s.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(g){if(!s[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(g){var w,v,S="";for(v=0;v<(g||"").length;v++)S+="\\x"+((w=g.charCodeAt(v))<16?"0":"")+w.toString(16).toUpperCase();return S},i.delay=function(g,w,v){setImmediate(function(){g.apply(v||null,w||[])})},i.inherits=function(g,w){function v(){}v.prototype=w.prototype,g.prototype=new v},i.extend=function(){var g,w,v={};for(g=0;g<arguments.length;g++)for(w in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],w)&&v[w]===void 0&&(v[w]=arguments[g][w]);return v},i.prepareContent=function(g,w,v,S,C){return l.Promise.resolve(w).then(function(k){return s.blob&&(k instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(k))!==-1)&&typeof FileReader<"u"?new l.Promise(function(N,_){var j=new FileReader;j.onload=function(T){N(T.target.result)},j.onerror=function(T){_(T.target.error)},j.readAsArrayBuffer(k)}):k}).then(function(k){var N=i.getTypeOf(k);return N?(N==="arraybuffer"?k=i.transformTo("uint8array",k):N==="string"&&(C?k=o.decode(k):v&&S!==!0&&(k=function(_){return d(_,s.uint8array?new Uint8Array(_.length):new Array(_.length))}(k))),k):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),a=n("./signature"),l=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(h)+", expected "+o.pretty(f)+")")}},isSignature:function(f,h){var m=this.reader.index;this.reader.setIndex(f);var y=this.reader.readString(4)===h;return this.reader.setIndex(m),y},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),h=u.uint8array?"uint8array":"array",m=o.transformTo(h,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,h,m,y=this.zip64EndOfCentralSize-44;0<y;)f=this.reader.readInt(2),h=this.reader.readInt(4),m=this.reader.readData(h),this.zip64ExtensibleData[f]={id:f,length:h,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,h;for(f=0;f<this.files.length;f++)h=this.files[f],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip f
805ile ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var h=f;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var y=h-m;if(0<y)this.isSignature(h,a.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(f){this.reader=s(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function h(m,y){this.options=m,this.loadOptions=y}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var y,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((y=function(w){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===w)return d[v];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,y,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var y=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(y),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&
vendor: 55,163 bytes, line 805
805(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var y,g,w,v=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<v;)y=m.readInt(2),g=m.readInt(2),w=m.readData(g),this.extraFields[y]={id:y,length:g,value:w};m.setIndex(v)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(y!==null)this.fileNameStr=y;else{var g=o.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var w=this.findExtraFieldUnicodeComment();if(w!==null)this.fileCommentStr=w;else{var v=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var y=s(m.value);return y.readInt(1)!==1||l(this.fileName)!==y.readInt(4)?null:u.utf8decode(y.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var y=s(m.value);return y.readInt(1)!==1||l(this.fileComment)!==y.readInt(4)?null:u.utf8decode(y.readData(m.length-5))}return null}},r.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(y,g,w){this.name=y,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=g,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var o=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(y){var g=null,w="string";try{if(!y)throw new Error("No output type specified.");var v=(w=y.toLowerCase())==="string"||w==="text";w!=="binarystring"&&w!=="text"||(w="string"),g=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(g=g.pipe(new l.Utf8EncodeWorker)),!S&&v&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(C){(g=new d("error")).error(C)}return new o(g,w,"")},async:function(y,g){return this.internalStream(y).accumulate(g)},nodeStream:function(y,g){return this.internalStream(y||"nodebuffer").toNodejsStream(g)},_compressWorker:function(y,g){if(this._data instanceof u&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(w,y,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new a(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)s.prototype[f[m]]=h;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var u=0,d=new l(y),f=s.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var g=s.document.createElement("script");g.onreadystatechange=function(){y(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},s.document.documentElement.appendChild(g)}:function(){setTimeout(y,0)};else{var h=new s.MessageChannel;h.port1.onmessage=y,o=function(){h.port2.postMessage(0)}}var m=[];function y(){var g,w;a=!0;for(var v=m.length;v;){for(w=m,m=[],g=-1;++g<v;)w[g]();v=m.length}a=!1}r.exports=function(g){m.push(g)!==1||a||o()}}).call(this,typeof jc<"u"?jc:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var a={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&g(this,v)}function h(v,S,C){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function m(v,S,C){s(function(){var k;try{k=S(C)}catch(N){return a.reject(v,N)}k===v?a.reject(v,new TypeError("Cannot resolve promise with itself")):a.resolve(v,k)})}function y(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function g(v,S){var C=!1;function k(j){C||(C=!0,a.reject(v,j))}function N(j){C||(C=!0,a.resolve(v,j))}var _=w(function(){S(N,k)});_.status==="error"&&k(_.value)}function w(v,S){var C={};try{C.value=v(S),C.status="success"}catch(k){C.status="error",C.value=k}return C}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(C){return S.resolve(v()).then(function(){return C})},function(C){return S.resolve(v()).then(function(){throw C})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===l)return this;var C=new this.constructor(o);return this.state!==d?m(C,this.state===u?v:S,this.outcome):this.queue.push(new h(C,v,S)),C},h.prototype.callFulfilled=function(v){a.resolve(this.promise,v)},h.prototype.otherCallFulfilled=function(v){m(this.promise,this.onFulfilled,v)},h.prototype.callRejected=function(v){a.reject(this.promise,v)},h.prototype.otherCallRejected=function(v){m(this.promise,this.onRejected,v)},a.resolve=function(v,S){var C=w(y,S);if(C.status==="error")return a.reject(v,C.value);var k=C.value;if(k)g(v,k);else{v.state=u,v.outcome=S;for(var N=-1,_=v.queue.length;++N<_;)v.queue[N].callFulfilled(S)}return v},a.reject=function(v,S){v.state=l,v.outcome=S;for(var C=-1,k=v.queue.length;++C<k;)v.queue[C].callRejected(S);return v},f.resolve=function(v){return v instanceof this?v:a.resolve(new this(o),v)},f.reject=function(v){var S=new this(o);return a.reject(S,v)},f.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=v.length,k=!1;if(!C)return this.resolve([]);for(var N=new Array(C),_=0,j=-1,T=new this(o);++j<C;)M(v[j],j);return T;function M(V,H){S.resolve(V).then(function(P){N[H]=P,++_!==C||k||(k=!0,a.resolve(T,N))},function(P){k||(k=!0,a.reject(T,P))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=v.length,k=!1;if(!C)return this.resolve([]);for(var N=-1,_=new this(o);++N<C;)j=v[N],S.resolve(j).then(function(T){k||(k=!0,a.resolve(_,T))},function(T){k||(k=!0,a.reject(_,T))});var j;return _}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,h=-1,m=0,y=8;function g(v){if(!(this instanceof g))return new g(v);this.options=o.assign({level:h,method:y,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},v||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(C!==f)throw new Error(l[C]);if(S.header&&s.deflateSetHeader(this.strm,S.header),S.dictionary){var k;if(k=typeof S.dictionary=="string"?a.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(C=s.deflateSetDictionary(this.strm,k))!==f)throw new Error(l[C]);this._dict_set=!0}}function w(v,S){var C=new g(S);if(C.push(v,!0),C.err)throw C.msg||l[C.err];return C.result}g.prototype.push=function(v,S){var C,k,N=this.strm,_=this.options.chunkSize;if(this.ended)return!1;k=S===~~S?S:S===!0?4:0,typeof v=="string"?N.input=a.string2buf(v):d.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new o.Buf8(_),N.next_out=0,N.avail_out=_),(C=s.deflate(N,k))!==1&&C!==f)return this.onEnd(C),!(this.ended=!0);N.avail_out!==0&&(N.avail_in!==0||k!==4&&k!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(o.shrinkBuf(N.output,N.next_out))):this.onData(o.shrinkBuf(N.output,N.next_out)))}while((0<N.avail_in||N.avail_out===0)&&C!==1);return k===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===f):k!==2||(this.onEnd(f),!(N.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=g,i.deflate=w,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,w(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,w(v,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),o=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),h=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},g||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,w.windowBits===0&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||g&&g.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&(15&w.windowBits)==0&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=s.inflateInit2(this.strm,w.windowBits);if(v!==l.Z_OK)throw new Error(u[v]);this.header=new f,s.inflateGetHeader(this.strm,this.header)}function y(g,w){var v=new m(w);if(v.push(g,!0),v.err)throw v.msg||u[v.err];return v.result}m.prototype.push=function(g,w){var v,S,C,k,N,_,j=this.strm,T=this.options.chunkSize,M=this.options.dictionary,V=!1;if(this.ended)return!1;S=w===~~w?w:w===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof g=="string"?j.input=a.binstring2buf(g):h.call(g)==="[object ArrayBuffer]"?j.input=new Uint8Array(g):j.input=g,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new o.Buf8(T),j.next_out=0,j.avail_out=T),(v=s.inflate(j,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&M&&(_=typeof M=="string"?a.string2buf(M):h.call(M)==="[object ArrayBuffer]"?new Uint8Array(M):M,v=s.inflateSetDictionary(this.strm,_)),v===l.Z_BUF_ERROR&&V===!0&&(v=l.Z_OK,V=!1),v!==l.Z_STREAM_END&&v!==l.Z_OK)return this.onEnd(v),!(this.ended=!0);j.next_out&&(j.avail_out!==0&&v!==l.Z_STREAM_END&&(j.avail_in!==0||S!==l.Z_FINISH&&S!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=a.utf8border(j.output,j.next_out),k=j.next_out-C,N=a.buf2string(j.output,C),j.next_out=k,j.avail_out=T-k,k&&o.arraySet(j.output,j.output,C,k,0),this.onData(N)):this.onData(o.shrinkBuf(j.output,j.next_out)))),j.avail_in===0&&j.avail_out===0&&(V=!0)}while((0<j.avail_in||j.avail_out===0)&&v!==l.Z_STREAM_END);return v===l.Z_STREAM_END&&(S=l.Z_FINISH),S===l.Z_FINISH?(v=s.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===l.Z_OK):S!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(j.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){g===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},i.Inflate=m,i.inflate=y,i.inflateRaw=function(g,w){return(w=w||{}).raw=!0,y(g,w)},i.ungzip=y},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},i.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var o={arraySet:function(l,u,d,f,h){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+f),h);else for(var m=0;m<f;m++)l[h+m]=u[d+m]},flattenChunks:function(l){var u,d,f,h,m,y;for(u=f=0,d=l.length;u<d;u++)f+=l[u].length;for(y=new Uint8Array(f),u=h=0,d=l.length;u<d;u++)m=l[u],y.set(m,h),h+=m.length;return y}},a={arraySet:function(l,u,d,f,h){for(var m=0;m<f;m++)l[h+m]=u[d+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,h){if(h<65537&&(f.subarray&&a||!f.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(f,h));for(var m="",y=0;y<h;y++)m+=String.fromCharCode(f[y]);return m}l[254]=l[254]=1,i.string2buf=function(f){var h,m,y,g,w,v=f.length,S=0;for(g=0;g<v;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<v&&(64512&(y=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),g++),S+=m<128?1:m<2048?2:m<65536?3:4;for(h=new s.Buf8(S),g=w=0;w<S;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<v&&(64512&(y=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),g++),m<128?h[w++]=m:(m<2048?h[w++]=192|m>>>6:(m<65536?h[w++]=224|m>>>12:(h[w++]=240|m>>>18,h[w++]=128|m>>>12&63),h[w++]=128|m>>>6&63),h[w++]=128|63&m);return h},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var h=new s.Buf8(f.length),m=0,y=h.length;m<y;m++)h[m]=f.charCodeAt(m);return h},i.buf2string=function(f,h){var m,y,g,w,v=h||f.length,S=new Array(2*v);for(m=y=0;m<v;)if((g=f[m++])<128)S[y++]=g;else if(4<(w=l[g]))S[y++]=65533,m+=w-1;else{for(g&=w===2?31:w===3?15:7;1<w&&m<v;)g=g<<6|63&f[m++],w--;1<w?S[y++]=65533:g<65536?S[y++]=g:(g-=65536,S[y++]=55296|g>>10&1023,S[y++]=56320|1023&g)}return d(S,y)},i.utf8border=function(f,h){var m;for((h=h||f.length)>f.length&&(h=f.length),m=h-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?h:m+l[f[m]]>h?m:h}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,o,a,l){for(var u=65535&s|0,d=s>>>16&65535|0,f=0;a!==0;){for(a-=f=2e3<a?2e3:a;d=d+(u=u+o[l++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a}();r.exports=function(o,a,l,u){var d=s,f=u+l;o^=-1;for(var h=u;h<f;h++)o=o>>>8^d[255&(o^a[h])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,h=4,m=0,y=-2,g=-1,w=4,v=2,S=8,C=9,k=286,N=30,_=19,j=2*k+1,T=15,M=3,V=258,H=V+M+1,P=42,F=113,I=1,R=2,U=3,A=4;function W(O,pe){return O.msg=d[pe],pe}function D(O){return(O<<1)-(4<O?9:0)}function B(O){for(var pe=O.length;0<=--pe;)O[pe]=0}function L(O){var pe=O.state,he=pe.pending;he>O.avail_out&&(he=O.avail_out),he!==0&&(o.arraySet(O.output,pe.pending_buf,pe.pending_out,he,O.next_out),O.next_out+=he,pe.pending_out+=he,O.total_out+=he,O.avail_out-=he,pe.pending-=he,pe.pending===0&&(pe.pending_out=0))}function $(O,pe){a._tr_flush_block(O,0<=O.block_start?O.block_start:-1,O.strstart-O.block_start,pe),O.block_start=O.strstart,L(O.strm)}function q(O,pe){O.pending_buf[O.pending++]=pe}function Z(O,pe){O.pending_buf[O.pending++]=pe>>>8&255,O.pending_buf[O.pending++]=255&pe}function ie(O,pe){var he,le,oe=O.max_chain_length,Q=O.strstart,de=O.prev_length,Ne=O.nice_match,Ce=O.strstart>O.w_size-H?O.strstart-(O.w_size-H):0,Ae=O.window,Ue=O.w_mask,Se=O.prev,ve=O.strstart+V,je=Ae[Q+de-1],Te=Ae[Q+de];O.prev_length>=O.good_match&&(oe>>=2),Ne>O.lookahead&&(Ne=O.lookahead);do if(Ae[(he=pe)+de]===Te&&Ae[he+de-1]===je&&Ae[he]===Ae[Q]&&Ae[++he]===Ae[Q+1]){Q+=2,he++;do;while(Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Ae[++Q]===Ae[++he]&&Q<ve);if(le=V-(ve-Q),Q=ve-V,de<le){if(O.match_start=pe,Ne<=(de=le))break;je=Ae[Q+de-1],Te=Ae[Q+de]}}while((pe=Se[pe&Ue])>Ce&&--oe!=0);return de<=O.lookahead?de:O.lookahead}function ge(O){var pe,he,le,oe,Q,de,Ne,Ce,Ae,Ue,Se=O.w_size;do{if(oe=O.window_size-O.lookahead-O.strstart,O.strstart>=Se+(Se-H)){for(o.arraySet(O.window,O.window,Se,Se,0),O.match_start-=Se,O.strstart-=Se,O.block_start-=Se,pe=he=O.hash_size;le=O.head[--pe],O.head[pe]=Se<=le?le-Se:0,--he;);for(pe=he=Se;le=O.prev[--pe],O.prev[pe]=Se<=le?le-Se:0,--he;);oe+=Se}if(O.strm.avail_in===0)break;if(de=O.strm,Ne=O.window,Ce=O.strstart+O.lookahead,Ae=oe,Ue=void 0,Ue=de.avail_in,Ae<Ue&&(Ue=Ae),he=Ue===0?0:(de.avail_in-=Ue,o.arraySet(Ne,de.input,de.next_in,Ue,Ce),de.state.wrap===1?de.adler=l(de.adler,Ne,Ue,Ce):de.state.wrap===2&&(de.adler=u(de.adler,Ne,Ue,Ce)),de.next_in+=Ue,de.total_in+=Ue,Ue),O.lookahead+=he,O.lookahead+O.insert>=M)for(Q=O.strstart-O.insert,O.ins_h=O.window[Q],O.ins_h=(O.ins_h<<O.hash_shift^O.window[Q+1])&O.hash_mask;O.insert&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[Q+M-1])&O.hash_mask,O.prev[Q&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=Q,Q++,O.insert--,!(O.lookahead+O.insert<M)););}while(O.lookahead<H&&O.strm.avail_in!==0)}function re(O,pe){for(var he,le;;){if(O.lookahead<H){if(ge(O),O.lookahead<H&&pe===f)return I;if(O.lookahead===0)break}if(he=0,O.lookahead>=M&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+M-1])&O.hash_mask,he=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),he!==0&&O.strstart-he<=O.w_size-H&&(O.match_length=ie(O,he)),O.match_length>=M)if(le=a._tr_tally(O,O.strstart-O.match_start,O.match_length-M),O.lookahead-=O.match_length,O.match_length<=O.max_lazy_match&&O.lookahead>=M){for(O.match_length--;O.strstart++,O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+M-1])&O.hash_mask,he=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart,--O.match_length!=0;);O.strstart++}else O.strstart+=O.match_length,O.match_length=0,O.ins_h=O.window[O.strstart],O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+1])&O.hash_mask;else le=a._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++;if(le&&($(O,!1),O.strm.avail_out===0))return I}return O.insert=O.strstart<M-1?O.strstart:M-1,pe===h?($(O,!0),O.strm.avail_out===0?U:A):O.last_lit&&($(O,!1),O.strm.avail_out===0)?I:R}function Y(O,pe){for(var he,le,oe;;){if(O.lookahead<H){if(ge(O),O.lookahead<H&&pe===f)return I;if(O.lookahead===0)break}if(he=0,O.lookahead>=M&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+M-1])&O.hash_mask,he=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),O.prev_length=O.match_length,O.prev_match=O.match_start,O.match_length=M-1,he!==0&&O.prev_length<O.max_lazy_match&&O.strstart-he<=O.w_size-H&&(O.match_length=ie(O,he),O.match_length<=5&&(O.strategy===1||O.match_length===M&&4096<O.strstart-O.match_start)&&(O.match_length=M-1)),O.prev_length>=M&&O.match_length<=O.prev_length){for(oe=O.strstart+O.lookahead-M,le=a._tr_tally(O,O.strstart-1-O.prev_match,O.prev_length-M),O.lookahead-=O.prev_length-1,O.prev_length-=2;++O.strstart<=oe&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+M-1])&O.hash_mask,he=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),--O.prev_length!=0;);if(O.match_available=0,O.match_length=M-1,O.strstart++,le&&($(O,!1),O.strm.avail_out===0))return I}else if(O.match_available){if((le=a._tr_tally(O,0,O.window[O.strstart-1]))&&$(O,!1),O.strstart++,O.lookahead--,O.strm.avail_out===0)return I}else O.match_available=1,O.strstart++,O.lookahead--}return O.match_available&&(le=a._tr_tally(O,0,O.window[O.strstart-1]),O.match_available=0),O.insert=O.strstart<M-1?O.strstart:M-1,pe===h?($(O,!0),O.strm.avail_out===0?U:A):O.last_lit&&($(O,!1),O.strm.avail_out===0)?I:R}function ne(O,pe,he,le,oe){this.good_length=O,this.max_lazy=pe,this.nice_length=he,this.max_chain=le,this.func=oe}function be(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*j),this.dyn_dtree=new o.Buf16(2*(2*N+1)),this.bl_tree=new o.Buf16(2*(2*_+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(T+1),this.heap=new o.Buf16(2*k+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*k+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function we(O){var pe;return O&&O.state?(O.total_in=O.total_out=0,O.data_type=v,(pe=O.state).pending=0,pe.pending_out=0,pe.wrap<0&&(pe.wrap=-pe.wrap),pe.status=pe.wrap?P:F,O.adler=pe.wrap===2?0:1,pe.last_flush=f,a._tr_init(pe),m):W(O,y)}function te(O){var pe=we(O);return pe===m&&function(he){he.window_size=2*he.w_size,B(he.head),he.max_lazy_match=s[he.level].max_lazy,he.good_match=s[he.level].good_length,he.nice_match=s[he.level].nice_length,he.max_chain_length=s[he.level].max_chain,he.strstart=0,he.block_start=0,he.lookahead=0,he.insert=0,he.match_length=he.prev_length=M-1,he.match_available=0,he.ins_h=0}(O.state),pe}function fe(O,pe,he,le,oe,Q){if(!O)return y;var de=1;if(pe===g&&(pe=6),le<0?(de=0,le=-le):15<le&&(de=2,le-=16),oe<1||C<oe||he!==S||le<8||15<le||pe<0||9<pe||Q<0||w<Q)return W(O,y);le===8&&(le=9);var Ne=new be;return(O.state=Ne).strm=O,Ne.wrap=de,Ne.gzhead=null,Ne.w_bits=le,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=oe+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+M-1)/M),Ne.window=new o.Buf8(2*Ne.w_size),Ne.head=new o.Buf16(Ne.hash_size),Ne.prev=new o.Buf16(Ne.w_size),Ne.lit_bufsize=1<<oe+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new o.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=pe,Ne.strategy=Q,Ne.method=he,te(O)}s=[new ne(0,0,0,0,function(O,pe){var he=65535;for(he>O.pending_buf_size-5&&(he=O.pending_buf_size-5);;){if(O.lookahead<=1){if(ge(O),O.lookahead===0&&pe===f)return I;if(O.lookahead===0)break}O.strstart+=O.lookahead,O.lookahead=0;var le=O.block_start+he;if((O.strstart===0||O.strstart>=le)&&(O.lookahead=O.strstart-le,O.strstart=le,$(O,!1),O.strm.avail_out===0)||O.strstart-O.block_start>=O.w_size-H&&($(O,!1),O.strm.avail_out===0))return I}return O.insert=0,pe===h?($(O,!0),O.strm.avail_out===0?U:A):(O.strstart>O.block_start&&($(O,!1),O.strm.avail_out),I)}),new ne(4,4,8,4,re),new ne(4,5,16,8,re),new ne(4,6,32,32,re),new ne(4,4,16,16,Y),new ne(8,16,32,32,Y),new ne(8,16,128,128,Y),new ne(8,32,128,256,Y),new ne(32,128,258,1024,Y),new ne(32,258,258,4096,Y)],i.deflateInit=function(O,pe){return fe(O,pe,S,15,8,0)},i.deflateInit2=fe,i.deflateReset=te,i.deflateResetKeep=we,i.deflateSetHeader=function(O,pe){return O&&O.state?O.state.wrap!==2?y:(O.state.gzhead=pe,m):y},i.deflate=function(O,pe){var he,le,oe,Q;if(!O||!O.state||5<pe||pe<0)return O?W(O,y):y;if(le=O.state,!O.output||!O.input&&O.avail_in!==0||le.status===666&&pe!==h)return W(O,O.avail_out===0?-5:y);if(le.strm=O,he=le.last_flush,le.last_flush=pe,le.status===P)if(le.wrap===2)O.adler=0,q(le,31),q(le,139),q(le,8),le.gzhead?(q(le,(le.gzhead.text?1:0)+(le.gzhead.hcrc?2:0)+(le.gzhead.extra?4:0)+(le.gzhead.name?8:0)+(le.gzhead.comment?16:0)),q(le,255&le.gzhead.time),q(le,le.gzhead.time>>8&255),q(le,le.gzhead.time>>16&255),q(le,le.gzhead.time>>24&255),q(le,le.level===9?2:2<=le.strategy||le.level<2?4:0),q(le,255&le.gzhead.os),le.gzhead.extra&&le.gzhead.extra.length&&(q(le,255&le.gzhead.extra.length),q(le,le.gzhead.extra.length>>8&255)),le.gzhead.hcrc&&(O.adler=u(O.adler,le.pending_buf,le.pending,0)),le.gzindex=0,le.status=69):(q(le,0),q(le,0),q(le,0),q(le,0),q(le,0),q(le,le.level===9?2:2<=le.strategy||le.level<2?4:0),q(le,3),le.status=F);else{var de=S+(le.w_bits-8<<4)<<8;de|=(2<=le.strategy||le.level<2?0:le.level<6?1:le.level===6?2:3)<<6,le.strstart!==0&&(de|=32),de+=31-de%31,le.status=F,Z(le,de),le.strstart!==0&&(Z(le,O.adler>>>16),Z(le,65535&O.adler)),O.adler=1}if(le.status===69)if(le.gzhead.extra){for(oe=le.pending;le.gzindex<(65535&le.gzhead.extra.length)&&(le.pending!==le.pending_buf_size||(le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),L(O),oe=le.pending,le.pending!==le.pending_buf_size));)q(le,255&le.gzhead.extra[le.gzindex]),le.gzindex++;le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),le.gzindex===le.gzhead.extra.length&&(le.gzindex=0,le.status=73)}else le.status=73;if(le.status===73)if(le.gzhead.name){oe=le.pending;do{if(le.pending===le.pending_buf_size&&(le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),L(O),oe=le.pending,le.pending===le.pending_buf_size)){Q=1;break}Q=le.gzindex<le.gzhead.name.length?255&le.gzhead.name.charCodeAt(le.gzindex++):0,q(le,Q)}while(Q!==0);le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),Q===0&&(le.gzindex=0,le.status=91)}else le.status=91;if(le.status===91)if(le.gzhead.comment){oe=le.pending;do{if(le.pending===le.pending_buf_size&&(le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),L(O),oe=le.pending,le.pending===le.pending_buf_size)){Q=1;break}Q=le.gzindex<le.gzhead.comment.length?255&le.gzhead.comment.charCodeAt(le.gzindex++):0,q(le,Q)}while(Q!==0);le.gzhead.hcrc&&le.pending>oe&&(O.adler=u(O.adler,le.pending_buf,le.pending-oe,oe)),Q===0&&(le.status=103)}else le.status=103;if(le.status===103&&(le.gzhead.hcrc?(le.pending+2>le.pending_buf_size&&L(O),le.pending+2<=le.pending_buf_size&&(q(le,255&O.adler),q(le,O.adler>>8&255),O.adler=0,le.status=F)):le.status=F),le.pending!==0){if(L(O),O.avail_out===0)return le.last_flush=-1,m}else if(O.avail_in===0&&D(pe)<=D(he)&&pe!==h)return W(O,-5);if(le.status===666&&O.avail_in!==0)return W(O,-5);if(O.avail_in!==0||le.lookahead!==0||pe!==f&&le.status!==666){var Ne=le.strategy===2?function(Ce,Ae){for(var Ue;;){if(Ce.lookahead===0&&(ge(Ce),Ce.lookahead===0)){if(Ae===f)return I;break}if(Ce.match_length=0,Ue=a._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++,Ue&&($(Ce,!1),Ce.strm.avail_out===0))return I}return Ce.insert=0,Ae===h?($(Ce,!0),Ce.strm.avail_out===0?U:A):Ce.last_lit&&($(Ce,!1),Ce.strm.avail_out===0)?I:R}(le,pe):le.strategy===3?function(Ce,Ae){for(var Ue,Se,ve,je,Te=Ce.window;;){if(Ce.lookahead<=V){if(ge(Ce),Ce.lookahead<=V&&Ae===f)return I;if(Ce.lookahead===0)break}if(Ce.match_length=0,Ce.lookahead>=M&&0<Ce.strstart&&(Se=Te[ve=Ce.strstart-1])===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]){je=Ce.strstart+V;do;while(Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&Se===Te[++ve]&&ve<je);Ce.match_length=V-(je-ve),Ce.match_length>Ce.lookahead&&(Ce.match_length=Ce.lookahead)}if(Ce.match_length>=M?(Ue=a._tr_tally(Ce,1,Ce.match_length-M),Ce.lookahead-=Ce.match_length,Ce.strstart+=Ce.match_length,Ce.match_length=0):(Ue=a._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++),Ue&&($(Ce,!1),Ce.strm.avail_out===0))return I}return Ce.insert=0,Ae===h?($(Ce,!0),Ce.strm.avail_out===0?U:A):Ce.last_lit&&($(Ce,!1),Ce.strm.avail_out===0)?I:R}(le,pe):s[le.level].func(le,pe);if(Ne!==U&&Ne!==A||(le.status=666),Ne===I||Ne===U)return O.avail_out===0&&(le.last_flush=-1),m;if(Ne===R&&(pe===1?a._tr_align(le):pe!==5&&(a._tr_stored_block(le,0,0,!1),pe===3&&(B(le.head),le.lookahead===0&&(le.strstart=0,le.block_start=0,le.insert=0))),L(O),O.avail_out===0))return le.last_flush=-1,m}return pe!==h?m:le.wrap<=0?1:(le.wrap===2?(q(le,255&O.adler),q(le,O.adler>>8&255),q(le,O.adler>>16&255),q(le,O.adler>>24&255),q(le,255&O.total_in),q(le,O.total_in>>8&255),q(le,O.total_in>>16&255),q(le,O.total_in>>24&255)):(Z(le,O.adler>>>16),Z(le,65535&O.adler)),L(O),0<le.wrap&&(le.wrap=-le.wrap),le.pending!==0?m:1)},i.deflateEnd=function(O){var pe;return O&&O.state?(pe=O.state.status)!==P&&pe!==69&&pe!==73&&pe!==91&&pe!==103&&pe!==F&&pe!==666?W(O,y):(O.state=null,pe===F?W(O,-3):m):y},i.deflateSetDictionary=function(O,pe){var he,le,oe,Q,de,Ne,Ce,Ae,Ue=pe.length;if(!O||!O.state||(Q=(he=O.state).wrap)===2||Q===1&&he.status!==P||he.lookahead)return y;for(Q===1&&(O.adler=l(O.adler,pe,Ue,0)),he.wrap=0,Ue>=he.w_size&&(Q===0&&(B(he.head),he.strstart=0,he.block_start=0,he.insert=0),Ae=new o.Buf8(he.w_size),o.arraySet(Ae,pe,Ue-he.w_size,he.w_size,0),pe=Ae,Ue=he.w_size),de=O.avail_in,Ne=O.next_in,Ce=O.input,O.avail_in=Ue,O.next_in=0,O.input=pe,ge(he);he.lookahead>=M;){for(le=he.strstart,oe=he.lookahead-(M-1);he.ins_h=(he.ins_h<<he.hash_shift^he.window[le+M-1])&he.hash_mask,he.prev[le&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=le,le++,--oe;);he.strstart=le,he.lookahead=M-1,ge(he)}return he.strstart+=he.lookahead,he.block_start=he.strstart,he.insert=he.lookahead,he.lookahead=0,he.match_length=he.prev_length=M-1,he.match_available=0,O.next_in=Ne,O.input=Ce,O.avail_in=de,he.wrap=Q,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,o){var a,l,u,d,f,h,m,y,g,w,v,S,C,k,N,_,j,T,M,V,H,P,F,I,R;a=s.state,l=s.next_in,I=s.input,u=l+(s.avail_in-5),d=s.next_out,R=s.output,f=d-(o-s.avail_out),h=d+(s.avail_out-257),m=a.dmax,y=a.wsize,g=a.whave,w=a.wnext,v=a.window,S=a.hold,C=a.bits,k=a.lencode,N=a.distcode,_=(1<<a.lenbits)-1,j=(1<<a.distbits)-1;e:do{C<15&&(S+=I[l++]<<C,C+=8,S+=I[l++]<<C,C+=8),T=k[S&_];t:for(;;){if(S>>>=M=T>>>24,C-=M,(M=T>>>16&255)===0)R[d++]=65535&T;else{if(!(16&M)){if((64&M)==0){T=k[(65535&T)+(S&(1<<M)-1)];continue t}if(32&M){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}V=65535&T,(M&=15)&&(C<M&&(S+=I[l++]<<C,C+=8),V+=S&(1<<M)-1,S>>>=M,C-=M),C<15&&(S+=I[l++]<<C,C+=8,S+=I[l++]<<C,C+=8),T=N[S&j];n:for(;;){if(S>>>=M=T>>>24,C-=M,!(16&(M=T>>>16&255))){if((64&M)==0){T=N[(65535&T)+(S&(1<<M)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(H=65535&T,C<(M&=15)&&(S+=I[l++]<<C,(C+=8)<M&&(S+=I[l++]<<C,C+=8)),m<(H+=S&(1<<M)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(S>>>=M,C-=M,(M=d-f)<H){if(g<(M=H-M)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(F=v,(P=0)===w){if(P+=y-M,M<V){for(V-=M;R[d++]=v[P++],--M;);P=d-H,F=R}}else if(w<M){if(P+=y+w-M,(M-=w)<V){for(V-=M;R[d++]=v[P++],--M;);if(P=0,w<V){for(V-=M=w;R[d++]=v[P++],--M;);P=d-H,F=R}}}else if(P+=w-M,M<V){for(V-=M;R[d++]=v[P++],--M;);P=d-H,F=R}for(;2<V;)R[d++]=F[P++],R[d++]=F[P++],R[d++]=F[P++],V-=3;V&&(R[d++]=F[P++],1<V&&(R[d++]=F[P++]))}else{for(P=d-H;R[d++]=R[P++],R[d++]=R[P++],R[d++]=R[P++],2<(V-=3););V&&(R[d++]=R[P++],1<V&&(R[d++]=R[P++]))}break}}break}}while(l<u&&d<h);l-=V=C>>3,S&=(1<<(C-=V<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l<u?u-l+5:5-(l-u),s.avail_out=d<h?h-d+257:257-(d-h),a.hold=S,a.bits=C}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),a=n("./crc32"),l=n("./inffast"),u=n("./inftrees"),d=1,f=2,h=0,m=-2,y=1,g=852,w=592;function v(P){return(P>>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(P){var F;return P&&P.state?(F=P.state,P.total_in=P.total_out=F.total=0,P.msg="",F.wrap&&(P.adler=1&F.wrap),F.mode=y,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new s.Buf32(g),F.distcode=F.distdyn=new s.Buf32(w),F.sane=1,F.back=-1,h):m}function k(P){var F;return P&&P.state?((F=P.state).wsize=0,F.whave=0,F.wnext=0,C(P)):m}function N(P,F){var I,R;return P&&P.state?(R=P.state,F<0?(I=0,F=-F):(I=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?m:(R.window!==null&&R.wbits!==F&&(R.window=null),R.wrap=I,R.wbits=F,k(P))):m}function _(P,F){var I,R;return P?(R=new S,(P.state=R).window=null,(I=N(P,F))!==h&&(P.state=null),I):m}var j,T,M=!0;function V(P){if(M){var F;for(j=new s.Buf32(512),T=new s.Buf32(32),F=0;F<144;)P.lens[F++]=8;for(;F<256;)P.lens[F++]=9;for(;F<280;)P.lens[F++]=7;for(;F<288;)P.lens[F++]=8;for(u(d,P.lens,0,288,j,0,P.work,{bits:9}),F=0;F<32;)P.lens[F++]=5;u(f,P.lens,0,32,T,0,P.work,{bits:5}),M=!1}P.lencode=j,P.lenbits=9,P.distcode=T,P.distbits=5}function H(P,F,I,R){var U,A=P.state;return A.window===null&&(A.wsize=1<<A.wbits,A.wnext=0,A.whave=0,A.window=new s.Buf8(A.wsize)),R>=A.wsize?(s.arraySet(A.window,F,I-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(R<(U=A.wsize-A.wnext)&&(U=R),s.arraySet(A.window,F,I-R,U,A.wnext),(R-=U)?(s.arraySet(A.window,F,I-R,R,0),A.wnext=R,A.whave=A.wsize):(A.wnext+=U,A.wnext===A.wsize&&(A.wnext=0),A.whave<A.wsize&&(A.whave+=U))),0}i.inflateReset=k,i.inflateReset2=N,i.inflateResetKeep=C,i.inflateInit=function(P){return _(P,15)},i.inflateInit2=_,i.inflate=function(P,F){var I,R,U,A,W,D,B,L,$,q,Z,ie,ge,re,Y,ne,be,we,te,fe,O,pe,he,le,oe=0,Q=new s.Buf8(4),de=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!P||!P.state||!P.output||!P.input&&P.avail_in!==0)return m;(I=P.state).mode===12&&(I.mode=13),W=P.next_out,U=P.output,B=P.avail_out,A=P.next_in,R=P.input,D=P.avail_in,L=I.hold,$=I.bits,q=D,Z=B,pe=h;e:for(;;)switch(I.mode){case y:if(I.wrap===0){I.mode=13;break}for(;$<16;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(2&I.wrap&&L===35615){Q[I.check=0]=255&L,Q[1]=L>>>8&255,I.check=a(I.check,Q,2,0),$=L=0,I.mode=2;break}if(I.flags=0,I.head&&(I.head.done=!1),!(1&I.wrap)||(((255&L)<<8)+(L>>8))%31){P.msg="incorrect header check",I.mode=30;break}if((15&L)!=8){P.msg="unknown compression method",I.mode=30;break}if($-=4,O=8+(15&(L>>>=4)),I.wbits===0)I.wbits=O;else if(O>I.wbits){P.msg="invalid window size",I.mode=30;break}I.dmax=1<<O,P.adler=I.check=1,I.mode=512&L?10:12,$=L=0;break;case 2:for(;$<16;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(I.flags=L,(255&I.flags)!=8){P.msg="unknown compression method",I.mode=30;break}if(57344&I.flags){P.msg="unknown header flags set",I.mode=30;break}I.head&&(I.head.text=L>>8&1),512&I.flags&&(Q[0]=255&L,Q[1]=L>>>8&255,I.check=a(I.check,Q,2,0)),$=L=0,I.mode=3;case 3:for(;$<32;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.head&&(I.head.time=L),512&I.flags&&(Q[0]=255&L,Q[1]=L>>>8&255,Q[2]=L>>>16&255,Q[3]=L>>>24&255,I.check=a(I.check,Q,4,0)),$=L=0,I.mode=4;case 4:for(;$<16;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.head&&(I.head.xflags=255&L,I.head.os=L>>8),512&I.flags&&(Q[0]=255&L,Q[1]=L>>>8&255,I.check=a(I.check,Q,2,0)),$=L=0,I.mode=5;case 5:if(1024&I.flags){for(;$<16;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.length=L,I.head&&(I.head.extra_len=L),512&I.flags&&(Q[0]=255&L,Q[1]=L>>>8&255,I.check=a(I.check,Q,2,0)),$=L=0}else I.head&&(I.head.extra=null);I.mode=6;case 6:if(1024&I.flags&&(D<(ie=I.length)&&(ie=D),ie&&(I.head&&(O=I.head.extra_len-I.length,I.head.extra||(I.head.extra=new Array(I.head.extra_len)),s.arraySet(I.head.extra,R,A,ie,O)),512&I.flags&&(I.check=a(I.check,R,ie,A)),D-=ie,A+=ie,I.length-=ie),I.length))break e;I.length=0,I.mode=7;case 7:if(2048&I.flags){if(D===0)break e;for(ie=0;O=R[A+ie++],I.head&&O&&I.length<65536&&(I.head.name+=String.fromCharCode(O)),O&&ie<D;);if(512&I.flags&&(I.check=a(I.check,R,ie,A)),D-=ie,A+=ie,O)break e}else I.head&&(I.head.name=null);I.length=0,I.mode=8;case 8:if(4096&I.flags){if(D===0)break e;for(ie=0;O=R[A+ie++],I.head&&O&&I.length<65536&&(I.head.comment+=String.fromCharCode(O)),O&&ie<D;);if(512&I.flags&&(I.check=a(I.check,R,ie,A)),D-=ie,A+=ie,O)break e}else I.head&&(I.head.comment=null);I.mode=9;case 9:if(512&I.flags){for(;$<16;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(L!==(65535&I.check)){P.msg="header crc mismatch",I.mode=30;break}$=L=0}I.head&&(I.head.hcrc=I.flags>>9&1,I.head.done=!0),P.adler=I.check=0,I.mode=12;break;case 10:for(;$<32;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}P.adler=I.check=v(L),$=L=0,I.mode=11;case 11:if(I.havedict===0)return P.next_out=W,P.avail_out=B,P.next_in=A,P.avail_in=D,I.hold=L,I.bits=$,2;P.adler=I.check=1,I.mode=12;case 12:if(F===5||F===6)break e;case 13:if(I.last){L>>>=7&$,$-=7&$,I.mode=27;break}for(;$<3;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}switch(I.last=1&L,$-=1,3&(L>>>=1)){case 0:I.mode=14;break;case 1:if(V(I),I.mode=20,F!==6)break;L>>>=2,$-=2;break e;case 2:I.mode=17;break;case 3:P.msg="invalid block type",I.mode=30}L>>>=2,$-=2;break;case 14:for(L>>>=7&$,$-=7&$;$<32;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if((65535&L)!=(L>>>16^65535)){P.msg="invalid stored block lengths",I.mode=30;break}if(I.length=65535&L,$=L=0,I.mode=15,F===6)break e;case 15:I.mode=16;case 16:if(ie=I.length){if(D<ie&&(ie=D),B<ie&&(ie=B),ie===0)break e;s.arraySet(U,R,A,ie,W),D-=ie,A+=ie,B-=ie,W+=ie,I.length-=ie;break}I.mode=12;break;case 17:for(;$<14;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(I.nlen=257+(31&L),L>>>=5,$-=5,I.ndist=1+(31&L),L>>>=5,$-=5,I.ncode=4+(15&L),L>>>=4,$-=4,286<I.nlen||30<I.ndist){P.msg="too many length or distance symbols",I.mode=30;break}I.have=0,I.mode=18;case 18:for(;I.have<I.ncode;){for(;$<3;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.lens[de[I.have++]]=7&L,L>>>=3,$-=3}for(;I.have<19;)I.lens[de[I.have++]]=0;if(I.lencode=I.lendyn,I.lenbits=7,he={bits:I.lenbits},pe=u(0,I.lens,0,19,I.lencode,0,I.work,he),I.lenbits=he.bits,pe){P.msg="invalid code lengths set",I.mode=30;break}I.have=0,I.mode=19;case 19:for(;I.have<I.nlen+I.ndist;){for(;ne=(oe=I.lencode[L&(1<<I.lenbits)-1])>>>16&255,be=65535&oe,!((Y=oe>>>24)<=$);){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(be<16)L>>>=Y,$-=Y,I.lens[I.have++]=be;else{if(be===16){for(le=Y+2;$<le;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(L>>>=Y,$-=Y,I.have===0){P.msg="invalid bit length repeat",I.mode=30;break}O=I.lens[I.have-1],ie=3+(3&L),L>>>=2,$-=2}else if(be===17){for(le=Y+3;$<le;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}$-=Y,O=0,ie=3+(7&(L>>>=Y)),L>>>=3,$-=3}else{for(le=Y+7;$<le;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}$-=Y,O=0,ie=11+(127&(L>>>=Y)),L>>>=7,$-=7}if(I.have+ie>I.nlen+I.ndist){P.msg="invalid bit length repeat",I.mode=30;break}for(;ie--;)I.lens[I.have++]=O}}if(I.mode===30)break;if(I.lens[256]===0){P.msg="invalid code -- missing end-of-block",I.mode=30;break}if(I.lenbits=9,he={bits:I.lenbits},pe=u(d,I.lens,0,I.nlen,I.lencode,0,I.work,he),I.lenbits=he.bits,pe){P.msg="invalid literal/lengths set",I.mode=30;break}if(I.distbits=6,I.distcode=I.distdyn,he={bits:I.distbits},pe=u(f,I.lens,I.nlen,I.ndist,I.distcode,0,I.work,he),I.distbits=he.bits,pe){P.msg="invalid distances set",I.mode=30;break}if(I.mode=20,F===6)break e;case 20:I.mode=21;case 21:if(6<=D&&258<=B){P.next_out=W,P.avail_out=B,P.next_in=A,P.avail_in=D,I.hold=L,I.bits=$,l(P,Z),W=P.next_out,U=P.output,B=P.avail_out,A=P.next_in,R=P.input,D=P.avail_in,L=I.hold,$=I.bits,I.mode===12&&(I.back=-1);break}for(I.back=0;ne=(oe=I.lencode[L&(1<<I.lenbits)-1])>>>16&255,be=65535&oe,!((Y=oe>>>24)<=$);){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(ne&&(240&ne)==0){for(we=Y,te=ne,fe=be;ne=(oe=I.lencode[fe+((L&(1<<we+te)-1)>>we)])>>>16&255,be=65535&oe,!(we+(Y=oe>>>24)<=$);){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}L>>>=we,$-=we,I.back+=we}if(L>>>=Y,$-=Y,I.back+=Y,I.length=be,ne===0){I.mode=26;break}if(32&ne){I.back=-1,I.mode=12;break}if(64&ne){P.msg="invalid literal/length code",I.mode=30;break}I.extra=15&ne,I.mode=22;case 22:if(I.extra){for(le=I.extra;$<le;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.length+=L&(1<<I.extra)-1,L>>>=I.extra,$-=I.extra,I.back+=I.extra}I.was=I.length,I.mode=23;case 23:for(;ne=(oe=I.distcode[L&(1<<I.distbits)-1])>>>16&255,be=65535&oe,!((Y=oe>>>24)<=$);){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if((240&ne)==0){for(we=Y,te=ne,fe=be;ne=(oe=I.distcode[fe+((L&(1<<we+te)-1)>>we)])>>>16&255,be=65535&oe,!(we+(Y=oe>>>24)<=$);){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}L>>>=we,$-=we,I.back+=we}if(L>>>=Y,$-=Y,I.back+=Y,64&ne){P.msg="invalid distance code",I.mode=30;break}I.offset=be,I.extra=15&ne,I.mode=24;case 24:if(I.extra){for(le=I.extra;$<le;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}I.offset+=L&(1<<I.extra)-1,L>>>=I.extra,$-=I.extra,I.back+=I.extra}if(I.offset>I.dmax){P.msg="invalid distance too far back",I.mode=30;break}I.mode=25;case 25:if(B===0)break e;if(ie=Z-B,I.offset>ie){if((ie=I.offset-ie)>I.whave&&I.sane){P.msg="invalid distance too far back",I.mode=30;break}ge=ie>I.wnext?(ie-=I.wnext,I.wsize-ie):I.wnext-ie,ie>I.length&&(ie=I.length),re=I.window}else re=U,ge=W-I.offset,ie=I.length;for(B<ie&&(ie=B),B-=ie,I.length-=ie;U[W++]=re[ge++],--ie;);I.length===0&&(I.mode=21);break;case 26:if(B===0)break e;U[W++]=I.length,B--,I.mode=21;break;case 27:if(I.wrap){for(;$<32;){if(D===0)break e;D--,L|=R[A++]<<$,$+=8}if(Z-=B,P.total_out+=Z,I.total+=Z,Z&&(P.adler=I.check=I.flags?a(I.check,U,Z,W-Z):o(I.check,U,Z,W-Z)),Z=B,(I.flags?L:v(L))!==I.check){P.msg="incorrect data check",I.mode=30;break}$=L=0}I.mode=28;case 28:if(I.wrap&&I.flags){for(;$<32;){if(D===0)break e;D--,L+=R[A++]<<$,$+=8}if(L!==(4294967295&I.total)){P.msg="incorrect length check",I.mode=30;break}$=L=0}I.mode=29;case 29:pe=1;break e;case 30:pe=-3;break e;case 31:return-4;case 32:default:return m}return P.next_out=W,P.avail_out=B,P.next_in=A,P.avail_in=D,I.hold=L,I.bits=$,(I.wsize||Z!==P.avail_out&&I.mode<30&&(I.mode<27||F!==4))&&H(P,P.output,P.next_out,Z-P.avail_out)?(I.mode=31,-4):(q-=P.avail_in,Z-=P.avail_out,P.total_in+=q,P.total_out+=Z,I.total+=Z,I.wrap&&Z&&(P.adler=I.check=I.flags?a(I.check,U,Z,P.next_out-Z):o(I.check,U,Z,P.next_out-Z)),P.data_type=I.bits+(I.last?64:0)+(I.mode===12?128:0)+(I.mode===20||I.mode===15?256:0),(q==0&&Z===0||F===4)&&pe===h&&(pe=-5),pe)},i.inflateEnd=function(P){if(!P||!P.state)return m;var F=P.state;return F.window&&(F.window=null),P.state=null,h},i.inflateGetHeader=function(P,F){var I;return P&&P.state?(2&(I=P.state).wrap)==0?m:((I.head=F).done=!1,h):m},i.inflateSetDictionary=function(P,F){var I,R=F.length;return P&&P.state?(I=P.state).wrap!==0&&I.mode!==11?m:I.mode===11&&o(1,F,R,0)!==I.check?-3:H(P,F,R,R)?(I.mode=31,-4):(I.havedict=1,h):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,h,m,y,g,w,v){var S,C,k,N,_,j,T,M,V,H=v.bits,P=0,F=0,I=0,R=0,U=0,A=0,W=0,D=0,B=0,L=0,$=null,q=0,Z=new s.Buf16(16),ie=new s.Buf16(16),ge=null,re=0;for(P=0;P<=15;P++)Z[P]=0;for(F=0;F<m;F++)Z[f[h+F]]++;for(U=H,R=15;1<=R&&Z[R]===0;R--);if(R<U&&(U=R),R===0)return y[g++]=20971520,y[g++]=20971520,v.bits=1,0;for(I=1;I<R&&Z[I]===0;I++);for(U<I&&(U=I),P=D=1;P<=15;P++)if(D<<=1,(D-=Z[P])<0)return-1;if(0<D&&(d===0||R!==1))return-1;for(ie[1]=0,P=1;P<15;P++)ie[P+1]=ie[P]+Z[P];for(F=0;F<m;F++)f[h+F]!==0&&(w[ie[f[h+F]]++]=F);if(j=d===0?($=ge=w,19):d===1?($=o,q-=257,ge=a,re-=257,256):($=l,ge=u,-1),P=I,_=g,W=F=L=0,k=-1,N=(B=1<<(A=U))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(T=P-W,V=w[F]<j?(M=0,w[F]):w[F]>j?(M=ge[re+w[F]],$[q+w[F]]):(M=96,0),S=1<<P-W,I=C=1<<A;y[_+(L>>W)+(C-=S)]=T<<24|M<<16|V|0,C!==0;);for(S=1<<P-1;L&S;)S>>=1;if(S!==0?(L&=S-1,L+=S):L=0,F++,--Z[P]==0){if(P===R)break;P=f[h+w[F]]}if(U<P&&(L&N)!==k){for(W===0&&(W=U),_+=I,D=1<<(A=P-W);A+W<R&&!((D-=Z[A+W])<=0);)A++,D<<=1;if(B+=1<<A,d===1&&852<B||d===2&&592<B)return 1;y[k=L&N]=U<<24|A<<16|_-g|0}}return L!==0&&(y[_+L]=P-W<<24|64<<16|0),v.bits=U,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),o=0,a=1;function l(oe){for(var Q=oe.length;0<=--Q;)oe[Q]=0}var u=0,d=29,f=256,h=f+1+d,m=30,y=19,g=2*h+1,w=15,v=16,S=7,C=256,k=16,N=17,_=18,j=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],T=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=new Array(2*(h+2));l(H);var P=new Array(2*m);l(P);var F=new Array(512);l(F);var I=new Array(256);l(I);var R=new Array(d);l(R);var U,A,W,D=new Array(m);function B(oe,Q,de,Ne,Ce){this.static_tree=oe,this.extra_bits=Q,this.extra_base=de,this.elems=Ne,this.max_length=Ce,this.has_stree=oe&&oe.length}function L(oe,Q){this.dyn_tree=oe,this.max_code=0,this.stat_desc=Q}function $(oe){return oe<256?F[oe]:F[256+(oe>>>7)]}function q(oe,Q){oe.pending_buf[oe.pending++]=255&Q,oe.pending_buf[oe.pending++]=Q>>>8&255}function Z(oe,Q,de){oe.bi_valid>v-de?(oe.bi_buf|=Q<<oe.bi_valid&65535,q(oe,oe.bi_buf),oe.bi_buf=Q>>v-oe.bi_valid,oe.bi_valid+=de-v):(oe.bi_buf|=Q<<oe.bi_valid&65535,oe.bi_valid+=de)}function ie(oe,Q,de){Z(oe,de[2*Q],de[2*Q+1])}function ge(oe,Q){for(var de=0;de|=1&oe,oe>>>=1,de<<=1,0<--Q;);return de>>>1}function re(oe,Q,de){var Ne,Ce,Ae=new Array(w+1),Ue=0;for(Ne=1;Ne<=w;Ne++)Ae[Ne]=Ue=Ue+de[Ne-1]<<1;for(Ce=0;Ce<=Q;Ce++){var Se=oe[2*Ce+1];Se!==0&&(oe[2*Ce]=ge(Ae[Se]++,Se))}}function Y(oe){var Q;for(Q=0;Q<h;Q++)oe.dyn_ltree[2*Q]=0;for(Q=0;Q<m;Q++)oe.dyn_dtree[2*Q]=0;for(Q=0;Q<y;Q++)oe.bl_tree[2*Q]=0;oe.dyn_ltree[2*C]=1,oe.opt_len=oe.static_len=0,oe.last_lit=oe.matches=0}function ne(oe){8<oe.bi_valid?q(oe,oe.bi_buf):0<oe.bi_valid&&(oe.pending_buf[oe.pending++]=oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0}function be(oe,Q,de,Ne){var Ce=2*Q,Ae=2*de;return oe[Ce]<oe[Ae]||oe[Ce]===oe[Ae]&&Ne[Q]<=Ne[de]}function we(oe,Q,de){for(var Ne=oe.heap[de],Ce=de<<1;Ce<=oe.heap_len&&(Ce<oe.heap_len&&be(Q,oe.heap[Ce+1],oe.heap[Ce],oe.depth)&&Ce++,!be(Q,Ne,oe.heap[Ce],oe.depth));)oe.heap[de]=oe.heap[Ce],de=Ce,Ce<<=1;oe.heap[de]=Ne}function te(oe,Q,de){var Ne,Ce,Ae,Ue,Se=0;if(oe.last_lit!==0)for(;Ne=oe.pending_buf[oe.d_buf+2*Se]<<8|oe.pending_buf[oe.d_buf+2*Se+1],Ce=oe.pending_buf[oe.l_buf+Se],Se++,Ne===0?ie(oe,Ce,Q):(ie(oe,(Ae=I[Ce])+f+1,Q),(Ue=j[Ae])!==0&&Z(oe,Ce-=R[Ae],Ue),ie(oe,Ae=$(--Ne),de),(Ue=T[Ae])!==0&&Z(oe,Ne-=D[Ae],Ue)),Se<oe.last_lit;);ie(oe,C,Q)}function fe(oe,Q){var de,Ne,Ce,Ae=Q.dyn_tree,Ue=Q.stat_desc.static_tree,Se=Q.stat_desc.has_stree,ve=Q.stat_desc.elems,je=-1;for(oe.heap_len=0,oe.heap_max=g,de=0;de<ve;de++)Ae[2*de]!==0?(oe.heap[++oe.heap_len]=je=de,oe.depth[de]=0):Ae[2*de+1]=0;for(;oe.heap_len<2;)Ae[2*(Ce=oe.heap[++oe.heap_len]=je<2?++je:0)]=1,oe.depth[Ce]=0,oe.opt_len--,Se&&(oe.static_len-=Ue[2*Ce+1]);for(Q.max_code=je,de=oe.heap_len>>1;1<=de;de--)we(oe,Ae,de);for(Ce=ve;de=oe.heap[1],oe.heap[1]=oe.heap[oe.heap_len--],we(oe,Ae,1),Ne=oe.heap[1],oe.heap[--oe.heap_max]=de,oe.heap[--oe.heap_max]=Ne,Ae[2*Ce]=Ae[2*de]+Ae[2*Ne],oe.depth[Ce]=(oe.depth[de]>=oe.depth[Ne]?oe.depth[de]:oe.depth[Ne])+1,Ae[2*de+1]=Ae[2*Ne+1]=Ce,oe.heap[1]=Ce++,we(oe,Ae,1),2<=oe.heap_len;);oe.heap[--oe.heap_max]=oe.heap[1],function(Te,ce){var se,ye,ke,ze,qe,ot,Ze=ce.dyn_tree,_t=ce.max_code,tt=ce.stat_desc.static_tree,gt=ce.stat_desc.has_stree,dt=ce.stat_desc.extra_bits,wt=ce.stat_desc.extra_base,Dt=ce.stat_desc.max_length,Kt=0;for(ze=0;ze<=w;ze++)Te.bl_count[ze]=0;for(Ze[2*Te.heap[Te.heap_max]+1]=0,se=Te.heap_max+1;se<g;se++)Dt<(ze=Ze[2*Ze[2*(ye=Te.heap[se])+1]+1]+1)&&(ze=Dt,Kt++),Ze[2*ye+1]=ze,_t<ye||(Te.bl_count[ze]++,qe=0,wt<=ye&&(qe=dt[ye-wt]),ot=Ze[2*ye],Te.opt_len+=ot*(ze+qe),gt&&(Te.static_len+=ot*(tt[2*ye+1]+qe)));if(Kt!==0){do{for(ze=Dt-1;Te.bl_count[ze]===0;)ze--;Te.bl_count[ze]--,Te.bl_count[ze+1]+=2,Te.bl_count[Dt]--,Kt-=2}while(0<Kt);for(ze=Dt;ze!==0;ze--)for(ye=Te.bl_count[ze];ye!==0;)_t<(ke=Te.heap[--se])||(Ze[2*ke+1]!==ze&&(Te.opt_len+=(ze-Ze[2*ke+1])*Ze[2*ke],Ze[2*ke+1]=ze),ye--)}}(oe,Q),re(Ae,je,oe.bl_count)}function O(oe,Q,de){var Ne,Ce,Ae=-1,Ue=Q[1],Se=0,ve=7,je=4;for(Ue===0&&(ve=138,je=3),Q[2*(de+1)+1]=65535,Ne=0;Ne<=de;Ne++)Ce=Ue,Ue=Q[2*(Ne+1)+1],++Se<ve&&Ce===Ue||(Se<je?oe.bl_tree[2*Ce]+=Se:Ce!==0?(Ce!==Ae&&oe.bl_tree[2*Ce]++,oe.bl_tree[2*k]++):Se<=10?oe.bl_tree[2*N]++:oe.bl_tree[2*_]++,Ae=Ce,je=(Se=0)===Ue?(ve=138,3):Ce===Ue?(ve=6,3):(ve=7,4))}function pe(oe,Q,de){var Ne,Ce,Ae=-1,Ue=Q[1],Se=0,ve=7,je=4;for(Ue===0&&(ve=138,je=3),Ne=0;Ne<=de;Ne++)if(Ce=Ue,Ue=Q[2*(Ne+1)+1],!(++Se<ve&&Ce===Ue)){if(Se<je)for(;ie(oe,Ce,oe.bl_tree),--Se!=0;);else Ce!==0?(Ce!==Ae&&(ie(oe,Ce,oe.bl_tree),Se--),ie(oe,k,oe.bl_tree),Z(oe,Se-3,2)):Se<=10?(ie(oe,N,oe.bl_tree),Z(oe,Se-3,3)):(ie(oe,_,oe.bl_tree),Z(oe,Se-11,7));Ae=Ce,je=(Se=0)===Ue?(ve=138,3):Ce===Ue?(ve=6,3):(ve=7,4)}}l(D);var he=!1;function le(oe,Q,de,Ne){Z(oe,(u<<1)+(Ne?1:0),3),function(Ce,Ae,Ue,Se){ne(Ce),q(Ce,Ue),q(Ce,~Ue),s.arraySet(Ce.pending_buf,Ce.window,Ae,Ue,Ce.pending),Ce.pending+=Ue}(oe,Q,de)}i._tr_init=function(oe){he||(function(){var Q,de,Ne,Ce,Ae,Ue=new Array(w+1);for(Ce=Ne=0;Ce<d-1;Ce++)for(R[Ce]=Ne,Q=0;Q<1<<j[Ce];Q++)I[Ne++]=Ce;for(I[Ne-1]=Ce,Ce=Ae=0;Ce<16;Ce++)for(D[Ce]=Ae,Q=0;Q<1<<T[Ce];Q++)F[Ae++]=Ce;for(Ae>>=7;Ce<m;Ce++)for(D[Ce]=Ae<<7,Q=0;Q<1<<T[Ce]-7;Q++)F[256+Ae++]=Ce;for(de=0;de<=w;de++)Ue[de]=0;for(Q=0;Q<=143;)H[2*Q+1]=8,Q++,Ue[8]++;for(;Q<=255;)H[2*Q+1]=9,Q++,Ue[9]++;for(;Q<=279;)H[2*Q+1]=7,Q++,Ue[7]++;for(;Q<=287;)H[2*Q+1]=8,Q++,Ue[8]++;for(re(H,h+1,Ue),Q=0;Q<m;Q++)P[2*Q+1]=5,P[2*Q]=ge(Q,5);U=new B(H,j,f+1,h,w),A=new B(P,T,0,m,w),W=new B(new Array(0),M,0,y,S)}(),he=!0),oe.l_desc=new L(oe.dyn_ltree,U),oe.d_desc=new L(oe.dyn_dtree,A),oe.bl_desc=new L(oe.bl_tree,W),oe.bi_buf=0,oe.bi_valid=0,Y(oe)},i._tr_stored_block=le,i._tr_flush_block=function(oe,Q,de,Ne){var Ce,Ae,Ue=0;0<oe.level?(oe.strm.data_type===2&&(oe.strm.data_type=function(Se){var ve,je=4093624447;for(ve=0;ve<=31;ve++,je>>>=1)if(1&je&&Se.dyn_ltree[2*ve]!==0)return o;if(Se.dyn_ltree[18]!==0||Se.dyn_ltree[20]!==0||Se.dyn_ltree[26]!==0)return a;for(ve=32;ve<f;ve++)if(Se.dyn_ltree[2*ve]!==0)return a;return o}(oe)),fe(oe,oe.l_desc),fe(oe,oe.d_desc),Ue=function(Se){var ve;for(O(Se,Se.dyn_ltree,Se.l_desc.max_code),O(Se,Se.dyn_dtree,Se.d_desc.max_code),fe(Se,Se.bl_desc),ve=y-1;3<=ve&&Se.bl_tree[2*V[ve]+1]===0;ve--);return Se.opt_len+=3*(ve+1)+5+5+4,ve}(oe),Ce=oe.opt_len+3+7>>>3,(Ae=oe.static_len+3+7>>>3)<=Ce&&(Ce=Ae)):Ce=Ae=de+5,de+4<=Ce&&Q!==-1?le(oe,Q,de,Ne):oe.strategy===4||Ae===Ce?(Z(oe,2+(Ne?1:0),3),te(oe,H,P)):(Z(oe,4+(Ne?1:0),3),function(Se,ve,je,Te){var ce;for(Z(Se,ve-257,5),Z(Se,je-1,5),Z(Se,Te-4,4),ce=0;ce<Te;ce++)Z(Se,Se.bl_tree[2*V[ce]+1],3);pe(Se,Se.dyn_ltree,ve-1),pe(Se,Se.dyn_dtree,je-1)}(oe,oe.l_desc.max_code+1,oe.d_desc.max_code+1,Ue+1),te(oe,oe.dyn_ltree,oe.dyn_dtree)),Y(oe),Ne&&ne(oe)},i._tr_tally=function(oe,Q,de){return oe.pending_buf[oe.d_buf+2*oe.last_lit]=Q>>>8&255,oe.pending_buf[oe.d_buf+2*oe.last_lit+1]=255&Q,oe.pending_buf[oe.l_buf+oe.last_lit]=255&de,oe.last_lit++,Q===0?oe.dyn_ltree[2*de]++:(oe.matches++,Q--,oe.dyn_ltree[2*(I[de]+f+1)]++,oe.dyn_dtree[2*$(Q)]++),oe.last_lit===oe.lit_bufsize-1},i._tr_align=function(oe){Z(oe,2,3),ie(oe,C,H),function(Q){Q.bi_valid===16?(q(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0):8<=Q.bi_valid&&(Q.pending_buf[Q.pending++]=255&Q.bi_buf,Q.bi_buf>>=8,Q.bi_valid-=8)}(oe)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(o,a){if(!o.setImmediate){var l,u,d,f,h=1,m={},y=!1,g=o.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(o);w=w&&w.setTimeout?w:o,l={}.toString.call(o.process)==="[object process]"?function(k){process.nextTick(function(){S(k)})}:function(){if(o.postMessage&&!o.importScripts){var k=!0,N=o.onmessage;return o.onmessage=function(){k=!1},o.postMessage("","*"),o.onmessage=N,k}}()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",C,!1):o.attachEvent("onmessage",C),function(k){o.postMessage(f+k,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(k){S(k.data)},function(k){d.port2.postMessage(k)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(k){var N=g.createElement("script");N.onreadystatechange=function(){S(k),N.onreadystatechange=null,u.removeChild(N),N=null},u.appendChild(N)}):function(k){setTimeout(S,0,k)},w.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var N=new Array(arguments.length-1),_=0;_<N.length;_++)N[_]=arguments[_+1];var j={callback:k,args:N};return m[h]=j,l(h),h++},w.clearImmediate=v}function v(k){delete m[k]}function S(k){if(y)setTimeout(S,0,k);else{var N=m[k];if(N){y=!0;try{(function(_){var j=_.callback,T=_.args;switch(T.length){case 0:j();break;case 1:j(T[0]);break;case 2:j(T[0],T[1]);break;case 3:j(T[0],T[1],T[2]);break;default:j.apply(a,T)}})(N)}finally{v(k),y=!1}}}}
805function C(k){k.source===o&&typeof k.data=="string"&&k.data.indexOf(f)===0&&S(+k.data.slice(f.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof jc<"u"?jc:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}($k)),$k.exports}var rhe=nhe();const AL=Vo(rhe);var mu={},Nb={},Uk,XA;function ihe(){if(XA)return Uk;XA=1;function t(i){var s=new r(i),o=s.readChunk();if(o.id!="MThd")throw"Bad MIDI file. Expected 'MHdr', got: '"+o.id+"'";for(var a=e(o.data),l=[],u=0;!s.eof()&&u<a.numTracks;u++){var d=s.readChunk();if(d.id!="MTrk")throw"Bad MIDI file. Expected 'MTrk', got: '"+d.id+"'";var f=n(d.data);l.push(f)}return{header:a,tracks:l}}function e(i){var s=new r(i),o=s.readUInt16(),a=s.readUInt16(),l={format:o,numTracks:a},u=s.readUInt16();return u&32768?(l.framesPerSecond=256-(u>>8),l.ticksPerFrame=u&255):l.ticksPerBeat=u,l}function n(i){for(var s=new r(i),o=[];!s.eof();){var a=u();o.push(a)}return o;var l;function u(){var d={};d.deltaTime=s.readVarInt();var f=s.readUInt8();if((f&240)===240)if(f===255){d.meta=!0;var h=s.readUInt8(),m=s.readVarInt();switch(h){case 0:if(d.type="sequenceNumber",m!==2)throw"Expected length for sequenceNumber event is 2, got "+m;return d.number=s.readUInt16(),d;case 1:return d.type="text",d.text=s.readString(m),d;case 2:return d.type="copyrightNotice",d.text=s.readString(m),d;case 3:return d.type="trackName",d.text=s.readString(m),d;case 4:return d.type="instrumentName",d.text=s.readString(m),d;case 5:return d.type="lyrics",d.text=s.readString(m),d;case 6:return d.type="marker",d.text=s.readString(m),d;case 7:return d.type="cuePoint",d.text=s.readString(m),d;case 32:if(d.type="channelPrefix",m!=1)throw"Expected length for channelPrefix event is 1, got "+m;return d.channel=s.readUInt8(),d;case 33:if(d.type="portPrefix",m!=1)throw"Expected length for portPrefix event is 1, got "+m;return d.port=s.readUInt8(),d;case 47:if(d.type="endOfTrack",m!=0)throw"Expected length for endOfTrack event is 0, got "+m;return d;case 81:if(d.type="setTempo",m!=3)throw"Expected length for setTempo event is 3, got "+m;return d.microsecondsPerBeat=s.readUInt24(),d;case 84:if(d.type="smpteOffset",m!=5)throw"Expected length for smpteOffset event is 5, got "+m;var y=s.readUInt8(),g={0:24,32:25,64:29,96:30};return d.frameRate=g[y&96],d.hour=y&31,d.min=s.readUInt8(),d.sec=s.readUInt8(),d.frame=s.readUInt8(),d.subFrame=s.readUInt8(),d;case 88:if(d.type="timeSignature",m!=2&&m!=4)throw"Expected length for timeSignature event is 4 or 2, got "+m;return d.numerator=s.readUInt8(),d.denominator=1<<s.readUInt8(),m===4?(d.metronome=s.readUInt8(),d.thirtyseconds=s.readUInt8()):(d.metronome=36,d.thirtyseconds=8),d;case 89:if(d.type="keySignature",m!=2)throw"Expected length for keySignature event is 2, got "+m;return d.key=s.readInt8(),d.scale=s.readUInt8(),d;case 127:return d.type="sequencerSpecific",d.data=s.readBytes(m),d;default:return d.type="unknownMeta",d.data=s.readBytes(m),d.metatypeByte=h,d}}else if(f==240){d.type="sysEx";var m=s.readVarInt();return d.data=s.readBytes(m),d}else if(f==247){d.type="endSysEx";var m=s.readVarInt();return d.data=s.readBytes(m),d}else throw"Unrecognised MIDI event type byte: "+f;else{var w;if((f&128)===0){if(l===null)throw"Running status byte encountered before status byte";w=f,f=l,d.running=!0}else w=s.readUInt8(),l=f;var v=f>>4;switch(d.channel=f&15,v){case 8:return d.type="noteOff",d.noteNumber=w,d.velocity=s.readUInt8(),d;case 9:var S=s.readUInt8();return d.type=S===0?"noteOff":"noteOn",d.noteNumber=w,d.velocity=S,S===0&&(d.byte9=!0),d;case 10:return d.type="noteAftertouch",d.noteNumber=w,d.amount=s.readUInt8(),d;case 11:return d.type="controller",d.controllerType=w,d.value=s.readUInt8(),d;case 12:return d.type="programChange",d.programNumber=w,d;case 13:return d.type="channelAftertouch",d.amount=w,d;case 14:return d.type="pitchBend",d.value=w+(s.readUInt8()<<7)-8192,d;default:throw"Unrecognised MIDI event type: "+v}}}}function r(i){this.buffer=i,this.bufferLen=this.buffer.length,this.pos=0}return r.prototype.eof=function(){return this.pos>=this.bufferLen},r.prototype.readUInt8=function(){var i=this.buffer[this.pos];return this.pos+=1,i},r.prototype.readInt8=function(){var i=this.readUInt8();return i&128?i-256:i},r.prototype.readUInt16=function(){var i=this.readUInt8(),s=this.readUInt8();return(i<<8)+s},r.prototype.readInt16=function(){var i=this.readUInt16();return i&32768?i-65536:i},r.prototype.readUInt24=function(){var i=this.readUInt8(),s=this.readUInt8(),o=this.readUInt8();return(i<<16)+(s<<8)+o},r.prototype.readInt24=function(){var i=this.readUInt24();return i&8388608?i-16777216:i},r.prototype.readUInt32=function(){var i=this.readUInt8(),s=this.readUInt8(),o=this.readUInt8(),a=this.readUInt8();return(i<<24)+(s<<16)+(o<<8)+a},r.prototype.readBytes=function(i){var s=this.buffer.slice(this.pos,this.pos+i);return this.pos+=i,s},r.prototype.readString=function(i){var s=this.readBytes(i);return String.fromCharCode.apply(null,s)},r.prototype.readVarInt=function(){for(var i=0;!this.eof();){var s=this.readUInt8();if(s&128)i+=s&127,i<<=7;else return i+s}return i},r.prototype.readChunk=function(){var i=this.readString(4),s=this.readUInt32(),o=this.readBytes(s);return{id:i,length:s,data:o}},Uk=t,Uk}var Vk,QA;
805function she(){if(QA)return Vk;QA=1;function t(s,o){if(typeof s!="object")throw"Invalid MIDI data";o=o||{};var a=s.header||{},l=s.tracks||[],u,d=l.length,f=new i;for(e(f,a,d),u=0;u<d;u++)n(f,l[u],o);return f.buffer}function e(s,o,a){var l=o.format==null?1:o.format,u=128;o.timeDivision?u=o.timeDivision:o.ticksPerFrame&&o.framesPerSecond?u=-(o.framesPerSecond&255)<<8|o.ticksPerFrame&255:o.ticksPerBeat&&(u=o.ticksPerBeat&32767);var d=new i;d.writeUInt16(l),d.writeUInt16(a),d.writeUInt16(u),s.writeChunk("MThd",d.buffer)}function n(s,o,a){var l=new i,u,d=o.length,f=null;for(u=0;u<d;u++)(a.running===!1||!a.running&&!o[u].running)&&(f=null),f=r(l,o[u],f,a.useByte9ForNoteOff);s.writeChunk("MTrk",l.buffer)}function r(s,o,a,l){var u=o.type,d=o.deltaTime,f=o.text||"",h=o.data||[],m=null;switch(s.writeVarInt(d),u){case"sequenceNumber":s.writeUInt8(255),s.writeUInt8(0),s.writeVarInt(2),s.writeUInt16(o.number);break;case"text":s.writeUInt8(255),s.writeUInt8(1),s.writeVarInt(f.length),s.writeString(f);break;case"copyrightNotice":s.writeUInt8(255),s.writeUInt8(2),s.writeVarInt(f.length),s.writeString(f);break;case"trackName":s.writeUInt8(255),s.writeUInt8(3),s.writeVarInt(f.length),s.writeString(f);break;case"instrumentName":s.writeUInt8(255),s.writeUInt8(4),s.writeVarInt(f.length),s.writeString(f);break;case"lyrics":s.writeUInt8(255),s.writeUInt8(5),s.writeVarInt(f.length),s.writeString(f);break;case"marker":s.writeUInt8(255),s.writeUInt8(6),s.writeVarInt(f.length),s.writeString(f);break;case"cuePoint":s.writeUInt8(255),s.writeUInt8(7),s.writeVarInt(f.length),s.writeString(f);break;case"channelPrefix":s.writeUInt8(255),s.writeUInt8(32),s.writeVarInt(1),s.writeUInt8(o.channel);break;case"portPrefix":s.writeUInt8(255),s.writeUInt8(33),s.writeVarInt(1),s.writeUInt8(o.port);break;case"endOfTrack":s.writeUInt8(255),s.writeUInt8(47),s.writeVarInt(0);break;case"setTempo":s.writeUInt8(255),s.writeUInt8(81),s.writeVarInt(3),s.writeUInt24(o.microsecondsPerBeat);break;case"smpteOffset":s.writeUInt8(255),s.writeUInt8(84),s.writeVarInt(5);var y={24:0,25:32,29:64,30:96},g=o.hour&31|y[o.frameRate];s.writeUInt8(g),s.writeUInt8(o.min),s.writeUInt8(o.sec),s.writeUInt8(o.frame),s.writeUInt8(o.subFrame);break;case"timeSignature":s.writeUInt8(255),s.writeUInt8(88),s.writeVarInt(4),s.writeUInt8(o.numerator);var w=Math.floor(Math.log(o.denominator)/Math.LN2)&255;s.writeUInt8(w),s.writeUInt8(o.metronome),s.writeUInt8(o.thirtyseconds||8);break;case"keySignature":s.writeUInt8(255),s.writeUInt8(89),s.writeVarInt(2),s.writeInt8(o.key),s.writeUInt8(o.scale);break;case"sequencerSpecific":s.writeUInt8(255),s.writeUInt8(127),s.writeVarInt(h.length),s.writeBytes(h);break;case"unknownMeta":o.metatypeByte!=null&&(s.writeUInt8(255),s.writeUInt8(o.metatypeByte),s.writeVarInt(h.length),s.writeBytes(h));break;case"sysEx":s.writeUInt8(240),s.writeVarInt(h.length),s.writeBytes(h);break;case"endSysEx":s.writeUInt8(247),s.writeVarInt(h.length),s.writeBytes(h);break;case"noteOff":var v=l!==!1&&o.byte9||l&&o.velocity==0?144:128;m=v|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.noteNumber),s.writeUInt8(o.velocity);break;case"noteOn":m=144|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.noteNumber),s.writeUInt8(o.velocity);break;case"noteAftertouch":m=160|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.noteNumber),s.writeUInt8(o.amount);break;case"controller":m=176|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.controllerType),s.writeUInt8(o.value);break;case"programChange":m=192|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.programNumber);break;case"channelAftertouch":m=208|o.channel,m!==a&&s.writeUInt8(m),s.writeUInt8(o.amount);break;case"pitchBend":m=224|o.channel,m!==a&&s.writeUInt8(m);var S=8192+o.value,C=S&127,k=S>>7&127;s.writeUInt8(C),s.writeUInt8(k);break;default:throw"Unrecognized event type: "+u}return m}function i(){this.buffer=[]}return i.prototype.writeUInt8=function(s){this.buffer.push(s&255)},i.prototype.writeInt8=i.prototype.writeUInt8,i.prototype.writeUInt16=function(s){var o=s>>8&255,a=s&255;this.writeUInt8(o),this.writeUInt8(a)},i.prototype.writeInt16=i.prototype.writeUInt16,i.prototype.writeUInt24=function(s){var o=s>>16&255,a=s>>8&255,l=s&255;this.writeUInt8(o),this.writeUInt8(a),this.writeUInt8(l)},i.prototype.writeInt24=i.prototype.writeUInt24,i.prototype.writeUInt32=function(s){var o=s>>24&255,a=s>>16&255,l=s>>8&255,u=s&255;this.writeUInt8(o),this.writeUInt8(a),this.writeUInt8(l),this.writeUInt8(u)},i.prototype.writeInt32=i.prototype.writeUInt32,i.prototype.writeBytes=function(s){this.buffer=this.buffer.concat(Array.prototype.slice.call(s,0))},i.prototype.writeString=function(s){var o,a=s.length,l=[];for(o=0;o<a;o++)l.push(s.codePointAt(o));this.writeBytes(l)},i.prototype.writeVarInt=function(s){if(s<0)throw"Cannot write negative variable-length integer";if(s<=127)this.writeUInt8(s);else{var o=s,a=[];for(a.push(o&127),o>>=7;o;){var l=o&127|128;a.push(l),o>>=7}this.writeBytes(a.reverse())}},i.prototype.writeChunk=function(s,o){this.writeString(s),this.writeUInt32(o.length),this.writeBytes(o)},Vk=t,Vk}var ZA;function ML(){return ZA||(ZA=1,Nb.parseMidi=ihe(),Nb.writeMidi=she()),Nb}var Hk={},gu={},JA;function BL(){if(JA)return gu;
805JA=1,Object.defineProperty(gu,"__esModule",{value:!0}),gu.insert=gu.search=void 0;function t(n,r,i){i===void 0&&(i="ticks");var s=0,o=n.length,a=o;if(o>0&&n[o-1][i]<=r)return o-1;for(;s<a;){var l=Math.floor(s+(a-s)/2),u=n[l],d=n[l+1];if(u[i]===r){for(var f=l;f<n.length;f++){var h=n[f];h[i]===r&&(l=f)}return l}else{if(u[i]<r&&d[i]>r)return l;u[i]>r?a=l:u[i]<r&&(s=l+1)}}return-1}gu.search=t;function e(n,r,i){if(i===void 0&&(i="ticks"),n.length){var s=t(n,r[i],i);n.splice(s+1,0,r)}else n.push(r)}return gu.insert=e,gu}var eM;function DC(){return eM||(eM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Header=t.keySignatureKeys=void 0;var e=BL(),n=new WeakMap;t.keySignatureKeys=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"];var r=function(){function i(s){var o=this;if(this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name="",n.set(this,480),s){n.set(this,s.header.ticksPerBeat),s.tracks.forEach(function(l){l.forEach(function(u){u.meta&&(u.type==="timeSignature"?o.timeSignatures.push({ticks:u.absoluteTime,timeSignature:[u.numerator,u.denominator]}):u.type==="setTempo"?o.tempos.push({bpm:6e7/u.microsecondsPerBeat,ticks:u.absoluteTime}):u.type==="keySignature"&&o.keySignatures.push({key:t.keySignatureKeys[u.key+7],scale:u.scale===0?"major":"minor",ticks:u.absoluteTime}))})});var a=0;s.tracks[0].forEach(function(l){a+=l.deltaTime,l.meta&&(l.type==="trackName"?o.name=l.text:(l.type==="text"||l.type==="cuePoint"||l.type==="marker"||l.type==="lyrics")&&o.meta.push({text:l.text,ticks:a,type:l.type}))}),this.update()}}return i.prototype.update=function(){var s=this,o=0,a=0;this.tempos.sort(function(l,u){return l.ticks-u.ticks}),this.tempos.forEach(function(l,u){var d=u>0?s.tempos[u-1].bpm:s.tempos[0].bpm,f=l.ticks/s.ppq-a,h=60/d*f;l.time=h+o,o=l.time,a+=f}),this.timeSignatures.sort(function(l,u){return l.ticks-u.ticks}),this.timeSignatures.forEach(function(l,u){var d=u>0?s.timeSignatures[u-1]:s.timeSignatures[0],f=(l.ticks-d.ticks)/s.ppq,h=f/d.timeSignature[0]/(d.timeSignature[1]/4);d.measures=d.measures||0,l.measures=h+d.measures})},i.prototype.ticksToSeconds=function(s){var o=(0,e.search)(this.tempos,s);if(o!==-1){var a=this.tempos[o],l=a.time,u=(s-a.ticks)/this.ppq;return l+60/a.bpm*u}else{var d=s/this.ppq;return 60/120*d}},i.prototype.ticksToMeasures=function(s){var o=(0,e.search)(this.timeSignatures,s);if(o!==-1){var a=this.timeSignatures[o],l=(s-a.ticks)/this.ppq;return a.measures+l/(a.timeSignature[0]/a.timeSignature[1])/4}else return s/this.ppq/4},Object.defineProperty(i.prototype,"ppq",{get:function(){return n.get(this)},enumerable:!1,configurable:!0}),i.prototype.secondsToTicks=function(s){var o=(0,e.search)(this.tempos,s,"time");if(o!==-1){var a=this.tempos[o],l=a.time,u=s-l,d=u/(60/a.bpm);return Math.round(a.ticks+d*this.ppq)}else{var f=s/.5;return Math.round(f*this.ppq)}},i.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map(function(s){return{bpm:s.bpm,ticks:s.ticks}}),timeSignatures:this.timeSignatures}},i.prototype.fromJSON=function(s){this.name=s.name,this.tempos=s.tempos.map(function(o){return Object.assign({},o)}),this.timeSignatures=s.timeSignatures.map(function(o){return Object.assign({},o)}),this.keySignatures=s.keySignatures.map(function(o){return Object.assign({},o)}),this.meta=s.meta.map(function(o){return Object.assign({},o)}),n.set(this,s.ppq),this.update()},i.prototype.setTempo=function(s){this.tempos=[{bpm:s,ticks:0}],this.update()},i}();t.Header=r}(Hk)),Hk}var Lp={},Gk={},tM;function RL(){return tM||(tM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ControlChange=t.controlChangeIds=t.controlChangeNames=void 0,t.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"},t.controlChangeIds=Object.keys(t.controlChangeNames).reduce(function(i,s){return i[t.controlChangeNames[s]]=s,i},{});var e=new WeakMap,n=new WeakMap,r=function(){function i(s,o){e.set(this,o),n.set(this,s.controllerType),this.ticks=s.absoluteTime,this.value=s.value}return Object.defineProperty(i.prototype,"number",{get:function(){return n.get(this)}
805,enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return t.controlChangeNames[this.number]?t.controlChangeNames[this.number]:null},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"time",{get:function(){var s=e.get(this);return s.ticksToSeconds(this.ticks)},set:function(s){var o=e.get(this);this.ticks=o.secondsToTicks(s)},enumerable:!1,configurable:!0}),i.prototype.toJSON=function(){return{number:this.number,ticks:this.ticks,time:this.time,value:this.value}},i}();t.ControlChange=r}(Gk)),Gk}var Fp={},nM;function ohe(){if(nM)return Fp;nM=1,Object.defineProperty(Fp,"__esModule",{value:!0}),Fp.createControlChanges=void 0;var t=RL();function e(){return new Proxy({},{get:function(n,r){if(n[r])return n[r];if(t.controlChangeIds.hasOwnProperty(r))return n[t.controlChangeIds[r]]},set:function(n,r,i){return t.controlChangeIds.hasOwnProperty(r)?n[t.controlChangeIds[r]]=i:n[r]=i,!0}})}return Fp.createControlChanges=e,Fp}var $p={},rM;function ahe(){if(rM)return $p;rM=1,Object.defineProperty($p,"__esModule",{value:!0}),$p.PitchBend=void 0;var t=new WeakMap,e=function(){function n(r,i){t.set(this,i),this.ticks=r.absoluteTime,this.value=r.value}return Object.defineProperty(n.prototype,"time",{get:function(){var r=t.get(this);return r.ticksToSeconds(this.ticks)},set:function(r){var i=t.get(this);this.ticks=i.secondsToTicks(r)},enumerable:!1,configurable:!0}),n.prototype.toJSON=function(){return{ticks:this.ticks,time:this.time,value:this.value}},n}();return $p.PitchBend=e,$p}var Up={},xl={},iM;function lhe(){return iM||(iM=1,Object.defineProperty(xl,"__esModule",{value:!0}),xl.DrumKitByPatchID=xl.InstrumentFamilyByID=xl.instrumentByPatchID=void 0,xl.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"],xl.InstrumentFamilyByID=["piano","chromatic percussion","organ","guitar","bass","strings","ensemble","brass","reed","pipe","synth lead","synth pad","synth effects","world","percussive","sound effects"],xl.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"}),xl}var sM;function che(){if(sM)return Up;sM=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.Instrument=void 0;
805var t=lhe(),e=new WeakMap,n=function(){function r(i,s){if(this.number=0,e.set(this,s),this.number=0,i){var o=i.find(function(a){return a.type==="programChange"});o&&(this.number=o.programNumber)}}return Object.defineProperty(r.prototype,"name",{get:function(){return this.percussion?t.DrumKitByPatchID[this.number]:t.instrumentByPatchID[this.number]},set:function(i){var s=t.instrumentByPatchID.indexOf(i);s!==-1&&(this.number=s)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"family",{get:function(){return this.percussion?"drums":t.InstrumentFamilyByID[Math.floor(this.number/8)]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"percussion",{get:function(){var i=e.get(this);return i.channel===9},enumerable:!1,configurable:!0}),r.prototype.toJSON=function(){return{family:this.family,number:this.number,name:this.name}},r.prototype.fromJSON=function(i){this.number=i.number},r}();return Up.Instrument=n,Up}var Vp={},oM;function uhe(){if(oM)return Vp;oM=1,Object.defineProperty(Vp,"__esModule",{value:!0}),Vp.Note=void 0;function t(o){var a=Math.floor(o/12)-1;return e(o)+a.toString()}function e(o){var a=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],l=o%12;return a[l]}function n(o){var a=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];return a.indexOf(o)}var r=function(){var o=/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,a={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(l){var u=o.exec(l),d=u[1],f=u[2],h=a[d.toLowerCase()];return h+(parseInt(f,10)+1)*12}}(),i=new WeakMap,s=function(){function o(a,l,u){i.set(this,u),this.midi=a.midi,this.velocity=a.velocity,this.noteOffVelocity=l.velocity,this.ticks=a.ticks,this.durationTicks=l.ticks-a.ticks}return Object.defineProperty(o.prototype,"name",{get:function(){return t(this.midi)},set:function(a){this.midi=r(a)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"octave",{get:function(){return Math.floor(this.midi/12)-1},set:function(a){var l=a-this.octave;this.midi+=l*12},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"pitch",{get:function(){return e(this.midi)},set:function(a){this.midi=12*(this.octave+1)+n(a)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"duration",{get:function(){var a=i.get(this);return a.ticksToSeconds(this.ticks+this.durationTicks)-a.ticksToSeconds(this.ticks)},set:function(a){var l=i.get(this),u=l.secondsToTicks(this.time+a);this.durationTicks=u-this.ticks},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"time",{get:function(){var a=i.get(this);return a.ticksToSeconds(this.ticks)},set:function(a){var l=i.get(this);this.ticks=l.secondsToTicks(a)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"bars",{get:function(){var a=i.get(this);return a.ticksToMeasures(this.ticks)},enumerable:!1,configurable:!0}),o.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}},o}();return Vp.Note=s,Vp}var aM;function lM(){if(aM)return Lp;aM=1,Object.defineProperty(Lp,"__esModule",{value:!0}),Lp.Track=void 0;var t=BL(),e=RL(),n=ohe(),r=ahe(),i=che(),s=uhe(),o=new WeakMap,a=function(){function l(u,d){var f=this;if(this.name="",this.notes=[],this.controlChanges=(0,n.createControlChanges)(),this.pitchBends=[],o.set(this,d),u){var h=u.find(function(k){return k.type==="trackName"});this.name=h?h.text:""}if(this.instrument=new i.Instrument(u,this),this.channel=0,u){for(var m=u.filter(function(k){return k.type==="noteOn"}),y=u.filter(function(k){return k.type==="noteOff"}),g=function(){var k=m.shift();w.channel=k.channel;var N=y.findIndex(function(j){return j.noteNumber===k.noteNumber&&j.absoluteTime>=k.absoluteTime});if(N!==-1){var _=y.splice(N,1)[0];w.addNote({durationTicks:_.absoluteTime-k.absoluteTime,midi:k.noteNumber,noteOffVelocity:_.velocity/127,ticks:k.absoluteTime,velocity:k.velocity/127})}},w=this;m.length;)g();var v=u.filter(function(k){return k.type==="controller"});v.forEach(function(k){f.addCC({number:k.controllerType,ticks:k.absoluteTime,value:k.value/127})});var S=u.filter(function(k){return k.type==="pitchBend"});
805S.forEach(function(k){f.addPitchBend({ticks:k.absoluteTime,value:k.value/Math.pow(2,13)})});var C=u.find(function(k){return k.type==="endOfTrack"});this.endOfTrackTicks=C!==void 0?C.absoluteTime:void 0}}return l.prototype.addNote=function(u){var d=o.get(this),f=new s.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},d);return Object.assign(f,u),(0,t.insert)(this.notes,f,"ticks"),this},l.prototype.addCC=function(u){var d=o.get(this),f=new e.ControlChange({controllerType:u.number},d);return delete u.number,Object.assign(f,u),Array.isArray(this.controlChanges[f.number])||(this.controlChanges[f.number]=[]),(0,t.insert)(this.controlChanges[f.number],f,"ticks"),this},l.prototype.addPitchBend=function(u){var d=o.get(this),f=new r.PitchBend({},d);return Object.assign(f,u),(0,t.insert)(this.pitchBends,f,"ticks"),this},Object.defineProperty(l.prototype,"duration",{get:function(){if(!this.notes.length)return 0;for(var u=this.notes[this.notes.length-1].time+this.notes[this.notes.length-1].duration,d=0;d<this.notes.length-1;d++){var f=this.notes[d].time+this.notes[d].duration;u<f&&(u=f)}return u},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"durationTicks",{get:function(){if(!this.notes.length)return 0;for(var u=this.notes[this.notes.length-1].ticks+this.notes[this.notes.length-1].durationTicks,d=0;d<this.notes.length-1;d++){var f=this.notes[d].ticks+this.notes[d].durationTicks;u<f&&(u=f)}return u},enumerable:!1,configurable:!0}),l.prototype.fromJSON=function(u){var d=this;this.name=u.name,this.channel=u.channel,this.instrument=new i.Instrument(void 0,this),this.instrument.fromJSON(u.instrument),u.endOfTrackTicks!==void 0&&(this.endOfTrackTicks=u.endOfTrackTicks);for(var f in u.controlChanges)u.controlChanges[f]&&u.controlChanges[f].forEach(function(h){d.addCC({number:h.number,ticks:h.ticks,value:h.value})});u.notes.forEach(function(h){d.addNote({durationTicks:h.durationTicks,midi:h.midi,ticks:h.ticks,velocity:h.velocity})})},l.prototype.toJSON=function(){for(var u={},d=0;d<127;d++)this.controlChanges.hasOwnProperty(d)&&(u[d]=this.controlChanges[d].map(function(h){return h.toJSON()}));var f={channel:this.channel,controlChanges:u,pitchBends:this.pitchBends.map(function(h){return h.toJSON()}),instrument:this.instrument.toJSON(),name:this.name,notes:this.notes.map(function(h){return h.toJSON()})};return this.endOfTrackTicks!==void 0&&(f.endOfTrackTicks=this.endOfTrackTicks),f},l}();return Lp.Track=a,Lp}var bu={};function dhe(t){var e=[];return OL(t,e),e}function OL(t,e){for(var n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?OL(r,e):e.push(r)}}const fhe=Object.freeze(Object.defineProperty({__proto__:null,flatten:dhe},Symbol.toStringTag,{value:"Module"})),hhe=Y4(fhe);var cM;function phe(){if(cM)return bu;cM=1;var t=bu&&bu.__spreadArray||function(v,S,C){if(C||arguments.length===2)for(var k=0,N=S.length,_;k<N;k++)(_||!(k in S))&&(_||(_=Array.prototype.slice.call(S,0,k)),_[k]=S[k]);return v.concat(_||Array.prototype.slice.call(S))};Object.defineProperty(bu,"__esModule",{value:!0}),bu.encode=void 0;var e=ML(),n=DC(),r=hhe;function i(v,S){return[{absoluteTime:v.ticks,channel:S,deltaTime:0,noteNumber:v.midi,type:"noteOn",velocity:Math.floor(v.velocity*127)},{absoluteTime:v.ticks+v.durationTicks,channel:S,deltaTime:0,noteNumber:v.midi,type:"noteOff",velocity:Math.floor(v.noteOffVelocity*127)}]}function s(v){return(0,r.flatten)(v.notes.map(function(S){return i(S,v.channel)}))}function o(v,S){return{absoluteTime:v.ticks,channel:S,controllerType:v.number,deltaTime:0,type:"controller",value:Math.floor(v.value*127)}}function a(v){for(var S=[],C=0;C<127;C++)v.controlChanges.hasOwnProperty(C)&&v.controlChanges[C].forEach(function(k){S.push(o(k,v.channel))});return S}function l(v,S){return{absoluteTime:v.ticks,channel:S,deltaTime:0,type:"pitchBend",value:v.value}}function u(v){var S=[];return v.pitchBends.forEach(function(C){S.push(l(C,v.channel))}),S}function d(v){return{absoluteTime:0,channel:v.channel,deltaTime:0,programNumber:v.instrument.number,type:"programChange"}}function f(v){return{absoluteTime:0,deltaTime:0,meta:!0,text:v,type:"trackName"}}function h(v){return{absoluteTime:v.ticks,deltaTime:0,meta:!0,microsecondsPerBeat:Math.floor(6e7/v.bpm),type:"setTempo"}}function m(v){return{absoluteTime:v.ticks,deltaTime:0,denominator:v.timeSignature[1],meta:!0,metronome:24,numerator:v.timeSignature[0],thirtyseconds:8,type:"timeSignature"}}function y(v){var S=n.keySignatureKeys.indexOf(v.key);return{absoluteTime:v.ticks,deltaTime:0,key:S+7,meta:!0,scale:v.scale==="major"?0:1,type:"keySignature"}}function g(v){return{absoluteTime:v.ticks,deltaTime:0,meta:!0,text:v.text,type:v.type}}function w(v){var S={header:{format:1,numTracks:v.tracks.length+1,ticksPerBeat:v.header.ppq},tracks:t([t(t(t(t([{absoluteTime:0,deltaTime:0,meta:!0,text:v.header.n
805ame,type:"trackName"}],v.header.keySignatures.map(function(C){return y(C)}),!0),v.header.meta.map(function(C){return g(C)}),!0),v.header.tempos.map(function(C){return h(C)}),!0),v.header.timeSignatures.map(function(C){return m(C)}),!0)],v.tracks.map(function(C){return t(t(t([f(C.name),d(C)],s(C),!0),a(C),!0),u(C),!0)}),!0)};return S.tracks=S.tracks.map(function(C){C=C.sort(function(N,_){return N.absoluteTime-_.absoluteTime});var k=0;return C.forEach(function(N){N.deltaTime=N.absoluteTime-k,k=N.absoluteTime,delete N.absoluteTime}),C.push({deltaTime:0,meta:!0,type:"endOfTrack"}),C}),new Uint8Array((0,e.writeMidi)(S))}return bu.encode=w,bu}var uM;function mhe(){return uM||(uM=1,function(t){var e=mu&&mu.__awaiter||function(f,h,m,y){function g(w){return w instanceof m?w:new m(function(v){v(w)})}return new(m||(m=Promise))(function(w,v){function S(N){try{k(y.next(N))}catch(_){v(_)}}function C(N){try{k(y.throw(N))}catch(_){v(_)}}function k(N){N.done?w(N.value):g(N.value).then(S,C)}k((y=y.apply(f,h||[])).next())})},n=mu&&mu.__generator||function(f,h){var m={label:0,sent:function(){if(w[0]&1)throw w[1];return w[1]},trys:[],ops:[]},y,g,w,v;return v={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function S(k){return function(N){return C([k,N])}}function C(k){if(y)throw new TypeError("Generator is already executing.");for(;m;)try{if(y=1,g&&(w=k[0]&2?g.return:k[0]?g.throw||((w=g.return)&&w.call(g),0):g.next)&&!(w=w.call(g,k[1])).done)return w;switch(g=0,w&&(k=[k[0]&2,w.value]),k[0]){case 0:case 1:w=k;break;case 4:return m.label++,{value:k[1],done:!1};case 5:m.label++,g=k[1],k=[0];continue;case 7:k=m.ops.pop(),m.trys.pop();continue;default:if(w=m.trys,!(w=w.length>0&&w[w.length-1])&&(k[0]===6||k[0]===2)){m=0;continue}if(k[0]===3&&(!w||k[1]>w[0]&&k[1]<w[3])){m.label=k[1];break}if(k[0]===6&&m.label<w[1]){m.label=w[1],w=k;break}if(w&&m.label<w[2]){m.label=w[2],m.ops.push(k);break}w[2]&&m.ops.pop(),m.trys.pop();continue}k=h.call(f,m)}catch(N){k=[6,N],g=0}finally{y=w=0}if(k[0]&5)throw k[1];return{value:k[0]?k[1]:void 0,done:!0}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Header=t.Track=t.Midi=void 0;var r=ML(),i=DC(),s=lM(),o=phe(),a=function(){function f(h){var m=this,y=null;if(h){var g=h instanceof ArrayBuffer?new Uint8Array(h):h;y=(0,r.parseMidi)(g),y.tracks.forEach(function(w){var v=0;w.forEach(function(S){v+=S.deltaTime,S.absoluteTime=v})}),y.tracks=d(y.tracks)}this.header=new i.Header(y),this.tracks=[],h&&(this.tracks=y.tracks.map(function(w){return new s.Track(w,m.header)}),y.header.format===1&&this.tracks[0].duration===0&&this.tracks.shift())}return f.fromUrl=function(h){return e(this,void 0,void 0,function(){var m,y;return n(this,function(g){switch(g.label){case 0:return[4,fetch(h)];case 1:return m=g.sent(),m.ok?[4,m.arrayBuffer()]:[3,3];case 2:return y=g.sent(),[2,new f(y)];case 3:throw new Error("Could not load '".concat(h,"'"))}})})},Object.defineProperty(f.prototype,"name",{get:function(){return this.header.name},set:function(h){this.header.name=h},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"duration",{get:function(){var h=this.tracks.map(function(m){return m.duration});return Math.max.apply(Math,h)},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"durationTicks",{get:function(){var h=this.tracks.map(function(m){return m.durationTicks});return Math.max.apply(Math,h)},enumerable:!1,configurable:!0}),f.prototype.addTrack=function(){var h=new s.Track(void 0,this.header);return this.tracks.push(h),h},f.prototype.toArray=function(){return(0,o.encode)(this)},f.prototype.toJSON=function(){return{header:this.header.toJSON(),tracks:this.tracks.map(function(h){return h.toJSON()})}},f.prototype.fromJSON=function(h){var m=this;this.header=new i.Header,this.header.fromJSON(h.header),this.tracks=h.tracks.map(function(y){var g=new s.Track(void 0,m.header);return g.fromJSON(y),g})},f.prototype.clone=function(){var h=new f;return h.fromJSON(this.toJSON()),h},f}();t.Midi=a;var l=lM();Object.defineProperty(t,"Track",{enumerable:!0,get:function(){return l.Track}});var u=DC();Object.defineProperty(t,"Header",{enumerable:!0,get:function(){return u.Header}});function d(f){for(var h=[],m=0;m<f.length;m++)for(var y=h.length,g=new Map,w=Array(16).fill(0),v=0,S=f[m];v<S.length;v++){var C=S[v],k=y,N=C.channel;if(N!==void 0){C.type==="programChange"&&(w[N]=C.programNumber);var _=w[N],j="".concat(_," ").concat(N);g.has(j)?k=g.get(j):(k=y+g.size,g.set(j,k))}h[k]||h.push([]),h[k].push(C)}return h}}(mu)),mu}var wv=mhe();const Ib=t=>t.replace(/[\\/:*?"<>|]/g,"").trim()||"untitled",DL=t=>{const e=t.length,n=t[0].length,r=t[0].length,i=44,s=r*e*2,o=i+s,a=new ArrayBuffer(o),l=new DataView(a),u=(f,h)=>{for(let m=0;m<h.length;m++)l.setUint8(f+m,h.charCodeAt(m))};u(0,"RIFF"),l.setUint32(4,o-8,!0),u(8,"WAVE"),u(12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,e,!0),l.setUint32(24,n,!0),l.setUint32(28,n*e*2,!0),l.setUint16(32,e*2,!0),l.setUint16(34,16,!0),u(36,"data"),l.setUint32(40,s,!0);let d=i;for(let f=0;f<r;f++)for(let h=0;h<e;h++){const m=Math.max(-1,Math.min(1,t[h][f]));l.setInt16(d,m*32767,!0),d+=2}return new Blob([a],{type:"audio/wav"})},kv=t=>
805{if(!t)return 0;const e=t.toLowerCase();if(ci(t)===$r.BuiltInDrumMachine||e.includes("drum")||e.includes("kit")||e.includes("percussion"))return-1;if(e.includes("piano")||e.includes("grand"))return 0;if(e.includes("bright piano"))return 1;if(e.includes("electric piano")||e.includes("rhodes"))return 4;if(e.includes("harpsichord"))return 6;if(e.includes("clavinet")||e.includes("clav"))return 7;if(e.includes("celesta"))return 8;if(e.includes("glockenspiel"))return 9;if(e.includes("music box"))return 10;if(e.includes("vibraphone"))return 11;if(e.includes("marimba"))return 12;if(e.includes("xylophone"))return 13;if(e.includes("tubular bell"))return 14;if(e.includes("dulcimer"))return 15;if(e.includes("organ"))return 19;if(e.includes("guitar")&&e.includes("nylon"))return 24;if(e.includes("guitar")&&e.includes("steel"))return 25;if(e.includes("guitar")&&e.includes("jazz"))return 26;if(e.includes("guitar")&&e.includes("clean"))return 27;if(e.includes("guitar")&&e.includes("muted"))return 28;if(e.includes("guitar")&&(e.includes("overdriven")||e.includes("distort")))return 29;if(e.includes("guitar")&&e.includes("harmonic"))return 31;if(e.includes("guitar"))return 24;if(e.includes("bass")&&e.includes("acoustic"))return 32;if(e.includes("bass")&&e.includes("finger"))return 33;if(e.includes("bass")&&e.includes("pick"))return 34;if(e.includes("bass")&&e.includes("fretless"))return 35;if(e.includes("bass")&&e.includes("slap"))return 36;if(e.includes("bass")&&e.includes("synth"))return 38;if(e.includes("bass"))return 33;if(e.includes("violin"))return 40;if(e.includes("viola"))return 41;if(e.includes("cello"))return 42;if(e.includes("contrabass")||e.includes("double bass"))return 43;if(e.includes("strings")||e.includes("orchestra")||e.includes("string"))return 48;if(e.includes("choir")||e.includes("voice"))return 52;if(e.includes("trumpet"))return 56;if(e.includes("trombone"))return 57;if(e.includes("tuba"))return 58;if(e.includes("brass")&&e.includes("muted"))return 59;if(e.includes("brass"))return 61;if(e.includes("sax")&&e.includes("soprano"))return 64;if(e.includes("sax")&&e.includes("alto"))return 65;if(e.includes("sax")&&e.includes("tenor"))return 66;if(e.includes("sax")&&e.includes("bari"))return 67;if(e.includes("sax"))return 66;if(e.includes("oboe"))return 68;if(e.includes("english horn"))return 69;if(e.includes("bassoon"))return 70;if(e.includes("clarinet"))return 71;if(e.includes("flute"))return 73;if(e.includes("lead")||e.includes("synth"))return 80;if(e.includes("pad"))return 88;const n=Bc==null?void 0:Bc(t);if(n)switch(n){case"piano":return 0;case"chromatic percussion":return 12;case"organ":return 19;case"guitar":return 24;case"bass":return 33;case"strings":return 48;case"ensemble":return 52;case"brass":return 61;case"reed":return 67;case"pipe":return 73;case"synth lead":return 80;case"synth pad":return 88;case"synth effects":return 96;case"ethnic":return 104;case"percussive":return-1;case"sound effects":return 120}return 0},LL=(t,e)=>{t.header.tempos.push({bpm:e.bpm,ticks:0}),t.header.timeSignatures.push({timeSignature:[e.timeSignature.beatsPerBar,e.timeSignature.beatDuration],ticks:0})},FL=t=>{const e=t.toArray(),n=new ArrayBuffer(e.length);return new Uint8Array(n).set(e),new Blob([n],{type:"audio/midi"})},$L=(t,e,n)=>{const r=new wv.Midi,i=r.header.ppq;LL(r,e);const s=r.addTrack();s.name=t.label;const o=kv(t.instrument);o===-1?(s.channel=9,s.instrument.number=0):(s.channel=0,s.instrument.number=o);const a=n(t.id);if(!a.length)return null;const l=a.filter(d=>typeof d.pitchInt=="number"&&!isNaN(d.pitchInt)).map(d=>({midi:d.pitchInt,startBeat:d.startBeat,durationBeats:d.durationInBeats,velocity:d.velocity/127}));if(!l.length)return null;const u=Math.min(...l.map(d=>d.startBeat));return l.forEach(d=>{s.addNote({midi:d.midi,ticks:(d.startBeat-u)*i,durationTicks:d.durationBeats*i,velocity:d.velocity})}),FL(r)},UL=(t,e,n)=>{const r=new wv.Midi,i=r.header.ppq;LL(r,t);const s=new Set,o=[],a=[];e.forEach(h=>{kv(h.instrument)===-1?o.push(h):a.push(h)}),s.add(9);const l=[],u=t.timeSignature.beatsPerBar||4;if(a.forEach(h=>{const m=h.songPosition.bar*u;
805n(h.id).forEach(g=>{typeof g.pitchInt!="number"||isNaN(g.pitchInt)||l.push({midi:g.pitchInt,startBeat:m+g.startBeat,durationBeats:g.durationInBeats,velocity:g.velocity/127,bloob:h})})}),o.forEach(h=>{const m=h.songPosition.bar*u;n(h.id).forEach(g=>{typeof g.pitchInt!="number"||isNaN(g.pitchInt)||l.push({midi:g.pitchInt,startBeat:m+g.startBeat,durationBeats:g.durationInBeats,velocity:g.velocity/127,bloob:h})})}),!l.length)return null;const d=Math.min(...l.map(h=>h.startBeat)),f=new Map;return l.forEach(h=>{var m;f.has(h.bloob.id)||f.set(h.bloob.id,[]),(m=f.get(h.bloob.id))==null||m.push(h)}),a.forEach(h=>{const m=r.addTrack();m.name=h.label;const y=kv(h.instrument);m.instrument.number=y;let g=0;for(;s.has(g);)g=(g+1)%16,g===9&&(g=10);m.channel=g,s.add(g),(f.get(h.id)||[]).forEach(v=>{m.addNote({midi:v.midi,ticks:(v.startBeat-d)*i,durationTicks:v.durationBeats*i,velocity:v.velocity})})}),o.forEach(h=>{const m=r.addTrack();m.name=h.label,m.channel=9,m.instrument.number=0,(f.get(h.id)||[]).forEach(g=>{m.addNote({midi:g.midi,ticks:(g.startBeat-d)*i,durationTicks:g.durationBeats*i,velocity:g.velocity})})}),FL(r)},VL=()=>{const{selectedCaiObjects:t}=Yn(),{getSongById:e,getBloobById:n,getBloobsInSong:r,getNotesInBloob:i,noteDetails:s,getAudioFileById:o,getAudioFileData:a}=mn(),{showBanner:l}=ts(),u=x.useCallback(y=>i(y).map(w=>{const v=s[w.noteDetailsHash];return v?{pitchInt:v.pitchInt,startBeat:v.startBeat,durationInBeats:v.durationInBeats,velocity:v.velocity}:null}).filter(w=>w!=null),[i,s]),d=x.useCallback(async(y,g)=>{const w=o(y.audioFileId),v=await a(y.audioFileId),S=DL(v);let C="";const k=[];if(w.originalKey){const N=`${w.originalKey.chroma}_${w.originalKey.quality}`;k.push(N)}w.originalBpm&&k.push(`${w.originalBpm}_BPM`),k.length>0&&(C=`_${k.join("_")}`),g[`${Ib(y.label).replace(/ /g,"_")}${C}.wav`]=S},[o,a]),f=x.useCallback((y,g,w)=>{const v=$L(y,g,u);if(v){const C=kv(y.instrument)===-1||ci(y.instrument)===$r.BuiltInDrumMachine||y.instrument.toLowerCase().includes("drum")||y.instrument.toLowerCase().includes("percussion")||y.instrument.toLowerCase().includes("kit");let k;C?k=`_${g.bpm}_BPM`:k=`_${g.key.chroma}_${g.key.quality}_${g.bpm}_BPM`,w[`${Ib(y.label).replace(/ /g,"_")}${k}.mid`]=v}},[u]),h=x.useCallback(async(y,g)=>{const w=Object.entries(y);if(!w.length){l("No files to export");return}if(w.length===1){const[N,_]=w[0],j=URL.createObjectURL(_),T=document.createElement("a");T.href=j,T.download=N,document.body.appendChild(T),T.click(),document.body.removeChild(T),URL.revokeObjectURL(j);return}const v=new AL;w.forEach(([N,_])=>v.file(N,_));const S=await v.generateAsync({type:"blob"}),C=URL.createObjectURL(S),k=document.createElement("a");k.href=C,k.download=`${Ib(g)}.zip`,document.body.appendChild(k),k.click(),document.body.removeChild(k),URL.revokeObjectURL(C)},[l]);return{handleExportToFiles:x.useCallback(async()=>{if(t.length===0){l("Select a song or bloob first");return}const y={};t.forEach(async g=>{try{if(g.type===J.Song){const w=e(g.id),v=r(w.id),S=v.filter(ln),C=v.filter(En);if(S.forEach(k=>f(k,w,y)),S.length>1){const k=UL(w,S,u);if(k){const N=`_${w.key.chroma}_${w.key.quality}_${w.bpm}_BPM`;y[`${Ib(w.label).replace(/ /g,"_")}_All_Midi${N}.mid`]=k}}await Promise.all(C.map(k=>
805d(k,y))),await h(y,w.label);return}if(g.type===J.Bloob){const w=n(g.id),v=e(w.songId);ln(w)?f(w,v,y):En(w)&&await d(w,y),await h(y,w.label)}}catch{l("Export failed")}})},[t,l,e,r,h,f,u,d,n])}},ghe=[{pitch:"C4",pitchInt:60,velocity:100,startBeat:0,durationInBeats:4},{pitch:"Eb4",pitchInt:63,velocity:100,startBeat:0,durationInBeats:4},{pitch:"G4",pitchInt:67,velocity:100,startBeat:0,durationInBeats:4},{pitch:"Bb4",pitchInt:70,velocity:100,startBeat:0,durationInBeats:4},{pitch:"C4",pitchInt:60,velocity:100,startBeat:4,durationInBeats:4},{pitch:"Eb4",pitchInt:63,velocity:100,startBeat:4,durationInBeats:4},{pitch:"G4",pitchInt:67,velocity:100,startBeat:4,durationInBeats:4},{pitch:"Ab4",pitchInt:68,velocity:100,startBeat:4,durationInBeats:4},{pitch:"C4",pitchInt:60,velocity:100,startBeat:8,durationInBeats:4},{pitch:"Db4",pitchInt:61,velocity:100,startBeat:8,durationInBeats:4},{pitch:"F4",pitchInt:65,velocity:100,startBeat:8,durationInBeats:4},{pitch:"Ab4",pitchInt:68,velocity:100,startBeat:8,durationInBeats:4},{pitch:"Bb3",pitchInt:58,velocity:100,startBeat:12,durationInBeats:4},{pitch:"Db4",pitchInt:61,velocity:100,startBeat:12,durationInBeats:4},{pitch:"F4",pitchInt:65,velocity:100,startBeat:12,durationInBeats:4},{pitch:"G4",pitchInt:67,velocity:100,startBeat:12,durationInBeats:4}],bhe=[{pitch:"C4",pitchInt:60,velocity:100,startBeat:0,durationInBeats:4},{pitch:"Eb4",pitchInt:63,velocity:100,startBeat:1,durationInBeats:4},{pitch:"G4",pitchInt:67,velocity:100,startBeat:2,durationInBeats:4},{pitch:"Bb4",pitchInt:70,velocity:100,startBeat:3,durationInBeats:4},{pitch:"C4",pitchInt:60,velocity:100,startBeat:4,durationInBeats:4},{pitch:"Eb4",pitchInt:63,velocity:100,startBeat:5,durationInBeats:4},{pitch:"G4",pitchInt:67,velocity:100,startBeat:6,durationInBeats:4},{pitch:"Ab4",pitchInt:68,velocity:100,startBeat:7,durationInBeats:4},{pitch:"C4",pitchInt:60,velocity:100,startBeat:8,durationInBeats:4},{pitch:"Db4",pitchInt:61,velocity:100,startBeat:9,durationInBeats:4},{pitch:"F4",pitchInt:65,velocity:100,startBeat:10,durationInBeats:4},{pitch:"Ab4",pitchInt:68,velocity:100,startBeat:11,durationInBeats:4},{pitch:"Bb3",pitchInt:58,velocity:100,startBeat:12,durationInBeats:4},{pitch:"Db4",pitchInt:61,velocity:100,startBeat:13,durationInBeats:3},{pitch:"F4",pitchInt:65,velocity:100,startBeat:14,durationInBeats:2},{pitch:"G4",pitchInt:67,velocity:100,startBeat:15,durationInBeats:1}
805],yhe=[{pitch:"B1",pitchInt:35,velocity:100,startBeat:0,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:0,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:1,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:2,durationInBeats:1},{pitch:"E2",pitchInt:40,velocity:100,startBeat:2,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:3,durationInBeats:1},{pitch:"B1",pitchInt:35,velocity:100,startBeat:4,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:4,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:5,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:6,durationInBeats:1},{pitch:"E2",pitchInt:40,velocity:100,startBeat:6,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:7,durationInBeats:1},{pitch:"B1",pitchInt:35,velocity:100,startBeat:8,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:8,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:9,durationInBeats:1}
805,{pitch:"F#2",pitchInt:42,velocity:100,startBeat:10,durationInBeats:1},{pitch:"E2",pitchInt:40,velocity:100,startBeat:10,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:11,durationInBeats:1},{pitch:"B1",pitchInt:35,velocity:100,startBeat:12,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:12,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:13,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:14,durationInBeats:1},{pitch:"E2",pitchInt:40,velocity:100,startBeat:14,durationInBeats:1},{pitch:"F#2",pitchInt:42,velocity:100,startBeat:15,durationInBeats:1}],HL=[{label:"Piano Chords",songPosition:{bar:0,track:0},bars:4,notes:ghe,instrument:ft.AcousticGrandPiano,melodicRole:"gAAAAABn8fVaK2wP4xF9ZzLtGqR6vNp1XmYK7sJdRzVfFw8nPzQr5c2BnM4vG1yFx8K3pL7jZtH9RqPz6vCx5Q2dGw8L4mVzNs9B==",metadata:"gAAAAABn8fUbK2wP4xF9ZzLtGqR6vNp1XmYK7sJdRzVfFw8nPzQr5c2BnM4vG1yFx8K3pL7jZtH9RqPz6vCx5Q2dGw8L4mVzNs9B1rFyGx3K8pQz2vL6c5vNm7jYzPdR2QrH9fG4tM1xBn6K3wFzQvL8s5cP2mYz7tGrH4vNx1dFzK6pQsL9wJyRzVfG3nPzQ5r8c2vM4jY1xBnF7KzPtL9sGqH2vCx6dZ5mVzNr3B4wFyGx8K1pQzL7c9vNj6YzPdR5QrH2fG8tM4xBn3K7wFzQvL1s9cP6mYz0tGrH9vNx4dFzK3pQsL2wJyRzVfG6nPzQ8r5c9vM7jY4xBnF0KzPtL2sGqH5vCx9dZ8mVzNr6B7wFyGx1K4pQzL0c2vNj9YzPdR8QrH5fG1tM7xBn6K0wFzQvL4s2cP9mYz3tGrH2vNx7dFzK6pQsL5wJyRzVfG9nPzQ1r8c5vM0jY7xBnF3KzPtL5sGqH8vCx2dZ1mVzNr9B0wFyGx4K7pQzL3c6vNj2YzPdR1QrH8fG4tM0xBn9K3wFzQvL7s5cP2mYz6tGrH5vNx0dFzK9pQsL8wJyRzVfG2nPzQ4r1c8vM3jY0xBnF6KzPtL8sGqH1vCx5dZ4mVzNr2B3wFyGx7K0pQzL6c9vNj5YzPdR4QrH1fG7tM3xBn2K6wFzQvL0s8cP5mYz9tGrH8vNx3dFzK2pQsL1wJyRzVfG5nPzQ7r4c1vM6jY3xBnF9KzPtL1sGqH4vCx8dZ7mVzNr5B6wFyGx0K3pQzL9c2vNj8YzPdR7QrH4fG0tM6xBn5K9wFzQvL3s1cP8mYz2tGrH1vNx6dFzK5pQsL4wJyRzVfG8nPzQ0r7c4vM9jY6xBnF2KzPtL4sGqH7vCx1dZ0mVzNr8B9wFyGx3K6pQzL2c5vNj1YzPdR0QrH7fG3tM9xBn8K2wFzQvL6s4cP1mYz5tGrH4vNx9dFzK8pQsL7wJyRzVfG1nPzQ3r0c7vM2jY9xBnF5KzPtL7sGqH0vCx4dZ3mVzNr1B2wFyGx6K9pQzL5c8vNj4YzPdR3QrH0fG6tM2xBn1K5wFzQvL9s7cP4mYz8tGrH7vNx2dFzK1pQsL0wJyRzVfG4nPzQ6r3c0vM5jY2xBnF8KzPtL0sGqH3vCx7dZ6mVzNr4B5wFyGx9K2pQzL8c1vNj7YzPdR6QrH3fG9tM5xBn4K8wFzQvL2s0cP7mYz1tGrH0vNx5dFzK4pQsL3wJyRzVfG7nPzQ9r6c3vM8jY5xBnF1KzPtL3sGqH6vCx0dZ9mVzNr7B8wFyGx2K5pQzL1c4vNj0YzPdR9QrH6fG2tM8xBn7K1wFzQvL5s3cP0mYz4tGrH3vNx8dFzK7pQsL6wJyRzVfG0nPzQ2r9c6vM1jY8xBnF4KzPtL6sGqH9vCx3dZ2mVzNr0B1wFyGx5K8pQzL4c7vNj3YzPdR2QrH9fG5tM1xBn0K4wFzQvL8s6cP3mYz7tGrH6vNx1dFzK0pQsL9wJyRzVfG3nPzQ5r2c9vM4jY1xBnF7KzPtL9sGqH2vCx6dZ5mVzNr3B4wFyGx8K1pQzL7c0vNj6YzPdR5QrH2fG8tM4xBn3K7wFzQvL1s9cP6mYz0tGrH9vNx4dFzK3pQsL2wJyRzVfG6nPzQ8r5c2vM7jY4xBnF0KzPtL2sGqH5vCx9dZ8mVzNr6B7wFyGx1K4pQzL0c3vNj9YzPdR8QrH5fG1tM7xBn6K0wFzQvL4s2cP9mYz3tGrH2vNx7dFzK6pQsL5wJyRzVfG9nPzQ1r8c5vM0jY7xBnF3KzPtL5sGqH8vCx2dZ1mVzNr9B0wFyGx4K7pQzL3c6vNj2YzPdR1QrH8fG4tM0xBn9K3wFzQvL7s5cP2mYz6tGrH5vNx0dFzK9pQsL8wJyRzVfG2nPzQ4r1c8vM3jY0xBnF6KzPtL8sGqH1vCx5dZ4mVzNr2B3wFyGx7K0pQzL6c9vNj5YzPdR4QrH1fG7tM3xBn2K6wFzQvL0s8cP5mYz9tGrH8vNx3dFzK2pQsL1wJyRzVfG5nPzQ7r4c1vM6jY3xBnF9KzPtL1sGqH4vCx8dZ7mVzNr5B6wFyGx0K3pQzL9c2vNj8YzPdR7QrH4fG0tM6xBn5K9wFzQvL3s1cP8mYz2tGrH1vNx6dFzK5pQsL4wJyRzVfG8nPzQ0r7c4vM9jY6xBnF2KzPtL4sGqH7vCx1dZ0mVzNr8B9wFyGx3K6pQzL2c5vNj1YzPdR0QrH7fG3tM9xBn8K2wFzQvL6s4cP1mYz5tGrH4vNx9dFzK8pQsL7wJyRzVfG1nPzQ3r0c7vM2jY9xBnF5KzPtL7sGqH0vCx4dZ3mVzNr1B2wFyGx6K9pQzL5c8vNj4YzPdR3QrH0fG6tM2xBn1K5wFzQvL9s7cP4mYz8tGrH7vNx2dFzK1pQsL0wJyRzVfG4nPzQ6r3c0vM5jY2xBnF8KzPtL0sGqH3vCx7dZ6mVzNr4B5wFyGx9K2pQzL8c1vNj7YzPdR6QrH3fG9tM5xBn4K8wFzQvL2s0cP7mYz1tGrH0vNx5dFzK4pQsL3wJyRzVfG7nPzQ9r6c3vM8jY5xBnF1KzPtL3sGqH6vCx0dZ9mVzNr7B8wFyGx2K5pQzL1c4vNj0YzPdR9QrH6fG2tM8xBn7K1wFzQvL5s3cP0mYz4tGrH3vNx8dFzK7pQsL6wJyRzVfG0nPzQ2r9c6vM1jY8xBnF4KzPtL6sGqH9vCx3dZ2mVzNr0B1wFyGx5K8pQzL4c7vNj3YzPdR2QrH9fG5tM1xBn0K4wFzQvL8s6cP3mYz7tGrH6vNx1dFzK0pQsL9wJyRzVfG3nPzQ5r2c9vM4jY1xBnF7KzPtL9sGqH2vCx6dZ5mVzNr3B4wFyGx8K1pQzL7c0vNj6YzPdR5QrH2fG8tM4xBn3K7wFzQvL1s9cP6mYz0tGrH9vNx4dFzK3pQsL2wJyRzVfG6nPzQ8r5c2vM7jY4xBnF0KzPtL2sGqH5vCx9dZ8mVzNr6B7wFyGx1K4pQzL0c3vNj9YzPdR8QrH5fG1tM7xBn6K0wFzQvL4s2cP9mYz3tGrH2vNx7dFzK6pQsL5wJyRzVfG9nPzQ1r8c5vM0jY7xBnF3KzPtL5sGqH8vCx2dZ1mVzNr9B0wFyGx4K7pQzL3c6vNj2YzPdR1QrH8fG4tM0xBn9K3wFzQvL7s5cP2mYz6tGrH5vNx0dFzK9pQsL8wJyRzVfG2nPzQ4r1c8vM3jY0xBnF6KzPtL8sGqH1vCx5dZ4mVzNr2B3wFyGx7K0pQzL6c9vNj5YzPdR4QrH1fG7tM3xBn2K6wFzQvL0s8cP5mYz9tGrH8vNx3dFzK2pQsL1wJyRzVfG5nPzQ7r4c1vM6jY3xBnF9KzPtL1sGqH4vCx8dZ7mVzNr5B6wFyGx0K3pQzL9c2vNj8YzPdR7QrH4fG0tM6x
805Bn5K9wFzQvL3s1cP8mYz2tGrH1vNx6dFzK5pQsL4wJyRzVfG8nPzQ0r7c4vM9jY6xBnF2KzPtL4sGqH7vCx1dZ0mVzNr8B9wFyGx3K6pQzL2c5vNj1YzPdR0QrH7fG3tM9xBn8K2wFzQvL6s4cP1mYz5tGrH4vNx9dFzK8pQsL7wJyRzVfG1nPzQ3r0c7vM2jY9xBnF5KzPtL7sGqH0vCx4dZ3mVzNr1B2wFyGx6K9pQzL5c8vNj4YzPdR3QrH0fG6tM2xBn1K5wFzQvL9s7cP4mYz8tGrH7vNx2dFzK1pQsL0wJyRzVfG4nPzQ6r3c0vM5jY2xBnF8KzPtL0sGqH3vCx7dZ6mVzNr4B5wFyGx9K2pQzL8c1vNj7YzPdR6QrH3fG9tM5xBn4K8wFzQvL2s0cP7mYz1tGrH0vNx5dFzK4pQsL3wJyRzVfG7nPzQ9r6c3vM8jY5xBnF1KzPtL3sGqH6vCx0dZ9mVzNr7B8wFyGx2K5pQzL1c4vNj0YzPdR9QrH6fG2tM8xBn7K1wFzQvL5s3cP0mYz4tGrH3vNx8dFzK7pQsL6wJyRzVfG0nPzQ2r9c6vM1jY8xBnF4KzPtL6sGqH9vCx3dZ2mVzNr0B1wFyGx5K8pQzL4c7vNj3YzPdR2QrH9fG5tM1xBn0K4wFzQvL8s6cP3mYz7tGrH6vNx1dFzK0pQsL9wJyRzVfG3nPzQ5r2c9vM4jY1xBnF7KzPtL9sGqH2vCx6dZ5m==",metadataOutdated:!1},{label:"Guitar Chords",songPosition:{bar:0,track:1},bars:4,notes:bhe,instrument:ft.ElectricGuitarClean,melodicRole:"gAAAAABn8fVbX7Y2pK9zFrGqH4vNx8dFzK3pQsL6wJyRzVfG9nPzQ1r8c5vM0jY7xBnF3KzPtL5sGqH8vCx2dZ1mVzNr9B0wFyGx4==",metadata:"gAAAAABn8fUdQ7mKpVzNr8B9wFyGx3K6pQzL2c5vNj1YzPdR0QrH7fG3tM9xBn8K2wFzQvL6s4cP1mYz5tGrH4vNx9dFzK8pQsL7wJyRzVfG1nPzQ3r0c7vM2jY9xBnF5KzPtL7sGqH0vCx4dZ3mVzNr1B2wFyGx6K9pQzL5c8vNj4YzPdR3QrH0fG6tM2xBn1K5wFzQvL9s7cP4mYz8tGrH7vNx2dFzK1pQsL0wJyRzVfG4nPzQ6r3c0vM5jY2xBnF8KzPtL0sGqH3vCx7dZ6mVzNr4B5wFyGx9K2pQzL8c1vNj7YzPdR6QrH3fG9tM5xBn4K8wFzQvL2s0cP7mYz1tGrH0vNx5dFzK4pQsL3wJyRzVfG7nPzQ9r6c3vM8jY5xBnF1KzPtL3sGqH6vCx0dZ9m==",metadataOutdated:!1},{label:"Drums",songPosition:{bar:0,track:2},bars:4,notes:yhe,instrument:m0.TR808,melodicRole:"gAAAAABn8fVcR2Nj8vFz0QKGdL3VRjLGKl_9wJXPzVfKm_nYzPdR==",metadata:"gAAAAABn8fUfH4mVzNr7B8wFyGx2K5pQzL1c4vNj0YzPdR9QrH6fG2tM8xBn7K1wFzQvL5s3cP0mYz4tGrH3vNx8dFzK7pQsL6wJyRzVfG0nPzQ2r9c6vM1jY8xBnF4KzPtL6sGqH9vCx3dZ2mVzNr0B1wFyGx5K8pQzL4c7vNj3YzPdR2QrH9fG5tM1xBn0K4wFzQvL8s6cP3mYz7tGrH6vNx1dFzK0pQsL9wJyRzVfG3nPzQ5r2c9vM4jY1xBnF7KzPtL9sGqH2vCx6dZ5mVzNr3B4wFyGx8K1pQzL7c0vNj6YzPdR5QrH2fG8tM4xBn3K7wFzQvL1s9cP6mYz0tGrH9vNx4dFzK3pQsL2wJyRzVfG6nPzQ8r5c2vM7jY4xBnF0KzPtL2sGqH5vCx9dZ8mVzNr6B7wFyGx1K4pQzL0c3vNj9YzPdR8QrH5fG1tM7xBn6K0wFzQvL4s2cP9mYz3tGrH2vNx7dFzK6pQsL5wJyRzVfG9nPzQ1r8c5vM0jY7xBnF3KzPtL5sGqH8vCx2dZ1mVzNr9B0wFyGx4==",metadataOutdated:!1}],vhe=[{label:"Drum Loop",songPosition:{bar:0,track:3},bars:4,instrument:"Drums",originalBpm:135,melodicRole:so.PERCUSSION,audioFilePath:"/src/canvas/test/test_drum_loop_135.wav"},{label:"Synth Loop",songPosition:{bar:0,track:4},bars:4,instrument:"Synth",originalKey:"F Minor",originalBpm:135,melodicRole:so.LEAD_MELODY,audioFilePath:"/src/canvas/test/test_synth_loop_135_Fmin.wav"}],ia={key:{chroma:"Ab",quality:"Major"},bpm:135,timeSignature:{beatsPerBar:4,beatDuration:4},canvasPosition:{x:100,y:100},label:"Test Song",bars:4,tracks:5},Sc=({id:t,name:e,autoComplete:n,value:r,onChange:i,placeholder:s,showPassword:o,toggleVisibility:a,error:l=null,disabled:u=!1})=>c.jsxs("div",{className:"w-full",children:[c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:o?"text":"password",id:t,name:e,autoComplete:n,placeholder:s,value:r,onChange:i,disabled:u,className:`w-full p-3 pr-10 border rounded-lg focus:outline-none focus:ring-2 transition-colors ${l?"border-red-500 bg-red-50 dark:bg-red-900/20 text-red-900 dark:text-red-200":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100 border-zinc-300 dark:border-zinc-700 focus:ring-caiGreen-500"} ${u?"opacity-50 cursor-not-allowed":""}`,required:!0}),c.jsx("button",{type:"button",onClick:d=>{d.preventDefault(),a()},disabled:u,className:`absolute inset-y-0 right-0 px-3 flex items-center transition-colors ${u?"opacity-50 cursor-not-allowed":"text-zinc-500 dark:text-zinc-400 hover:text-caiBlue-500"}`,children:o?c.jsx(Jy,{size:20}):c.jsx(gD,{size:20})})]}),l&&c.jsxs("p",{className:"mt-1 text-sm text-red-600 dark:text-red-400 flex items-center gap-1",children:[c.jsx(T0,{size:14}),l]})]}),jb=({id:t,name:e,type:n="text",autoComplete:r,value:i,onChange:s,placeholder:o,error:a=null,disabled:l=!1,required:u=!1})=>c.jsxs("div",{className:"w-full",children:[c.jsx("input",{type:n,id:t,name:e,autoComplete:r,placeholder:o,value:i,onChange:s,disabled:l,required:u,className:`w-full p-3 border rounded-lg focus:outline-none focus:ring-2 transition-colors ${a?"border-red-500 bg-red-50 dark:bg-red-900/20 text-red-900 dark:text-red-200":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100 border-zinc-300 dark:border-zinc-700 focus:ring-caiGreen-500"} ${l?"opacity-50 cursor-not-allowed":""}`}),a&&c.jsxs("p",{className:"mt-1 text-sm text-red-600 dark:text-red-400 flex items-center gap-1",children:[c.jsx(T0,{size:14}),a]})]}),Tb=({title:t,icon:e,children:n,defaultExpanded:r=!0,isDarkMode:i}
805)=>{const[s,o]=x.useState(r);return c.jsxs("div",{className:`mb-4 rounded-lg border ${i?"border-zinc-700":"border-zinc-200"}`,children:[c.jsxs("button",{onClick:()=>o(!s),className:`w-full px-4 py-3 flex items-center justify-between transition-colors rounded-t-lg ${i?s?"bg-gradient-to-r from-caiGreen-700/100 to-caiBlue-700/50 text-zinc-100":"bg-zinc-800 text-zinc-300 hover:bg-zinc-700":s?"bg-gradient-to-r from-caiGreen-100/100 to-caiBlue-100/50 text-zinc-800":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"} ${s?"":"rounded-b-lg"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[e,c.jsx("h2",{className:"font-medium",children:t})]}),c.jsx(Vi,{size:18,className:`transition-transform duration-300 ${s?"rotate-180":""}`})]}),s&&c.jsx("div",{className:"rounded-b-lg bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 dark:from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm",children:c.jsx("div",{className:"p-4 space-y-6 pb-6",children:n})})]})},xhe=({isOpen:t,onClose:e,onConfirm:n,password:r,onPasswordChange:i,error:s,loading:o,isDarkMode:a,passwordInputProps:l})=>t?c.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-4",children:c.jsx(et.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"},className:`relative max-w-md w-full rounded-2xl shadow-2xl border ${a?"bg-gradient-to-br from-zinc-900/100 to-zinc-600/25 backdrop-blur-sm border-zinc-700":"bg-gradient-to-br from-zinc-200/100 to-zinc-100/25 backdrop-blur-sm border-zinc-300"}`,children:c.jsxs("div",{className:"p-6",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h3",{className:`text-lg font-semibold ${a?"text-white":"text-zinc-900"}`,children:"Confirm your password"}),c.jsx("button",{type:"button",onClick:e,className:`p-1 rounded-full transition-colors ${a?"hover:bg-zinc-700":"hover:bg-zinc-200"}`,children:c.jsx(nr,{size:18})})]}),c.jsx("p",{className:`text-sm mb-4 ${a?"text-zinc-400":"text-zinc-600"}`,children:"Enter your password to permanently delete your account and all associated data."}),c.jsx("div",{className:"mb-6",children:c.jsx(Sc,{id:"delete-account-password",name:"delete-account-password",autoComplete:"current-password",value:r,onChange:i,placeholder:"Your password",showPassword:l.showPassword,toggleVisibility:l.toggleVisibility,error:s,disabled:o})}),c.jsxs("div",{className:"flex gap-3 justify-end",children:[c.jsx(et.button,{type:"button",whileHover:{scale:1.02},whileTap:{scale:.98},onClick:e,disabled:o,className:`px-4 py-2 rounded-lg border transition-colors ${a?"border-zinc-600 text-zinc-300 hover:bg-zinc-700":"border-zinc-300 text-zinc-700 hover:bg-zinc-100"} ${o?"opacity-50 cursor-not-allowed":""}`,children:"Cancel"}),c.jsx(et.button,{type:"button",whileHover:{scale:1.02},whileTap:{scale:.98},onClick:n,disabled:o||!r.trim(),className:`px-4 py-2 rounded-lg font-medium transition-colors ${o||!r.trim()?"opacity-50 cursor-not-allowed":""} bg-red-600 hover:bg-red-700 text-white`,children:o?"Deleting...":"Delete Account"})]})]})})}):null,whe=({onClose:t,onSignOut:e})=>{const{focusCanvas:n}=di(),{theme:r}=Pn(),{showBanner:i}=ts(),{isMobile:s}=Hn(),o=r===gi.Dark,[a,l]=x.useState("profile"),[u,d]=x.useState(!1),[f,h]=x.useState({email:"",firstName:"",lastName:"",email_verified:"false"}),[m,y]=x.useState({firstName:"",lastName:"",email:""}),[g,w]=x.useState({currentPassword:"",newPassword:"",confirmNewPassword:""}),[v,S]=x.useState({hasEmailProvider:!0,hasSocialProvider:!1,onlySocialAuth:!1}),[C,k]=x.useState(!1),[N,_]=x.useState(!1),[j,T]=x.useState(!1),[M,V]=x.useState(!1),[H,P]=x.useState(""),[F,I]=x.useState(""),[R,U]=x.useState(""),[A,W]=x.useState(!1),[D,B]=x.useState(!1),[L,$]=x.useState({}),[q,Z]=x.useState(!1),[ie,ge]=x.useState({}),[re,Y]=x.useState({}),[ne,be]=x.useState(!1),[we,te]=x.useState(!1),[fe,O]=x.useState(""),[pe,he]=x.useState(null),[le,oe]=x.useState(!1),[Q,de]=x.useState(null),[Ne,Ce]=x.use
805State(!1),[Ae,Ue]=x.useState(!1);x.useEffect(()=>{(async()=>{try{const[gt,dt]=await Promise.all([wA(),yy()]);h(gt),S(dt),y({firstName:gt.firstName||"",lastName:gt.lastName||"",email:gt.email||""})}catch{i("Failed to load account information")}})()},[i]),x.useEffect(()=>{const tt=m.firstName!==(f.firstName||"")||m.lastName!==(f.lastName||""),gt=m.email!==(f.email||"");Ce(tt),Ue(gt)},[m,f]);const Se=x.useCallback(()=>{t(),n()},[t,n]),ve=tt=>gt=>{y(dt=>({...dt,[tt]:gt.target.value})),ie[tt]&&ge(dt=>({...dt,[tt]:""}))},je=tt=>gt=>{w(dt=>({...dt,[tt]:gt.target.value})),re[tt]&&Y(dt=>({...dt,[tt]:""}))},Te=async()=>{d(!0),ge({});try{const tt={};if(m.firstName.trim()||(tt.firstName="First name is required"),m.lastName.trim()||(tt.lastName="Last name is required"),Object.keys(tt).length>0){ge(tt);return}await yue({firstName:m.firstName.trim(),lastName:m.lastName.trim()});const gt=await wA();h(gt),y(dt=>({...dt,firstName:gt.firstName||"",lastName:gt.lastName||""})),i("Profile updated successfully")}catch(tt){i(`Failed to update profile: ${tt.message||"Unknown error"}`)}finally{d(!1)}},ce=async()=>{d(!0),ge({});try{const tt={};if(m.email.trim()?/\S+@\S+\.\S+/.test(m.email)||(tt.email="Please enter a valid email address"):tt.email="Email is required",Object.keys(tt).length>0){ge(tt);return}await bue(m.email.trim()),i("Email change requested. Check your email for confirmation."),y(gt=>({...gt,email:f.email||""}))}catch(tt){i(`Failed to change email: ${tt.message||"Unknown error"}`)}finally{d(!1)}},se=async()=>{var tt,gt;d(!0),Y({});try{const dt={};if(!v.onlySocialAuth&&!g.currentPassword&&(dt.currentPassword="Current password is required"),g.newPassword?g.newPassword.length<8&&(dt.newPassword="Password must be at least 8 characters"):dt.newPassword="New password is required",g.newPassword!==g.confirmNewPassword&&(dt.confirmNewPassword="Passwords do not match"),Object.keys(dt).length>0){Y(dt);return}await xue({oldPassword:v.onlySocialAuth?"":g.currentPassword,newPassword:g.newPassword}),w({currentPassword:"",newPassword:"",confirmNewPassword:""});const wt=v.onlySocialAuth?"Password set successfully! You can now sign in with email and password.":"Password updated successfully";i(wt);const Dt=await yy();S(Dt)}catch(dt){const wt=dt;(tt=wt.message)!=null&&tt.includes("social login")||(gt=wt.message)!=null&>.includes("password that doesn't exist")?i("This account uses social login only. You can set a password to enable email/password sign-in."):wt.name==="NotAuthorizedException"?Y({currentPassword:"Current password is incorrect"}):i(`${wt.message||"Unknown error"}`)}finally{d(!1)}},ye=async()=>{Z(!0),$({});try{const tt=f.email;if(!tt)throw new Error("No email found for current user");await F8({username:tt}),V(!0),i("Password reset code sent to your email")}catch(tt){$({general:tt.message||"Failed to send reset email"})}finally{Z(!1)}},ke=async()=>{Z(!0),$({});try{const tt={};if(H.trim()||(tt.code="Reset code is required"),F.trim()?F.length<8&&(tt.newPassword="Password must be at least 8 characters"):tt.newPassword="New password is required",F!==R&&(tt.confirmPassword="Passwords do not match"),Object.keys(tt).length>0){$(tt);return}const gt=f.email;if(!gt)throw new Error("No email found for current user");await $8({username:gt,confirmationCode:H.trim(),newPassword:F}),V(!1),P(""),I(""),U(""),$({}),i("Password reset successfully! You can now sign in with your new password.")}catch(tt){$({code:tt.message||"Failed to reset password"})}finally{Z(!1)}},ze=x.useCallback(async()=>{be(!0);try{const tt=await yy();de({onlySocialAuth:tt.onlySocialAuth})}catch{de(null)}},[]),qe=x.useCallback(async()=>{d(!0),he(null);try{await wue(),i("Account deleted successfully"),await WE(),e()}catch(tt){i(`Failed to delete account: ${tt.message||"Unknown error"}`)}finally{d(!1),be(!1),te(!1),O(""),he(null)}},[e,i]),ot=x.useCallback(()=>{Q!=null&&Q.onlySocialAuth?qe():(be(!1),te(!0),O(""),he(null))},[Q==null?void 0:Q.onlySocialAuth,qe]),Ze=x.useCallback(async()=>{const tt=f.email;if(!(tt!=null&&tt.trim())){he("No email found for this account.");return}d(!0),he(null);try{await vC({username:tt,password:fe}),await qe()}catch(gt){he(gt.message||"Invalid password. Please try again.")}finally{d(!1)}},[f.email,fe,qe]),_t=[{id:"profile",label:"Profile",icon:c.jsx(wm,{size:16})},{id:"security",label:"Security",icon:c.jsx(yb,{size:16})},{id:"danger",label:"Danger Zone",icon:c.jsx(js,{size:16})}];return c.jsxs(c.Fragment,{children:[c.jsx(Wr,{onClose:Se,widthClass:s?"w-[93%]":"w-2/5",heightClass:s?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors backdrop-blur-sm ${o?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 text-zinc-100":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 text-zinc-800"}`,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${o?"border-zinc-800 bg-gradient-to-br from-zinc-800/50 to-zinc-900/25":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(wm,{size:20,className:o?"text-caiBlue-400":"text-caiBlue-600"}),c.jsx("h1",{className:"text-2xl font-semibold",children:"Account"})]}),c.jsx("button",{onClick:Se,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${o?"hover:bg-white":"hover:bg-black"}`,"aria-label":"Close account settings",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:`flex gap-1 p-2 border-b overflow-x-auto scrollbar-hide ${o?"border-zinc-800 bg-gradient-to-br from-zinc-900/50 to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:_t.map(tt=>c.jsxs("button",{onClick:()=>l(tt.id),className:`flex items-center gap-1.5 px-3 py-2 rounded-lg whitespace-nowrap transition-colors ${a===tt.id?o?"bg-zinc-800/75 text-caiBlue-300":"bg-zinc-100/75 text-caiBlue-600":o?"text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-300":"text-zinc-600 hover:bg-zinc-100/50 hover:text-zinc-800"}`,children:[tt.icon,c.jsx("span",{className:"font-medium",children:tt.label})]},tt.id))}),c.jsx("div",{className:"relative flex-1 overflow-y-auto",children:c.jsxs("div",{className:"relative z-10 p-4",children:[a==="profile"&&c.jsx(Tb,{title:"Profile Information",icon:c.jsx(wm,{size:18}),isDarkMode:o,children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Email Address"}),c.jsxs("div",{className:"relative",children:[c.jsx(_h,{size:16,className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-zinc-400"}),c.jsx(jb,{id:"email",name:"email",type:"email",autoComplete:"email",value:m.email,onChange:ve("email"),placeholder:"Enter your email address",error:ie.email||null,disabled:u,required:!0})]}),f.email_verified==="true"&&c.jsxs("div",{className:"mt-2 flex items-center gap-1 text-sm text-green-600 dark:text-green-400",children:[c.jsx(yre,{size:14}),c.jsx("span",{children:"Email verified"})]}),Ae&&c.jsxs(et.button,{initial:{opacity:0,y:10}
805,animate:{opacity:1,y:0},whileHover:{scale:1.02},whileTap:{scale:.98},onClick:ce,disabled:u,className:"mt-2 flex items-center justify-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white hover:from-caiGreen-600 hover:to-caiBlue-600 disabled:opacity-50",children:[c.jsx(_h,{size:16}),u?"Requesting...":"Change Email"]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"First Name"}),c.jsx(jb,{id:"firstName",name:"firstName",autoComplete:"given-name",value:m.firstName,onChange:ve("firstName"),placeholder:"Enter your first name",error:ie.firstName||null,disabled:u,required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Last Name"}),c.jsx(jb,{id:"lastName",name:"lastName",autoComplete:"family-name",value:m.lastName,onChange:ve("lastName"),placeholder:"Enter your last name",error:ie.lastName||null,disabled:u,required:!0})]}),Ne&&c.jsxs(et.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},whileHover:{scale:1.02},whileTap:{scale:.98},onClick:Te,disabled:u,className:"w-full flex items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white hover:from-caiGreen-600 hover:to-caiBlue-600 disabled:opacity-50",children:[c.jsx(Lne,{size:16}),u?"Updating...":"Update Profile"]})]})}),a==="security"&&c.jsxs(c.Fragment,{children:[c.jsx(Tb,{title:"Change Password",icon:c.jsx(xm,{size:18}),isDarkMode:o,children:v.onlySocialAuth?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800/40 rounded-lg",children:[c.jsx("h3",{className:"font-medium mb-2 text-blue-800 dark:text-blue-300",children:"Social Login Account"}),c.jsx("p",{className:"text-sm text-blue-700 dark:text-blue-400 mb-4",children:"Your account uses social login only. Set a password to enable email/password sign-in."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"New Password"}),c.jsx(Sc,{id:"new-password",name:"new-password",autoComplete:"new-password",value:g.newPassword,onChange:je("newPassword"),placeholder:"Enter your new password",showPassword:N,toggleVisibility:()=>_(!N),error:re.newPassword||null,disabled:u}),c.jsx("p",{className:"mt-1 text-xs text-zinc-500 dark:text-zinc-400",children:"Password must be at least 8 characters long"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Confirm New Password"}),c.jsx(Sc,{id:"confirm-new-password",name:"confirm-new-password",autoComplete:"new-password",value:g.confirmNewPassword,onChange:je("confirmNewPassword"),placeholder:"Confirm your new password",showPassword:j,toggleVisibility:()=>T(!j),error:re.confirmNewPassword||null,disabled:u})]}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:se,disabled:u||!g.newPassword||!g.confirmNewPassword,className:"w-full flex items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white hover:from-caiGreen-600 hover:to-caiBlue-600 disabled:opacity-50 disabled:cursor-not-allowed",children:[c.jsx(xm,{size:16}),u?"Setting password...":"Set Password"]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Current Password"}),c.jsx(Sc,{id:"current-password",name:"current-password",autoComplete:"current-password",value:g.currentPassword,onChange:je("currentPassword"),placeholder:"Enter your current password",showPassword:C,toggleVisibility:()=>k(!C),error:re.currentPassword||null,disabled:u})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"New Password"}),c.jsx(Sc,{id:"new-password",name:"new-password",autoComplete:"new-password",value:g.newPassword,onChange:je("newPassword"),placeholder:"Enter your new password",showPassword:N,toggleVisibility:()=>_(!N),error:re.newPassword||null,disabled:u}),c.jsx("p",{className:"mt-1 text-xs text-zinc-500 dark:text-zinc-400",children:"Password must be at least 8 characters long"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Confirm New Password"}),c.jsx(Sc,{id:"confirm-new-password",name:"confirm-new-password",autoComplete:"new-password",value:g.confirmNewPassword,onChange:je("confirmNewPassword"),placeholder:"Confirm your new password",showPassword:j,toggleVisibility:()=>T(!j),error:re.confirmNewPassword||null,disabled:u})]}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:se,disabled:u||!g.currentPassword||!g.newPassword||!g.confirmNewPassword,className:"w-full flex items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white hover:from-caiGreen-600 hover:to-caiBlue-600 disabled:opacity-50 disabled:cursor-not-allowed",children:[c.jsx(xm,{size:16}),u?"Updating...":"Update Password"]})]})}),c.jsx(Tb,{title:"Forgot Password?",icon:c.jsx(yb,{size:18}),isDarkMode:o,defaultExpanded:!1,children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/40 rounded-lg",children:[c.jsx("h3",{className:"font-medium mb-2 text-amber-800 dark:text-amber-300",children:"Reset Your Password"}),c.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400",children:"If you've forgotten your current password, you can reset it using your email address. We'll send you a secure reset link."})]}),M?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800/40 rounded-lg",children:c.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:"Check your email for a reset code. Enter it below with your new password."})}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Reset Code"}),c.jsx(jb,{id:"reset-code",name:"reset-code",value:H,onChange:tt=>P(tt.target.value),placeholder:"Enter the code from your email",error:L.code||null,disabled:q,required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"New Password"}),c.jsx(Sc,{id:"reset-new-password",name:"reset-new-password",autoComplete:"new-password",value:F,onChange:tt=>I(tt.target.value),placeholder:"Enter your new password",showPassword:A,toggleVisibility:()=>W(!A),error:L.newPassword||null,disabled:q}),c.jsx("p",{className:"mt-1 text-xs text-zinc-500 dark:text-zinc-400",children:"Password must be at least 8 characters long"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Confirm New Password"}),c.jsx(Sc,{id:"reset-confirm-password",name:"reset-confirm-password",autoComplete:"new-password",value:R,onChange:tt=>U(tt.target.value),placeholder:"Confirm your new password",showPassword:D,toggleVisibility:()=>B(!D),error:L.confirmPassword||null,disabled:q})]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>{V(!1),P(""),I(""),U(""),$({})}
805,disabled:q,className:"flex-1 py-3 px-4 rounded-lg font-medium transition-colors border border-zinc-300 dark:border-zinc-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-50",children:"Back"}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:ke,disabled:q||!H.trim()||!F.trim()||!R.trim(),className:"flex-2 flex items-center justify-center gap-2 py-3 px-6 rounded-lg font-medium transition-colors bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 disabled:opacity-50 disabled:cursor-not-allowed",children:[c.jsx(yb,{size:16}),q?"Resetting...":"Reset Password"]})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"p-4 bg-zinc-50 dark:bg-zinc-800/50 border border-zinc-200 dark:border-zinc-700 rounded-lg",children:c.jsxs("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:["We'll send a reset code to your current email address: ",c.jsx("strong",{children:f.email})]})}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:ye,disabled:q,className:"w-full flex items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 disabled:opacity-50 disabled:cursor-not-allowed",children:[c.jsx(yb,{size:16}),q?"Sending...":"Send Reset Code"]})]})]})})]}),a==="danger"&&c.jsx(Tb,{title:"Danger Zone",icon:c.jsx(js,{size:18}),isDarkMode:o,children:c.jsxs("div",{className:`p-4 border rounded-lg ${o?"bg-red-900/20 border-red-800/40":"bg-red-50 border-red-200"}`,children:[c.jsx("h3",{className:"font-medium mb-2 text-red-600 dark:text-red-400",children:"Delete Account"}),c.jsx("p",{className:"text-sm mb-4 text-red-600/80 dark:text-red-400/80",children:"This will permanently delete your account and all associated data. This action cannot be undone."}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:ze,disabled:u,className:"flex items-center gap-2 py-2 px-4 rounded-lg transition-colors bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:[c.jsx(js,{size:16}),"Delete Account"]})]})})]})})]})}),c.jsx(al,{isOpen:ne,onClose:()=>be(!1),onConfirm:ot,title:"Delete Account",message:"Are you sure you want to delete your account? This action cannot be undone and will permanently remove all your data.",confirmText:"Continue",isDangerous:!0}),c.jsx(xhe,{isOpen:we,onClose:()=>{te(!1),O(""),he(null)},onConfirm:Ze,password:fe,onPasswordChange:tt=>{O(tt.target.value),he(null)},error:pe,loading:u,isDarkMode:o,passwordInputProps:{showPassword:le,toggleVisibility:()=>oe(tt=>!tt)}})]})},khe=({isOpen:t,onClose:e})=>{const{usage:n,subscription:r,isLoading:i,isReactivating:s,isCanceling:o,error:a,refreshSubscriptionData:l,cancelSubscription:u,reactivateSubscription:d,setError:f}=tl(),{theme:h}=Pn(),{isMobile:m}=Hn(),y=h===gi.Dark,g=Tce(),[w,v]=x.useState(null),[S,C]=x.useState(null),[k,N]=x.useState(null),_=(r==null?void 0:r.plan)===Nr.KIPP_CAPITAL,j=x.useMemo(()=>{var A;return k?((A=k.split("@")[1])==null?void 0:A.toLowerCase())==="cai.audio":!1},[k]),T=_,M=x.useMemo(()=>!!(i||s||!w||T||w===Nr.BASE&&(r==null?void 0:r.plan)===Nr.BASE||(r==null?void 0:r.plan)===w&&!(r!=null&&r.cancel_at_period_end)),[i,s,w,r==null?void 0:r.plan,r==null?void 0:r.cancel_at_period_end,T]);x.useEffect(()=>{t&&r!=null&&r.plan?v(r.plan):v(null)},[t,r==null?void 0:r.plan]),x.useEffect(()=>{t&&(async()=>{try{const A=await dd();C(A.id),N(A.email||null),await l(A.id)}catch{}})()},[t,l]);const V=x.useCallback(async()=>{if(!S||!w||M)return;if((r==null?void 0:r.plan)===w&&(r==null?void 0:r.cancel_at_period_end))try{await d(S),await l(S)}catch{f("Failed to reactivate subscription")}else{const A=`${window.location.origin}/payments/checkout?plan=${w}&userId=${S}`;window.location.href=A}},[S,w,r,M,d,l,f]),H=U=>{switch(U){case Nr.PRO:return c.jsx(WS,{size:24,className:"text-caiBlue-500"});case Nr.KIPP_CAPITAL:return c.jsx(WS,{size:24,className:"text-caiPeach-500"});default:return c.jsx(Qf,{size:24,className:"text-gray-500"})}},P=U=>{const A=mC[U],W=(r==null?void 0:r.plan)===U,D=w===U,B=A.price.month,L=()=>{T||v(W&&w===U?null:U)};return c.jsxs(et.div,{whileHover:{scale:T?1:1.02},whileTap:{scale:T?1:.98},className:` 806 relative p-6 rounded-xl border-2 transition-all duration-200
807 ${T?"cursor-default":"cursor-pointer"} 808 ${W&&U===Nr.KIPP_CAPITAL?y?"border-caiPeach-500 bg-gradient-to-br from-caiPeach-900/30 to-caiPeach-800/20 backdrop-blur-sm":"border-caiPeach-400 bg-gradient-to-br from-caiPeach-100/60 to-caiPeach-50/30 backdrop-blur-sm":W&&!D?y?"border-zinc-600 bg-gradient-to-br from-zinc-800/50 to-zinc-900/25 backdrop-blur-sm":"border-zinc-300 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm":W&&D?"border-caiGreen-500 bg-gradient-to-br from-caiGreen-100/50 to-caiGreen-200/25 dark:from-caiGreen-900/20 dark:to-caiGreen-800/25 backdrop-blur-sm":D?"border-caiBlue-500 bg-gradient-to-br from-caiBlue-100/50 to-caiBlue-200/25 dark:from-caiBlue-900/20 dark:to-caiBlue-800/25 backdrop-blur-sm":y?"border-zinc-700 hover:border-caiBlue-300 bg-gradient-to-br from-zinc-800/50 to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 hover:border-caiBlue-300 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"} 809 `,onClick:L,children:[W&&U===Nr.KIPP_CAPITAL&&c.jsxs("div",{className:"absolute -top-2 -right-2 bg-caiPeach-500 text-white px-3 py-1 rounded-full text-xs font-medium flex items-center space-x-1",children:[c.jsx(xm,{size:12}),c.jsx("span",{children:"Locked"})]}),W&&U!==Nr.KIPP_CAPITAL&&c.jsx("div",{className:"absolute -top-2 -right-2 bg-caiGreen-500 text-white px-2 py-1 rounded-full text-xs font-medium",children:(()=>{if(!(r!=null&&r.current_period_end))return"Current";const q=new Date(r.current_period_end).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return`${r.cancel_at_period_end?"Ends":"Renews"} ${q}`})()}),!W&&D&&(r==null?void 0:r.plan)&&c.jsx("div",{className:`absolute -top-2 -right-2 text-white px-2 py-1 rounded-full text-xs font-medium ${lA(w,r.plan)?"bg-caiBlue-500":"bg-orange-500"}`,children:lA(w,r.plan)?"Upgrade":"Downgrade"}),c.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[H(U),c.jsx("div",{children:c.jsx("h3",{className:`text-lg font-bold ${W&&!D?y?"text-zinc-400":"text-zinc-500":y?"text-zinc-100":"text-zinc-900"}`,children:A.name})})]}),c.jsxs("div",{className:"mb-4",children:[c.jsxs("div",{className:"flex items-baseline space-x-1",children:[c.jsxs("span",{className:`text-3xl font-bold ${W&&!D?y?"text-zinc-400":"text-zinc-500":y?"text-zinc-100":"text-zinc-900"}`,children:["$",B]}),c.jsx("span",{className:`${W&&!D?y?"text-zinc-500":"text-zinc-400":y?"text-zinc-400":"text-zinc-600"}`,children:"/month"})]}),U===Nr.KIPP_CAPITAL&&c.jsx("div",{className:"text-sm font-medium text-caiGreen-600 dark:text-caiGreen-400 mt-1",children:"($0 with valid promo code)"})]}),c.jsx("ul",{className:"space-y-2 mb-2",children:A.features.map(($,q)=>c.jsxs("li",{className:"flex items-center space-x-2 text-sm",children:[c.jsx(Ml,{size:16,className:`flex-shrink-0 ${W&&!D?"text-zinc-400":"text-caiGreen-500"}`}),c.jsx("span",{className:W&&!D?y?"text-zinc-500":"text-zinc-400":y?"text-zinc-300":"text-zinc-700",children:$})]},q))})]},U)},F=x.useMemo(()=>{const U=[];return _?(U.push(Nr.KIPP_CAPITAL),U):j?(U.push(Nr.BASE),U.push(Nr.PRO),U.push(Nr.KIPP_CAPITAL),U):((r==null?void 0:r.plan)===Nr.PRO?U.push(Nr.PRO):(U.push(Nr.BASE),g?U.push(Nr.KIPP_CAPITAL):U.push(Nr.PRO)),U)},[r,g,_,j]),I=()=>s?"Reactivating...":i?"Processing...":w?(r==null?void 0:r.plan)===w?r.cancel_at_period_end?"Reactivate Subscription":"Current Plan":`Switch to ${mC[w].name}`:"Select a Plan",R=()=>{e()};return c.jsx(Vn,{children:t&&c.jsx(Wr,{onClose:R,widthClass:m?"w-[93%]":"w-2/5",heightClass:m?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100",children:[c.jsxs("div",{className:`flex items-center justify-between p-6 border-b ${y?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsx("div",{children:c.jsx("h2",{className:`text-2xl font-bold ${y?"text-zinc-100":"text-zinc-900"}`,children:_?"Your KIPP Capital Subscription":"Upgrade Your Experience"})}),c.jsx("button",{onClick:R,className:`p-2 rounded-lg transition-colors ${y?"hover:bg-zinc-800 text-zinc-400 hover:text-zinc-200":"hover:bg-zinc-100 text-zinc-600 hover:text-zinc-800"}`,children:c.jsx(nr,{size:24})})]}),_&&c.jsx("div",{className:`p-6 border-b ${y?"border-zinc-800 bg-gradient-to-br from-caiPeach-900/20 to-caiPeach-800/10":"border-zinc-200 bg-gradient-to-br from-caiPeach-100/50 to-caiPeach-50/25"}`,children:c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx("div",{className:"flex-shrink-0 mt-1",children:c.jsx("div",{className:"w-8 h-8 rounded-full bg-caiPeach-500 flex items-center justify-center",children:c.jsx(xm,{size:16,className:"text-white"})})}),c.jsxs("div",{className:"flex-1",children:[c.jsx("h3",{className:`text-lg font-semibold mb-2 ${y?"text-caiPeach-300":"text-caiPeach-900"}`,children:"Organization Subscription"}),c.jsxs("p",{className:`text-sm ${y?"text-zinc-300":"text-zinc-700"}`,children:["You have a sponsored subscription provided by your organization. This subscription cannot be modified or cancelled through this portal.",(r==null?void 0:r.subscription_end_date)&&c.jsxs("span",{className:"block mt-2 font-medium",children:["Valid until:"," ",new Date(r.subscription_end_date).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]}),c.jsx("p",{className:`text-xs mt-3 ${y?"text-zinc-400":"text-zinc-600"}`,children:"For questions about your subscription, please contact your organization administrator."})]})]})}),n&&n.takes_used>=n.takes_quota&&!_&&c.jsx("div",{className:`p-6 border-b ${y?"border-zinc-800":"border-zinc-200"}`,children:c.jsxs("p",{className:`text-center text-lg ${y?"text-zinc-300":"text-zinc-600"}`,children:["Keep the ideas flowing! You've used ",n.takes_used,"/",n.takes_quota," takes this month but you can upgrade to continue creating music."]})}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-6 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:[c.jsx("div",{className:`grid gap-6 mb-6 ${F.length===1?"grid-cols-1 max-w-md mx-auto":"grid-cols-1"}`,children:F.map(P)}),a&&c.jsx("div",{className:`mb-4 p-3 rounded-lg border ${y?"bg-red-900/20 border-red-700 text-red-400":"bg-red-100 border-red-300 text-red-700"}`,children:c.jsx("p",{className:"text-sm",children:a})})]}),c.jsx("div",{className:`p-6 border-t ${y?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:c.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[!_&&c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:V,disabled:M,className:`px-8 py-3 rounded-lg font-medium text-lg transition-all duration-200 810 ${M?y?"bg-zinc-700 text-zinc-400 cursor-not-allowed":"bg-zinc-300 text-zinc-600 cursor-not-allowed":"bg-gradient-to-r from-caiBlue-500 to-caiGreen-500 hover:from-caiBlue-600 hover:to-caiGreen-600 text-white shadow-lg hover:shadow-xl"} 811 `,children:i||s?c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent roun
811ded-full animate-spin"}),c.jsx("span",{children:s?"Reactivating...":"Processing..."})]}):I()}),r&&r.plan!==Nr.BASE&&!_&&c.jsx("button",{onClick:async()=>{if(S)try{await u(S)}catch(U){console.error("Error canceling subscription:",U)}},disabled:o||(r==null?void 0:r.cancel_at_period_end),className:`text-xs transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed ${y?"text-zinc-500 hover:text-red-400":"text-zinc-500 hover:text-red-500"}`,children:o?"Canceling...":"Downgrade to Base"}),_&&c.jsx("p",{className:`text-xs text-center ${y?"text-zinc-500":"text-zinc-600"}`,children:"Your subscription is managed by your organization"})]})})]})})})},She=({isOpen:t,onClose:e,countryCode:n})=>{const r=Ix(),{theme:i}=Pn(),{isMobile:s}=Hn(),o=i===gi.Dark,a=d=>({AT:"Austria",BE:"Belgium",BG:"Bulgaria",HR:"Croatia",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",EE:"Estonia",FI:"Finland",FR:"France",DE:"Germany",GR:"Greece",HU:"Hungary",IE:"Ireland",IT:"Italy",LV:"Latvia",LT:"Lithuania",LU:"Luxembourg",MT:"Malta",NL:"Netherlands",PL:"Poland",PT:"Portugal",RO:"Romania",SK:"Slovakia",SI:"Slovenia",ES:"Spain",SE:"Sweden"})[d]||d,l=()=>r?Math.round(r.takes_used/r.takes_quota*100):0,u=d=>d>=90?"text-red-500":d>=75?"text-yellow-500":"text-green-500";return c.jsx(Vn,{children:t&&c.jsx(Wr,{onClose:e,widthClass:s?"w-[93%]":"w-2/5",heightClass:s?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100",children:[c.jsxs("div",{className:`flex items-center justify-between p-6 border-b ${o?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx("div",{className:"w-12 h-12 bg-red-500/20 rounded-full flex items-center justify-center",children:c.jsx(z0,{size:24,className:"text-red-500"})}),c.jsxs("div",{children:[c.jsx("h2",{className:`text-xl font-bold ${o?"text-zinc-100":"text-zinc-900"}`,children:"Upgrade Not Available"}),c.jsx("p",{className:`text-sm ${o?"text-zinc-300":"text-zinc-600"}`,children:"In your region"})]})]}),c.jsx("button",{onClick:e,className:`p-2 rounded-lg transition-colors ${o?"hover:bg-zinc-800 text-zinc-400 hover:text-zinc-200":"hover:bg-zinc-100 text-zinc-600 hover:text-zinc-800"}`,children:c.jsx(nr,{size:24})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:[c.jsx("div",{className:`rounded-lg p-4 bg-gradient-to-br from-zinc-200/50 to-zinc-300/25 dark:from-zinc-900/50 dark:to-zinc-800/25 backdrop-blur-sm border ${o?"border-zinc-700":"border-zinc-200"}`,children:c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx(Yte,{size:20,className:o?"text-zinc-400":"text-zinc-500"}),c.jsxs("div",{children:[c.jsx("p",{className:`text-sm ${o?"text-zinc-400":"text-zinc-600"}`,children:"Your location detected:"}),c.jsxs("p",{className:`font-semibold ${o?"text-zinc-100":"text-zinc-900"}`,children:[a(n)," (",n,")"]})]})]})}),c.jsxs("div",{className:`text-sm space-y-3 ${o?"text-zinc-300":"text-zinc-600"}`,children:[c.jsx("p",{children:"Unfortunately, we're not able to offer paid subscriptions in your region at this time due to regulatory requirements."}),c.jsx("p",{children:"We're actively working on expanding our service to support more countries. Please check back later or contact us for updates."})]}),c.jsxs("div",{className:`rounded-lg p-4 bg-gradient-to-br from-caiBlue-100/50 to-caiBlue-200/25 dark:from-caiBlue-900/20 dark:to-caiBlue-800/25 backdrop-blur-sm border ${o?"border-caiBlue-800/40":"border-caiBlue-200"}`,children:[c.jsx("h3",{className:`font-semibold mb-3 ${o?"text-caiBlue-200":"text-caiBlue-900"}`,children:"What's Still Available"}),c.jsxs("ul",{className:`text-sm space-y-2 ${o?"text-caiBlue-300":"text-caiBlue-800"}`,children:[c.jsxs("li",{className:"flex items-start space-x-2",children:[c.jsx("span",{className:"text-caiBlue-500 mt-0.5",children:"â¢"}),c.jsxs("span",{children:["Free tier with ",(r==null?void 0:r.takes_quota)||48," takes per month"]})]}),c.jsxs("li",{className:"flex items-start space-x-2",children:[c.jsx("span",{className:"text-caiBlue-500 mt-0.5",children:"â¢"}),c.jsx("span",{children:"All core AI music generation features"})]}),c.jsxs("li",{className:"flex items-start space-x-2",children:[c.jsx("span",{className:"text-caiBlue-500 mt-0.5",children:"â¢"}),c.jsx("span",{children:"Community support and resources"})]})]})]}),r&&c.jsxs("div",{className:`rounded-lg p-4 bg-gradient-to-br from-zinc-200/50 to-zinc-300/25 dark:from-zinc-900/50 dark:to-zinc-800/25 backdrop-blur-sm border ${o?"border-zinc-700":"border-zinc-200"}`,children:[c.jsxs("div",{className:"flex justify-between items-center mb-2",children:[c.jsx("span",{className:`text-sm ${o?"text-zinc-300":"text-zinc-600"}`,children:"Your current usage:"}),c.jsxs("span",{className:`text-sm font-semibold ${u(l())}`,children:[r.takes_used," / ",r.takes_quota," takes"]})]}),c.jsx("div",{className:`w-full rounded-full h-2 ${o?"bg-zinc-700":"bg-zinc-200"}`,children:c.jsx("div",{className:`h-2 rounded-full transition-all duration-300 ${l()>=90?"bg-red-500":l()>=75?"bg-yellow-500":"bg-green-500"}`,style:{width:`${Math.min(l(),100)}%`}})}),c.jsxs("p",{className:`text-xs mt-2 ${o?"text-zinc-400":"text-zinc-500"}`,children:[r.takes_quota-r.takes_used," takes remaining this month"]})]})]}),c.jsx("div",{className:`p-6 border-t ${o?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98}
811,onClick:e,className:`w-full py-3 px-4 rounded-lg font-medium transition-colors ${o?"bg-zinc-800 hover:bg-zinc-700 text-zinc-200":"bg-zinc-100 hover:bg-zinc-200 text-zinc-800"}`,children:"Got it"})})]})})})};var tn=(t=>(t.WELCOME="welcome",t.CANVAS="canvas",t.SONG_NODE="song_node",t.BLOOB_NODE="bloob_node",t.TEXT_NODE="text_node",t.EMBEDDING_NODE="embedding_node",t.VISUAL_MEDIA_NODE="visual_media_node",t.SONG_INSPECTOR="song_inspector",t.BLOOB_INSPECTOR="bloob_inspector",t.TEXT_NODE_INSPECTOR="text_node_inspector",t.EMBEDDING_NODE_INSPECTOR="embedding_node_inspector",t.VISUAL_MEDIA_NODE_INSPECTOR="visual_media_node_inspector",t.GLOBAL_INSPECTOR="global_inspector",t.CHAT="chat",t.DETAILS="details",t.MENU="menu",t.PLAYBACK="playback",t.RECORDING="recording",t.NAVIGATION="navigation",t.CREATION="creation",t))(tn||{});const nN=()=>{const[t,e]=x.useState(!1),[n,r]=x.useState(0),[i,s]=x.useState(!1),{addSong:o,addBloob:a,addNotes:l,addTextNode:u,addEmbeddingNode:d,addVisualMediaNode:f}=Gn(),{selectCaiObject:h}=cr(),{commitToStore:m}=Ln(),y=x.useRef([]),g=x.useRef({}),w=x.useCallback(async()=>{if(i)return;const M=window.innerWidth<768,V=M?550:800,H=M?650:600,P=225,F=295,I=375,R=V-I,U=H-P,A=o(ia.key,ia.bpm,ia.timeSignature,{x:R+P/2,y:U+P/2},"Demo Song");let W;HL.forEach((D,B)=>{const L=a(A,{instrument:D.instrument},D.bars,D.songPosition,D.label,D.melodicRole,D.metadata,D.metadataOutdated);B===0&&(W=L);const $=D.notes.map(q=>({pitch:q.pitch,velocity:q.velocity,startBeat:q.startBeat,durationInBeats:q.durationInBeats}));l(L,$)}),u({x:V,y:H-P/8}
811,"Welcome to Cai! ð",`This is your musical canvas where creativity comes to life. 812 813Follow the demo tooltips to continue the tour!`),u({x:V-F,y:H+P/2},"ð¬ Ask Me Anything!","Use the AI chat to ask questions like:<br>⢠'How do I create a jazz chord progression?'<br>⢠'What's the difference between MIDI and audio?'<br>⢠'Can you help me write a pop song?'<br>I can help with music theory, composition, and using Cai!<br>⨠The chat is ALWAYS available - ask me about any feature anytime!"),u({x:V+P/2,y:H-P*2},"ð Complete User Guide","The Usage Manual has everything you need:<br>⢠Step-by-step tutorials<br>⢠Keyboard shortcuts<br>⢠Advanced features<br>⢠Troubleshooting tips<br>Access it from the menu (top-right corner)!<br>ð Use this manual whenever you need detailed help with any Cai feature."),d({x:V+P,y:H-P/2},"Playlist â Getting Started with Cai","https://www.youtube.com/playlist?list=PLtQW2HfB7CHlowbCJHfq8LzmzxNz5eUGR");try{const B=await(await fetch("/icons/cai-logo.png")).blob(),L=new FileReader;L.onload=()=>{const $=L.result;f({x:V+P/8,y:H+P},"Cai Logo",$)},L.readAsDataURL(B)}catch{f({x:V-P/2,y:H+I},"Cai Logo","")}if(u({x:V+F,y:H+P/1.25},"Example Notes","This is an example text node!<br>You can use these for:<br>⢠Song lyrics<br>⢠Chord progressions<br>⢠Creative ideas<br>⢠Project notes<br>Double-click to edit!"),u({x:R-F/2,y:U+P},"ð¡ Tip","Songs are containers that hold your musical tracks (called 'bloobs')"),u({x:R+250,y:U-P/2},"ðµ Try This","Select any track to see development handles for copying/extending.<br>Use Details button for precise editing, or chat to modify it!"),M){const D=/iPad|iPhone|iPod/.test(navigator.userAgent),B=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);D&&B&&u({x:R-P/2,y:U-P/4},"ð iOS Audio","On iOS Safari, make sure your ringer switch is ON to hear audio playback!")}g.current={songId:A,firstBloobId:W},m(),s(!0)},[i,o,a,l,u,d,f,m]),v=x.useCallback(()=>{e(!1),r(0)},[]),S=x.useCallback(()=>{r(0)},[]),C=x.useCallback(()=>{r(M=>{const V=M+1;return V>=y.current.length?(v(),M):V})},[v]),k=x.useCallback(()=>{r(M=>Math.max(0,M-1))},[]),N=x.useCallback(M=>{M>=0&&M<y.current.length&&r(M)}
813,[]),_=x.useCallback(()=>{const{songId:M,firstBloobId:V}=g.current;return[{id:"welcome",title:"Welcome to Cai!",content:"Welcome to your musical playground! This demo will show you all the powerful features available. Let's start by exploring the main workspace.",position:"center",actions:{primary:{text:"Start Tour",action:()=>C()},secondary:{text:"Skip Demo",action:()=>v()}}},{id:"song_overview",title:"Your First Song",content:"This gray container is a SONG - it holds all your musical elements. Each song has its own key, tempo (BPM), and time signature. Click on it to see its properties.",targetSelector:'[aria-label*="Song: Demo Song"]',position:"top",beforeStep:()=>{M&&h({type:J.Song,id:M})},actions:{primary:{text:"Next: Tracks",action:()=>C()}}},{id:"inspectors_overview",title:"Inspector Panel",content:"When you select any element, this inspector panel shows its properties. Here you can see the song's key (C Major), tempo (120 BPM), and controls to organize or duplicate it.",targetSelector:".absolute.w-56.py-2.px-3.rounded-lg",position:"right",actions:{primary:{text:"Next: Tracks",action:()=>C()}}},{id:"bloobs_overview",title:"Musical Tracks (Bloobs)",content:'These colored rectangles are TRACKS (we call them "bloobs"). Each contains musical notes for different instruments like piano, guitar, and drums.',targetSelector:'[title*="Piano Chords"]',position:"bottom",beforeStep:()=>{const H=document.querySelector('[title*="Piano Chords"]');H&&H.scrollIntoView({behavior:"smooth",block:"center"})},actions:{primary:{text:"Select This Track",action:()=>{V&&h({type:J.Bloob,id:V}),C()}}}},{id:"bloob_inspector",title:"Track Inspector",content:"Now you can see the track's properties: instrument (Piano), volume control, mute/solo buttons, and the Details button for advanced editing.",targetSelector:".absolute.w-56.py-2.px-3.rounded-lg",position:"right",actions:{primary:{text:"Next: Development Handles",action:()=>C()}}},{id:"bloob_handles",title:"Development Handles",content:"When a track is selected, these handles appear around it! Use them to copy tracks in different directions, generate AI variations, or extend/retract track length. These handles are your creative expansion tools.",targetSelector:'[title*="Piano Chords"]',position:"bottom",actions:{primary:{text:"Next: Details",action:()=>C()}}},{id:"details_view",title:"Details Editor (Piano Roll)",content:"Click the Details button to open the piano roll editor. This lets you see and edit individual notes, adjust timing, and fine-tune your music with precision.",targetSelector:'[title="Open details editor"]',position:"bottom",actions:{primary:{text:"Try Details View",action:()=>C()}}},{id:"transport_controls",title:"Playback Controls",content:"Use these controls to play your music! The play button starts playback, and you can adjust volume, loop, and create new elements.",targetSelector:'[title*="Play"]',position:"bottom",actions:{primary:{text:"Try Playing",action:()=>C()}}},{id:"ai_chat",title:"AI Assistant",content:'This is where the magic happens! Use natural language to create and modify music. Try typing "make the piano more jazzy" or "add a guitar solo".',targetSelector:"#cai-chat-input",position:"top",actions:{primary:{text:"Try the Chat",action:()=>C()}}},{id:"voice_recording",title:"Voice Recording",content:"Hold the Space key or click the microphone to record your voice. Cai can convert your humming or singing into MIDI notes, or use your voice descriptions to create music!",targetSelector:'[title*="Hold to record voice"]',position:"top",actions:{primary:{text:"Next: File Support",action:()=>C()}}},{id:"file_support",title:"File Format Support",content:"Cai supports many file types: MIDI files (.mid), audio files (MP3, WAV, FLAC), images (JPG, PNG), videos (MP4, MOV), and text files for notes. Simply drag and drop!",targetSelector:'[title*="Upload"]',position:"bottom",actions:{primary:{text:"Next: Drag & Drop",action:()=>C()}}},{id:"drag_drop",title:"Drag & Drop Upload",content:"You can drag files directly onto the canvas! Drop them on songs to add to that song, or on empty space to create new elements. It's the fastest way to add content.",position:"center",actions:{primary:{text:"Next: Export",action:()=>C()}}},{id:"export_features",title:"Export Your Work",content:"Select any song or track and use the export features to save your music as MIDI files, audio recordings, or project data. Perfect for sharing or using in other music software.",targetSelector:'[title*="Export"]',position:"bottom",actions:{primary:{text:"Next: Text Notes",action:()=>C()}}}
813,{id:"text_nodes",title:"Text Notes",content:"These yellow nodes store your ideas, lyrics, chord progressions, or any text. Double-click to edit them!",targetSelector:'[aria-label*="Notes: This is an example"]',position:"left",actions:{primary:{text:"Next: Media",action:()=>C()}}},{id:"visual_media",title:"Visual Media",content:"Add images and videos for inspiration or reference. Great for album artwork, mood boards, or visual concepts.",targetSelector:'[aria-label*="Visual Media"]',position:"left",actions:{primary:{text:"Next: Embeds",action:()=>C()}}},{id:"embeds",title:"Link Embeds",content:"Embed content from YouTube, Spotify, SoundCloud and more for reference and inspiration while you create.",targetSelector:'[aria-label*="Embed"]',position:"left",actions:{primary:{text:"Next: Help",action:()=>C()}}},{id:"help_resources",title:"Help & Resources",content:"Need help? Access the Usage Manual through the menu (top-right) for detailed guides, or simply ask the AI chat any questions about using Cai!",targetSelector:"#sidebar-button",position:"left",actions:{primary:{text:"Final Tips",action:()=>C()}}},{id:"final_tips",title:"You're Ready to Create!",content:"Here are some final tips:<br>⢠Double-click empty space to create new songs<br>⢠Use the chat to describe what you want<br>⢠Try voice recording with Space key<br>⢠Drag and drop files anywhere<br>⢠Press H for keyboard shortcuts<br>⢠Check the Usage Manual for detailed help<br>Your demo content will remain for you to explore.",position:"center",actions:{primary:{text:"Start Creating!",action:()=>v()},secondary:{text:"Restart Tour",action:()=>S()}}}]},[v,C,S,h]),j=x.useCallback(async()=>{await w(),y.current=_(),r(0),e(!0)},[w,_]),T=x.useCallback(()=>y.current[n]||null,[n]);return{isActive:t,currentStepIndex:n,totalSteps:y.current.length,getCurrentStep:T,startDemo:j,endDemo:v,nextStep:C,previousStep:k,goToStep:N,restartDemo:S,isInitialized:i}},GL=()=>{const{generalSettings:t}=bi(),{isFetchingFromCloud:e}=Qh(),{setHasSeenTutorial:n}=il(),{closeWelcome:r}=Br(),{isMobile:i}=Hn(),{isActive:s}=nN(),[o,a]=x.useState(null),[l,u]=x.useState(new Set),[d,f]=x.useState(!1),h=x.useRef(!0),m=x.useRef(!1),[y,g]=x.useState(!1);x.useEffect(()=>{if(e){g(!1),m.current=!1,h.current=!0;return}if(y)return;if((h.current&&!e||!h.current&&!e)&&!m.current){m.current=!0;const T=setTimeout(()=>{g(!0),m.current=!1},3e3);return()=>{clearTimeout(T),m.current=!1}}h.current=e},[e,y]),x.useEffect(()=>{e||!y||(t.hasSeenTutorial?f(!1):f(!s))},[t.hasSeenTutorial,s,e,y]),x.useEffect(()=>{if(!(e||!y)){if(t.hasSeenTutorial&&o===tn.WELCOME){a(null),f(!1);return}!t.hasSeenTutorial&&!o&&d&&!s&&a(tn.WELCOME)}},[t.hasSeenTutorial,o,d,s,e,y]);const w=x.useMemo(()=>[{step:tn.CANVAS,selectors:["#cai-flow",".react-flow__pane"]},{step:tn.SONG_NODE,selectors:['[aria-label*="Song:"]']},{step:tn.BLOOB_NODE,selectors:['[title*="Bloob"]','.drag-handle[title*="click to open details"]']},{step:tn.TEXT_NODE,selectors:['[aria-label*="Notes:"]']},{step:tn.EMBEDDING_NODE,selectors:['[aria-label*="Embed:"]']},{step:tn.VISUAL_MEDIA_NODE,selectors:['[aria-label*="Visual Media:"]']},{step:tn.SONG_INSPECTOR,selectors:['[id*="song-label-"]','[id*="song-bpm-"]','[id*="song-key-"]'],parentSelectors:[".absolute.w-56.py-2.px-3.rounded-lg"]},{step:tn.BLOOB_INSPECTOR,selectors:['[id*="bloob-label-"]','[id*="bloob-volume-"]'],parentSelectors:[".absolute.w-56.py-2.px-3.rounded-lg"]},{step:tn.TEXT_NODE_INSPECTOR,selectors:['[id*="notes-node-label-"]'],parentSelectors:[".absolute.w-56.py-2.px-3.rounded-lg"]},{step:tn.EMBEDDING_NODE_INSPECTOR,selectors:['[id*="embedding-node-label-"]'],parentSelectors:[".absolute.w-56.py-2.px-3.rounded-lg"]},{step:tn.VISUAL_MEDIA_NODE_INSPECTOR,selectors:['[id*="visual-media-node-label-"]'],parentSelectors:[".absolute.w-56.py-2.px-3.rounded-lg"]},{step:tn.GLOBAL_INSPECTOR,selectors:['[title*="Play"]','[title*="Pause"]','[title*="Volume"]','[title*="Loop"]','[title*="Metronome"]']},{step:tn.CHAT,selectors:["#cai-chat-input",".chatBoxContainer",".promptContainer"]},{step:tn.DETAILS,selectors:['[title="Delete Bloob"]','[title="Delete Song"]','[title="Delete Notes"]']},{step:tn.MENU,selectors:['[aria-label*="menu"]','[title*="menu"]']},{step:tn.RECORDING,selectors:['[title*="Record"]','[title*="recording"]']},{step:tn.CREATION,selectors:['[title*="Create"]','[title*="New"]']}],[]),v=x.useCallback(()=>{f(!1),a(null),r(),n(!0)},[n,r]);x.useEffect(()=>{if(!d||s)return;const j=T=>{const M=T.target;if(M)for(const{step:V,selectors:H,parentSelectors:P}of w){if(l.has(V)||V===tn.WELCOME)continue;const F=H.some(R=>{try{return M.matches(R)||M.closest(R)}catch{return!1}}),I=P?P.some(R=>{try{const U=M.closest(R);return U&&H.some(A=>{try{return U.querySelector(A)}catch{return!1}})}catch{return!1}}):!1;if(F||I){a(V);break}}};return document.addEventListener("click",j,!0),()=>document.removeEventListener("click",j,!0)},[d,s,l,w]);const S=x.useCallback(j=>{const T=()=>{u(H=>new Set([...H,j]));const V=S(j);V.nextStep&&!l.has(V.nextStep)?a(V.nextStep):a(null),j===tn.WELCOME&&r()};return{[tn.WELCOME]:{id:tn.WELCOME,title:"Welcome to Cai",content:"Cai is an AI-powered music co-composer that helps you create and manipulate musical ideas through an intuitive visual interface.",allowSkip:!0,nextStep:tn.CANVAS,actions:{primary:{text:"Let's get started!",action:T},secondary:{text:"Skip tutorial",action:v}}},[tn.CANVAS]:{id:tn.CANVAS,title:"Canvas Navigation",content:i?"Navigate the canvas using touch gestures: pinch to zoom, drag to pan, tap to
813select. Double-tap empty space to create new elements.":"Navigate using mouse: scroll to zoom, drag to pan, click to select. Double-click empty space to create new elements.",allowSkip:!0,nextStep:tn.CREATION,actions:{primary:{text:"Next",action:T}}},[tn.SONG_NODE]:{id:tn.SONG_NODE,title:"Working with Songs",content:"Songs are containers for musical elements. Each has its own key, tempo, and time signature. Click to select, double-click inside to add tracks.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.BLOOB_NODE]:{id:tn.BLOOB_NODE,title:"Working with Tracks (Bloobs)",content:"Tracks contain musical phrases like melodies, bass lines, or drums. Each has its own instrument. Click to select, drag to move, double-click to edit. Development handles appear around selected tracks for copying and extending.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.TEXT_NODE]:{id:tn.TEXT_NODE,title:"Text Notes",content:"Text nodes store your ideas, lyrics, or project notes. Double-click to edit content, drag to reposition on the canvas.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.EMBEDDING_NODE]:{id:tn.EMBEDDING_NODE,title:"Link Embeds",content:"Embed links from YouTube, Spotify, or other platforms for reference. Double-click to add or change the URL.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.VISUAL_MEDIA_NODE]:{id:tn.VISUAL_MEDIA_NODE,title:"Visual Media",content:"Add images or videos for visual reference and inspiration. Double-click to upload new media files.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.SONG_INSPECTOR]:{id:tn.SONG_INSPECTOR,title:"Song Inspector",content:"Control song properties: change key and tempo, adjust time signature, organize tracks, and duplicate or delete songs.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.BLOOB_INSPECTOR]:{id:tn.BLOOB_INSPECTOR,title:"Track Inspector",content:"Control track properties: adjust volume, change instruments, mute/solo, record MIDI, and access detailed editing.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.TEXT_NODE_INSPECTOR]:{id:tn.TEXT_NODE_INSPECTOR,title:"Notes Inspector",content:"Edit note properties: change title, preview content, and duplicate or delete text nodes.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.EMBEDDING_NODE_INSPECTOR]:{id:tn.EMBEDDING_NODE_INSPECTOR,title:"Link Inspector",content:"Manage embedded links: change URL, view platform details, and control embed settings.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.VISUAL_MEDIA_NODE_INSPECTOR]:{id:tn.VISUAL_MEDIA_NODE_INSPECTOR,title:"Media Inspector",content:"Control visual media: change media files, play videos, and manage media properties.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.GLOBAL_INSPECTOR]:{id:tn.GLOBAL_INSPECTOR,title:"Transport Controls",content:"Control playback: play/pause, adjust master volume, toggle metronome and loop, create new elements.",allowSkip:!0,nextStep:tn.PLAYBACK,actions:{primary:{text:"Next",action:T}}},[tn.CHAT]:{id:tn.CHAT,title:"AI Chat Assistant",content:'Use natural language to create music. Describe what you want: "Create a jazz piano melody" or "Make an upbeat pop song". Use the microphone for voice input.',allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.DETAILS]:{id:tn.DETAILS,title:"Detailed Editing",content:"Access advanced editing features for precise control over your musical elements and their properties.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.MENU]:{id:tn.MENU,title:"Application Menu",content:"Access settings, export options, file management, and other application features through the main menu.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.PLAYBACK]:{id:tn.PLAYBACK,title:"Playback Features",content:"Control audio playback with play/pause, looping, and volume controls. The playhead shows current position during playback.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.RECORDING]:{id:tn.RECORDING,title:"Recording Audio",content:"Record MIDI or audio directly into your tracks. Use voice recording or connect MIDI instruments for live input.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.NAVIGATION]:{id:tn.NAVIGATION,title:"Canvas Navigation",content:"Navigate the canvas efficie
813ntly using zoom, pan, and selection tools. Use keyboard shortcuts for faster workflow.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}},[tn.CREATION]:{id:tn.CREATION,title:"Creating Elements",content:"Create new elements by double-clicking empty space, using the plus button, or through the AI chat assistant.",allowSkip:!0,actions:{primary:{text:"Close",action:T}}}}[j]},[i,l,r,v]),C=x.useCallback(()=>{if(o){u(T=>new Set([...T,o]));const j=S(o);j.nextStep&&!l.has(j.nextStep)?a(j.nextStep):a(null),o===tn.WELCOME&&r()}},[o,l,r,S]),k=x.useCallback(()=>{o&&(u(j=>new Set([...j,o])),a(null),o===tn.WELCOME&&r())},[o,r]),N=x.useCallback(j=>{d&&!s&&a(j)},[d,s]),_=x.useCallback(()=>{n(!1),u(new Set),a(tn.WELCOME)},[n]);return{currentStep:o,seenSteps:l,isWizardActive:d,completeStep:C,skipStep:k,triggerStep:N,endWizard:v,resetWizard:_,getStepData:S}},Che=({isOpen:t,onClose:e})=>{const{theme:n}=Pn(),r=n===gi.Dark,{isMobile:i}=Hn(),[s,o]=x.useState("getting-started"),[a,l]=x.useState(new Set(["getting-started"])),[u,d]=x.useState(""),[f,h]=x.useState(!1),[m,y]=x.useState(!1),g=()=>{m||(y(!0),h(C=>{const k=!C;return localStorage.setItem("cai-usage-manual-quick-tips",JSON.stringify(k)),k}))},w=C=>{l(k=>{const N=new Set(k);return N.has(C)?N.delete(C):N.add(C),N})};x.useEffect(()=>{const C=localStorage.getItem("cai-usage-manual-quick-tips");C&&h(JSON.parse(C))},[]);const v=x.useMemo(()=>[{id:"getting-started",title:"Getting Started",icon:c.jsx(bD,{className:"size-4"}),content:[{title:"Canvas Navigation",description:"Learn how to navigate the main workspace",details:["Desktop: Use mouse scroll wheel to zoom in/out","Desktop: Click and drag to pan around the canvas","Mobile: Pinch to zoom, drag with one finger to pan","Click on empty space to deselect all items","Double-click empty space to create new elements","Use the minimap (bottom-right) for quick navigation on desktop"]},{title:"First Steps",description:"Your journey into music creation",details:["Double-click anywhere on the canvas to create your first song","Or use the + button in the transport bar to create new elements","Songs appear as gray containers that hold musical tracks","Each song has its own key, tempo (BPM), and time signature","Start with simple 4/4 time signature and 120 BPM for beginners"]}]},{id:"cai-chat",title:"Cai Chat Assistant",icon:c.jsx(uo,{className:"size-4"}),content:[{title:"Chat Basics",description:"Communicate with Cai using natural language",details:["Chat box appears at the bottom of the screen",'Type requests like "Create a jazz piano melody"','Ask for specific genres: "Make a reggae bass line"','Request chord progressions: "Add a C-Am-F-G progression"','Describe moods: "Create something dark and mysterious"',"Press Enter to send messages, C key to focus chat"]},{title:"Song Creation Commands",description:"Create new songs from scratch with AI",details:['Start new songs: "Create a hip hop beat with drums and bass"','Specify genres: "Make a jazz song with piano and trumpet"','Request multiple instruments: "Give me a rock song with guitar, bass, and drums"','Set musical parameters: "Create a song in C major at 120 BPM"','Describe styles: "Make something that sounds like The Beatles"','Use artist references: "Create a Miles Davis style jazz piece"']},{title:"Adding Content to Songs",description:"Expand existing songs with new musical elements",details:['Add instruments: "Add a bass line to this song"','Layer parts: "Put a guitar solo on top"','Complement existing parts: "Add drums that go with the piano"','Request harmonies: "Add strings that harmonize with the melody"','Specify placement: "Add a trumpet at bar 5"','Create arrangements: "Layer a choir over the existing parts"']},{title:"Editing and Modifying Content",description:"Transform existing musical parts with precision",details:['Change instruments: "Change the piano to a guitar"','Modify styles: "Make the drums more aggressive"','Transpose music: "Move this up an octave"','Adjust patterns: "Make the bass line more syncopated"','Regenerate content: "Give me a different version of this melody"','Apply effects: "Make the guitar sound more distorted"']},{title:"Copying and Duplicating",description:"Replicate musical sections and patterns",details:['Duplicate parts: "Copy this piano section t
813wice"','Repeat with spacing: "Copy the drums every 4 bars"','Specific positioning: "Copy the bass from bar 1 to bar 9"','Multiple copies: "Duplicate this melody 3 times"','Group copying: "Copy the piano and drums together"','Pattern extension: "Repeat this section throughout the song"']},{title:"Deletion and Cleanup",description:"Remove unwanted musical elements",details:['Delete specific parts: "Remove the piano"','Clear by position: "Delete everything on track 2"','Remove by ID: "Delete bloob 3"','Mass deletion: "Delete all the drums"','Selective removal: "Remove the guitar but keep the bass"','Clean slate: "Delete everything and start over"']},{title:"Song Structure Editing",description:"Modify overall song properties and arrangements",details:['Change tempo: "Make this song faster" or "Set BPM to 140"','Adjust key: "Change the key to G major"','Modify time signature: "Switch to 3/4 time"',`Rename songs: "Call this song 'Jazz Fusion'"`,'Global changes: "Apply swing feel to the entire song"','Structural edits: "Add an intro and outro to this song"']},{title:"Music Theory and Education",description:"Learn about music theory and get expert guidance",details:['Theory questions: "What is a chord progression?"','Key analysis: "What key is this song in?"','Scale information: "Tell me about the blues scale"','Harmony help: "How do I create a jazz chord progression?"','Rhythm guidance: "What makes a good drum pattern?"','Composition tips: "How do I write a good melody?"']},{title:"Application Help and Support",description:"Get assistance with using Cai features",details:['Feature guidance: "How do I export my song?"','Interface help: "How do I switch to dark mode?"','Workflow tips: "How do I organize my bloobs?"','Keyboard shortcuts: "What are the hotkeys for playback?"','Account questions: "How do I upgrade my subscription?"',`Technical support: "Why isn't my MIDI controller working?"`]},{title:"Voice Input",description:"Speak your musical ideas naturally",details:["Click the microphone button to start voice recording","Hold Space key to record voice (desktop)","Speak clearly and describe what you want to create","Voice input works for melodies, rhythms, and creative requests","You can hum melodies that Cai will try to interpret","Release Space or click microphone again to stop recording"]},{title:"Chat Controls and Interface",description:"Manage your conversation experience",details:["T key toggles between minimized, default, and maximized chat","Maximize chat for longer conversations and detailed requests","Chat remembers context within the current session","Drag the chat resize handle to adjust width","Position chat on left or right side of screen","Clear conversations by refreshing or resetting Cai"]},{title:"Advanced AI Capabilities",description:"Sophisticated musical understanding and generation",details:['Context awareness: "Make the drums match the bass style"','Multiple variations: "Give me 3 different versions of this melody"','Technical precision: "Add a guitar solo in E minor pentatonic"','Layering intelligence: "Add strings that complement the piano"','Style matching: "Make this sound more like reggae"','Structural composition: "Create a bridge that contrasts the verse"']},{title:"Smart Intent Recognition",description:"Natural language understanding for complex requests",details:['Multi-action requests: "Add bass, change piano to guitar, and copy drums"','Contextual editing: "Make the selected part more jazzy"','Conditional operations: "If this is in C major, transpose to D major"','Reference-based edits: "Make the new part match the existing drums"','Sequential instructions: "First add bass, then copy it twice"','Preference learning: "Remember I like dark, atmospheric sounds"']},{title:"Collaborative Features",description:"Work together with AI as your musical partner",details:['Creative suggestions: "What should I add next to this song?"','Style guidance: "How can I make this more interesting?"','Arrangement ideas: "What instruments work well with piano and drums?"',`Problem solving: "This doesn't sound right, can you fix it?"`,'Inspiration: "Give me ideas for a chorus melody"','Feedback: "Does this chord progression work well?"']}]},{id:"songs",title:"Working with Songs",icon:c.jsx(Mn,{className:"size-4"}),content:[{title:"Creating Songs",description:"Songs are containers for your musical ideas",details:["Double-click empty canvas space to create a new song","Each song has a musical key (like C Major or A Minor)","Set the tempo (BPM) - common values: 80 (slow), 120 (medium), 140 (fast)","Time signature controls the beat structure (4/4 is most common)","Songs automatically resize as you add more tracks and bars"]},{title:"Song Properties",description:"Customize your song settings",details:["Click a song to select it and see the inspector on the left","Edit the song name by clicking on the title","Drag the BPM slider to change tempo (30-300 BPM)","Click the key signature to change the musical key","Click Major/Minor to switch between key qualities","Time signature shows as fractions (4/4, 3/4, 6/8, etc.)"]},{title:"Song Controls",description:"Manage and organize your songs",details:["Organize button: Automatically arranges tracks neatly","Copy button: Duplicates the entire song with all tracks","Drag songs around the canvas to reposition them","Resize songs by dragging the edges (desktop) or corners (mobile)","Delete songs using the red trash icon (this removes all tracks inside)"]}]},{id:"bloobs",title:"Working with Tracks (Bloobs)",icon:c.jsx(Qf,{className:"size-4"}),content:[{title:"Understanding Bloobs",description:"Bloobs are individual musical tracks within songs",details:["Bloobs contain musical phrases like melodies, bass lines, chords, or drums","Each bloob has its own instrument and sound settings","MIDI bloobs use virtual instruments and can be edited note-by-note","Audio bloobs contain recorded audio files or samples","Bloobs are colored and labeled for easy identification"]},{title:"Creating Bloobs",description:"Add musical tracks to your songs",details:["Double-click inside a song container to create a new track","Use the + button while a song is selected to add tracks","Choose between MIDI (virtual instruments) or Audio (recorded files)","Select an instrument from the dropdown menu","Set the track length in bars (1, 4, 8, 16, etc.)","Upload MIDI files (.mid) or audio files (MP3, WAV, etc.)"]},{title:"Bloob Controls",description:"Adjust and control your tracks",details:["Volume slider: Control how loud the track plays (0-100%)","Mute button: Temporarily silence the track (M key)","Solo button: Play only this track, muting all others (S key)","Instrument selector: Change the virtual instrument or audio type","Record button: Record MIDI input from connected devices (R key)","For audio bloobs: Set original key and BPM for better sync"]},{title:"Bloob Development",description:"Expand and develop your musical ideas",details:["Development handles appear when you select a bloob","Copy buttons (square icon): Duplicate the bloob in different directions","AI buttons (sparkles icon): Generate new musical content","Extend mode: Copy or AI-extend the bloob content within the same track","Before/After: Add content to the beginning or end of the track","Below: Create a new track underneath with related content"]},{title:"Advanced Bloob Features",description:"Professional editing capabilities",details:["Resize bloobs by dragging the left/right edges (MIDI only)","Use Details button to access advanced note editing","Transpose bloobs when changing song key","Extend button: Increase track length
813while preserving content","Copy button: Duplicate track to another position","Delete with Backspace key or trash icon"]}]},{id:"details",title:"Bloob Details Editor (Piano Roll)",icon:c.jsx(Mn,{className:"size-4"}),content:[{title:"Piano Roll Interface",description:"Advanced note editing environment",details:["Click Details button on any MIDI bloob to open the piano roll","Visual representation of musical notes on a timeline","Horizontal axis represents time (beats/bars)","Vertical axis represents pitch (musical notes)","Background grid shows beat divisions and pitch levels","Colored notes indicate relationship to the song key"]},{title:"Note Creation and Selection",description:"Working with individual notes",details:["Double-click on the grid to create new notes","Click notes to select them (single selection)","Cmd/Ctrl+click to select multiple notes","Drag to create selection boxes around multiple notes","Selected notes are highlighted in blue","Click empty space to deselect all notes"]},{title:"Note Editing",description:"Modify note properties and positions",details:["Drag notes horizontally to change timing","Drag notes vertically to change pitch","Resize note tails by dragging the right edge","Hold Alt/Option and drag note head to adjust velocity","Arrow keys: Move selected notes by semitone/beat","Cmd/Ctrl+Arrow keys: Move by octave/larger intervals"]},{title:"Piano Roll Playback",description:"Hear your changes in real-time",details:["Play button: Start/stop playback of the current bloob","Space bar: Quick play/pause toggle","Record button: Capture MIDI input while playing","Playhead shows current position during playback","Notes light up when playing for visual feedback","Volume and mute controls affect playback"]},{title:"Mobile Piano Roll",description:"Touch-optimized editing",details:["Floating controls appear when notes are selected","Arrow buttons for precise note movement","Plus/Minus buttons for note duration adjustment","Touch and drag for note repositioning","Pinch to zoom for detailed editing","Delete button for selected notes"]}]},{id:"playback",title:"Transport & Playback",icon:c.jsx(ka,{className:"size-4"}),content:[{title:"Transport Controls",description:"Control playback and recording",details:["Play/Pause button: Start and stop playback (Space key)","Master volume slider: Control overall output level","Loop button: Enable continuous playback of selected content","Metronome: Click to cycle through Off/Always On/Recording Only","Create button (+): Add new songs, tracks, notes, or media","Transport bar appears at the top center of the screen"]},{title:"Playback Features",description:"Advanced playback options",details:["Select items before playing to start from that location","Playhead (vertical line) shows current playback position","Loop mode repeats the selected content continuously","Master volume affects all tracks simultaneously","Indiv
813idual track volumes can be adjusted independently","Muted tracks are excluded from playback"]},{title:"Recording",description:"Capture your musical performances",details:["Connect MIDI keyboards or controllers via USB","Select a MIDI bloob and press R to start recording","Recording automatically starts playback for timing","Voice recording captures audio through your microphone","Snap to Grid: Quantize notes to beat divisions","Snap to Key: Correct voice input to the song's key"]}]},{id:"text-nodes",title:"Text Notes",icon:c.jsx($i,{className:"size-4"}),content:[{title:"Creating Notes",description:"Document your musical ideas",details:['Double-click empty space and select "New Notes"',"Or use the + button and choose text notes","Notes appear as yellow containers on the canvas","Perfect for lyrics, chord charts, and project notes","Resize notes by dragging corners or edges"]},{title:"Editing Notes",description:"Add and modify text content",details:["Double-click a note to enter edit mode","Type any text content - lyrics, chords, ideas","Press Cmd/Ctrl+Enter to save changes","Press Escape to cancel editing","Click outside the note to save automatically","Change the note title in the inspector panel"]},{title:"Note Management",description:"Organize your text content",details:["Drag notes around the canvas to organize them","Copy notes using the inspector Copy button","Delete notes with the red trash icon","Preview content shows in the inspector when selected","Line count displayed in inspector for multi-line notes"]}]},{id:"embedding-nodes",title:"Link Embeds",icon:c.jsx(Ka,{className:"size-4"}),content:[{title:"Supported Platforms",description:"Embed content from music platforms",details:["YouTube: Embed videos for reference and inspiration","Spotify: Add tracks, albums, and playlists","SoundCloud: Share tracks and user content","Apple Music: Link to songs and albums","Bandcamp: Support independent artists","Other platforms: Deezer, Tidal, Amazon Music"]},{title:"Creating Embeds",description:"Add external content to your project",details:['Double-click empty space and select "New Link"',"Paste a URL from supported music platforms","Content automatically detects platform and formats embed","Change the embed title in the inspector","Click the external link icon to open in new tab"]},{title:"Browser Compatibility",description:"Platform-specific behaviors",details:["Chrome/Firefox: Full embedding support with audio/video","Safari: Limited embedding - shows open link option instead","Mobile browsers: May have restricted embedding capabilities","All browsers support opening links in new tabs","Embedded content respects platform privacy settings"]}]},{id:"visual-media",title:"Visual Media",icon:c.jsx(Gs,{className:"size-4"}),content:[{title:"Supported Formats",description:"Add images and videos to your project",details:["Images: JPG, PNG, GIF, WebP, BMP, SVG","Videos: MP4, WebM, OGG, AVI, MOV, WMV, FLV, MKV","Drag and drop files directly onto media nodes","Click to upload or use the file picker","Media automatically scales to fit the container"]},{title:"Media Controls",description:"Manage your visual content",details:['Double-click empty space and select "New Media"',"Upload images for visual inspiration and mood boards","Videos can be played/paused with click controls","Resize media nodes by dragging corners","Export link opens media in full resolution","Change media files by uploading new content"]},{title:"Creative Uses",description:"Inspiration and workflow tips",details:["Add album artwork for song references","Include video references for music video concepts","Create mood boards with multiple images","Document live performances with video recordings","Store visual inspiration for creative projects"]}]},{id:"file-upload",title:"File Upload & Management",icon:c.jsx(wc,{className:"size-4"}),content:[{title:"Upload Methods",description:"Multiple ways to add files to your project",details:["Use the Upload button in the top menu","Drag and drop files directly onto the canvas","Use Cmd/Ctrl+U keyboard shortcut","Upload from the + button in transport bar","Supports batch uploading of multiple files"]},{title:"Supported File Types",description:"Wide range of compatible formats",details:["MIDI Files: .mid format for musical data","Audio Files: MP3, WAV, FLAC, OGG, AAC, M4A, AIFF","Image Files: JPG, PNG, GIF, WebP, BMP, SVG","Video Files: MP4, MOV, AVI, MKV, WebM","Text Files: TXT, MD, RTF for notes and lyrics"]},{title:"Upload Options",description:"Choose how files are processed",details:["To Existing Song: Add f
813iles to currently selected song","Single Song: Combine all audio/MIDI into one song","Multiple Songs: Create separate songs for each file","Visual Media: Add images/videos to canvas","Notes: Convert text files to note nodes","Links: Embed URLs for music platform content"]},{title:"Drag & Drop Behavior",description:"Smart file handling based on context",details:["Drop on song: Files added to that song","Drop on canvas: Creates new songs or nodes","MIDI files become MIDI bloobs with instruments","Audio files become audio bloobs with automatic tempo detection","Images/videos become visual media nodes","Text files become note nodes with content"]}]},{id:"account-system",title:"Account & Subscription",icon:c.jsx(wm,{className:"size-4"}),content:[{title:"Account Management",description:"Manage your Cai account settings",details:["Access account settings through the menu","Update profile information and display name","Change password with current password verification","Email verification status shown in profile","Account deletion option in danger zone","Export account data before deletion"]},{title:"Subscription Plans",description:"Choose the right plan for your needs",details:["Base Plan: 48 takes per month, core features","Pro Plan: 500 takes per month, priority support","Takes reset monthly on your billing date","Unused takes do not roll over to next month","Upgrade/downgrade anytime from account menu","Payment processing through secure Stripe integration"]},{title:"Usage Tracking",description:"Monitor your monthly usage",details:["Takes counter shows remaining monthly allowance","Color-coded indicators: green (plenty), yellow (moderate), red (low)","Usage resets on your monthly billing cycle","Upgrade prompts when approaching limits","Real-time usage updates after each request","Historical usage data in account dashboard"]},{title:"Regional Availability",description:"Subscription availability by location",details:["Full subscription access in supported regions","Base plan available worldwide","Regional restrictions due to payment processing","Contact support for region-specific questions","Free tier available in all regions","Expansion to new regions ongoing"]}]},{id:"application-controls",title:"Application Controls",icon:c.jsx(Pte,{className:"size-4"}),content:[{title:"Menu System",description:"Access all application features",details:["Hamburger menu in top-right corner","Settings: Configure app preferences","Account: Manage profile and subscription","Upload: Add files to your project","About: Version info and credits","Help & Support: Documentation and contact"]},{title:"History & Undo",description:"Never lose your work",details:["Undo/Redo buttons in desktop top-left corner","Cmd/Ctrl+Z for undo, Cmd/Ctrl+Shift+Z for redo","Comprehensive history tracking for all actions","Automatic commit points for major operations","History preserved during session","Reset option clears all data and history"]},{title:"Search Functionality",description:"Find content quickly across your project",details:["Search button in top controls","Find songs, bloobs, notes, and media","Filter results by content type","Preview content before opening","Quick navigation to search results","Keyboard shortcut for quick access"]},{title:"Auto-Save & Data",description:"Your work is automatically preserved",details:["Continuous auto-save of all changes","Data stored locally in browser","No manual save required","Export functionality for backup","Reset clears all local data","Import/export for project sharing"]}]},{id:"settings",title:"Settings & Preferences",icon:c.jsx(cE,{className:"size-4"}),content:[{title:"General Settings",description:"Core application preferences",details:["Default Instrument: Set preferred virtual instrument","Drag Snap Grid: Control bloob positioning precision","Piano Roll Scrolling: Auto-follow during playback","Settings organized in collapsible sections","Changes apply immediately without restart","Reset to defaults option available"]},{title:"Audio Settings",description:"Configure sound and playback",details:["Master Volume: Overall application audio level","Metronome: Configure click track settings","Metronome Volume: Separate volume control","Metronome Sound: Choose from available instruments","Metronome Pitch: Set the click note","Recording settings for MIDI input"]}
813,{title:"Appearance Settings",description:"Customize the visual experience",details:["Theme Selection: Light, Dark, or Auto (system)","Auto theme follows system preferences","Instant theme switching without reload","Bloob ID Display: Toggle ID visibility","Color schemes adapt to selected theme","High contrast options for accessibility"]},{title:"Advanced Settings",description:"Power user options and data management",details:["Data Reset: Clear all application data","Confirmation required for destructive actions","Export settings and data before reset","Developer options in debug builds","Performance optimization settings","Backup and restore functionality"]}]},{id:"keyboard-shortcuts",title:"Keyboard Shortcuts",icon:c.jsx(aE,{className:"size-4"}),content:[{title:"Playback Controls",description:"Quick access to transport functions",details:["Space: Play/Pause (or hold for voice recording)","M: Mute selected bloob","S: Solo selected bloob","R: Record MIDI to selected bloob","L: Toggle loop mode","C: Focus chat input"]},{title:"Navigation & Selection",description:"Move around and select elements",details:["Arrow Keys: Move selected bloob or navigate between bloobs","T: Toggle chat size (minimized/default/maximized)","Backspace: Delete selected item","Esc: Deselect all items","Tab: Switch between elements","Enter: Confirm edits and inputs","Cmd/Ctrl+A: Select all items","Cmd/Ctrl+click: Multi-select items"]},{title:"Editing & Creation",description:"Modify and create content",details:["Cmd/Ctrl+A: Select all items","Cmd/Ctrl+click: Multi-select items","Cmd/Ctrl+C: Copy selected item","Cmd/Ctrl+V: Paste copied item","Cmd/Ctrl+Z: Undo last action","Cmd/Ctrl+Shift+Z: Redo action","Cmd/Ctrl+E: Export selected content","D: Open bloob details editor"]},{title:"Application Controls",description:"Manage the application",details:["H: Show hotkeys reference","Cmd/Ctrl+U: Open file upload dialog","Cmd/Ctrl+/: Toggle bloob ID display","Alt+Shift+E: Export application data","F: Focus canvas (from any input)","Menu button: Access application settings"]},{title:"Piano Roll Shortcuts",description:"Advanced editing in bloob details",details:["Double-click: Create new note","Cmd/Ctrl+click: Multi-select notes","Arrow keys: Move selected notes","Cmd/Ctrl+Arrow: Move by octave/large intervals","Alt+drag: Adjust note velocity","Drag note tail: Change note duration"]}]},{id:"mobile-usage",title:"Mobile Usage",icon:c.jsx(Qne,{className:"size-4"}),content:[{title:"Touch Navigation",description:"Navigate on mobile devices",details:["Pinch to zoom in and out on the canvas","Drag with one finger to pan around","Tap to select items","Double-tap to edit or create elements","Tap empty area to deselect all items","Long press for context menus (where available)"]},{title:"Mobile Interface",description:"Optimized mobile experience",details:["Inspector panel appears above chat on mobile","Larger touch targets for easier interaction","Simplified menus with touch-friendly buttons","Swipe gestures for certain navigation","Auto-hide keyboard when not needed","Responsive design adapts to screen size"]},{title:"Mobile Chat",description:"AI assistant on mobile devices",details:["Full-screen chat modal on mobile","Voice recording with touch controls","Expandable chat for longer conversations","Quick action buttons for media creation","Touch-optimized text input","Mobile-specific UI animations"]},{title:"iOS Audio Settings",description:"Audio playback on iOS devices",details:["On iOS Safari, ensure your ringer switch is ON to hear audio","Check that your device is not in silent mode","Volume buttons control app audio during playback","Some iOS versions may require user interaction before audio plays","Use headphones for best audio experience on mobile","Audio may have slight delay compared to desktop browsers"]},{title:"Mobile Limitations",description:"Platform-specific considerations",details:["Some keyboard shortcuts not available","Voice recording may require permissions","File upload limited to device capabilities","Some advanced editing features simplified","External link embeds may have restrictions","Audio latency may vary by device"]}]},{id:"advanced-features",title:"Advanced Features",icon:c.jsx(pre,{className:"size-4"}),content:[{title:"Audio Settings",description:"Configure audio preferences",details:["Master volume controls overall output level","Individual track volumes for mixing","Metronome settings for timing reference","Audio device selection in system settings","Latency compensation for recording","Sample rate and buffer size optimization"]},{title:"Project Management",description:"Organize and save your work",details:["Auto-save preserves work continuously","Export projects as MIDI, audio, or data files","Import existing MIDI and audio files","Copy and paste between different songs","Organize content with labels and colors","Re
813set function clears all data (use carefully!)"]},{title:"Search & Discovery",description:"Find content quickly",details:["Search button finds songs, tracks, notes, and media","Filter by content type (songs, notes, links, media)","Quick navigation to any element in your project","Preview content details before opening","Organized results with thumbnails and descriptions"]},{title:"Collaboration Features",description:"Share and collaborate on projects",details:["Export functionality for sharing projects","Link embeds for reference sharing","Visual media for mood and concept sharing","Text notes for communication and documentation","Standardized formats for cross-platform compatibility"]}]},{id:"troubleshooting",title:"Troubleshooting",icon:c.jsx(Kc,{className:"size-4"}),content:[{title:"Common Issues",description:"Solutions to frequent problems",details:["No audio: Check browser permissions and device volume","iOS Safari: Ensure ringer switch is ON for audio playback","Lag or performance: Reduce browser tabs and close other apps","MIDI not working: Ensure device is connected and recognized","Voice recording fails: Grant microphone permissions","Files won't upload: Check file size and format restrictions","Content not saving: Ensure stable internet connection"]},{title:"Browser Compatibility",description:"Optimal browser settings",details:["Chrome: Best performance and full feature support","Firefox: Good performance with most features","Safari: Limited embedding capabilities","Edge: Good compatibility with minor limitations","Mobile browsers: Simplified feature set","Enable JavaScript and allow audio/microphone access"]},{title:"Performance Tips",description:"Optimize your experience",details:["Close unnecessary browser tabs and applications","Use a stable internet connection for best results","Restart browser if experiencing slowdowns","Clear browser cache if content doesn't load","Update to the latest browser version","Use headphones to prevent audio feedback"]},{title:"Reset and Recovery",description:"When things aren't working correctly",details:["Refresh the page to reset app state without losing data","Auto-save protects your work during page refreshes","Try your action again after refreshing if it failed","Hard refresh (Ctrl+F5 or Cmd+Shift+R) clears cached files","Reset app data only as last resort (Settings > Reset)","Export your work before performing a full reset"]},{title:"Getting Help",description:"When you need additional support",details:["H key shows hotkeys reference anytime","Menu > Help & Support for documentation","Contact Us option for direct support","Tutorial button restarts the guided tour","About section for version and system information","Community forums and documentation online"]}]}],[]),S=x.useMemo(()=>u?v.filter(C=>C.title.toLowerCase().includes(u.toLowerCase())||C.content.some(k=>k.title.toLowerCase().includes(u.toLowerCase())||k.description.toLowerCase().includes(u.toLowerCase())||k.details.some(N=>N.toLowerCase().includes(u.toLowerCase())))):v,[v,u]);return t?c.jsx(Wr,{onClose:e,widthClass:i?"w-[95%]":"w-[95%] max-w-6xl",heightClass:i?"h-[92%]":"h-[90%]",blurBackground:!0,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors ${r?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm text-zinc-100":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm text-zinc-900"}`,children:[c.jsxs("div",{className:`flex-shrink-0 border-b ${i?"px-4 py-3":"px-6 py-4"} ${r?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm border-zinc-700":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm border-zinc-200"}`,children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h1",{className:`${i?"text-xl":"text-2xl"} font-bold`,children:"Cai Usage Manual"}),c.jsx("button",{onClick:e,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${r?"hover:bg-zinc-100":"hover:bg-zinc-900"}`,"aria-label":"Close manual",children:c.jsx(nr,{size:i?18:20})})]}),c.jsxs("div",{className:"relative max-w-md",children:[c.jsx(px,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-zinc-400 ${i?"size-3":"size-4"}`}),c.jsx("input",{type:"text",placeholder:"Search the manual...",value:u,onChange:C=>d(C.target.value),className:`w-full ${i?"pl-8 pr-3 py-2 text-sm":"pl-10 pr-4 py-2"} border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${r?"border-zinc-600 bg-zinc-800 text-zinc-100":"border-zinc-300 bg-white text-zinc-900"}`})]})]}),c.jsxs("div",{className:`flex flex-1 overflow-hidden ${i?"flex-col":""}`,children:[c.jsx("div",{className:`${i?"w-full border-b max-h-28 min-h-0 overflow-x-auto overflow-y-hidden":"w-80 border-r min-h-0"} ${i?"p-4 pb-6":"p-6"} ${i?"":"overflow-x-auto"} ${r?"bg-gradient-to-br from-zinc-800/100 to-zinc-900/50 border-zinc-700":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 border-zinc-200"}`,children:c.jsx("nav",{className:`${i?"flex gap-3":"space-y-2"}`,children:S.map(C=>c.jsxs("button",{onClick:()=>o(C.id),className:`${i?"flex-shrink-0 flex flex-col items-center justify-center gap-2 px-3 py-4 text-center min-h-[80px] min-w-[50%]":"w-full flex items-center gap-3 px-4 py-3 text-left"}
813 rounded-lg transition-colors ${s===C.id?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-700 dark:text-zinc-300"}`,children:[c.jsx("div",{className:`${i?"size-4 flex-shrink-0":""}`,children:C.icon}),c.jsx("span",{className:`font-medium ${i?"text-xs leading-tight":""}`,children:C.title})]},C.id))})}),c.jsx("div",{className:`flex-1 ${i?"p-4":"p-6"} overflow-y-auto min-h-0`,children:S.map(C=>c.jsx("div",{className:s===C.id?"block":"hidden",children:c.jsxs("div",{className:"mb-8",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:`${i?"p-1.5":"p-2"} bg-blue-100 dark:bg-blue-900 rounded-lg`,children:c.jsx("div",{className:`${i?"size-4":""}`,children:C.icon})}),c.jsx("h2",{className:`${i?"text-lg":"text-2xl"} font-bold`,children:C.title})]}),c.jsx("div",{className:`${i?"space-y-4":"space-y-6"}`,children:C.content.map((k,N)=>c.jsxs("div",{className:`rounded-xl ${i?"p-4":"p-6"} ${r?"bg-gradient-to-br from-zinc-800/100 to-zinc-900/50":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25"}`,children:[c.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>w(`${C.id}-${N}`),children:[c.jsxs("div",{className:"flex-1 pr-3",children:[c.jsx("h3",{className:`${i?"text-base":"text-lg"} font-semibold ${i?"mb-1":"mb-2"}`,children:k.title}),c.jsx("p",{className:`${i?"text-sm":""} ${r?"text-zinc-400":"text-zinc-600"}`,children:k.description})]}),c.jsx(et.div,{animate:{rotate:a.has(`${C.id}-${N}`)?90:0},transition:{duration:.2},className:"flex-shrink-0",children:c.jsx(pi,{className:"size-4 text-zinc-400"})})]}),c.jsx(Vn,{children:a.has(`${C.id}-${N}`)&&c.jsx(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:`${i?"mt-3 pt-3":"mt-4 pt-4"} border-t ${r?"border-zinc-700":"border-zinc-200"}`,children:c.jsx("ul",{className:`${i?"space-y-2":"space-y-3"}`,children:k.details.map((_,j)=>c.jsxs(et.li,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:j*.05},className:`flex items-start ${i?"gap-2":"gap-3"}`,children:[c.jsx("div",{className:`flex-shrink-0 ${i?"w-1.5 h-1.5 mt-1.5":"w-2 h-2 mt-2"} bg-blue-500 rounded-full`}),c.jsx("span",{className:`leading-relaxed ${i?"text-sm":""} ${r?"text-zinc-300":"text-zinc-700"}`,children:_})]},j))})})})]},N))})]})},C.id))})]}),c.jsx("div",{className:`flex-shrink-0 border-t ${r?"bg-gradient-to-r from-blue-950 to-purple-950 border-zinc-700":"bg-gradient-to-r from-blue-50 to-purple-50 border-zinc-200"}`,children:c.jsx(Vn,{children:f&&c.jsx(et.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},onAnimationComplete:()=>{y(!1)},className:"overflow-hidden",children:c.jsx("div",{className:`${i?"p-4":"p-6"}`,children:c.jsxs("div",{className:"max-w-4xl mx-auto",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Gu,{className:`${i?"size-4":"size-6"} text-blue-600 dark:text-blue-400`}),c.jsx("h3",{className:`${i?"text-base":"text-lg"} font-semibold`,children:"Quick Start Tips"})]}),c.jsx("button",{onClick:g,disabled:m,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${r?"hover:bg-white":"hover:bg-black"} ${m?"opacity-50 cursor-not-allowed":""}`,"aria-label":"Hide quick tips",title:"Hide quick tips",children:c.jsx(nr,{size:i?16:18})})]}),c.jsxs("div",{className:`${i?"space-y-3":"grid md:grid-cols-2 gap-4"}`,children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(xz,{className:`${i?"size-3":"size-4"} text-blue-500 mt-1 flex-shrink-0`}),c.jsxs("p",{className:`${i?"text-sm":"text-base"} ${r?"text-zinc-300":"text-zinc-700"}`,children:[c.jsx("strong",{children:"New to Cai?"})," Start by double-clicking the canvas to create your first song, then use the AI chat to describe what you want to create."]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(xz,{className:`${i?"size-3":"size-4"} text-blue-500 mt-1 flex-shrink-0`}),c.jsxs("p",{className:`${i?"text-sm":"text-base"} ${r?"text-zinc-300":"text-zinc-700"}`,children:[c.jsx("strong",{children:"Pro tip:"})," Use the H key anytime to see keyboard shortcuts, and the T key to resize the chat for longer conversations."]})]})]})]})})})})}),!f&&!m&&c.jsx(et.div,{initial:{opacity:0}
813,animate:{opacity:1},className:`flex-shrink-0 border-t ${i?"p-2":"p-3"} ${r?"bg-gradient-to-r from-blue-950 to-purple-950 border-zinc-700":"bg-gradient-to-r from-blue-50 to-purple-50 border-zinc-200"}`,children:c.jsx("div",{className:"max-w-4xl mx-auto flex justify-center",children:c.jsxs("button",{onClick:g,className:`flex items-center gap-2 ${i?"px-3 py-2":"px-4 py-2"} rounded-lg transition-colors ${r?"hover:bg-zinc-700/50 text-zinc-300 hover:text-zinc-100":"hover:bg-zinc-200/50 text-zinc-600 hover:text-zinc-900"}`,"aria-label":"Show quick tips",title:"Show quick tips",children:[c.jsx(Gu,{className:`${i?"size-3":"size-4"}`}),c.jsx("span",{className:`${i?"text-xs":"text-sm"} font-medium`,children:"Show Quick Start Tips"})]})})})]})}):null},WL=({onClick:t=()=>{},className:e})=>{const n=r=>{typeof t=="function"&&t(),r.stopPropagation()};return c.jsx("div",{id:"click-interceptor",onClick:n,className:`left-0 top-0 h-screen w-screen fixed overflow-hidden ${e}`})},_he=({options:t,selectedOption:e,onOptionChange:n,label:r,icon:i,placeholder:s,disabled:o=!1})=>{var h;const[a,l]=x.useState(!1),u=x.useRef(null),d=x.useCallback(m=>{n(m),l(!1)},[n]);x.useEffect(()=>{const m=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const f=((h=t.find(m=>m.value===e))==null?void 0:h.label)||s;return c.jsxs("div",{className:"w-full",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i&&c.jsx("span",{className:"text-zinc-400",children:i}),c.jsx("label",{className:"font-medium text-zinc-700 dark:text-zinc-300",children:r})]}),c.jsxs("div",{ref:u,className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>!o&&l(!a),disabled:o,className:`flex items-center justify-between w-full px-3 py-2 rounded-lg border border-zinc-300/60 dark:border-zinc-700/60 transition-colors bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100 hover:bg-white/20 dark:hover:bg-white/10 ${o?"opacity-50 cursor-not-allowed":""}`,children:[c.jsx("span",{className:e?"":"text-zinc-400 dark:text-zinc-500",children:f}),c.jsx(Vi,{size:18,className:`transition-transform duration-300 ${a?"rotate-180":""}`})]}),a&&c.jsxs(c.Fragment,{children:[c.jsx(WL,{onClick:()=>l(!1)}),c.jsx("div",{className:"absolute z-[9999] mt-1 rounded-lg overflow-hidden shadow-lg border border-zinc-300/60 dark:border-zinc-700/60 w-full bg-gradient-to-br from-zinc-100/90 to-zinc-200/75 dark:from-zinc-800/90 dark:to-zinc-900/75 backdrop-blur-sm",style:{maxHeight:"160px"},children:c.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"160px"},children:t.map(m=>c.jsxs("div",{className:`px-3 py-2 cursor-pointer flex items-center justify-between ${m.value===e?"bg-caiBlue-500/20 text-caiBlue-600 dark:text-caiBlue-300":"hover:bg-white/10 dark:hover:bg-white/10 text-zinc-700 dark:text-zinc-300"}`,onClick:()=>d(m.value),children:[c.jsx("span",{children:m.label}),m.value===e&&c.jsx(Ml,{size:16,className:"text-caiBlue-600 dark:text-caiBlue-300"})]},m.value))})})]})]})]})},Ehe=({isOpen:t,onClose:e,userId:n})=>{const{focusCanvas:r}=di(),{isMobile:i}=Hn(),[s,o]=x.useState({description:"",category:"",includeState:!1}),[a,l]=x.useState(!1),[u,d]=x.useState(!1),[f,h]=x.useState(null),{handleFeedbackSubmission:m}=U0(),y=()=>h(null),g=async S=>{if(S.preventDefault(),!!s.description.trim()){d(!0),h(null);try{await m(n,s.description,{category:s.category},s.includeState),l(!0),o({description:"",category:"",includeState:!1}),setTimeout(()=>{l(!1),e()},2e3)}catch(C){const k=C instanceof Error?C.message:"Failed to submit feedback";h(k)}finally{d(!1)}}},w=x.useCallback(()=>{o({description:"",category:"",includeState:!1}),l(!1),y(),e(),r()},[e,r]),v=[{value:"bug",label:"Bug Report"},{value:"feature",label:"Feature Request"},{value:"improvement",label:"Improvement"},{value:"other",label:"Other"}];return t?c.jsx(Wr,{onClose:w,widthClass:i?"w-[93%]":"w-2/5",heightClass:i?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40 rounded-md shadow-sm transition-all duration-200 text-zinc-900 dark:text-zinc-100",children:[c.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-zinc-200/50 dark:border-zinc-700/50 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 dark:from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(wD,{size:20,className:"text-caiBlue-400 dark:text-caiBlue-300"}),c.jsx("h1",{className:"text-xl font-semibold",children:"Send Feedback"})]}),c.jsx("button",{onClick:w,disabled:u,className:`p-2 rounded-full hover:bg-white/10 dark:hover:bg-white/10 transition-colors ${u?"opacity-50 cursor-not-allowed":""}`,"aria-label":"Close feedback modal",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4 bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:a?c.jsxs("div",{className:"text-center py-8",children:[c.jsx("div",{className:"mb-4 text-caiGreen-400 dark:text-caiGreen-300",children:c.jsx($S,{size:64,className:"mx-auto"})}),c.jsx("h3",{className:"text-lg font-medium mb-2",children:"Feedback Sent!"}),c.jsx("p",{className:"text-zinc-600 dark:text-zinc-400",children:"Thank y
813ou for your feedback. We'll review it soon."})]}):c.jsxs("form",{onSubmit:g,className:"space-y-4",children:[c.jsx(_he,{label:"Category",placeholder:"Select a category",options:v,selectedOption:s.category,onOptionChange:S=>o({...s,category:S}),disabled:u}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium mb-2 text-zinc-700 dark:text-zinc-300",children:"Description"}),c.jsx("textarea",{value:s.description,onChange:S=>o({...s,description:S.target.value}),placeholder:"Please describe your feedback, bug report, or feature request...",rows:4,disabled:u,required:!0,className:"w-full p-3 border border-zinc-300/60 dark:border-zinc-700/60 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500 transition-colors resize-none bg-glass text-zinc-900 dark:text-zinc-100 disabled:opacity-50 disabled:cursor-not-allowed"})]}),c.jsxs("div",{className:"flex items-start",children:[c.jsx("input",{type:"checkbox",checked:s.includeState||!1,onChange:S=>o({...s,includeState:S.target.checked}),disabled:u,className:"mt-1 h-4 w-4 text-caiBlue-600 focus:ring-caiBlue-500 border-zinc-300 dark:border-zinc-600 rounded"}),c.jsxs("div",{className:"ml-3",children:[c.jsx("label",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-300",children:"Include my current music state to help with debugging"}),c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 mt-1",children:"Including your state shares your current music and app data with admins for report purposes only. This helps us reproduce and fix issues, but is completely optional. Your data is only used for debugging and nothing else."})]})]}),f&&c.jsxs("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-400 dark:border-red-600 text-red-700 dark:text-red-300 rounded-lg flex items-center gap-2",children:[c.jsx(T0,{size:16}),f]}),c.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},type:"button",onClick:w,disabled:u,className:"px-4 py-2 rounded-lg border border-zinc-300/60 dark:border-zinc-600/60 text-zinc-700 dark:text-zinc-300 hover:bg-white/10 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:"Cancel"}),c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},type:"submit",disabled:u||!s.description.trim()||!s.category,className:"px-4 py-2 rounded-lg font-medium transition-colors bg-gradient-to-r from-caiGreen to-caiBlue hover:from-caiGreen/90 hover:to-caiBlue/90 text-white disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Sending...":"Send Feedback"})]})]})})]})}):null},Nhe=()=>{throw new Error("This is a test error to preview the error page")},ky=({className:t="",onSignOut:e,isMobile:n=!1,setShowSettings:r})=>{const{showBanner:i}=ts(),{showInspectStorage:s,showUpload:o,showExport:a,showHotkeys:l}=Br(),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,y]=x.useState(!1),[g,w]=x.useState(!1),[v,S]=x.useState(!1),[C,k]=x.useState(!1),[N,_]=x.useState(!1),[j,T]=x.useState(""),{loadBloobAudio:M}=es(),{addSong:V,addBloob:H,addNotes:P,addAudioBloob:F,organizeBloobs:I,addAudioFile:R,clearCanvas:U}=Gn(),{commitToStore:A}=Ln(),{openSettings:W}=il(),{doesSongWithNameExist:D}=mn(),{clearAllThreads:B}=xd(),{focusCanvas:L}=di(),[$,q]=x.useState(!0),[Z,ie]=x.useState(!0),[ge,re]=x.useState(!1),[Y,ne]=x.useState(!0),{isDarkMode:be}=Pn(),{status:we,isOffline:te,isServerUnavailable:fe}=hD(),{getLastSyncTime:O}=Qh(),pe=we==="online",{setShowUpgradeModal:he,setShowUnsupportedModal:le}=tl(),{showUpgradeModal:oe,showUnsupportedModal:Q}=tl(),[de]=x.useState(null),{getCurrentAudioContext:Ne}=es(),{resetWizard:Ce}=GL(),{deselectAllCaiObjects:Ae}=cr();x.useEffect(()=>{(async()=>{try{const dt=await dd();T(dt.id)}catch{}})()},[]);const Ue=gt=>{window.location.hash=gt},Se=x.useCallback(()=>{l(),d(!1)},[l]),ve=x.useCallback(()=>{d(!1),L(),Ce()},[Ce,L]),je=x.useCallback(()=>{k(!0),d(!1)},[]),Te=()=>{Ue("about")},ce=()=>{window.location.href="mailto:[email protected]",d(!1)},se=x.useCallback(()=>{S(!0),d(!1)},[]),ye=x.useCallback(()=>{_(!0),d(!1)},[]),ke=x.useCallback(async()=>{try{await WE(),e()}catch(gt){throw i("There was an issue signing out"),gt}d(!1)},[e,i]),ze=x.useCallback(()=>{try{Ae(),U(),B(),A(),Ji.event({category:qs.USER_ACTIONS,action:"Clear Canvas",label:bo.UI_ACTS}),i("Canvas cleared successfully")}catch{i("Error clearing canvas")}y(!1),d(!1)},[Ae,U,B,A,i]),qe=x.useCallback(async gt=>{const wt=await Ne().decodeAudioData(await gt.arrayBuffer());return await R(gt.name,wt)},[R,Ne]),ot=x.useCallback(async()=>{try{let gt=ia.label,dt=1;for(;D(gt);)gt=`${ia.label} (${dt})`,dt++;const wt=V(ia.key,ia.bpm,ia.timeSignature,ia.canvasPosition,gt,ia.bars,ia.tracks);return await Promise.all(HL.map(async Dt=>{const Kt=H(wt,{instrument:Dt.instrument},Dt.bars,Dt.songPosition,Dt.label),rn=Dt.notes.map(pn=>({pitch:pn.pitch,velocity:pn.velocity,startBeat:pn.startBeat,durationInBeats:pn.durationInBeats}));P(Kt,rn);try{await M(Kt)}catch(pn){pr("Failed to load MIDI bloob audio:",pn)}})),await Promise.all(vhe.map(async Dt=>{const Kt=await fetch(Dt.audioFilePath).then(cn=>cn.blob()).then(cn=>new File([cn],Dt.label)),rn=await qe(Kt),pn=F(wt,rn,Dt.bars,Dt.songPosition,Dt.label,Dt.melodicRole);try{await M(pn)}catch(cn){pr("Failed to load audio bloob audio:",cn)}})),I(wt),A(),wt}catch{return null}},[F,H,qe,P,V,A,D,M,I]);x.useCallback(async()=>{try{await ot(),i("Test song created successfully!",void 0),Ji.event({category:qs.USER_ACTIONS,action:"Add Test Data",label:bo.UI_ACTS})}catch{i("Error adding test data")}d(!1)},[i,ot]),x.useCallback(()=>{s(),d(!1),Ji.event({category:qs.USER_ACTIONS,action:"Inspect Storage",label:bo.UI_ACTS})},[s]);const Ze=x.useCallback(()=>{o(),d(!1)},[o]),_t=x.useCallback(()=>{a(),d(!1)},[a]),tt=()=>{d(!1),L()};return x.useEffect(()=>{const gt=()=>{window.location.hash&&d(!1)};return window.addEventListener("hashchange",gt),()=>window.removeEventListener("hashchange",gt)},[]),c.jsxs(c.Fragment,{children:[f&&c.jsx(Nhe,{}),c.jsx("button",{id:"sidebar-button",onMouseDown:()=>{u||d(!0)},className:`${t} 814 bg-glass border-glass 815 rounded-xl shadow-sm 816 text-zinc-900 dark:text-zinc-100 817 flex items-center justify-center size-10 818 `,"aria-label":"Menu",children:c.jsx("span",{className:"transform scale-95 transition-transform duration-200 hover:scale-100",children:c.jsx(xD,{size:24})})}),u&&c.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-25 transition-opacity z-50",onClick:tt}),c.jsx("div",{className:` 819 sidebar 820 fixed top-0 right-0 h-full w-64 z-50 821 transform transition-transform duration-300 ease-in-out 822 ${u?"translate-x-0":"translate-x-full"} 823 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/100 dar
823k:to-zinc-900/25 backdrop-blur-sm 824 before:absolute before:top-0 before:left-0 before:w-[2px] before:h-full 825 before:bg-gradient-to-b before:from-[#6b88cc] before:via-[#7dc383] before:to-[#f8c291] 826 `,children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsx("div",{className:"flex-grow overflow-y-auto pt-16",children:c.jsxs("div",{className:"px-4 space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-500 cursor-pointer transition-colors duration-200 hover:text-zinc-800 dark:hover:text-zinc-200",onClick:()=>ne(!Y),children:c.jsxs("div",{className:"flex items-center",children:["Account",c.jsx(Vi,{size:16,className:`ml-2 transition-transform duration-200 ${Y?"rotate-180":""}`})]})}),c.jsx(Vn,{children:Y&&c.jsxs(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.5,staggerChildren:.1},children:[c.jsxs(et.button,{onMouseDown:se,className:` 827 flex items-center w-full px-4 py-2.5 text-base rounded-md 828 transition-colors duration-200 829 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 830 text-zinc-900 dark:text-zinc-100 831 hover:text-zinc-100 dark:hover:text-zinc-900 832 bg-transparent 833 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5},children:[c.jsx(wm,{size:16,className:"mr-3"}),"Account"]}),c.jsxs(et.button,{onMouseDown:$0,className:` 834 flex items-center w-full px-4 py-2.5 text-base rounded-md 835 transition-colors duration-200 836 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 837 text-zinc-900 dark:text-zinc-100 838 hover:text-zinc-100 dark:hover:text-zinc-900 839 bg-transparent 840 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.1},children:[c.jsx(Bte,{size:16,className:"mr-3"}),"Subscriptions"]})]})})]}),c.jsx("div",{className:"my-4 border-t border-zinc-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-500 cursor-pointer transition-colors duration-200 hover:text-zinc-800 dark:hover:text-zinc-200",onClick:()=>q(!$),children:c.jsxs("div",{className:"flex items-center",children:["Utilities",c.jsx(Vi,{size:16,className:`ml-2 transition-transform duration-200 ${$?"rotate-180":""}`})]})}),c.jsx(Vn,{children:$&&c.jsxs(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.5,staggerChildren:.1},children:[c.jsxs(et.button,{onMouseDown:()=>{n&&r?r(!0):W(),d(!1)},className:` 841 flex items-center w-full px-4 py-2.5 text-base rounded-md 842 transition-colors duration-200 843 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 844 text-zinc-900 dark:text-zinc-100 845 hover:text-zinc-100 dark:hover:text-zinc-900 846 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.1},children:[c.jsx(cE,{size:16,className:"mr-3"}),"Settings"]}),c.jsxs(et.button,{onMouseDown:Ze,className:` 847 flex items-center w-full px-4 py-2.5 text-base rounded-md 848 transition-colors duration-200 849 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 850 text-zinc-900 dark:text-zinc-100 851 hover:text-zinc-100 dark:hover:text-zinc-900 852 `,initial:{opacity:0,y:20}
852,animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.2},children:[c.jsx(gx,{size:16,className:"mr-3"}),"Upload Files"]}),c.jsxs(et.button,{onMouseDown:_t,className:` 853 flex items-center w-full px-4 py-2.5 text-base rounded-md 854 transition-colors duration-200 855 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 856 text-zinc-900 dark:text-zinc-100 857 hover:text-zinc-100 dark:hover:text-zinc-900 858 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.3},children:[c.jsx(cd,{size:16,className:"mr-3"}),"Export Files"]}),c.jsxs(et.button,{onMouseDown:()=>w(!0),className:` 859 flex items-center w-full px-4 py-2.5 text-base rounded-md 860 transition-colors duration-200 861 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 862 text-zinc-900 dark:text-zinc-100 863 hover:text-zinc-100 dark:hover:text-zinc-900 864 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.35},children:[c.jsx(Tre,{size:16,className:"mr-3"}),"Check Connection"]}),c.jsxs(et.button,{onMouseDown:()=>y(!0),className:` 865 flex items-center w-full px-4 py-2.5 text-base rounded-md 866 transition-colors duration-200 867 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 868 text-zinc-900 dark:text-zinc-100 869 hover:text-zinc-100 dark:hover:text-zinc-900 870 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.4},children:[c.jsx(js,{size:16,className:"mr-3"}),"Clear Canvas"]})]})})]}),PS,c.jsx("div",{className:"my-4 border-t border-zinc-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-500 cursor-pointer transition-colors duration-200 hover:text-zinc-800 dark:hover:text-zinc-200",onClick:()=>ie(!Z),children:c.jsxs("div",{className:"flex items-center",children:["Help & Support",c.jsx(Vi,{size:16,className:`ml-2 transition-transform duration-200 ${Z?"rotate-180":""}`})]})}),c.jsx(Vn,{children:Z&&c.jsxs(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.5,staggerChildren:.1},children:[c.jsxs(et.button,{onMouseDown:ve,className:` 871 flex items-center w-full px-4 py-2.5 text-base rounded-md 872 transition-colors duration-200 873 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 874 text-zinc-900 dark:text-zinc-100 875 hover:text-zinc-100 dark:hover:text-zinc-900 876 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.1},children:[c.jsx(Gu,{size:16,className:"mr-3"}),"Tutorial"]}),c.jsxs(et.button,{onMouseDown:je,className:` 877 flex items-center w-full px-4 py-2.5 text-base rounded-md 878 transition-colors duration-200 879 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 880 text-zinc-900 dark:text-zinc-100 881 hover:text-zinc-100 dark:hover:text-zinc-900 882 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.2},children:[c.jsx(ux,{size:16,className:"mr-3"}),"Usage Manual"]}),c.jsxs(et.button,{onMouseDown:Se,className:` 883 flex items-center w-full px-4 py-2.5 text-base rounded-md 884 transition-colors duration-200 885 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 886 text-zinc-900 dark:text-zinc-100 887 hover:text-zinc-100 dark:hover:text-zinc-900 888 `,initial:{opacity:0,y:20}
888,animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.3},children:[c.jsx(aE,{size:16,className:"mr-3"}),"Hotkeys"]}),c.jsxs(et.button,{onMouseDown:ye,className:` 889 flex items-center w-full px-4 py-2.5 text-base rounded-md 890 transition-colors duration-200 891 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 892 text-zinc-900 dark:text-zinc-100 893 hover:text-zinc-100 dark:hover:text-zinc-900 894 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.4},children:[c.jsx(wD,{size:16,className:"mr-3"}),"Give Feedback"]}),c.jsxs(et.button,{onMouseDown:ce,className:` 895 flex items-center w-full px-4 py-2.5 text-base rounded-md 896 transition-colors duration-200 897 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 898 text-zinc-900 dark:text-zinc-100 899 hover:text-zinc-100 dark:hover:text-zinc-900 900 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.5},children:[c.jsx(_h,{size:16,className:"mr-3"}),"Contact Us"]}),c.jsxs(et.button,{onMouseDown:Te,className:` 901 flex items-center w-full px-4 py-2.5 text-base rounded-md 902 transition-colors duration-200 903 hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500 904 text-zinc-900 dark:text-zinc-100 905 hover:text-zinc-100 dark:hover:text-zinc-900 906 `,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.5,delay:.6},children:[c.jsx(Kc,{size:16,className:"mr-3"}),"About Cai"]})]})})]})]})}),c.jsxs("div",{className:"px-4 pb-4",children:[c.jsxs("button",{onMouseDown:ke,className:` 907 flex items-center w-full px-4 py-3 mt-4 mb-4 text-base rounded-md 908 transition-colors duration-200 font-medium 909 text-zinc-900 dark:text-zinc-100 910 bg-[#f8c291] hover:bg-[#f4a261] 911 `,children:[c.jsx(yD,{size:16,className:"mr-3"}),"Sign Out"]}),c.jsx("div",{className:"text-xs text-center text-zinc-500",children:"© Cai Creative, Inc. 2025"})]})]})}),g&&c.jsx(TD,{isOpen:g,onClose:()=>w(!1),isOffline:te,isServerUnavailable:fe,isOnline:pe,lastSyncTime:O()}),c.jsx(al,{isOpen:m,onClose:()=>y(!1),onConfirm:ze,title:"Clear Canvas",message:"Are you sure you want to clear the canvas? This will delete all songs, bloobs, notes, text notes, embeddings, visual media nodes, and chat history.",confirmText:"Clear Canvas",isDangerous:!0}),c.jsx(khe,{isOpen:oe,onClose:()=>he(!1)}),c.jsx(She,{isOpen:Q,onClose:()=>le(!1),countryCode:de||""}),v&&c.jsx(whe,{onClose:()=>S(!1),onSignOut:e}),C&&c.jsx(Che,{isOpen:C,onClose:()=>k(!1)}),N&&j&&c.jsx(Ehe,{isOpen:N,onClose:()=>_(!1),userId:j})]})},Ihe=()=>{var I,R,U;const{songs:t,textNodes:e,embeddingNodes:n,visualMediaNodes:r,getSongById:i,getTextNodeById:s,getEmbeddingNodeById:o,getVisualMediaNodeById:a}=mn(),{selectCaiObject:l}=cr(),{centerCaiObject:u}=sl(),{closeMobileSearch:d}=Br(),{mobileSearchOpen:f}=Pn(),{isMobile:h}=Hn(),[m,y]=x.useState(""),[g,w]=x.useState([]),[v,S]=x.useState(null),C=x.useRef(null),k=x.useMemo(()=>{const A=[];return Object.entries(t).forEach(([W,D])=>{A.push({id:parseInt(W),type:J.Song,title:D.label,subtitle:`${D.key.chroma} ${D.key.quality} ⢠${D.bpm} BPM`,icon:c.jsx(hx,{className:"size-3"})})}),Object.entries(e).forEach(([W,D])=>{A.push({id:parseInt(W),type:J.TextNode,title:D.label,subtitle:D.content?`${D.content.substring(0,40)}${D.content.length>40?"...":""}`:"Empty",icon:c.jsx($i,{className:"size-3"})})}),Object.entries(n).forEach(([W,D])=>{A.push({id:parseInt(W),type:J.EmbeddingNode,title:D.label,subtitle:D.url||"No URL set",icon:c.jsx(Ka,{className:"size-3"})})}),Object.entries(r).forEach(([W,D])=>{var L;const B=(L=D.mediaData)==null?void 0:L.startsWith("data:video/");
911A.push({id:parseInt(W),type:J.VisualMediaNode,title:D.label,subtitle:D.mediaData?B?"Video":"Image":"No media",icon:B?c.jsx(Ul,{className:"size-3"}):c.jsx(Gs,{className:"size-3"})})}),A},[t,e,n,r]),N=x.useMemo(()=>[...k].sort(()=>Math.random()-.5).slice(0,10),[k]);x.useEffect(()=>{f&&!m&&w(N)},[f,m,N]),x.useEffect(()=>{if(!f||!m.trim())return;const A=m.toLowerCase().trim(),W=k.map(D=>{var B;return{...D,score:D.title.toLowerCase().includes(A)?D.title.toLowerCase().startsWith(A)?2:1:(B=D.subtitle)!=null&&B.toLowerCase().includes(A)?.5:0}}).filter(D=>D.score>0).sort((D,B)=>B.score-D.score).slice(0,10);w(W)},[f,m,k]);const _=x.useCallback(A=>{y(A.target.value)},[]),j=x.useCallback((A,W)=>{l({type:W,id:A}),d(),u({type:W,id:A}),y(""),S(null)},[l,d,u]),T=x.useCallback((A,W,D)=>{D.stopPropagation(),(v==null?void 0:v.id)===A&&(v==null?void 0:v.type)===W?S(null):S({id:A,type:W})},[v]),M=x.useMemo(()=>(v==null?void 0:v.type)!==J.Song?null:i(v.id),[v,i]),V=x.useMemo(()=>(v==null?void 0:v.type)!==J.TextNode?null:s(v.id),[v,s]),H=x.useMemo(()=>(v==null?void 0:v.type)!==J.EmbeddingNode?null:o(v.id),[v,o]),P=x.useMemo(()=>(v==null?void 0:v.type)!==J.VisualMediaNode?null:a(v.id),[v,a]),F=M||V||H||P;return x.useEffect(()=>{f&&C.current&&C.current.focus()},[f]),f?c.jsx(Wr,{onClose:d,widthClass:h?"w-[93%]":"w-2/5",heightClass:h?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full bg-glass border-glass rounded-xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-zinc-200/50 dark:border-zinc-700/50",children:[c.jsx("h2",{className:"text-lg font-medium",children:"Locate Items"}),c.jsx("button",{onClick:d,className:"p-2 rounded-lg hover:bg-zinc-200/20 transition-colors","aria-label":"Close search",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:"p-4",children:c.jsx("input",{ref:C,type:"text",placeholder:"Search...",value:m,onChange:_,className:"w-full px-3 py-2 bg-white/80 dark:bg-zinc-800/80 border border-zinc-300/60 dark:border-zinc-700/60 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 backdrop-blur-sm"})}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[g.length>0&&c.jsx("div",{className:"space-y-2 pb-4",children:g.map(A=>c.jsx("div",{onClick:()=>j(A.id,A.type),className:"px-3 py-3 flex items-center text-sm rounded-lg cursor-pointer transition-colors duration-150 w-full relative bg-transparent hover:bg-zinc-200/20",children:c.jsxs("div",{className:"flex items-center gap-3 w-full overflow-hidden",children:[c.jsx("div",{className:"flex-shrink-0",children:A.icon}),c.jsxs("div",{className:"flex-1 overflow-hidden",children:[c.jsx("div",{className:"font-medium truncate",children:A.title}),A.subtitle&&c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 truncate",children:A.subtitle})]}),c.jsx("button",{onClick:W=>T(A.id,A.type,W),className:`flex-shrink-0 p-2 rounded-lg transition-colors ${(v==null?void 0:v.id)===A.id&&(v==null?void 0:v.type)===A.type?"bg-blue-500/20 text-blue-600 dark:text-blue-400":"hover:bg-zinc-300/20 text-zinc-500 dark:text-zinc-400"}`,"aria-label":"Show details",children:c.jsx(Kc,{size:20})})]})},`${A.type}-${A.id}`))}),m&&g.length===0&&c.jsx("div",{className:"px-3 py-4 text-sm text-zinc-500 dark:text-zinc-400 text-center",children:"No items found"})]}),c.jsx(Vn,{children:v&&F&&c.jsxs(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"border-t border-zinc-200/50 dark:border-zinc-700/50 p-4 bg-zinc-100/50 dark:bg-zinc-800/50",children:[M&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-3 text-center truncate",children:M.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Key:"}),c.jsxs("span",{className:"text-xs font-medium",children:[M.key.chroma," ",M.key.quality]})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"BPM:"}),c.jsx("span",{className:"text-xs font-medium",children:M.bpm})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Time Signature:"}),c.jsxs("span",{className:"text-xs font-medium",children:[((I=M.timeSignature)==null?void 0:I.beatsPerBar)||"4","/",((R=M.timeSignature)==null?void 0:R.beatDuration)||"4"]})]})]})]}),V&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-3 text-center truncate",children:V.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:"Text Notes"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 break-words max-h-20 overflow-hidden",children:V.content?`${V.content.substring(0,150)}${V.content.length>150?"...":""}`:"No content"})]})]}),H&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-3 text-center truncate",children:H.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:"Embed"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 break-words",children:H.url||"No URL set"})]})]}),P&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-3 text-center truncate",children:P.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:(U=P.mediaData)!=null&&U.startsWith("data:video/")?"Video":"Image"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:P.mediaData?"Contains media":"No media uploaded"})]})]})]})})]})}):null},jhe=({openDirection:t})=>{var Z,ie,ge;const{songs:e,textNodes:n,embeddingNodes:r,visualMediaNodes:i,getSongById:s,getTextNodeById:o,getEmbeddingNodeById:a,getVisualMediaNodeById:l}=mn(),{selectCaiObject:u}=cr(),{centerCaiObject:d}=sl(),[f,h]=x.useState(!1),[m,y]=x.useState(""),[g,w]=x.useState([]),[v,S]=x.useState(null),[C,k]=x.useState(null),N=x.useRef(null),_=x.useRef(null),[j,T]=x.useState(!1),M=x.useMemo(()=>{switch(t){case"bottom-right":return{top:"0",left:"0"};case"bottom-left":return{top:"0",right:"0"};case"top-right":return{bottom:"0",left:"0"};case"top-left":return{bottom:"0",right:"0"};default:return{top:"0",left:"0"}}},[t]),[V,H]=x.useState(null);x.useEffect(()=>{f&&j&&_.current&&(_.current.focus(),T(!1))},[f,j]);const P=x.useMemo(()=>{const re=[];return Object.entries(e).forEach(([Y,ne])=>{re.push({id:parseInt(Y),type:J.Song,title:ne.label,subtitle:`${ne.key.chroma} ${ne.key.quality} ⢠${ne.bpm} BPM`,icon:c.jsx(hx,{className:"size-3"})})}
911),Object.entries(n).forEach(([Y,ne])=>{re.push({id:parseInt(Y),type:J.TextNode,title:ne.label,subtitle:ne.content?`${ne.content.substring(0,40)}${ne.content.length>40?"...":""}`:"Empty",icon:c.jsx($i,{className:"size-3"})})}),Object.entries(r).forEach(([Y,ne])=>{re.push({id:parseInt(Y),type:J.EmbeddingNode,title:ne.label,subtitle:ne.url||"No URL set",icon:c.jsx(Ka,{className:"size-3"})})}),Object.entries(i).forEach(([Y,ne])=>{var we;const be=(we=ne.mediaData)==null?void 0:we.startsWith("data:video/");re.push({id:parseInt(Y),type:J.VisualMediaNode,title:ne.label,subtitle:ne.mediaData?be?"Video":"Image":"No media",icon:be?c.jsx(Ul,{className:"size-3"}):c.jsx(Gs,{className:"size-3"})})}),re},[e,n,r,i]),F=x.useMemo(()=>[...P].sort(()=>Math.random()-.5).slice(0,10),[P]);x.useEffect(()=>{f&&!m&&w(F)},[f,m,F]),x.useEffect(()=>{if(!f||!m.trim())return;const re=m.toLowerCase().trim(),Y=P.map(ne=>{var be;return{...ne,score:ne.title.toLowerCase().includes(re)?ne.title.toLowerCase().startsWith(re)?2:1:(be=ne.subtitle)!=null&&be.toLowerCase().includes(re)?.5:0}}).filter(ne=>ne.score>0).sort((ne,be)=>be.score-ne.score).slice(0,10);w(Y)},[f,m,P]);const I=x.useCallback(re=>{y(re.target.value)},[]),R=x.useCallback((re,Y)=>{u({type:Y,id:re}),h(!1),d({type:Y,id:re}),y("")},[d,u]);x.useEffect(()=>{const re=Y=>{f&&N.current&&!N.current.contains(Y.target)&&(h(!1),S(null),k(null))};return document.addEventListener("mousedown",re),()=>{document.removeEventListener("mousedown",re)}},[f]);const U=x.useCallback((re,Y)=>{S(re),k(Y)},[]),A=x.useMemo(()=>v===null||C!==J.Song?null:s(v),[v,C,s]),W=x.useMemo(()=>v===null||C!==J.TextNode?null:o(v),[v,C,o]),D=x.useMemo(()=>v===null||C!==J.EmbeddingNode?null:a(v),[v,C,a]),B=x.useMemo(()=>v===null||C!==J.VisualMediaNode?null:l(v),[v,C,l]),L=A||W||D||B,$=x.useCallback(()=>120+Math.min(g.length,5)*56,[g.length]),q=x.useCallback(()=>{if(N.current){const re=N.current.getBoundingClientRect(),Y=N.current.offsetParent?N.current.offsetParent.getBoundingClientRect():{top:0,left:0};let ne=0,be=0;const we=8,te=192;switch(t){case"bottom-right":ne=re.top-Y.top,be=re.right-Y.left+we;break;case"bottom-left":ne=re.top-Y.top,be=re.left-Y.left-te-we;break;case"top-right":ne=re.bottom-Y.top-te-we,be=re.right-Y.left+we;break;case"top-left":ne=re.bottom-Y.top-te-we,be=re.left-Y.left-te-we;break;default:ne=re.top-Y.top,be=re.right-Y.left+we}H({top:ne,left:be})}},[t]);return x.useEffect(()=>{if(f&&L)return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[f,L,q]),c.jsxs("div",{className:"z-40 relative",children:[c.jsx("div",{className:"w-10 h-10",children:c.jsxs(et.div,{ref:N,initial:!1,animate:{width:f?256:40,height:f?$():40,borderRadius:8},transition:{width:{duration:.1},height:{duration:.1}},onAnimationComplete:()=>{f&&T(!0)},className:"absolute overflow-hidden bg-glass border-glass rounded-xl",style:{...M,zIndex:50},children:[c.jsx(et.button,{className:"absolute top-0 right-0 w-10 h-10 flex items-center justify-center transition-colors",onClick:()=>{h(!f)},"aria-label":f?"Close search":"Open search",animate:{rotate:f?90:0,scale:f?.9:1},whileHover:{scale:f?1:1.1,transition:{duration:.2}},transition:{duration:.1},children:f?c.jsx(nr,{size:24}):c.jsx(px,{size:20})}),c.jsxs(et.div,{initial:{opacity:0}
911,animate:{opacity:f?1:0,pointerEvents:f?"auto":"none"},transition:{duration:.1},className:"p-2",children:[c.jsx("div",{className:"ml-2 text-lg font-medium mb-3",children:"Locate Items"}),c.jsx("input",{ref:_,type:"text",placeholder:"Search...",value:m,onChange:I,className:"w-full px-2 py-1 bg-white/80 dark:bg-zinc-800/80 border border-zinc-300/60 dark:border-zinc-700/60 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 backdrop-blur-sm"}),c.jsx(Vn,{children:c.jsxs(et.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.1},className:"mt-2",children:[g.length>0&&c.jsx("div",{className:"max-h-60 overflow-y-auto",children:g.map(re=>c.jsx("div",{onClick:()=>R(re.id,re.type),onMouseEnter:()=>U(re.id,re.type),onMouseLeave:()=>U(null,null),className:"px-2 h-14 flex items-center text-sm rounded cursor-pointer transition-colors duration-150 w-full mb-2 relative bg-transparent group hover:bg-gradient-to-br hover:from-zinc-400 hover:to-zinc-600 dark:hover:from-zinc-200 dark:hover:to-zinc-500",children:c.jsxs("div",{className:"flex items-center gap-2 w-full overflow-hidden",children:[c.jsx("div",{className:"flex-shrink-0 group-hover:text-zinc-100 group-hover:dark:text-zinc-900",children:re.icon}),c.jsxs("div",{className:"flex-1 overflow-hidden",children:[c.jsx("div",{className:"font-medium truncate group-hover:text-zinc-100 group-hover:dark:text-zinc-900",children:re.title}),re.subtitle&&c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 truncate group-hover:text-zinc-200 group-hover:dark:text-zinc-800",children:re.subtitle})]})]})},`${re.type}-${re.id}`))}),m&&g.length===0&&c.jsx("div",{className:"px-2 py-1.5 text-sm text-zinc-500 dark:text-zinc-400",children:"No nodes found"})]})})]})]})}),c.jsx(Vn,{children:f&&L&&V&&c.jsxs(et.div,{initial:{opacity:0,x:t.includes("left")?20:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:t.includes("left")?20:-20},transition:{duration:.2},className:"absolute p-3 rounded-lg bg-glass border-glass w-48 z-46",style:{position:"absolute",top:V.top,left:V.left,zIndex:46,width:192},children:[A&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-2 text-center truncate",children:A.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Key:"}),c.jsxs("span",{className:"text-xs font-medium",children:[A.key.chroma," ",A.key.quality]})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"BPM:"}),c.jsx("span",{className:"text-xs font-medium",children:A.bpm})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Time Signature:"}),c.jsxs("span",{className:"text-xs font-medium",children:[((Z=A.timeSignature)==null?void 0:Z.beatsPerBar)||"4","/",((ie=A.timeSignature)==null?void 0:ie.beatDuration)||"4"]})]})]})]}),W&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-2 text-center truncate",children:W.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:"Text Notes"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 break-words max-h-16 overflow-hidden",children:W.content?`${W.content.substring(0,100)}${W.content.length>100?"...":""}`:"No content"})]})]}),D&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-2 text-center truncate",children:D.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:"Embed"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 break-words",children:D.url||"No URL set"})]})]}),B&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium mb-2 text-center truncate",children:B.label}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Type:"}),c.jsx("span",{className:"text-xs font-medium",children:(ge=B.mediaData)!=null&&ge.startsWith("data:video/")?"Video":"Image"})]}),c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:B.mediaData?"Contains media":"No media uploaded"})]})]})]})})]})},qL=()=>{const{isMobile:t}=Hn();return t?c.jsx(Ihe,{}):c.jsx(jhe,{openDirection:"bottom-left"})},Qs="/api/v0/collaboration";async function The(t,e,n,r={}){const{role:i="viewer",allowCopyForCollaborators:s=!1,allowExportForCollaborators:o=!1}=r;return(await tr.post(`${Qs}/objects/${t}/${e}/invite`,{emails:n,role:i,allow_copy:s,allow_export:o})).data}async function zhe(){return(await tr.get(`${Qs}/invites/inbox`)).data}async function Phe(t){await tr.post(`${Qs}/invites/${t}/accept`,{})}async function Ahe(t){await tr.post(`${Qs}/invites/${t}/decline`,{})}async function Mhe(t){return(await tr.post(`${Qs}/objects/state`,{objects:t})).data}async function Bhe(){return(await tr.get(`${Qs}/shared-with-me`)).data}async function Rhe(){return(await tr.get(`${Qs}/owned-objects`)).data}async function Sy(){return(await tr.get(`${Qs}/shared-by-me`)).data}async function Ohe(t,e,n,r){await tr.patch(`${Qs}/objects/${t}/${e}/members/${n}`,{role:r})}async function Dhe(t,e,n,r){await tr.patch(`${Qs}/objects/${t}/${e}/members/${n}`,r)}async function dM(t,e,n){await tr.delete(`${Qs}/objects/${t}/${e}/members/${n}`)}async function Lhe(t,e){await tr.patch(`${Qs}/invites/${t}`,{role:e})}async function Fhe(t,e){await tr.patch(`${Qs}/invites/${t}`,e)}async function $he(t){await tr.delete(`${Qs}/invites/${t}`)}function Wk(t){return{Song:"song",TextNode:"text_node",EmbeddingNode:"embedding_node",VisualMediaNode:"visual_node"}[t]??t}const fM=[J.Song,J.TextNode,J.EmbeddingNode,J.VisualMediaNode],KL=({isOpen:t,onClose:e})=>{const{songs:n,textNodes:r,embeddingNodes:i,visualMediaNodes:s}=mn(),{isDarkMode:o}=Pn(),{generalSettings:a}=bi(),{setHideCollabAgenticHintModal:l}=il(),{forceSync:u,applyObjectStatesToStore:d}=Qh(),{selectedSingleCaiObject:f}
911=Yn(),[h,m]=x.useState("share"),[y,g]=x.useState([]),[w,v]=x.useState(!1),[S,C]=x.useState(null),[k,N]=x.useState(""),[_,j]=x.useState("viewer"),[T,M]=x.useState(!1),[V,H]=x.useState(!1),[P,F]=x.useState(!1),[I,R]=x.useState(null),[U,A]=x.useState(!1),[W,D]=x.useState(0),[B,L]=x.useState(null),[$,q]=x.useState(null),[Z,ie]=x.useState(!1),[ge,re]=x.useState(null),[Y,ne]=x.useState(null),[be,we]=x.useState(null),[te,fe]=x.useState(null),[O,pe]=x.useState(null),[he,le]=x.useState(null),[oe,Q]=x.useState(new Set),[de,Ne]=x.useState(null),[Ce,Ae]=x.useState(!0),[Ue,Se]=x.useState(!0),[ve,je]=x.useState(null),[Te,ce]=x.useState(!1),[se,ye]=x.useState("show_again"),ke=at(Ie=>Ie.sharedByMe),ze=at(Ie=>Ie.setSharedByMe),qe=at(Ie=>Ie.sharedWithMe),ot=at(Ie=>Ie.setSharedWithMe),Ze=at(Ie=>Ie.currentUserId),_t=x.useCallback(async()=>{try{const Ie=await Rhe();Q(new Set(Ie.map(it=>`${it.object_type}-${it.object_id}`)))}catch{Q(new Set)}},[]),tt=mr.useMemo(()=>{const Ie=[],it=(ct,Ut)=>oe.has(`${ct}-${Ut}`);return Object.entries(n).forEach(([ct,Ut])=>{const Et=parseInt(ct);it("song",Et)&&Ie.push({id:Et,type:J.Song,label:Ut.label,objectTypeLabel:"Song"})}),Object.entries(r).forEach(([ct,Ut])=>{const Et=parseInt(ct);it("text_node",Et)&&Ie.push({id:Et,type:J.TextNode,label:Ut.label,objectTypeLabel:"Text"})}),Object.entries(i).forEach(([ct,Ut])=>{const Et=parseInt(ct);it("embedding_node",Et)&&Ie.push({id:Et,type:J.EmbeddingNode,label:Ut.label,objectTypeLabel:"Embed"})}),Object.entries(s).forEach(([ct,Ut])=>{const Et=parseInt(ct);it("visual_node",Et)&&Ie.push({id:Et,type:J.VisualMediaNode,label:Ut.label,objectTypeLabel:"Media"})}),Ie},[n,r,i,s,oe]),gt=x.useCallback(async()=>{v(!0);try{const Ie=await zhe();g(Ie)}catch{g([])}finally{v(!1)}},[]),dt=x.useCallback(async()=>{ie(!0);try{const Ie=await Sy();ze(Ie)}catch{ze([])}finally{ie(!1)}},[ze]),wt=x.useCallback(async()=>{try{const Ie=await Bhe();ot(Ie)}catch{ot([])}},[ot]),Dt=x.useCallback(async Ie=>{if(!Ze)return;const it=`${Ie.object_type}-${Ie.object_id}`;Ne(it);try{await dM(Ie.object_type,Ie.object_id,Ze),ot((qe??[]).filter(ct=>!(ct.object_type===Ie.object_type&&ct.object_id===Ie.object_id)))}catch{}finally{Ne(null)}},[Ze,qe,ot]),Kt=x.useCallback(Ie=>{je({title:"Leave Collaboration",message:`Are you sure you want to leave "${Ie.object_name}"? You will lose access and would need a new invite to rejoin.`,confirmText:"Leave",onConfirm:()=>{je(null),Dt(Ie)}})},[Dt]);x.useEffect(()=>{t&&(gt(),_t(),Sy().then(Ie=>ze(Ie)).catch(()=>ze([])),wt(),R(null),A(!1))},[t,gt,_t,ze,wt]),x.useEffect(()=>{if(h!=="manage"){ne(null);return}if(ge){const it=(ke??[]).find(ct=>ct.object_type===ge.object_type&&ct.object_id===ge.object_id);it?(re(it),ne(it)):(re(null),ne(null))}else ne(null)},[h,ge,ke]),x.useEffect(()=>{if(t&&f&&fM.includes(f.type)){const Ie=tt.find(it=>it.type===f.type&&it.id===f.id);Ie&&C(Ie)}},[t,f,tt]),x.useEffect(()=>{if(h!=="manage"||!(ke!=null&&ke.length)||!f||!fM.includes(f.type))return;const Ie=Wk(f.type),it=(ke??[]).find(ct=>ct.object_type===Ie&&ct.object_id===f.id);it&&re(ct=>ct??it)},[h,f,ke]);const rn=x.useCallback(()=>{(a.hideCollabAgenticHintModal??!1)||(ye("show_again"),ce(!0))},[a.hideCollabAgenticHintModal]),pn=x.useCallback(async()=>{var it,ct;if(!S||!k.trim()){R("Select an item and enter at least one email address.");return}const Ie=Wk(S.type);F(!0),R(null),A(!1);try{const Ut=await The(Ie,S.id,k.trim(),{role:_,allowCopyForCollaborators:T,allowExportForCollaborators:V});A(!0),N("");const Et=await Sy();ze(Et),D(Ut.length),rn()}catch(Ut){const Et=Ut&&typeof Ut=="object"&&"response"in Ut?(ct=(it=Ut.response)==null?void 0:it.data)==null?void 0:ct.detail:null;R(Et||"Failed to send invite(s).")}finally{F(!1)}},[S,k,_,T,V,ze,rn]),cn=x.useCallback(async Ie=>{L(Ie.id);try{await Phe(Ie.id),g(ct=>ct.filter(Ut=>Ut.id!==Ie.id));const{states:it}=await Mhe([{object_type:Ie.object_type,object_id:Ie.object_id}]);it.length>0&&d(it),u().catch(()=>{}),rn()}catch{}finally{L(null)}},[u,d,rn]),kt=x.useCallback(async Ie=>{q(Ie.id);try{await Ahe(Ie.id),g(it=>it.filter(ct=>ct.id!==Ie.id))}catch{}finally{q(null)}},[]),rt=x.useCallback(Ie=>{je({title:"Decline Invite",message:`Are you sure you want to decline the invite to "${Ie.object_name}"?`,confirmText:"Decline",onConfirm:()=>{je(null),kt(Ie)}})},[kt]),Tt=Ie=>Ie==="Editor"?"editor":"viewer",Mt=x.useCallback(async(Ie,it,ct)=>{we(it);try{await Ohe(Ie.object_type,Ie.object_id,it,ct),await dt()}catch{}finally{we(null)}},[dt]),Rt=x.useCallback(async(Ie,it)=>{fe(it);try{await dM(Ie.object_type,Ie.object_id,it),await dt()}catch{}finally{fe(null)}},[dt]),Ct=x.useCallback((Ie,it)=>{const ct=Ie.members.find(Et=>Et.user_id===it),Ut=(ct==null?void 0:ct.name)??(ct==null?void 0:ct.email)??it;je({title:"Remove Collaborator",message:`Are you sure you want to remove ${Ut} from "${Ie.object_name}"? They will lose access immediately.`,confirmText:"Remove",onConfirm:()=>{je(null),Rt(Ie,it)}})},[Rt]),Gt=x.useCallback(async(Ie,it)=>{pe(Ie);try{await Lhe(Ie,it),await dt()}catch{}finally{pe(null)}},[dt]),Lt=x.useCallback(async Ie=>{le(Ie);try{await $he(Ie),await dt()}catch{}finally{le(null)}},[dt]),$t=x.useCallback((Ie,it)=>{je({title:"Cancel Invite",message:`Are you sure you want to cancel the invite${it?` to ${it}`:""}? They will no longer be able to accept it.`,confirmText:"Cancel Invite",onConfirm:()=>{je(null),Lt(Ie)}})},[Lt]),Qt=x.useCallback(async(Ie,it,ct)=>{try{await Dhe(Ie.object_type,Ie.object_id,it,ct),await dt()}catch{}},[dt]),Ye=x.useCallback(async(Ie,it)=>{try{await Fhe(Ie,it),await dt()}catch{}},[dt]),bt=Ie=>({song:"Song",text_node:"Text",embedding_node:"Embed",visual_node:"Media"})[Ie]??Ie;return t?c.jsxs(c.Fragment,{children:[c.jsx(Wr,{onClose:e,widthClass:"w-[420px]",heightClass:"max-h-[85vh]",children:c.jsxs("div",{className:`flex flex-col h-full rounded-xl overflow-hidden ${o?"bg-zinc-900/95 border border-zinc-700":"bg-white/95 border border-zinc-300"}`,children:[c.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${o?"border-zinc-700":"border-zinc-200"}`,children:[c.jsxs("h2",{className:"text-lg font-medium flex items-center gap-2",children:[c.jsx(bx,{className:"w-5 h-5"}),"Collaboration"]}),c.jsx("button",{onClick:e,className:"p-2 rounded-lg hover:bg-zinc-200/20 transition-colors","aria-label":"Close",children:c.jsx(nr,{size:20})})]}),c.jsxs("div",{className:`flex border-b ${o?"border-zinc-700":"border-zinc-200"}`,children:[c.jsxs("button",{onClick:()=>m("share"),className:`flex-1 flex items-center justify-center gap-2 py-3 text-sm font-medium transition-colors ${h==="share"?"text-caiGreen border-b-2 border-caiGreen":o?"text-zinc-400 hover:text-zinc-200":"text-zinc-500 hover:text-zinc-700"}`,children:[c.jsx(Gne,{className:"w-4 h-4"}),"Share"]}),c.jsxs("button",{onClick:()=>m("invites"),className:`flex-1 flex items-center justify-center gap-2 py-3 text-sm font-medium transition-colors ${h==="invites"?"text-caiGreen border-b-2 border-caiGreen":o?"text-zinc-400 hover:text-zinc-200":"text-zinc-500 hover:text-zinc-700"}`,children:[c.jsx(tne,{className:"w-4 h-4"}),"Invites",y.length>0&&c.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-xs bg-caiGreen/20 text-caiGreen",children:y.length})]}),c.jsxs("button",{onClick:()=>m("manage"),className:`flex-1 flex items-center justify-center gap-2 py-3 text-sm font-medium transition-colors ${h==="manage"?"text-caiGreen border-b-2 border-caiGreen":o?"text-zinc-400 hover:text-zinc-200":"text-zinc-500 hover:text-zinc-700"}`,children:[c.jsx(_z,{className:"w-4 h-4"}),"Manage"]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[h==="share"&&c.jsx("section",{className:"space-y-3",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:`block text-xs font-medium mb-1 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Role"}),c.jsxs("div",{className:"flex gap-4 mb-3",children:[c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"radio",name:"inviteRole",value:"viewer",checked:_==="viewer",onChange:()=>j("viewer"),className:"accent-caiGreen"}),c.jsx("span",{className:"text-sm",children:"Viewer"})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"radio",name:"inviteRole",value:"editor",checked:_==="editor",onChange:()=>j("editor"),className:"accent-caiGreen"}),c.jsx("span",{className:"text-sm",children:"Editor"})]})]}),c.jsx("label",{className:`block text-xs font-medium mb-1 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Item to share"}),c.jsxs("select",{value:S?`${S.type}-${S.id}`:"",onChange:Ie=>{const it=Ie.target.value;if(!it){C(null);return}const[ct,Ut]=it.split("-"),Et=parseInt(Ut,10),yn=tt.find(nn=>nn.type===ct&&nn.id===Et);C(yn||null)},className:`w-full px-3 py-2 rounded-lg text-sm border ${o?"bg-zinc-800 border-zinc-600 text-zinc-100":"bg-white border-zinc-300 text-zinc-900"}`,children:[c.jsx("option",{value:"",children:"Select item to share"}),tt.map(Ie=>c.jsxs("option",{value:`${Ie.type}-${Ie.id}`,children:[Ie.objectTypeLabel,": ",Ie.label]},`${Ie.type}-${Ie.id}`))]}),c.jsxs("div",{className:`flex flex-col gap-2 p-3 rounded-lg ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:[c.jsx("span",{className:`text-xs font-medium ${o?"text-zinc-400":"text-zinc-500"}`,children:"Permissions for invitee"}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:T,onChange:Ie=>M(Ie.target.checked),className:"rounded accent-caiGreen"}),c.jsx("span",{className:"text-sm",children:"Allow collaborator to copy"})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:V,onChange:Ie=>H(Ie.target.checked),className:"rounded accent-caiGreen"}),c.jsx("span",{className:"text-sm",children:"Allow collaborator to export"})]})]}),S&&c.jsx("div",{className:`rounded-lg overflow-hidden ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:(()=>{const Ie=Wk(S.type),it=(ke??[]).find(nn=>nn.object_type===Ie&&nn.object_id===S.id),ct=(it==null?void 0:it.members)??[],Ut=(it==null?void 0:it.pending_invites)??[],Et=ct.length>0||Ut.length>0,yn=`w-4 h-4 shrink-0 ${o?"text-zinc-500":"text-zinc-400"}`;return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between p-2",children:[c.jsx("span",{className:`text-xs font-medium ${o?"text-zinc-400":"text-zinc-500"}`,children:"Shared with"}),Et&&c.jsx("button",{type:"button",onClick:()=>{it&&(re(it),m("manage"))},className:`p-0.5 rounded bg-transparent border-0 cursor-pointer ${o?"text-zinc-500 hover:text-zinc-400":"text-zinc-400 hover:text-zinc-600"}`,title:"Manage","aria-label":"Manage",children:c.jsx(_z,{className:"w-3.5 h-3.5"})})]}),c.jsx("div",{className:"max-h-32 overflow-y-auto p-2 space-y-1.5",children:ct.length===0&&Ut.length===0?c.jsx("p",{className:`text-xs ${o?"text-zinc-500":"text-zinc-400"}`,children:"No collaborators yet"}):c.jsxs("div",{className:"space-y-1.5",children:[ct.map(nn=>{var rr,xn,Bn;return c.jsxs("div",{className:"flex items-center gap-2 w-full",children:[c.jsxs("div",{className:"w-[55%] min-w-0 shrink-0",children:[c.jsx("span",{className:`text-xs block truncate ${o?"text-zinc-300":"text-zinc-700"}`,children:nn.name??nn.email??nn.user_id}),nn.email&&nn.name&&c.jsx("span",{className:`text-[10px] block truncate ${o?"text-zinc-500":"text-zinc-400"}`,children:nn.email})]}),c.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 justify-end",children:[c.jsx("span",{title:((rr=nn.role)==null?void 0:rr.toLowerCase())==="editor"?"Editor":"Viewer","aria-label":((xn=nn.role)==null?void 0:xn.toLowerCase())==="editor"?"Editor":"Viewer",children:((Bn=nn.role)==null?void 0:Bn.toLowerCase())==="editor"?c.jsx(Tl,{className:yn}
911):c.jsx(Jy,{className:yn})}),nn.allow_copy&&c.jsx("span",{title:"Can copy","aria-label":"Can copy",children:c.jsx(Do,{className:yn})}),nn.allow_export&&c.jsx("span",{title:"Can export","aria-label":"Can export",children:c.jsx(cd,{className:yn})})]})]},nn.user_id)}),Ut.map(nn=>{var rr,xn,Bn;return c.jsxs("div",{className:"flex items-center gap-2 w-full",children:[c.jsxs("div",{className:"w-[55%] min-w-0 shrink-0",children:[c.jsx("span",{className:`text-xs block truncate ${o?"text-zinc-500":"text-zinc-400"}`,children:nn.email}),c.jsx("span",{className:`text-[10px] block truncate ${o?"text-zinc-600":"text-zinc-400"}`,children:"pending"})]}),c.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 justify-end",children:[c.jsx("span",{title:((rr=nn.role)==null?void 0:rr.toLowerCase())==="editor"?"Editor":"Viewer","aria-label":((xn=nn.role)==null?void 0:xn.toLowerCase())==="editor"?"Editor":"Viewer",children:((Bn=nn.role)==null?void 0:Bn.toLowerCase())==="editor"?c.jsx(Tl,{className:yn}):c.jsx(Jy,{className:yn})}),nn.allow_copy&&c.jsx("span",{title:"Can copy","aria-label":"Can copy",children:c.jsx(Do,{className:yn})}),nn.allow_export&&c.jsx("span",{title:"Can export","aria-label":"Can export",children:c.jsx(cd,{className:yn})})]})]},nn.id)})]})})]})})()}),c.jsx("label",{className:`block text-xs font-medium mb-1 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Email addresses"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"flex-1 relative",children:[c.jsx(_h,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-500"}),c.jsx("input",{type:"text",inputMode:"email",placeholder:"Comma-separated emails",value:k,onChange:Ie=>N(Ie.target.value),className:`w-full pl-9 pr-3 py-2 rounded-lg text-sm border ${o?"bg-zinc-800 border-zinc-600 text-zinc-100 placeholder-zinc-500":"bg-white border-zinc-300 text-zinc-900 placeholder-zinc-400"}`})]}),c.jsxs("button",{onClick:pn,disabled:P,className:"px-4 py-2 rounded-lg bg-gradient-to-r from-caiGreen to-caiBlue text-white text-sm font-medium hover:opacity-90 disabled:opacity-60 flex items-center gap-2",children:[P?c.jsx(Da,{className:"w-4 h-4 animate-spin"}):null,"Send"]})]}),I&&c.jsx("p",{className:"text-sm text-red-500",children:I}),U&&c.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:W>1?`Invites sent to ${W} people!`:"Invite sent!"})]})}),h==="invites"&&c.jsx("section",{children:w?c.jsxs("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[c.jsx(Da,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):y.length===0?c.jsx("p",{className:`text-sm ${o?"text-zinc-400":"text-zinc-500"}`,children:"No pending invites"}):c.jsx("ul",{className:"space-y-2",children:y.map(Ie=>c.jsxs("li",{className:`flex items-center justify-between p-3 rounded-lg ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-sm font-medium truncate",children:Ie.object_name}),c.jsxs("p",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:[bt(Ie.object_type)," shared with you"]})]}),c.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[c.jsx("button",{onClick:()=>cn(Ie),disabled:B===Ie.id,className:"p-2 rounded-lg bg-green-600/20 text-green-600 hover:bg-green-600/30 disabled:opacity-50",title:"Accept",children:B===Ie.id?c.jsx(Da,{className:"w-4 h-4 animate-spin"}):c.jsx(Ml,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>rt(Ie),disabled:$===Ie.id,className:"p-2 rounded-lg bg-red-600/20 text-red-600 hover:bg-red-600/30 disabled:opacity-50",title:"Decline",children:$===Ie.id?c.jsx(Da,{className:"w-4 h-4 animate-spin"}):c.jsx(Cte,{className:"w-4 h-4"})})]})]},Ie.id))})}),h==="manage"&&c.jsx("section",{className:"space-y-4",children:Z?c.jsxs("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[c.jsx(Da,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):(ke??[]).length===0&&(qe??[]).length===0?c.jsx("p",{className:`text-sm ${o?"text-zinc-400":"text-zinc-500"}`,children:"No shared objects. Share something from the Share tab to manage it here."}):c.jsxs(c.Fragment,{children:[(ke??[]).length>0&&c.jsxs("div",{children:[c.jsxs("button",{type:"button",onClick:()=>Se(Ie=>!Ie),className:`flex items-center gap-1 w-full text-left text-xs font-medium mb-2 ${o?"text-zinc-400 hover:text-zinc-300":"text-zinc-500 hover:text-zinc-700"} transition-colors`,children:[c.jsx(Vi,{className:`w-3.5 h-3.5 transition-transform ${Ue?"":"-rotate-90"}`}),"Shared by me",c.jsxs("span",{className:`ml-1 text-[10px] ${o?"text-zinc-500":"text-zinc-400"}`,children:["(",(ke??[]).length,")"]})]}),Ue&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:`block text-xs font-medium mb-1 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Select shared object"}),c.jsxs("select",{value:ge?`${ge.object_type}-${ge.object_id}`:"",onChange:Ie=>{const it=Ie.target.value;if(!it){re(null);return}const[ct,Ut]=it.split("-"),Et=parseInt(Ut,10),yn=(ke??[]).find(nn=>nn.object_type===ct&&nn.object_id===Et);re(yn||null)},className:`w-full px-3 py-2 rounded-lg text-sm border ${o?"bg-zinc-800 border-zinc-600 text-zinc-100":"bg-white border-zinc-300 text-zinc-900"}`,children:[c.jsx("option",{value:"",children:"Choose an object..."}),(ke??[]).map(Ie=>c.jsxs("option",{value:`${Ie.object_type}-${Ie.object_id}
911`,children:[Ie.object_name," (",bt(Ie.object_type),")"]},`${Ie.object_type}-${Ie.object_id}`))]})]}),Y&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:`text-xs font-medium mb-2 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Collaborators"}),Y.members.length===0?c.jsx("p",{className:`text-sm ${o?"text-zinc-500":"text-zinc-400"}`,children:"No collaborators yet"}):c.jsx("ul",{className:"space-y-2",children:Y.members.map(Ie=>c.jsxs("li",{className:`p-3 rounded-lg ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("span",{className:`text-sm block truncate max-w-[200px] ${o?"text-zinc-300":"text-zinc-700"}`,title:[Ie.name,Ie.email,Ie.user_id].filter(Boolean).join(" · ")||Ie.user_id,children:Ie.name??Ie.email??(Ie.user_id.length>16?`${Ie.user_id.slice(0,14)}â¦`:Ie.user_id)}),Ie.email!=null&&(Ie.name==null||Ie.email!==Ie.name)&&c.jsx("span",{className:`text-xs block truncate max-w-[200px] ${o?"text-zinc-500":"text-zinc-400"}`,children:Ie.email})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("select",{value:Tt(Ie.role),onChange:it=>Mt(Y,Ie.user_id,it.target.value),disabled:be===Ie.user_id,className:`text-xs px-2 py-1 rounded border ${o?"bg-zinc-700 border-zinc-600 text-zinc-200":"bg-white border-zinc-300 text-zinc-800"}`,children:[c.jsx("option",{value:"viewer",children:"Viewer"}),c.jsx("option",{value:"editor",children:"Editor"})]}),c.jsx("button",{onClick:()=>Ct(Y,Ie.user_id),disabled:te===Ie.user_id,className:"p-1.5 rounded hover:bg-red-600/20 text-red-600",title:"Remove",children:te===Ie.user_id?c.jsx(Da,{className:"w-4 h-4 animate-spin"}):c.jsx(xre,{className:"w-4 h-4"})})]})]}),c.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:Ie.allow_copy,onChange:it=>Qt(Y,Ie.user_id,{allow_copy:it.target.checked}),className:"rounded accent-caiGreen w-3.5 h-3.5"}),c.jsx("span",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:"Copy"})]}),c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:Ie.allow_export,onChange:it=>Qt(Y,Ie.user_id,{allow_export:it.target.checked}),className:"rounded accent-caiGreen w-3.5 h-3.5"}),c.jsx("span",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:"Export"})]})]})]},Ie.user_id))})]}),c.jsxs("div",{children:[c.jsx("h3",{className:`text-xs font-medium mb-2 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Pending invites"}),Y.pending_invites.length===0?c.jsx("p",{className:`text-sm ${o?"text-zinc-500":"text-zinc-400"}`,children:"No pending invites"}):c.jsx("ul",{className:"space-y-2",children:Y.pending_invites.map(Ie=>c.jsxs("li",{className:`p-3 rounded-lg ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:`text-sm truncate ${o?"text-zinc-300":"text-zinc-700"}`,children:Ie.email}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("select",{value:Tt(Ie.role),onChange:it=>Gt(Ie.id,it.target.value),disabled:O===Ie.id,className:`text-xs px-2 py-1 rounded border ${o?"bg-zinc-700 border-zinc-600 text-zinc-200":"bg-white border-zinc-300 text-zinc-800"}`,children:[c.jsx("option",{value:"viewer",children:"Viewer"}),c.jsx("option",{value:"editor",children:"Editor"})]}),c.jsx("button",{onClick:()=>$t(Ie.id,Ie.email),disabled:he===Ie.id,className:"p-1.5 rounded hover:bg-red-600/20 text-red-600",title:"Cancel invite",children:he===Ie.id?c.jsx(Da,{className:"w-4 h-4 animate-spin"}):c.jsx(js,{className:"w-4 h-4"})})]})]}),c.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:Ie.allow_copy,onChange:it=>Ye(Ie.id,{allow_copy:it.target.checked}),className:"rounded accent-caiGreen w-3.5 h-3.5"}),c.jsx("span",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:"Copy"})]}),c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:Ie.allow_export,onChange:it=>Ye(Ie.id,{allow_export:it.target.checked}),className:"rounded accent-caiGreen w-3.5 h-3.5"}),c.jsx("span",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:"Export"})]})]})]},Ie.id))})]})]})]})]}),(qe??[]).length>0&&c.jsxs("div",{children:[c.jsxs("button",{type:"button",onClick:()=>Ae(Ie=>!Ie),className:`flex items-center gap-1 w-full text-left text-xs font-medium mb-2 ${o?"text-zinc-400 hover:text-zinc-300":"text-zinc-500 hover:text-zinc-700"} transition-colors`,children:[c.jsx(Vi,{className:`w-3.5 h-3.5 transition-transform ${Ce?"":"-rotate-90"}`}),"Shared with me",c.jsxs("span",{className:`ml-1 text-[10px] ${o?"text-zinc-500":"text-zinc-400"}`,children:["(",(qe??[]).length,")"]})]}),Ce&&c.jsx("ul",{className:"space-y-2",children:(qe??[]).map(Ie=>{const it=`${Ie.object_type}-${Ie.object_id}`,ct=de===it;return c.jsxs("li",{className:`flex items-center justify-between p-3 rounded-lg ${o?"bg-zinc-800/50":"bg-zinc-100/50"}`,children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-sm font-medium truncate",children:Ie.object_name}),c.jsxs("p",{className:`text-xs ${o?"text-zinc-400":"text-zinc-500"}`,children:[bt(Ie.object_type)," · ",Ie.role]})]}),c.jsxs("button",{onClick:()=>Kt(Ie),disabled:ct,className:`ml-2 flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${o?"bg-red-600/20 text-red-400 hover:bg-red-600/30":"bg-red-50 text-red-600 hover:bg-red-100"} disabled:opacity-50`,title:"Leave collaboration",children:[ct?c.jsx(Da,{className:"w-3.5 h-3.5 animate-spin"}):c.jsx(yD,{className:"w-3.5 h-3.5"}),"Leave"]})]},it)})})]})]})})]})]})}
911),c.jsx(al,{isOpen:ve!==null,onClose:()=>je(null),onConfirm:()=>ve==null?void 0:ve.onConfirm(),title:(ve==null?void 0:ve.title)??"",message:(ve==null?void 0:ve.message)??"",confirmText:(ve==null?void 0:ve.confirmText)??"Confirm",isDangerous:!0}),Te&&c.jsx(Wr,{onClose:()=>ce(!1),widthClass:"w-[460px]",blurBackground:!0,children:c.jsxs("div",{className:`flex flex-col rounded-xl overflow-hidden ${o?"bg-zinc-900/95 border border-zinc-700":"bg-white/95 border border-zinc-300"}`,children:[c.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${o?"border-zinc-700":"border-zinc-200"}`,children:[c.jsx("h3",{className:"text-base font-medium",children:"Agentic requests in collaboration"}),c.jsx("button",{onClick:()=>ce(!1),className:"p-2 rounded-lg hover:bg-zinc-200/20 transition-colors","aria-label":"Close",children:c.jsx(nr,{size:18})})]}),c.jsxs("div",{className:"p-4 space-y-3",children:[c.jsxs("p",{className:`text-sm ${o?"text-zinc-300":"text-zinc-700"}`,children:["In collaborative chats, use ",c.jsx("span",{className:"font-semibold",children:"@cai"})," when you want Cai to perform an agentic request."]}),c.jsxs("p",{className:`text-sm ${o?"text-zinc-400":"text-zinc-600"}`,children:["Messages without ",c.jsx("span",{className:"font-semibold",children:"@cai"})," are treated as human-only chat."]}),c.jsxs("p",{className:`text-sm ${o?"text-zinc-300":"text-zinc-700"}`,children:["Example: ",c.jsx("span",{className:"font-semibold",children:"@cai give me a heartfelt piano"})]}),c.jsxs("div",{className:"pt-1",children:[c.jsx("label",{className:`block text-xs font-medium mb-1 ${o?"text-zinc-400":"text-zinc-500"}`,children:"Future reminders"}),c.jsxs("select",{value:se,onChange:Ie=>ye(Ie.target.value),className:`w-full px-3 py-2 rounded-lg text-sm border ${o?"bg-zinc-800 border-zinc-600 text-zinc-100":"bg-white border-zinc-300 text-zinc-900"}`,children:[c.jsx("option",{value:"show_again",children:"Show this message again"}),c.jsx("option",{value:"do_not_show",children:"Do not show again"})]})]})]}),c.jsx("div",{className:`p-4 border-t flex justify-end ${o?"border-zinc-700":"border-zinc-200"}`,children:c.jsx("button",{onClick:()=>{se==="do_not_show"&&l(!0),ce(!1)},className:"px-4 py-2 rounded-lg bg-gradient-to-r from-caiGreen to-caiBlue text-white text-sm font-medium hover:opacity-90",children:"Got it"})})]})})]}):null},Uhe=()=>{const[t,e]=x.useState(!1);return c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>e(!0),className:"bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-transform duration-150 active:scale-90 focus:outline-none hover:opacity-90",title:"Collaboration","aria-label":"Open collaboration",children:c.jsx(bx,{className:"w-5 h-5"})}),c.jsx(KL,{isOpen:t,onClose:()=>e(!1)})]})},hM=()=>{const{getSongById:t,getEmbeddingNodeById:e,getVisualMediaNodeById:n,getTextNodeById:r,getBloobById:i,getNoteById:s,findOpenSongPositionNear:o}=mn(),{duplicateSong:a,duplicateEmbeddingNode:l,duplicateVisualMediaNode:u,duplicateTextNode:d,duplicateBloob:f,deleteBloob:h,deleteSong:m,deleteEmbeddingNode:y,deleteVisualMediaNode:g,deleteTextNode:w}=Gn(),{selectedSingleCaiObject:v,selectedCaiObjects:S,dragMode:C}=Yn(),{setDragMode:k,selectCaiObjects:N,deselectAllCaiObjects:_}=cr(),{commitToStore:j}=Ln(),{showMobileInspector:T,showMobileSearch:M}=Br(),[V,H]=x.useState(!1),[P,F]=x.useState(!1),[I,R]=x.useState(!1),U=at(be=>be.domainRoleByChannel),A=at(be=>be.domainPolicyByChannel),W=at(be=>be.sharedByMe),D={getBloobById:i,getNoteById:s},{canCopySelection:B,canDeleteSelection:L}=x.useMemo(()=>{var te;let be=!0,we=!0;for(const fe of S){const O=Xy(fe,D);if(O){const pe=(te=U[O])==null?void 0:te.toLowerCase();if(pe==="viewer"){if(we=!1,fe.type===J.Song||fe.type===J.TextNode||fe.type===J.EmbeddingNode||fe.type===J.VisualMediaNode){const le=A[O];le!=null&&le.allowCopy||(be=!1)}}else if(pe==="editor"&&(fe.type===J.Song||fe.type===J.TextNode||fe.type===J.EmbeddingNode||fe.type===J.VisualMediaNode)){we=!1;const le=A[O];le!=null&&le.allowCopy||(be=!1)}}}return{canCopySelection:be,canDeleteSelection:we}},[S,U,A,i,s]),$=x.useCallback(()=>{v&&T()},[v,T]),q=x.useCallback(be=>{switch(be.type){case J.Song:{const we=t(be.id);return Ro(we.canvasPosition)}case J.EmbeddingNode:{const we=e(be.id);return Ro(we.canvasPosition)}case J.VisualMediaNode:{const we=n(be.id);return Ro(we.canvasPosition)}case J.TextNode:{const we=r(be.id);return Ro(we.canvasPosition)}default:throw new Error("Invalid copyCaiObject type")}},[e,t,r,n]),Z=x.useCallback(be=>{if(be.type===J.Bloob)throw new Error("Cannot paste non-bloob bloob");const we=q(be);switch(be.type){case J.Song:return a(be.id,we);case J.EmbeddingNode:return l(be.id,we);case J.VisualMediaNode:return u(be.id,we);case J.TextNode:return d(be.id,we)}},[q,a,l,u,d]),ie=x.useCallback(be=>{const we=i(be),te=o(we.songId,we.songPosition,we.bars??1);return te==null?-1:f(we.id,te)},[i,f,o]),ge=x.useCallback(()=>
911{if(!S)return;const be=[];S.forEach(we=>{let te;we.type===J.Bloob?te=ie(we.id):te=Z(we),te!==void 0&&be.push({type:we.type,id:te})}),be.length>0&&(N(be),j())},[j,ie,Z,N,S]),re=x.useCallback(()=>{if(!S)return;const be=at.getState().domainRoleByChannel,we={getBloobById:i,getNoteById:s};S.forEach(te=>{var O;const fe=Xy(te,we);if(fe){const pe=(O=be[fe])==null?void 0:O.toLowerCase();if(pe==="viewer"||(te.type===J.Song||te.type===J.TextNode||te.type===J.EmbeddingNode||te.type===J.VisualMediaNode)&&pe==="editor")return}te.type===J.Bloob?h(te.id):te.type===J.Song?m(te.id):te.type===J.EmbeddingNode?y(te.id):te.type===J.VisualMediaNode?g(te.id):te.type===J.TextNode&&w(te.id)}),_(),j(),F(!1)},[S,_,j,h,m,y,g,w,i,s]),Y=x.useCallback(()=>{if(!(S!=null&&S.length))return;const be=S.filter(fe=>{if(!dv(fe.type))return!1;const O=Zf(fe);return O?v8(O,U):!1}),we=be.some(fe=>fe.type===J.Song),te=be.some(fe=>{const O=Zf(fe);return O?So(O,U,W):!1});we||te?F(!0):re()},[S,re,U,W]),ne=x.useMemo(()=>{const be=S.filter(O=>dv(O.type)),we=be.filter(O=>{const pe=Zf(O);return pe?So(pe,U,W):!1}),te=be.map(O=>O.type===J.Song?t(O.id).label:O.type===J.TextNode?r(O.id).label:O.type===J.EmbeddingNode?e(O.id).label:O.type===J.VisualMediaNode?n(O.id).label:"");let fe="Are you sure you want to delete the selected objects?";if(be.length===1&&te[0]){const O=be[0];if(O.type===J.Song)fe=`Are you sure you want to delete "${te[0]}"? This will permanently remove the song and all its bloobs.`;else{const pe=O.type===J.TextNode?"note":O.type===J.EmbeddingNode?"embedding":"visual media object";fe=`Are you sure you want to delete "${te[0]}"? This will permanently remove this ${pe}.`}}else be.length>1?fe=`Are you sure you want to delete ${be.length} selected objects? This action cannot be undone.`:S.length===1&&S[0].type===J.Bloob&&(fe="Are you sure you want to delete this bloob?");return we.length>0?`${fe} ${we.length===1?"One selected object is currently shared with collaborators.":`${we.length} selected objects are currently shared with collaborators.`}`:fe},[S,U,W,t,r,e,n]);return c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:`bg-glass border-glass rounded-xl flex flex-col w-10 gap-5 items-center py-2 text-cai-secondary transition-[opacity,transform] duration-300 ease-in-out transform origin-top ${V?"opacity-100 scale-y-100 translate-y-0":"opacity-0 scale-y-0 translate-y-0 pointer-events-none"}`,children:[c.jsx("button",{onClick:()=>H(!1),className:"transition-transform duration-150 active:scale-90",children:c.jsx(kD,{className:"size-6 text-zinc-900 dark:text-zinc-100"})}),c.jsx("button",{onClick:()=>k(Hs.MOVE),className:"transition-transform duration-150 active:scale-90",children:c.jsx(ev,{className:`size-5 ${C===Hs.MOVE?"text-zinc-900 dark:text-zinc-100":"text-zinc-400 dark:text-zinc-400"}`})}),c.jsx("button",{onClick:()=>k(Hs.SELECT),className:"transition-transform duration-150 active:scale-90",children:c.jsx(ED,{className:`size-5 ${C===Hs.SELECT?"text-zinc-900 dark:text-zinc-100":"text-zinc-400 dark:text-zinc-400"}`})}),c.jsx("button",{className:`transition-[colors,transform] duration-150 ease-in-out active:scale-90 ${v?"text-cai-secondary":"text-zinc-400 dark:text-zinc-500"}`,onClick:$,children:c.jsx(Kc,{className:"size-5"})}),c.jsx("button",{className:`transition-colors duration-150 ease-in-out ${S.length&&B?"text-cai-secondary":"text-zinc-400 dark:text-zinc-500"}`,disabled:!S.length||!B,onClick:ge,children:c.jsx(Do,{className:"size-5"})}),c.jsx("button",{className:`transition-colors duration-150 ease-in-out ${S.length&&L?"text-red-500":"text-red-300 dark:text-red-800"}`,disabled:!S.length||!L,onClick:Y,children:c.jsx(js,{className:"size-5"})}),c.jsx("button",{className:"transition-[transform] duration-150 ease-in-out active:scale-90 text-cai-secondary",onClick:M,children:c.jsx(px,{className:"size-5"})}),c.jsx("button",{className:"transition-[transform] duration-150 ease-in-out active:scale-90 text-cai-secondary",onClick:()=>R(!0),title:"Collaboration","aria-label":"Open collaboration",children:c.jsx(bx,{className:"size-5"})})]}),c.jsx("button",{className:`bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-[opacity,transform] duration-300 ease-in-out transform active:scale-90 focus:outline-none flex-shrink-0 absolute top-0 left-0 ${V?"opacity-0 scale-95 translate-y-2 pointer-events-none":"opacity-100 scale-100 translate-y-0"}`,onClick:()=>H(!0),title:"Expand Actions",children:c.jsx(jD,{className:"w-6 h-6"})}),c.jsx(al,{isOpen:P,onClose:()=>F(!1),onConfirm:re,title:"Confirm Delete",message:ne,confirmText:"Delete",isDangerous:!0}),c.jsx(KL,{isOpen:I,onClose:()=>R(!1)})]})},Vhe=({onSignOut:t})=>{const{undo:e,redo:n}=Ln(),{isMobile:r,isMobileSmall:i}=Hn();return r?i?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed top-4 left-4 z-49 flex flex-col gap-2",children:c.jsx(hM,{})}),c.jsxs("div",{className:"fixed top-4 right-4 z-49 flex flex-col gap-2",children:[c.jsx(ky,{onSignOut:t}),c.jsx("button",{className:"bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-transform duration-150 active:scale-90 focus:outline-none ",onClick:e,title:"Undo",children:c.jsx(qS,{className:"w-5 h-5"})}),c.jsx("button",{className:"bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-transform duration-150 active:scale-90 focus:outline-none ",onClick:n,title:"Redo",children:c.jsx(HS,{className:"w-5 h-5"})})]})]}):c.jsx(c.Fragment,{children:c.jsxs("div",{className:"fixed top-4 left-4 right-4 z-49 flex items-start justify-between gap-2 pointer-events-none",children:[c.jsxs("div",{className:"flex items-start gap-2 pointer-events-auto",children:[c.jsx(hM,{}),c.jsx("button",{className:"bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-transform duration-150 active:scale-90 focus:outline-none flex-shrink-0 ",onClick:e,title:"Undo",children:c.jsx(qS,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex items-center gap-2 pointer-events-auto",children:[c.jsx("button",{className:"bg-glass border-glass w-10 h-10 rounded-xl flex items-center justify-center transition-transform duration-150 active:scale-90 focus:outline-none flex-shrink-0 ",onClick:n,title:"Redo",children:c.jsx(HS,{className:"w-5 h-5"})}),c.jsx(ky,{onSignOut:t})]})]})}):c.jsx(c.Fragment,{children:c.jsxs("div",{className:"fixed top-4 right-4 z-49 flex flex-col space-y-4",children:[c.jsx("div",{className:"w-full flex justify-end",children:c.jsx(ky,{onSignOut:t})}),c.jsx(qL,{}),c.jsx(Uhe,{})]})})},pM=({sizeClassName:t,fillClassName:e,showR:n})=>c.jsxs("svg",{className:`text-zinc-100 ${e} ${t}`,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),c.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsxs("g",{id:"SVGRepo_iconCarrier",children:[c.jsxs("g",{fillRule:"evenodd",children:[c.jsx("path",{d:"M64.458 228.867c-.428 2.167 1.007 3.91 3.226 3.893l121.557-.938c2.21-.017 3.68-1.794 3.284-3.97l-11.838-64.913c-.397-2.175-1.626-2.393-2.747-.487l-9.156 15.582c-1.12 1.907-1.71 5.207-1.313 7.388l4.915 27.03c.395 2.175-1.072 3.937-3.288 3.937H88.611c-2.211 0-3.659-1.755-3.233-3.92L114.85 62.533l28.44-.49 11.786 44.43c.567 2.139 2.01 2.386 3.236.535l8.392-12.67c1.22-1.843 1.73-5.058 1.139-7.185l-9.596-34.5c-1.184-4.257-5.735-7.677-10.138-7.638l-39.391.349c-4.415.039-8.688 3.584-9.544 7.912L64.458 228.867z"}),c.jsx("path",{d:"M118.116 198.935c-1.182 1.865-.347 3.377 1.867 3.377h12.392c2.214 0 4.968-1.524 6.143-3.39l64.55-102.463c1.18-1.871 3.906-3.697 6.076-4.074l9.581-1.667c2.177-.379 4.492-2.38 5.178-4.496l4.772-14.69c.683-2.104-.063-5.034-1.677-6.555L215.53 54.173c-1.609-1.517-4.482-1.862-6.4-.78l-11.799 6.655c-1.925 1.086-3.626 3.754-3.799 5.954l-.938 11.967c-.173 2.202-1.27 5.498-2.453 7.363l-72.026 113.603z"})]}),n&&c.jsx("text",{x:"0",y:"20",fill:It.red[500],fontSize:"110",fontWeight:"bold",dominantBaseline:"hanging",children:"R"})]})]}),Sv=({size:t=22,className:e=""})=>typeof t=="number"?c.jsx("div",{className:`animate-spin rounded-full border-2 border-zinc-400 border-t-zinc-700 dark:border-zinc-400 dark:border-t-zinc-100 ${e}`,style:{width:t,height:t}}):c.jsx("div",{className:`animate-spin rounded-full border-2 border-zinc-400 border-t-zinc-700 dark:border-zinc-400 dark:border-t-zinc-100 ${t} ${e}`});let um={};const LC=new Set,Hhe=()=>{const t={...um};
911LC.forEach(e=>e(t))},YL=()=>{const{getAllEmbeddingNodes:t}=mn(),[e,n]=x.useState(()=>({...um}));x.useEffect(()=>{const o=a=>{n(a)};return LC.add(o),n({...um}),()=>{LC.delete(o)}},[]);const r=x.useCallback((o,a)=>{um={...um,[o]:a},Hhe()},[]),i=x.useCallback(o=>{var f;const a=Object.values(t()).find(h=>h&&h.id===o);if(!(a!=null&&a.url))return;const l=e[o]||!1,u=document.querySelectorAll('[aria-label*="Embed"]');let d=null;for(const h of u){const m=h.querySelector("iframe");if(m){d=m;break}}if(d)if(a.url.includes("youtube.com")||a.url.includes("youtu.be")){let h=d.src;if(!h.includes("enablejsapi=1")){const m=h.includes("?")?"&":"?";h+=m+"enablejsapi=1"}if(!h.includes("origin=")){const m=h.includes("?")?"&":"?";h+=m+`origin=${encodeURIComponent(window.location.origin)}`}if(d.src!==h)d.src=h,setTimeout(()=>{var y;const m=l?"pauseVideo":"playVideo";(y=d.contentWindow)==null||y.postMessage(`{"event":"command","func":"${m}","args":""}`,"*")},1e3);else{const m=l?"pauseVideo":"playVideo";(f=d.contentWindow)==null||f.postMessage(`{"event":"command","func":"${m}","args":""}`,"*")}setTimeout(()=>{(()=>{r(o,!l)})()},50)}else d.click(),setTimeout(()=>{r(o,!l)},50)},[t,e,r]),s=x.useCallback(o=>{r(o,!1)},[r]);return{embeddingPlayStates:e,handleEmbeddingPlayPause:i,updateEmbeddingPlayState:r,resetEmbeddingState:s}},Ghe=1024,Whe=540,mM={desktop:{icon:"size-7",slider:"h-2",panelPadding:"p-2",panelWidth:"w-48",volumeFontSize:"text-lg",sliderHeight:"h-8",gap:"gap-3"},mobile:{icon:"size-7",slider:"h-2",panelPadding:"p-2",panelWidth:"w-48",volumeFontSize:"text-lg",sliderHeight:"h-6",gap:"gap-2"}},XL=({onSignOut:t,immersedContainerWidth:e=null})=>{const{getSongById:n,getSongName:r,getBloobById:i,findOpenSongPositionNear:s,getEmbeddingNodeById:o,getVisualMediaNodeById:a}=mn(),{addBloob:l,addSong:u,updateSongDetails:d}=Gn(),{selectedSingleCaiObject:f,caiChatState:h,workspaceView:m,immersedSongId:y}=Yn(),{selectCaiObject:g,closeImmersedSong:w}=cr(),{getRandomViewportCenteredCanvasPosition:v}=sl(),{focusCanvas:S}=di(),{isPlaying:C,togglePlayStop:k,isAwaitingAudioLoad:N}=zs(),{audioSettings:_,generalSettings:j}=bi(),{setLoop:T,setMetronomeActive:M,setMasterVolume:V}=il(),{isMobile:H}=Hn(),{undo:P,redo:F,commitToStore:I}=Ln(),{showBanner:R}=ts(),U=H?mM.mobile:mM.desktop,[A,W]=x.useState(_.masterVolume),[D,B]=x.useState(!1),[L,$]=x.useState(!1),[q,Z]=x.useState(""),{currentSource:ie}=Lo(),ge=x.useMemo(()=>{if(!f)return"";switch(f.type){case J.Song:return`song:${f.id}`;case J.Bloob:{const yt=i(f.id);return yt?`song:${yt.songId}`:""}default:return""}},[f,i]),re=Vr(ge||"global"),Y=!ge||re,ne=x.useRef(null),be=x.useRef(null),we=x.useRef(null),te=x.useRef(null),fe=x.useRef(null),O=x.useRef(null),pe=e!=null&&e<Ghe,he=e!=null&&e<=Whe,[le,oe]=x.useState(!1),[Q,de]=x.useState(""),[Ne,Ce]=x.use
911State(!1),[Ae,Ue]=x.useState(!1),[Se,ve]=x.useState(""),[je,Te]=x.useState(""),ce=x.useRef(null),{embeddingPlayStates:se,handleEmbeddingPlayPause:ye}=YL(),{visualMediaPlayStates:ke,handleVisualMediaPlayPause:ze}=KE(),{showMobileRecordDetails:qe}=Br(),ot=x.useMemo(()=>{const yt={top:"1rem",left:"50%",transform:"translateX(-50%)",zIndex:49,pointerEvents:"auto",touchAction:"manipulation"};return H?h===zn.MAXIMIZED?{...yt,position:"fixed"}:{...yt,position:"absolute"}:{...yt,position:"absolute"}},[H,h]),Ze=x.useMemo(()=>{if(!f||f.type===J.TextNode)return!1;if(f.type===J.EmbeddingNode)return!0;if(f.type===J.VisualMediaNode){const yt=a(f.id);return yt!=null&&yt.mediaData?yt.mediaData.startsWith("data:video/"):!1}return f.type===J.Song||f.type===J.Bloob},[f,a]),_t=x.useCallback(()=>(f==null?void 0:f.type)===J.VisualMediaNode&&ke[f.id]||!1,[f,ke]),tt=x.useMemo(()=>{if(!f)return"Play (must select something first)";if(f.type===J.TextNode)return"Notes don't support playback";if(f.type===J.EmbeddingNode){const yt=o(f.id);return yt!=null&&yt.url?se[f.id]||!1?"Pause embedded content":"Play embedded content":"No embedded content to play"}if(f.type===J.VisualMediaNode){const yt=a(f.id);return yt!=null&&yt.mediaData?yt.mediaData.startsWith("data:video/")?_t()?"Pause video":"Play video":"Images don't support playback":"No media to play"}return N?"Loading... (click to cancel)":C?"Pause":"Play"},[f,N,C,o,se,a,_t]),gt=x.useMemo(()=>_.metronome.active===ls.Off?"Metronome":_.metronome.active===ls.AlwaysOn?"Metronome (always on)":"Metronome (while recording only)",[_.metronome.active]),dt=x.useCallback(async()=>{var yt;if(Ze){if((f==null?void 0:f.type)===J.EmbeddingNode){ye(f.id);return}if((f==null?void 0:f.type)===J.VisualMediaNode){const Wt=a(f.id);(yt=Wt==null?void 0:Wt.mediaData)!=null&&yt.startsWith("data:video/")&&ze(f.id);return}if(N){C&&k();return}k()}},[Ze,f,N,k,ye,a,ze,C]),wt=x.useCallback(()=>{_.metronome.active===ls.Off?M(ls.AlwaysOn):_.metronome.active===ls.AlwaysOn?M(ls.WhileRecordingOnly):M(ls.Off)},[_.metronome.active,M]),Dt=x.useCallback(()=>{T(!_.loop)},[_.loop,T]),Kt=x.useCallback(()=>{B(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{B(!1)},2e3)},[]),rn=x.useCallback(yt=>{const Wt=G2(yt,Ss);return Wt<=Ss?"-inf":Wt.toFixed(1)},[]),pn=x.useCallback(yt=>{W(yt),V(yt),Kt()},[V,Kt]),cn=x.useCallback(yt=>{pn(Q4(yt,Ss))},[pn]),kt=x.useCallback(()=>{$(!0),Z(rn(A)),O.current&&clearTimeout(O.current),setTimeout(()=>{te.current&&(te.current.focus(),te.current.select())},0)},[A,rn]),rt=x.useCallback(yt=>{let Wt=yt.target.value.replace(/[^0-9.-]/g,"");const An=Wt.indexOf(".");An!==-1&&(Wt=Wt.slice(0,An+1)+Wt.slice(An+1).replace(/\./g,""));const Un=Wt.indexOf("-");Un>0?Wt=Wt.replace(/-/g,""):Un===0&&(Wt="-"+Wt.slice(1).replace(/-/g,"").slice(0)),Z(Wt)},[]),Tt=x.useCallback(()=>{if(q.trim()==="-inf")cn(Ss);else{const yt=Number(q);if(!Number.isNaN(yt)){const Wt=Math.min(0,Math.max(Ss,yt));cn(Wt)}}$(!1),Kt()},[q,Kt,cn]),Mt=x.useCallback(()=>{Tt()},[Tt]),Rt=x.useCallback(yt=>{yt.key==="Enter"?(yt.preventDefault(),Tt(),S()):yt.key==="Escape"&&($(!1),B(!1),S())},[Tt,S]),Ct=x.useCallback(yt=>{if(!we.current)return;const Wt=we.current.getBoundingClientRect(),An=yt.touches[0],Un=Math.max(0,Math.min(An.clientX-Wt.left,Wt.width)),Rr=Ss+Un/Wt.width*(0-Ss);cn(Rr)},[cn]),Gt=x.useCallback(()=>{oe(!0),de(rn(A)),setTimeout(()=>{var yt,Wt;(yt=fe.current)==null||yt.focus(),(Wt=fe.current)==null||Wt.select()},0)},[A,rn]),Lt=x.useCallback(yt=>{let Wt=yt.target.value.replace(/[^0-9.-]/g,"");const An=Wt.indexOf(".");An!==-1&&(Wt=Wt.slice(0,An+1)+Wt.slice(An+1).replace(/\./g,""));const Un=Wt.indexOf("-");Un>0?Wt=Wt.replace(/-/g,""):Un===0&&(Wt="-"+Wt.slice(1).replace(/-/g,"").slice(0)),de(Wt)},[]),$t=x.useCallback(()=>{if(Q.trim()==="-inf")cn(Ss);else{const yt=Number(Q);if(!Number.isNaN(yt)){const Wt=Math.min(0,Math.max(Ss,yt));cn(Wt)}}oe(!1)},[Q,cn]),Qt=x.useCallback(()=>{$t()},[$t]),Ye=x.useCallback(yt=>{yt.key==="Enter"?(yt.preventDefault(),$t(),S()):yt.key==="Escape"&&(oe(!1),S())},[$t,S]),[bt,Ie]=x.useState(null),it=x.useCallback((yt,Wt)=>{switch(ie){case zr.MidiInstrument:case zr.VoiceToMidi:return l(yt,{instrument:j.defaultInstrument},8,Wt);case zr.Audio:return l(yt,{audioFileId:void 0},8,Wt)}},[l,ie,j.defaultInstrument]),ct=x.useCallback(()=>
911{if(C||!Y)return;let yt;switch(f==null?void 0:f.type){case J.Bloob:{yt=f.id;break}case J.Song:{const Wt=n(f.id),An=s(Wt.id,{bar:Math.ceil(Wt.bars/2),track:Math.ceil(Wt.tracks/2)},8);yt=it(Wt.id,An);break}default:{const Wt=v(),An=u({chroma:"C",quality:"Major"},120,{beatsPerBar:4,beatDuration:4},Wt,void 0,8,1);yt=it(An,{bar:0,track:0})}}Ie(yt),g({type:J.Bloob,id:yt})},[C,Y,f,g,n,s,it,v,u]),{bind:Ut}=V0({onShortPress:ct,onLongPress:H?qe:ct});x.useEffect(()=>{bt!==null&&(f==null?void 0:f.type)===J.Bloob&&f.id===bt&&(Ie(null),k(!0))},[f,bt,k]),x.useEffect(()=>{W(_.masterVolume)},[_.masterVolume]),x.useEffect(()=>()=>{O.current&&clearTimeout(O.current)},[]);const Et=x.useMemo(()=>m!=="immersed-song"||y===null?null:n(y),[m,y,n]),yn=at(yt=>yt.domainRoleByChannel),nn=at(yt=>yt.sharedByMe),rr=x.useMemo(()=>{if(!Et)return!1;const yt=`song:${Et.id}`;return So(yt,yn,nn)},[Et,yn,nn]),xn=Vr(Et?`song:${Et.id}`:"global"),Bn=x.useMemo(()=>!!(Et&&Et.bloobIds.size>0),[Et]);x.useEffect(()=>{Et&&(ve(`${Et.timeSignature.beatsPerBar}/${Et.timeSignature.beatDuration}`),Ue(!1))},[Et]),x.useEffect(()=>{Ae&&ce.current&&(ce.current.focus(),ce.current.select())},[Ae]),x.useEffect(()=>{he||Ce(!1)},[he]);const dr=x.useCallback(()=>{!Et||!xn||(Bn?(R("Cannot change time signature when there are bloobs in the song"),Te("animate-shake"),setTimeout(()=>Te(""),500)):Ue(!0))},[Et,xn,Bn,R]),gr=x.useCallback(()=>{if(!Et)return;const yt=Se.split("/");if(yt.length===2){const Wt=parseInt(yt[0],10),An=parseInt(yt[1],10),Un=Math.max(1,Math.min(16,Wt)),Rr=[1,2,4,8,16].includes(An)?An:4;!isNaN(Un)&&!isNaN(Rr)?((Un!==Et.timeSignature.beatsPerBar||Rr!==Et.timeSignature.beatDuration)&&(d(Et.id,{timeSignature:{beatsPerBar:Un,beatDuration:Rr}}),I()),ve(`${Un}/${Rr}`)):ve(`${Et.timeSignature.beatsPerBar}/${Et.timeSignature.beatDuration}`)}else ve(`${Et.timeSignature.beatsPerBar}/${Et.timeSignature.beatDuration}`);Ue(!1)},[Et,Se,d,I]),on=m==="immersed-song",Fn=c.jsxs("div",{className:`flex items-center ${U.gap}`,children:[c.jsx(Vn,{mode:"wait",initial:!1,children:D?c.jsx(et.div,{initial:{opacity:0}
911,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex items-center justify-center",children:c.jsx(Ya,{className:`${U.icon} brightness-125`})},"volume-icon"):c.jsx(et.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"transition-transform duration-150 active:scale-90 focus:outline-none",title:gt,onClick:wt,children:c.jsx(pM,{sizeClassName:U.icon,fillClassName:_.metronome.active===ls.Off?"fill-zinc-400 dark:fill-zinc-400 hover:fill-zinc-500 hover:dark:fill-zinc-300":"fill-zinc-700 dark:fill-zinc-100 hover:fill-zinc-900 hover:dark:fill-white",showR:_.metronome.active===ls.WhileRecordingOnly})},"metronome-button")}),c.jsx("div",{className:"flex justify-center items-center",children:c.jsx(Vn,{mode:"wait",initial:!1,children:D?c.jsx(et.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"text-center cursor-pointer",onClick:L?void 0:kt,children:L?c.jsx("input",{ref:te,type:"text",id:"global-volume-input",name:"global-volume",value:q,onChange:rt,onBlur:Mt,onKeyDown:Rt,className:`${U.volumeFontSize} text-center bg-transparent outline-none`}):c.jsx("span",{className:`${U.volumeFontSize} font-medium`,children:rn(A)})},"volume-number"):c.jsx(et.button,{initial:{opacity:0}
911,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`transition-transform duration-150 ${Ze?"active:scale-90":"opacity-50"} focus:outline-none`,disabled:!Ze,onClick:dt,title:tt,children:(f==null?void 0:f.type)!==J.EmbeddingNode&&(f==null?void 0:f.type)!==J.VisualMediaNode&&N?c.jsx(Sv,{size:"size-5"}):((f==null?void 0:f.type)===J.EmbeddingNode?se[f.id]:(f==null?void 0:f.type)===J.VisualMediaNode?_t():C)?c.jsx(Zm,{className:`${U.icon} hover:text-zinc-900 hover:dark:text-white transition-colors duration-150`}):c.jsx(ka,{className:`${U.icon} ${Ze?"hover:text-zinc-900 hover:dark:text-white":"text-zinc-400 dark:text-zinc-400"} transition-colors duration-150`})},"play-pause-button")})}),c.jsx("button",{className:"transition-transform duration-150 active:scale-90 focus:outline-none",title:_.loop?"Loop (on)":"Loop (off)",onClick:Dt,children:c.jsx(GS,{className:`${U.icon} ${_.loop?"hover:text-zinc-900 hover:dark:text-white":"text-zinc-400 dark:text-zinc-400 hover:text-zinc-500 hover:dark:text-zinc-300"} transition-colors duration-150`})}),c.jsx("button",{ref:be,className:`transition-transform duration-150 focus:outline-none ${Y?"active:scale-90":"opacity-40 cursor-not-allowed"}`,disabled:!Y,...Y?Ut():{},children:c.jsx(ld,{className:`size-6 ${Y?"fill-red-500 text-red-500 hover:text-zinc-900 hover:dark:text-white":"fill-red-300 text-red-300"} transition-colors duration-150`})}),!H&&c.jsx(xv,{hoverTriggerRef:be,positionAnchorRef:ne,disabled:!Y})]}),Xn=c.jsx("div",{ref:we,className:`${U.sliderHeight} flex items-center cursor-pointer touch-action-none`,onTouchStart:Ct,onTouchMove:Ct,children:c.jsx(TL,{min:Ss,max:0,step:.1,value:G2(A,Ss),onChange:cn,className:"flex items-center py-3 w-full",renderThumb:yt=>{const{key:Wt,...An}=yt;return c.jsx("div",{...An,title:"Master Volume",className:"size-5 bg-zinc-700 dark:bg-zinc-100 text-zinc-100 dark:text-zinc-900 flex items-center justify-center rounded-full cursor-pointer text-xs hover:scale-110 transition-transform duration-150",onDoubleClick:()=>cn(0)},Wt)},renderTrack:(yt,Wt)=>{const{key:An,...Un}=yt;return c.jsx("div",{...Un,title:"Master Volume",className:`${U.slider} rounded-full ${Wt.index===0?"bg-zinc-600 dark:bg-zinc-300":"bg-zinc-300 dark:bg-zinc-500"}`},An)}})});return on&&Et?c.jsxs("div",{ref:ne,className:"shrink-0 relative overflow-hidden border-b border-zinc-300/50 dark:border-zinc-700/50",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-400/20 via-zinc-500/20 to-zinc-600/20 dark:from-zinc-600/20 dark:via-zinc-700/20 dark:to-zinc-800/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-zinc-100/40 to-transparent dark:from-zinc-100/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-300/30 via-zinc-400/30 to-zinc-500/30 dark:from-zinc-500/30 dark:via-zinc-600/30 dark:to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute inset-0 bg-glass"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-0.5 border-b border-zinc-300/35 dark:border-zinc-700/35",children:[c.jsx("button",{className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none rounded-md p-1 hover:bg-zinc-200/60 dark:hover:bg-zinc-700/60",title:"Back to canvas",onClick:w,children:c.jsx(rte,{className:"size-4 text-zinc-700 dark:text-zinc-200"})}),c.jsx("div",{className:"w-px h-4 bg-zinc-300/60 dark:bg-zinc-600/60 shrink-0"}),c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[c.jsx("span",{className:"text-xs font-semibold leading-tight truncate text-zinc-800 dark:text-zinc-100",children:r(Et.id)}),rr&&c.jsx(F0,{variant:"song",className:"shrink-0"})]}),t&&c.jsx(ky,{onSignOut:t,className:"shrink-0",isMobile:H})]}),c.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 sm:px-4 sm:gap-4",children:[H&&c.jsx("button",{className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none rounded-md p-1 hover:bg-zinc-200/60 dark:hover:bg-zinc-700/60",onClick:P,title:"Undo",children:c.jsx(qS,{className:"size-4.5 text-zinc-600 dark:text-zinc-300"})}),c.jsxs("div",{className:"flex flex-1 flex-wrap items-center justify-center gap-3 min-w-0 sm:gap-4 sm:gap-x-6",children:[he?c.jsx("button",{type:"button",onClick:()=>Ce(!0),className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none rounded-md p-1.5 hover:bg-zinc-200/60 dark:hover:bg-zinc-700/60",title:"Tempo, meter & key","aria-label":"Edit tempo, time signature, and key",children:c.jsx(Ez,{className:"size-5 text-zinc-700 dark:text-zinc-200"})}):c.jsxs(c.Fragment,{children:[c.jsx(BC,{songId:Et.id,variant:pe?"compactText":"compact"}),c.jsxs("div",{className:"flex flex-col items-center shrink-0 text-xs font-medium tabular-nums px-1",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:"Time"}),c.jsxs("span",{className:"text-zinc-800 dark:text-zinc-100",children:[Et.timeSignature.beatsPerBar,"/",Et.timeSignature.beatDuration]})]}),c.jsx(RC,{songId:Et.id,variant:"compact"})]}),c.jsx(Vn,{mode:"wait",initial:!1,children:D?c.jsx(et.div,{initial:{opacity:0}
911,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex items-center justify-center shrink-0",children:c.jsx(Ya,{className:`${U.icon} brightness-125`})},"volume-icon"):c.jsx(et.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none",title:gt,onClick:wt,children:c.jsx(pM,{sizeClassName:U.icon,fillClassName:_.metronome.active===ls.Off?"fill-zinc-400 dark:fill-zinc-400 hover:fill-zinc-500 hover:dark:fill-zinc-300":"fill-zinc-700 dark:fill-zinc-100 hover:fill-zinc-900 hover:dark:fill-white",showR:_.metronome.active===ls.WhileRecordingOnly})},"metronome-button")}),c.jsx(Vn,{mode:"wait",initial:!1,children:D?c.jsx(et.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"text-center cursor-pointer shrink-0",onClick:L?void 0:kt,children:L?c.jsx("input",{ref:te,type:"text",id:"global-volume-input",name:"global-volume",value:q,onChange:rt,onBlur:Mt,onKeyDown:Rt,className:`${U.volumeFontSize} text-center bg-transparent outline-none`}):c.jsx("span",{className:`${U.volumeFontSize} font-medium`,children:rn(A)})},"volume-number"):c.jsx(et.button,{initial:{opacity:0}
911,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`shrink-0 transition-transform duration-150 ${Ze?"active:scale-90":"opacity-50"} focus:outline-none`,disabled:!Ze,onClick:dt,title:tt,children:(f==null?void 0:f.type)!==J.EmbeddingNode&&(f==null?void 0:f.type)!==J.VisualMediaNode&&N?c.jsx(Sv,{size:"size-5"}):((f==null?void 0:f.type)===J.EmbeddingNode?se[f.id]:(f==null?void 0:f.type)===J.VisualMediaNode?_t():C)?c.jsx(Zm,{className:`${U.icon} hover:text-zinc-900 hover:dark:text-white transition-colors duration-150`}):c.jsx(ka,{className:`${U.icon} ${Ze?"hover:text-zinc-900 hover:dark:text-white":"text-zinc-400 dark:text-zinc-400"} transition-colors duration-150`})},"play-pause-button")}),c.jsx("button",{className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none",title:_.loop?"Loop (on)":"Loop (off)",onClick:Dt,children:c.jsx(GS,{className:`${U.icon} ${_.loop?"hover:text-zinc-900 hover:dark:text-white":"text-zinc-400 dark:text-zinc-400 hover:text-zinc-500 hover:dark:text-zinc-300"} transition-colors duration-150`})}),c.jsx("button",{ref:be,className:`shrink-0 transition-transform duration-150 focus:outline-none ${Y?"active:scale-90":"opacity-40 cursor-not-allowed"}`,disabled:!Y,...Y?Ut():{},children:c.jsx(ld,{className:`${H?"size-5":"size-6"} ${Y?"fill-red-500 text-red-500 hover:text-zinc-900 hover:dark:text-white":"fill-red-300 text-red-300"} transition-colors duration-150`})}),!H&&c.jsx(xv,{hoverTriggerRef:be,positionAnchorRef:ne,disabled:!Y}),pe?c.jsxs("div",{className:"flex flex-col items-center shrink-0 w-10 max-w-[2.5rem] min-w-0 overflow-hidden",children:[le?c.jsx("input",{ref:fe,type:"text",inputMode:"numeric",id:"immersed-master-volume-input",name:"immersed-master-volume",value:Q,onChange:Lt,onBlur:Qt,onKeyDown:Ye,className:"box-border w-full min-w-0 max-w-full text-center text-sm font-semibold tabular-nums bg-transparent outline-none text-zinc-800 dark:text-zinc-100 border-b border-zinc-400/50 dark:border-zinc-500/50","aria-label":"Master volume"}):c.jsx("button",{type:"button",onClick:Gt,className:"text-sm font-semibold tabular-nums text-zinc-800 dark:text-zinc-100 min-h-[1.25rem] px-0.5 rounded hover:bg-zinc-200/50 dark:hover:bg-zinc-700/50",title:"Master volume (click to edit)",children:rn(A)}),c.jsx("span",{className:"text-[10px] text-zinc-500 dark:text-zinc-400 mt-0.5",children:"volume"})]}):c.jsx("div",{className:"w-36 shrink-0 min-w-0",children:Xn})]}),H&&c.jsx("button",{className:"shrink-0 transition-transform duration-150 active:scale-90 focus:outline-none rounded-md p-1 hover:bg-zinc-200/60 dark:hover:bg-zinc-700/60",onClick:F,title:"Redo",children:c.jsx(HS,{className:"size-4.5 text-zinc-600 dark:text-zinc-300"})})]})]}),Ne&&c.jsx(Wr,{onClose:()=>Ce(!1),children:c.jsxs("div",{className:"flex w-full max-w-[min(100vw-2rem,24rem)] min-w-[16rem] flex-col items-start gap-5 p-4 text-left max-h-[85vh] overflow-y-auto",children:[c.jsxs("div",{className:"flex w-full min-w-0 items-center justify-start gap-2",children:[c.jsx(Ez,{className:"size-4 shrink-0 text-zinc-500 dark:text-zinc-400"}),c.jsx("span",{className:"text-sm font-semibold text-zinc-800 dark:text-zinc-100",children:"Tempo & meter"})]}),!xn&&c.jsx("p",{className:"w-full text-left text-xs text-zinc-500 dark:text-zinc-400 italic",children:"View only"}),c.jsxs("div",{className:"flex w-full min-w-0 flex-col items-start gap-1 overflow-hidden",children:[c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:"BPM"}),c.jsx(BC,{songId:Et.id,variant:"modal"})]}),c.jsxs("div",{className:"flex w-full flex-col items-start gap-1",children:[c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:"Time signature"}),c.jsx("div",{className:`flex min-h-[2.5rem] w-full items-center justify-start rounded-md px-1 tabular-nums text-2xl font-semibold text-zinc-800 dark:text-zinc-100 ${xn?`cursor-pointer hover:bg-zinc-200/50 dark:hover:bg-zinc-700/40 ${je}`:"cursor-default"}`,title:xn?"Click to edit time signature":void 0,onClick:xn?dr:void 0,children:Ae?c.jsx("input",{ref:ce,type:"text",id:`immer
911sed-modal-time-signature-${Et.id}`,name:"immersed-modal-time-signature",value:Se,onChange:yt=>ve(yt.target.value),onBlur:gr,onKeyDown:yt=>{yt.key==="Enter"&&yt.currentTarget.blur()},className:"w-24 rounded bg-transparent text-left text-2xl text-zinc-800 dark:text-zinc-100 outline-none",placeholder:"4/4"}):c.jsxs("span",{children:[Et.timeSignature.beatsPerBar,"/",Et.timeSignature.beatDuration]})})]}),c.jsxs("div",{className:"flex w-full flex-col items-start gap-1",children:[c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-zinc-500 dark:text-zinc-400",children:"Key"}),c.jsx("div",{className:"w-full self-start",children:c.jsx(RC,{songId:Et.id,variant:"compact",align:"start"})})]})]})})]}):c.jsx(c.Fragment,{children:c.jsxs("div",{ref:ne,className:`bg-glass border-glass ${U.panelPadding} rounded-xl ${U.panelWidth}`,style:ot,children:[c.jsx("div",{className:`flex items-center justify-center ${U.gap}`,children:Fn}),c.jsx("div",{className:"relative mt-1 px-1",children:Xn})]})})},qhe=()=>{const e=Kn(s=>({transform:s.transform})).transform,n=e[0],r=e[1],i=e[2];return{xOffset:n,yOffset:r,zoom:i}},Khe=(t=.75)=>{const e=Math.random()>=t?"Minor":"Major",r={Major:["Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#"],Minor:["A","E","B","F#","C#","G#","D","G","C","F","Bb","Eb"]}[e];return{chroma:r[Math.floor(Math.random()*r.length)],quality:e}},zb=({icon:t,title:e,onClick:n,gradient:r,delay:i})=>{const[s,o]=x.useState(!1);return x.useEffect(()=>{const a=setTimeout(()=>{o(!0)},i);return()=>clearTimeout(a)},[i]),c.jsx("button",{className:`size-12 hover:scale-105 transition-all duration-150 cursor-pointer flex items-center justify-center rounded-lg text-white bg-gradient-to-r ${r} hover:shadow-lg transform hover:brightness-110 ${s?"animate-in slide-in-from-bottom-4 fade-in duration-150":"opacity-0 translate-y-4"}`,onClick:n,title:e,style:{transitionDelay:s?"0ms":`${i}ms`},children:t})},Yhe=({canvasPosition:t,onOptionSelect:e})=>{const{xOffset:n,yOffset:r,zoom:i}=qhe(),{textNodes:s,embeddingNodes:o,visualMediaNodes:a}=mn(),{addSong:l,addVisualMediaNode:u,addTextNode:d,addEmbeddingNode:f}=Gn(),{selectCaiObject:h}=cr(),{focusCaiChat:m,focusCanvas:y}=di(),{commitToStore:g}=Ln(),w=x.useCallback(()=>{const k=Khe(),N=Math.round(80+Math.random()*120),_={beatsPerBar:4,beatDuration:4},j=4,T=1,M={x:t.x-Yv(j)/2,y:t.y-$_(T)/2},V=l(k,N,_,M,void 0,j,T);h({type:J.Song,id:V}),m(),g(),e()},[l,t.x,t.y,g,m,e,h]),v=x.useCallback(()=>{const k={x:t.x-R_/2,y:t.y-O_/2},N=u(k,void 0,"");h({type:J.VisualMediaNode,id:N}),g(),y(),e()},[u,t.x,t.y,g,y,e,h,a]),S=x.useCallback(()=>{const k={x:t.x-D_/2,y:t.y-L_/2},N=Object.keys(s).map(T=>parseInt(T)),_=N.length>0?Math.max(...N)+1:1,j=d(k,void 0,`Note ${_}`);h({type:J.TextNode,id:j}),g(),y(),e()},[d,t.x,t.y,g,y,e,h,s]),C=x.useCallback(()=>{const k={x:t.x-M_/2,y:t.y-B_/2},N=Object.keys(o).map(T=>parseInt(T)),_=N.length>0?Math.max(...N)+1:1,j=f(k,void 0,`Link ${_}`);h({type:J.EmbeddingNode,id:j}),g(),y(),e()},[t.x,t.y,o,f,h,g,y,e]);return c.jsxs("div",{style:{left:t.x*i+n,top:t.y*i+r},className:"absolute -translate-x-1/2 -translate-y-1/2 flex flex-col gap-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(zb,{icon:c.jsx(Mn,{size:20}),title:"New Song",onClick:w,gradient:"from-caiGreen/80 to-caiBlue/80",delay:0}),c.jsx(zb,{icon:c.jsx(Gs,{size:20}),title:"New Media",onClick:v,gradient:"from-rose-500/70 to-red-600/70",delay:50})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(zb,{icon:c.jsx($i,{size:20}),title:"New Notes",onClick:S,gradient:"from-yellow-400/70 to-orange-400/70",delay:100}),c.jsx(zb,{icon:c.jsx(Ka,{size:20}),title:"New Link",onClick:C,gradient:"from-blue-400/70 to-purple-400/70",delay:150})]})]})},QL=({rect:t})=>!t||!t.width||!t.height?null:c.jsx(O3,{children:c.jsx("div",{className:"absolute border-2 border-dashed bg-zinc-900/15 dark:bg-zinc-100/15 border-zinc-900 dark:border-zinc-100 rounded pointer-events-none z-10",style:{left:"canvasPosition"in t?t.canvasPosition.x:t.pianoRollPosition.x,top:"canvasPosition"in t?t.canvasPosition.y:t.pianoRollPosition.y,width:t.width,height:t.height}})}),Xhe=({onSignOut:t,canvasWrapperRef:e})=>{const{getBloobsOverlappingWithPosition:n,getSongById:r,getBloobById:i,getNoteById:s,getVisualMediaNodeById:o,findOpenSongPositionNear:a,getEmbeddingNodeById:l,getTextNodeById:u,getCaiObjectsInRect:d,getAllCaiObjects:f}=mn(),{duplicateBloob:h,deleteSong:m,deleteBloob:y,shiftBloob:g,updateSongDetails:w,updateBloobDetails:v,addBloob:S,updateTextNode:C,updateEmbeddingNode:k,updateVisualMediaNode:N,deleteTextNode:_,deleteEmbeddingNode:j,deleteVisualMediaNode:T,duplicateSong:M,duplicateEmbeddingNode:V,duplicateVisualMediaNode:H,duplicateTextNode:P,addTextNode:F,addEmbeddingNode:I,addVisualMediaNode:R,addAudioFile:U,addSong:A,addBarsToSong:W}=Gn(),{deleteThreadsForSong:D}
911=xd(),{commitToStore:B,undo:L,redo:$}=Ln(),{clientToCanvasPosition:q}=sl(),{togglePlayStop:Z,isPlaying:ie,currentlyPlayingSongId:ge}=zs(),{isMobile:re}=Hn(),{handleExportToFiles:Y}=VL(),{showUpload:ne,showHotkeys:be,showProject:we,toggleVolumeAutomation:te}=Br(),{hasCmdModifier:fe}=Wl(),{appearanceSettings:O,generalSettings:pe}=bi(),he=pe.bloobNudgeAmount??1/256,{setShowBloobIds:le}=il(),[,oe]=x.useState(!1),{selectedSingleCaiObject:Q,selectedCaiObjects:de,caiChatState:Ne,isCaiObjectSelected:Ce,dragMode:Ae}=Yn(),{selectCaiObject:Ue,selectCaiObjects:Se,deselectAllCaiObjects:ve,setCaiChatState:je}=cr(),{downloadStorageFile:Te}=_d(),{handleEmbeddingPlayPause:ce}=YL(),{handleVisualMediaPlayPause:se}=KE(),{focusCaiChat:ye,focusCanvas:ke}=di(),ze=x.useRef(null),[qe,ot]=x.useState(!1),[Ze,_t]=x.useState(null),[tt,gt]=x.useState(null),{showBanner:dt}=ts(),[wt,Dt]=x.useState(!1),[Kt,rn]=x.useState(!1),pn=x.useRef(null),cn=at(Be=>Be.domainRoleByChannel),kt=at(Be=>Be.sharedByMe),rt=x.useRef(null),[Tt,Mt]=x.useState(null),[Rt,Ct]=x.useState(null),[Gt,Lt]=x.useState(null),$t=x.useCallback((Be,De)=>{var Le;if(wt)return;if(De.type===J.Bloob){const He=i(De.id),mt=at.getState().domainRoleByChannel;if(He&&((Le=mt[`song:${He.songId}`])==null?void 0:Le.toLowerCase())==="viewer")return}let Xe;switch(De.type){case J.Bloob:{Be.altKey&&Lt(De.id);const He=i(De.id);Xe={x:He.songPosition.bar*dn+Qi,y:He.songPosition.track*bn+fo+Is};break}case J.Song:{Xe=r(De.id).canvasPosition;break}case J.TextNode:{Xe=u(De.id).canvasPosition;break}case J.EmbeddingNode:{Xe=l(De.id).canvasPosition;break}case J.VisualMediaNode:{Xe=o(De.id).canvasPosition;break}}Ce(De)||Ue(De,!1),rt.current=Xe},[wt,Ce,i,r,u,l,o,Ue]),Qt=x.useCallback((Be,De)=>{var Wo;const Xe=i(Be);if(((Wo=at.getState().domainRoleByChannel[`song:${Xe.songId}`])==null?void 0:Wo.toLowerCase())==="viewer")return{x:0,y:0};const He=r(Xe.songId),mt=De.x+Xe.bars*dn,Ht=Yv(He.bars);mt>=Ht-.5&&W(Xe.songId,Tr.Right,1);const Nn=Qi,sr=Is+fo,$n=Is+fo+(He.tracks-1)*bn,ri={x:Math.max(Nn,De.x),y:Math.max(sr,Math.min(De.y,$n))},wr=pe.dragSnapAmount,ns=dn*wr,rs={bar:Math.floor((ri.x-Qi+ns/2)/ns)*wr,track:Math.floor((ri.y-Is-fo+bn/2)/bn)},er={bar:Math.max(0,Math.min(rs.bar,He.bars-Xe.bars)),track:Math.max(0,Math.min(rs.track,He.tracks-1))},Ai=n(Xe.songId,er,Xe.bars).filter(Gi=>Gi.id!==Xe.id);let ys=er;const Id=er.bar-Xe.songPosition.bar;if(Ai.length>0&&Gt===null){let Gi=er.bar;const ql=Id>=0;Ai.forEach(Ni=>{ql?Gi=Math.min(Gi,Ni.songPosition.bar-Xe.bars):Gi=Math.max(Gi,Ni.songPosition.bar+Ni.bars)}),ys={...er,bar:Math.max(0,Math.min(Gi,He.bars-Xe.bars))}}const ul=n(Xe.songId,ys,Xe.bars).filter(Gi=>Gi.id!==Xe.id),Na={songId:Xe.songId,songPosition:ys,bars:Xe.bars};return ul.length===0&&Ct(Na),{x:ri.x-rt.current.x,y:ri.y-rt.current.y}},[i,r,pe.dragSnapAmount,n,Gt,W]),Ye=x.useCallback((Be,De)=>{wt||de.length!==0&&de.forEach(Xe=>{let Le;if(Xe.type===J.Bloob)Le=Qt(Xe.id,De);else{const He=rt.current;if(!He)return;Le={x:De.x-He.x,y:De.y-He.y}}Mt(Le)})},[Qt,wt,de]),bt=x.useCallback(Be=>{var Le;const De=i(Be);if(((Le=at.getState().domainRoleByChannel[`song:${De.songId}`])==null?void 0:Le.toLowerCase())==="viewer"){Ct(null),Lt(null);return}if(Rt){const He=i(Be),mt={bar:Rt.songPosition.bar,track:Rt.songPosition.track};if(Gt!==null){const Ht=h(He.id,mt);Ue({type:J.Bloob,id:Ht}),B()}else v(He.id,{songPosition:mt})}Ct(null),Lt(null)},[Gt,B,h,i,Rt,Ue,v]),Ie=x.useCallback(()=>{wt||de.length!==0&&(de.forEach(Be=>{switch(Be.type){case J.Bloob:{bt(Be.id);break}case J.Song:{const De=r(Be.id);w(De.id,{canvasPosition:Ua(De.canvasPosition,Tt)});break}case J.TextNode:{const De=u(Be.id);C(De.id,{canvasPosition:Ua(De.canvasPosition,Tt)});break}case J.EmbeddingNode:{const De=l(Be.id);k(De.id,{canvasPosition:Ua(De.canvasPosition,Tt)});break}case J.VisualMediaNode:{const De=o(Be.id);N(De.id,{canvasPosition:Ua(De.canvasPosition,Tt)});break}}}),B(),Mt(null),rt.current=null)},[B,wt,de,bt,r,w,Tt,u,C,l,k,o,N]),{detailsBloobId:it,selectedNoteIds:ct}=Ho(),{showBloobDetails:Ut,closeBloobDetails:Et,deselectAllNotes:yn}=Xs(),nn=x.useCallback(()=>{const Be=f();Be.length>0&&Se(Be,!1)},[f,Se]),rr=x.useCallback(()=>
911{if(it!==null){yn(),Et(),ke();return}if(de.length!==1)return;const Be=de[0];if(Be.type===J.Bloob){const De=i(Be.id);if(!De||!ln(De)&&!En(De))return;Ut(De.id)}},[Et,yn,it,ke,i,de,Ut]),xn=x.useCallback(async()=>{await Y()},[Y]),Bn=x.useCallback(async()=>{await Te()},[Te]),dr=x.useCallback(()=>{we()},[we]),gr=x.useCallback(()=>{te()},[te]),on=x.useCallback(()=>{be()},[be]),Fn=x.useCallback(()=>{if(de.some(Xe=>Xe.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Xe=>{var He;const Le=i(Xe.id);return Le&&((He=Be[`song:${Le.songId}`])==null?void 0:He.toLowerCase())==="viewer"}))return;let De=!1;de.forEach(Xe=>{Xe.type===J.Bloob&&(i(Xe.id).muted||(De=!0))}),de.forEach(Xe=>{v(Xe.id,{muted:De})}),B()},[B,i,de,v]),Xn=x.useCallback(()=>{switch(Ne){case zn.DEFAULT:je(zn.MAXIMIZED);break;case zn.MAXIMIZED:je(zn.MINIMIZED);break;case zn.MINIMIZED:je(zn.DEFAULT);break}oe(!1)},[Ne,je]),yt=x.useCallback(()=>{if(de.some(Xe=>Xe.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Xe=>{var He;const Le=i(Xe.id);return Le&&((He=Be[`song:${Le.songId}`])==null?void 0:He.toLowerCase())==="viewer"}))return;let De=!1;de.forEach(Xe=>{Xe.type===J.Bloob&&(i(Xe.id).soloed||(De=!0))}),de.forEach(Xe=>{v(Xe.id,{soloed:De})}),B()},[B,i,de,v]),Wt=x.useCallback(()=>{ie?Z():Q.type===J.Bloob&&Z(!0)},[ie,Q,Z]),An=x.useCallback(async()=>{var Be;if((Q==null?void 0:Q.type)===J.EmbeddingNode){ce(Q.id);return}if((Q==null?void 0:Q.type)===J.VisualMediaNode){const De=o(Q.id);if((Be=De==null?void 0:De.mediaData)!=null&&Be.startsWith("data:video/")){se(Q.id);return}return}(Q==null?void 0:Q.type)!==J.TextNode&&Z()},[Q,ce,se,o,Z]),Un=x.useCallback(()=>{if(!ze.current)return ze.current=setTimeout(()=>{ot(!0)},500),()=>{ze.current&&clearTimeout(ze.current)}},[]),Rr=x.useCallback(()=>{qe?ot(!1):An(),clearTimeout(ze.current),ze.current=null},[An,qe]),yr=x.useCallback(Be=>{Ji.event({category:qs.USER_ACTIONS,action:Be.length===1&&Be[0].type===J.Bloob?Jt.DELETE_BLOOB:Jt.DELETE_SONG,label:bo.MANUAL_BLOOB_ACTS});const De=at.getState().domainRoleByChannel,Xe={getBloobById:i,getNoteById:s};Be.forEach(Le=>{var mt;const He=Xy(Le,Xe);if(He){const Ht=(mt=De[He])==null?void 0:mt.toLowerCase();if(Ht==="viewer"||(Le.type===J.Song||Le.type===J.TextNode||Le.type===J.EmbeddingNode||Le.type===J.VisualMediaNode)&&Ht==="editor")return}Le.type===J.Bloob?y(Le.id):Le.type===J.Song?(ge===Le.id&&Z(),m(Le.id),D(Le.id)):Le.type===J.TextNode?_(Le.id):Le.type===J.EmbeddingNode?j(Le.id):Le.type===J.VisualMediaNode&&T(Le.id)}),ve(),B()},[ve,B,y,ge,m,D,Z,_,j,T,i,s]),Ps=x.useCallback(()=>{const Be=de.filter(Le=>{if(!dv(Le.type))return!1;const He=Zf(Le);return He?v8(He,cn):!1}),De=Be.some(Le=>Le.type===J.Song),Xe=Be.some(Le=>{const He=Zf(Le);return He?So(He,cn,kt):!1});De||Xe?(pn.current=[...Be],rn(!0)):yr(de)},[de,yr,cn,kt]),Kr=x.useCallback(()=>{pn.current&&(yr(pn.current),pn.current=null),rn(!1)},[yr]),xe=x.useMemo(()=>{const Be=pn.current??de,De=Be.filter(mt=>dv(mt.type)),Xe=De.filter(mt=>{const Ht=Zf(mt);return Ht?So(Ht,cn,kt):!1}),Le=De.map(mt=>mt.type===J.Song?r(mt.id).label:mt.type===J.TextNode?u(mt.id).label:mt.type===J.EmbeddingNode?l(mt.id).label:mt.type===J.VisualMediaNode?o(mt.id).label:"");let He="Are you sure you want to delete the selected objects?";if(De.length===1&&Le[0]){const mt=De[0];if(mt.type===J.Song)He=`Are you sure you want to delete "${Le[0]}"? This will permanently remove the song and all its bloobs.`;else{const Ht=mt.type===J.TextNode?"note":mt.type===J.EmbeddingNode?"embedding":"visual media object";He=`Are you sure you want to delete "${Le[0]}"? This will permanently remove this ${Ht}.`}}else De.length>1?He=`Are you sure you want to delete ${De.length} selected objects? This action cannot be undone.`:Be.length===1&&Be[0].type===J.Bloob&&(He="Are you sure you want to delete this bloob?");return Xe.length>0?`${He} ${Xe.length===1?"One selected object is currently shared with collaborators.":`${Xe.length} selected objects are currently shared with collaborators.`}`:He},[de,cn,kt,r,u,l,o]),Re=x.useCallback(()=>{if(ct.size===0||it===null)return!1;const Be=i(it);return!!(Be&&ln(Be))},[ct,it,i]),_e=x.useCallback(()=>
911{if(Re()||de.some(Le=>Le.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Le=>{var mt;const He=i(Le.id);return He&&((mt=Be[`song:${He.songId}`])==null?void 0:mt.toLowerCase())==="viewer"}))return;const De=de.map(Le=>i(Le.id)),Xe=new Set(De.map(Le=>Le.id));for(const Le of De){const He={bar:Le.songPosition.bar,track:Le.songPosition.track-1};if(n(Le.songId,He,Le.bars).filter(Ht=>!Xe.has(Ht.id)).length>0&&He.track!==Le.songPosition.track)return}De.sort((Le,He)=>Le.songPosition.track-He.songPosition.track).forEach(Le=>{g(Le.id,jr.Up)}),B()},[de,i,n,g,B,Re]),Ve=x.useCallback(()=>{if(Re()||de.some(Le=>Le.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Le=>{var mt;const He=i(Le.id);return He&&((mt=Be[`song:${He.songId}`])==null?void 0:mt.toLowerCase())==="viewer"}))return;const De=de.map(Le=>i(Le.id)),Xe=new Set(De.map(Le=>Le.id));for(const Le of De){const He={bar:Le.songPosition.bar+he,track:Le.songPosition.track};if(n(Le.songId,He,Le.bars).filter(Ht=>!Xe.has(Ht.id)).length>0&&He.track!==Le.songPosition.track)return}De.sort((Le,He)=>He.songPosition.bar-Le.songPosition.bar).forEach(Le=>{g(Le.id,jr.Right,he)}),B()},[de,B,i,n,g,Re,he]),Ge=x.useCallback(()=>{if(Re()||de.some(Le=>Le.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Le=>{var mt;const He=i(Le.id);return He&&((mt=Be[`song:${He.songId}`])==null?void 0:mt.toLowerCase())==="viewer"}))return;const De=de.map(Le=>i(Le.id)),Xe=new Set(De.map(Le=>Le.id));for(const Le of De){const He={bar:Le.songPosition.bar,track:Le.songPosition.track+1};if(n(Le.songId,He,Le.bars).filter(Ht=>!Xe.has(Ht.id)).length>0)return}De.sort((Le,He)=>He.songPosition.track-Le.songPosition.track).forEach(Le=>{g(Le.id,jr.Down)}),B()},[de,B,i,n,g,Re]),Fe=x.useCallback(()=>{if(Re()||de.some(Le=>Le.type!==J.Bloob))return;const Be=at.getState().domainRoleByChannel;if(de.some(Le=>{var mt;const He=i(Le.id);return He&&((mt=Be[`song:${He.songId}`])==null?void 0:mt.toLowerCase())==="viewer"}))return;const De=de.map(Le=>i(Le.id)),Xe=new Set(De.map(Le=>Le.id));for(const Le of De){const He={bar:Le.songPosition.bar-he,track:Le.songPosition.track};if(n(Le.songId,He,Le.bars).filter(Ht=>!Xe.has(Ht.id)).length>0)return}De.sort((Le,He)=>Le.songPosition.bar-He.songPosition.bar).forEach(Le=>{g(Le.id,jr.Left,he)}),B()},[de,B,i,n,g,Re,he]),pt=x.useCallback(()=>{de.length?gt(de):gt(null)},[de]),St=x.useCallback(Be=>{switch(Be.type){case J.Song:{const De=r(Be.id);if(!De){dt("Cannot paste song that no longer exists");return}return Ro(De.canvasPosition)}case J.EmbeddingNode:{const De=l(Be.id);if(!De){dt("Cannot paste embedding that no longer exists");return}return Ro(De.canvasPosition)}case J.VisualMediaNode:{const De=o(Be.id);if(!De){dt("Cannot paste visual media node that no longer exists");return}return Ro(De.canvasPosition)}case J.TextNode:{const De=u(Be.id);if(!De){dt("Cannot paste text node that no longer exists");return}return Ro(De.canvasPosition)}default:throw new Error("Invalid copyCaiObject type")}},[l,r,u,o,dt]),zt=x.useCallback(Be=>{if(Be.type===J.Bloob)throw new Error("Cannot paste non-bloob bloob");const De=St(Be);if(De)switch(Be.type){case J.Song:return M(Be.id,De);case J.EmbeddingNode:return V(Be.id,De);case J.VisualMediaNode:return H(Be.id,De);case J.TextNode:return P(Be.id,De);default:throw new Error("Invalid copyCaiObject type")}},[St,M,V,H,P]),Nt=x.useCallback(Be=>{const De=i(Be);if(!De){dt("Cannot paste bloob that no longer exists");return}let Xe;switch(Q==null?void 0:Q.type){case void 0:{Xe=a(De.songId,De.songPosition,De.bars);break}case J.Bloob:{const He=i(Q.id);if(He.songId!==De.songId){dt("Cannot copy bloob to a different song than the one it is in");return}Xe=a(He.songId,He.songPosition,He.bars);break}case J.Song:if(Q.id!==De.songId){dt("Cannot copy bloob to a different song than the one it is in");return}Xe=a(Q.id,De.songPosition,De.bars);break;default:{dt("Select a bloob to paste near or song to paste into");return}}if(Xe==null){dt("No open spot found to paste bloob; try selecting a song or another bloob");return}const Le=h(De.id,Xe);return B(),Le},[B,i,Q,h,dt,a]),At=Be=>{try{return new URL(Be),!0}catch{return!1}},Zt=Be=>Be.startsWith("image/")||Be.startsWith("video/"),Me=Be=>Be.startsWith("audio/"),Qe=x.useCallback(async()=>{try{const Be=await navigator.clipboard.read();let De=!1;for(const Xe of Be){if(Xe.types.includes("text/plain")){const He=await(await Xe.getType("text/plain")).text();if(He.trim()){if(At(He.trim())){const mt={x:window.innerWidth/2-M_/2,y:window.innerHeight/2-B_/2},Ht=q(mt),fn=I(Ht,"Pasted Link",He.trim());Ue({type:J.EmbeddingNode,id:fn}),dt("Link pasted as embedding"),De=!0}else{const mt={x:window.innerWidth/2-D_/2,y:window.innerHeight/2-L_/2},Ht=q(mt),fn=F(Ht,"Pasted Text",He);Ue({type:J.TextNode,id:fn}),dt("Text pasted as text node"),De=!0}break}}for(const Le of Xe.types){if(Zt(Le)){const He=await Xe.getType(Le),mt=new FileReader;mt.onload=Ht=>{var ri;const fn=(ri=Ht.target)==null?void 0:ri.result,Nn={x:window.innerWidth/2-R_/2,y:window.innerHeight/2-O_/2},sr=q(Nn),$n=R(sr,"Pasted Media",fn);Ue({type:J.VisualMediaNode,id:$n}),dt(Le.startsWith("video/")?"Video pasted as visual media node":"Image pasted as visual media node")}
911,mt.readAsDataURL(He),De=!0;break}if(Me(Le)){const mt=await(await Xe.getType(Le)).arrayBuffer();try{const fn=await new AudioContext().decodeAudioData(mt),Nn=await U("pasted-audio.wav",fn),sr={x:window.innerWidth/2-3*dn,y:window.innerHeight/2-1.5*bn},$n=q(sr),ri=A({chroma:"C",quality:"Major"},120,{beatsPerBar:4,beatDuration:4},$n,"Pasted Audio Song"),wr=S(ri,{audioFileId:Nn},4,{bar:1,track:1},"Pasted Audio");Ue({type:J.Bloob,id:wr}),dt("Audio pasted as audio bloob"),De=!0;break}catch(Ht){dt("Failed to paste audio file"),ar("Failed to paste audio file: ",Ht)}}}if(De){B();break}}De||dt("No pasteable content found in clipboard")}catch{dt("Failed to access clipboard")}},[q,I,F,R,U,A,S,Ue,dt,B]),ae=x.useCallback(()=>{if(!tt){Qe();return}const Be=at.getState().domainRoleByChannel,De=at.getState().domainPolicyByChannel,Xe={getBloobById:i,getNoteById:s},Le=[];tt.forEach(He=>{var fn;if(He.type===J.Song||He.type===J.TextNode||He.type===J.EmbeddingNode||He.type===J.VisualMediaNode){const Nn=Xy(He,Xe);if(Nn){const sr=(fn=Be[Nn])==null?void 0:fn.toLowerCase();if(sr&&sr!=="owner"){const $n=De[Nn];if(!($n!=null&&$n.allowCopy))return}}}let Ht;He.type===J.Bloob?Ht=Nt(He.id):Ht=zt(He),Ht!==void 0&&Le.push({type:He.type,id:Ht})}),Le.length>0&&(Se(Le),B())},[tt,Qe,Nt,zt,Se,B,i,s]);x.useEffect(()=>{Ji.event({category:qs.USER_ACTIONS,action:Ne===zn.MINIMIZED?Jt.CHAT_MIN:Ne===zn.MAXIMIZED?Jt.CHAT_MAX:Jt.CHAT_DEF,label:bo.UI_ACTS})},[Ne]);const K=()=>{var Xe,Le,He,mt,Ht,fn,Nn;if(document.activeElement&&(document.activeElement.tagName==="INPUT"||document.activeElement.tagName==="TEXTAREA"||document.activeElement.getAttribute("contenteditable")==="true")||document.activeElement&&(document.activeElement.id==="cai-chat-input"||document.activeElement.id==="cai-chat-expanded-input"||document.activeElement.id==="cai-chat-expanded-mobile-input"||document.activeElement.id==="prompt"||(Xe=document.activeElement.id)!=null&&Xe.includes("instrument-selector")||(Le=document.activeElement.id)!=null&&Le.includes("custom-instrument")||(He=document.activeElement.id)!=null&&He.includes("bloob-label")||(mt=document.activeElement.id)!=null&&mt.includes("song-label")||(Ht=document.activeElement.id)!=null&&Ht.includes("song-key")||(fn=document.activeElement.id)!=null&&fn.includes("volume-input")||(Nn=document.activeElement.id)!=null&&Nn.includes("bpm-input")))return!0;let Be=document.activeElement;for(;Be;){if(Be.classList){const sr=["promptInput","chatBoxInput","promptInputContainer","chatBoxInputContainer","chatBoxContainer","promptContainer","promptContainerStatic","recordBarContainer","chatBoxBody","floatingControls","instrument-selector","custom-instrument-input","bloob-name-input","song-name-input"];for(const $n of sr)if(Be.classList.contains($n))return!0}Be=Be.parentElement}const De=[".promptContainer",".promptContainerStatic",".chatBoxContainer",".chatMinimizedContainer",'[data-testid="modal-dialog"]',".modal-content"];for(const sr of De){const $n=document.querySelector(sr);if($n&&$n.contains(document.activeElement))return!0}return!1},ee=x.useCallback(Be=>{if(!(K()||rt.current))switch(Be.key){case" ":{Un();break}case"Backspace":{Ps();break}case"ArrowUp":{_e();break}case"ArrowRight":{Ve();break}case"ArrowDown":{Ge();break}case"ArrowLeft":{Fe();break}case"a":{fe(Be)?(Be.preventDefault(),nn()):gr();break}case"c":{fe(Be)?pt():(Be.preventDefault(),ye());break}case"d":{if(fe(Be))break;Be.preventDefault(),rr();break}case"e":{fe(Be)&&xn();break}case"h":{on();break}case"m":{Fn();break}case"p":{dr();break}case"r":{Wt();break}case"s":{yt();break}case"t":{Xn();break}case"u":{fe(Be)&&ne();break}case"v":{fe(Be)&&ae();break}case"z":{if(fe(Be))if(Be.shiftKey)$();else{const De=new Set(f().map(Xe=>`${Xe.type}-${Xe.id}`));L(),setTimeout(()=>{const Le=f().filter(He=>!De.has(`${He.type}-${He.id}`));Le.length>0?Se(Le,!1):ve()},0)}break}case"/":{fe(Be)&&le(!O.showBloobIds);break}case"´":{Bn();break}}},[Un,Ps,_e,Ve,Ge,Fe,fe,gr,nn,pt,ye,rr,xn,on,Fn,dr,Wt,yt,Xn,ne,ae,$,f,L,Se,ve,le,O.showBloobIds,Bn]),ue=x.useCallback(Be=>{if(!K())switch(Be.key){case" ":{Rr();break}}},[Rr]);x.useEffect(()=>{const Be=e.current;return Be==null||Be.addEventListener("keydown",ee),Be==null||Be.addEventListener("keyup",ue),()=>{Be==null||Be.removeEventListener("keydown",ee),Be==null||Be.removeEventListener("keyup",ue)}},[e,ee,ue]);const Ee=x.useCallback(()=>{ve(),_t(null)},[ve]),Je=x.useCallback(Be=>{ve(),_t(Be)}
911,[ve]),Ke=x.useRef(null),[Oe,ut]=x.useState(null);return x.useEffect(()=>{const Be={};de.forEach(Xe=>{if(Xe.type===J.Bloob){const Le=i(Xe.id);if(!Le)return;Be[Le.songId]=Le.id}});const De=Object.entries(Be);De.length!==0&&De.forEach(([Xe,Le])=>{const He=parseInt(Xe,10);if(!Number.isFinite(He)||!Le)return;const mt=`song:${He}`;tD(mt,{kind:"bloob_selection",data:{bloobId:Le}})})},[de,i]),vr(({event:Be,first:De,last:Xe,xy:Le})=>{var Ht;if(!((Ht=Be.target.classList)!=null&&Ht.contains("react-flow__pane")))return;const He={x:Le[0],y:Le[1]},mt=q(He);if(De)Ke.current=mt;else if(Xe)ut(null),Ke.current=null;else{const fn=Math.min(mt.x,Ke.current.x),Nn=Math.min(mt.y,Ke.current.y),sr=Math.abs(mt.x-Ke.current.x),$n=Math.abs(mt.y-Ke.current.y),ri={canvasPosition:{x:fn,y:Nn},width:sr,height:$n};ut(ri);const wr=d(ri);Se(wr,!1)}},{filterTaps:!0,target:e.current,touch:!0,delay:50,enabled:!re||Ae===Hs.SELECT}),c.jsxs(c.Fragment,{children:[c.jsx(lde,{onCaiObjectDragStart:$t,onCaiObjectDrag:Ye,onCaiObjectDragStop:Ie,dragCanvasOffset:Tt,ghostBloob:Rt,copyBloobId:Gt,onCanvasClick:Ee,onCanvasDoubleClick:Je,shouldShowBloobDevelopHandles:Q!==null&&Q.type===J.Bloob&&!ie&&!Tt,isSongResizing:wt,onSongResizingStart:()=>Dt(!0),onSongResizingStop:()=>Dt(!1)}),c.jsx(QL,{rect:Oe}),Ze&&c.jsx(Yhe,{canvasPosition:Ze,onOptionSelect:()=>_t(null)}),c.jsx(XL,{onSignOut:t}),c.jsx(Vhe,{onSignOut:t}),!Oe&&c.jsx(ehe,{}),c.jsx(the,{dragCanvasOffset:Tt}),c.jsx(al,{isOpen:Kt,onClose:()=>{rn(!1),pn.current=null},onConfirm:Kr,title:"Confirm Delete",message:xe,confirmText:"Delete",isDangerous:!0})]})},Qhe=18,Zhe=350,Jhe=100,epe=2e3,tpe=2;function npe(t){const r=9.333333333333334;let i="";t.forEach((s,o)=>{const a=o/t.length*100,l=r-s*r*.95;o===0?i+=`M ${a},${r} L ${a},${l}`:i+=` L ${a},${l}`});for(let s=t.length-1;s>=0;s--){const o=s/t.length*100,a=r+t[s]*r*.95;i+=` L ${o},${a}`}return i+=" Z",i}const rpe=({audioFileId:t,clipPixelWidth:e,audioClipStartInSeconds:n=0,clipDurationInSeconds:r,loopContentBars:i,totalBars:s})=>{const{getAudioFileData:o,isAudioFileAvailable:a,getAudioFileById:l}=mn(),[u,d]=x.useState(null),[f,h]=x.useState(e),m=x.useRef(null);x.useEffect(()=>(m.current=setTimeout(()=>h(e),80),()=>clearTimeout(m.current)),[e]),x.useEffect(()=>{let w=!1,v=null;const S=async()=>{try{if(!await a(t)||w)return;const k=await o(t);if(w)return;d(k),v&&(clearInterval(v),v=null)}catch{}};return S(),v=setInterval(()=>{S()},500),()=>{w=!0,v&&clearInterval(v)}},[t,o,a]);const y=x.useMemo(()=>{if(!u||u.length===0)return null;const w=f?Math.max(Jhe,Math.min(epe,Math.round(f*tpe))):Zhe;if(n>0||r!=null){const v=l(t),S=(v==null?void 0:v.sampleRate)??44100,C=u[0].length,k=Math.min(C,Math.round(n*S)),N=r!=null?Math.min(C,k+Math.round(r*S)):C;if(k>=N)return null;const _=u.map(j=>j.subarray(k,N));return $y(_,w)}return $y(u,w)},[u,f,n,r,t,l]),g=x.useMemo(()=>y!=null&&y.length?npe(y):null,[y]);return c.jsx("div",{className:"absolute left-0 right-0 bottom-1 z-0 overflow-hidden pointer-events-none",style:{top:Qhe},children:g?(()=>{const w=i&&s&&i>0&&s>i,v=w?Math.ceil(s/i):1,S=w?i/s:1;return c.jsxs("svg",{width:"100%",height:"28",viewBox:"0 0 100 28",preserveAspectRatio:"none",className:"block",children:[c.jsx("rect",{x:"0",y:"0",width:"100%",height:"28",fill:"rgba(0,0,0,0.0)",rx:"2"}),c.jsx("line",{x1:"0",y1:"14",x2:"100%",y2:"14",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"}),Array.from({length:v}).map((C,k)=>{const N=k*S*100,j=(Math.min((k+1)*S*100,100)-N)/100,M=k>0?"rgba(255,255,255,0.45)":"rgba(255,255,255,0.8)";return c.jsx("g",{transform:`translate(${N},0) scale(${j},1)`,children:c.jsx("path",{d:g,fill:M,stroke:M,strokeWidth:"0.75"})},`wf-${k}`)}),w&&Array.from({length:Math.floor(s/i)},(C,k)=>(k+1)*S*100).filter(C=>C<100).map(C=>c.jsx("line",{x1:C,y1:"0",x2:C,y2:"28",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"},`loop-${C}`))]})})():c.jsxs("svg",{width:"100%",height:"28",viewBox:"0 0 100 28",preserveAspectRatio:"none",className:"block",children:[c.jsx("rect",{x:"0",y:"0",width:"100%",height:"28",fill:"rgba(0,0,0,0.1)",rx:"2"}),c.jsx("line",{x1:"0",y1:"14",x2:"100%",y2:"14",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"})]})})},ipe=mr.memo(rpe),th=500,spe=4,ope=10,ape=({bloob:t,clipWidth:e,clipHeight:n})=>{const{showVolumeAutomation:r}=Pn(),{updateBloobDetails:i}=Gn(),{commitToStore:s}=Ln(),o=x.useRef(null),a=x.useRef(null),l=t.volumeAutomation,u=r,d=!!l&&l.length>0,f=x.useMemo(()=>d?[...l].sort((M,V)=>M.bar-V.bar):[],[d,l]),h=x.useCallback(M=>M/t.bars*e,[t.bars,e]),m=x.useCallback(M=>(1-M)*n,[n]),y=x.useCallback(M=>Math.max(0,Math.min(t.bars,M/e*t.bars)),[t.bars,e]),g=x.useCallback(M=>Math.max(0,Math.min(1,1-M/n)),[n]),{pathPoints:w,fillPath:v}=x.useMemo(()=>
911{if(f.length===0)return{pathPoints:"",fillPath:""};const M=f.map(H=>`${h(H.bar)},${m(H.value)}`),V=[`${h(f[0].bar)},${n}`,...M,`${h(f[f.length-1].bar)},${n}`].join(" ");return{pathPoints:M.join(" "),fillPath:V}},[f,h,m,n]),S=x.useCallback(M=>{i(t.id,{volumeAutomation:[...M].sort((V,H)=>V.bar-H.bar)})},[t.id,i]),C=x.useCallback(M=>{const V=o.current;if(!V)return{x:0,y:0};const H=V.getBoundingClientRect();return{x:M.clientX-H.left,y:M.clientY-H.top}},[]),k=x.useCallback(M=>{if(!u||M.target.closest("[data-automation-point]"))return;M.stopPropagation();const{x:V,y:H}=C(M),P={bar:Math.round(y(V)*100)/100,value:Math.round(g(H)*100)/100};S([...f,P]),s()},[u,C,y,g,f,S,s]),N=x.useCallback((M,V)=>{u&&(M.stopPropagation(),M.preventDefault(),M.target.setPointerCapture(M.pointerId),a.current=V)},[u]),_=x.useCallback(M=>{if(a.current===null)return;M.stopPropagation();const{x:V,y:H}=C(M),P=[...f];P[a.current]={bar:Math.round(y(V)*100)/100,value:Math.round(g(H)*100)/100},S(P)},[C,y,g,f,S]),j=x.useCallback(M=>{a.current!==null&&(M.stopPropagation(),a.current=null,s())},[s]),T=x.useCallback((M,V)=>{if(!u||(M.stopPropagation(),f.length<=2))return;const H=f.filter((P,F)=>F!==V);S(H),s()},[u,f,S,s]);return!r||!d?null:c.jsxs("svg",{ref:o,className:"absolute inset-0 z-[3]",style:{width:e,height:n,pointerEvents:u?"auto":"none",cursor:u?"crosshair":"default"},viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none",onClick:k,onPointerMove:_,onPointerUp:j,children:[c.jsx("polygon",{points:v,fill:"rgba(255,255,255,0.12)",stroke:"none"}),c.jsx("polyline",{points:w,fill:"none",stroke:"rgba(255,255,255,0.6)",strokeWidth:1.5,strokeLinejoin:"round"}),u&&f.map((M,V)=>c.jsx("circle",{"data-automation-point":!0,cx:h(M.bar),cy:m(M.value),r:spe,fill:"white",stroke:"rgba(0,0,0,0.4)",strokeWidth:1,style:{cursor:"grab",pointerEvents:"auto"},onPointerDown:H=>N(H,V),onDoubleClick:H=>T(H,V),children:c.jsxs("title",{children:["Bar ",M.bar.toFixed(1),", Vol ",Math.round(M.value*100),"%"]})},V)),u&&f.map((M,V)=>c.jsx("circle",{cx:h(M.bar),cy:m(M.value),r:ope,fill:"transparent",style:{cursor:"grab",pointerEvents:"auto"},onPointerDown:H=>N(H,V),onDoubleClick:H=>T(H,V)},`hit-${V}`))]})},lpe=52,cpe=32,Pb=3.5,gM=["#f97316","#22c55e","#3b82f6","#14b8a6","#a855f7","#06b6d4","#facc15"];function qk(t){let e=0;for(let r=0;r<t.length;r+=1)e=e*31+t.charCodeAt(r)|0;const n=Math.abs(e)%gM.length;return gM[n]}function Ab(t,e,n){const r=t.getBoundingClientRect(),i=lpe,s=cpe;let o=0,a=0;e<r.left+i?o=-Math.min(s,r.left+i-e):e>r.right-i&&(o=Math.min(s,e-(r.right-i))),n<r.top+i?a=-Math.min(s,r.top+i-n):n>r.bottom-i&&(a=Math.min(s,n-(r.bottom-i))),o!==0&&(t.scrollLeft=Math.max(0,Math.min(t.scrollWidth-t.clientWidth,t.scrollLeft+o))),a!==0&&(t.scrollTop=Math.max(0,Math.min(t.scrollHeight-t.clientHeight,t.scrollTop+a)))}const upe=({bloob:t,song:e,activeCollaborators:n,gridRef:r,barWidth:i,trackHeight:s,children:o,liveDragByBloobId:a=null,onImmersedLiveDragChange:l})=>{const{isCaiObjectSelected:u,selectedCaiObjects:d,selectedSingleCaiObject:f}=Yn(),{selectCaiObject:h}=cr(),{getBloobById:m,getBloobsOverlappingWithPosition:y,getSongById:g,getBloobsInSong:w}=mn(),{updateBloobDetails:v,addBarsToSong:S,addBarsToBloobIfPossible:C,removeBarsFromBloob:k,duplicateBloob:N,setLoopBars:_}=Gn(),{commitToStore:j}=Ln(),{showBloobDetails:T}=Xs(),{generalSettings:M}=bi(),{isDarkMode:V}=Pn(),{showMobileInspector:H}=Br(),{isMobile:P}=Hn(),{isPlaying:F}=zs(),I=at(rt=>rt.awaitingResponse),R=Vr(`song:${e.id}`),U="url('/cursors/loop-refresh-cursor.svg') 6 6, pointer",[A,W]=x.useState(!1),D=x.useRef(l);D.current=l;const B=x.useCallback(()=>{h({type:J.Bloob,id:t.id},!1),H()},[t.id,h,H]),{bind:L}=V0({onLongPress:P?B:void 0}),$=L(),q=x.useCallback(rt=>{rt.stopPropagation()},[]),Z=x.useCallback(rt=>{rt.stopPropagation(),h({type:J.Bloob,id:t.id},!1),T(t.id)},[t,h,T]),ie=Xc({onClick:q,onDoubleClick:Z}),[ge,re]=x.useState(null),[Y,ne]=x.useState(!1),be=x.useRef(null),we=x.useRef(!1),[te,fe]=x.useState(!1),O=u(t),pe=x.useMemo(()=>Gh(t),[t]),he=(f==null?void 0:f.type)===J.Bloob&&f.id===t.id&&!F&&ge===null&&!te,le=x.useMemo(()=>R?pe?!1:I?A:O&&he:!1,[I,R,A,pe,O,he]),oe=t.muted||e.hasSoloedBloobs&&!t.soloed,Q=oe?It.zinc[700]:t.color,de=x.useMemo(()=>{const rt=a==null?void 0:a[t.id];return rt?{bar:rt.bar,track:rt.track}:ge&&!te?ge:{bar:t.songPosition.bar,track:t.songPosition.track}},[a,t.id,t.songPosition.bar,t.songPosition.track,ge,te]),Ne=x.useCallback((rt,Tt)=>{const Mt=r.current;if(!Mt)return null;const Rt=Mt.getBoundingClientRect();return{x:Mt.scrollLeft+(rt-Rt.left),y:Mt.scrollTop+(Tt-Rt.top)}},[r]),Ce=x.useCallback((rt,Tt,Mt)=>{const Rt=M.dragSnapAmount,Ct=i*Rt,Gt=g(e.id);if(!Gt)return null;const Lt=Math.floor((rt+Ct/2)/Ct)*Rt,$t=Math.floor((Tt+s/2)/s),Qt=Math.max(0,th-Mt);return{bar:Math.max(0,Math.min(Lt,Qt)),track:Math.max(0,Math.min($t,Gt.tracks-1))}},[i,M.dragSnapAmount,g,e.id,s]),Ae=vr(({first:rt,last:Tt,xy:Mt,memo:Rt,event:Ct})=>{var nn,rr;if(!R)return;
911if(rt){const xn=!!(Ct!=null&&Ct.altKey);fe(xn);const Bn=Ne(Mt[0],Mt[1]);if(!Bn)return;we.current=!1;const dr=Bn.x-t.songPosition.bar*i,gr=Bn.y-t.songPosition.track*s,on=O?d.filter(yt=>yt.type===J.Bloob).map(yt=>m(yt.id)).filter(yt=>!!yt&&yt.songId===e.id):[],Xn=(on.length>0?on:[m(t.id)].filter(yt=>!!yt)).map(yt=>({id:yt.id,bar:yt.songPosition.bar,track:yt.songPosition.track,bars:yt.bars}));return{grabOffsetX:dr,grabOffsetY:gr,originBar:t.songPosition.bar,originTrack:t.songPosition.track,group:Xn,isAltDrag:xn}}const Gt=Rt;if(!Gt)return;const Lt=m(t.id);if(!Lt)return Gt;if(Tt){if((nn=D.current)==null||nn.call(D,null),we.current&&be.current){const xn=be.current,Bn=xn.bar-Gt.originBar,dr=xn.track-Gt.originTrack,gr=g(e.id);if(gr){let on=0;Gt.group.forEach(Fn=>{const Xn=Fn.bar+Bn+Fn.bars;Xn>gr.bars&&(on=Math.max(on,Xn-gr.bars))}),on>0&&S(e.id,Tr.Right,on)}if(Gt.isAltDrag){const on=[];Gt.group.forEach(Fn=>{const Xn=m(Fn.id);if(!Xn||Xn.songId!==e.id)return;const yt=N(Fn.id,{bar:Fn.bar+Bn,track:Fn.track+dr});yt!==void 0&&on.push({type:J.Bloob,id:yt})}),on.length>0&&(h(on[0]),on.slice(1).forEach(Fn=>h(Fn,!0)))}else Gt.group.forEach(on=>{const Fn=m(on.id);!Fn||Fn.songId!==e.id||v(on.id,{songPosition:{bar:on.bar+Bn,track:on.track+dr}})});j()}be.current=null,re(null),fe(!1),we.current=!1;return}const $t=r.current;$t&&Ab($t,Mt[0],Mt[1]);const Qt=Ne(Mt[0],Mt[1]);if(!Qt)return Gt;const Ye=Qt.x-Gt.grabOffsetX,bt=Qt.y-Gt.grabOffsetY,Ie=Ce(Ye,bt,Lt.bars);if(!Ie)return Gt;const it=Ie.bar-Gt.originBar,ct=Ie.track-Gt.originTrack,Ut=new Set(Gt.group.map(xn=>xn.id));let Et=it,yn=!0;for(const xn of Gt.group){const Bn=m(xn.id),dr=(Bn==null?void 0:Bn.bars)??xn.bars,gr=xn.bar+Et,on=xn.track+ct;if(gr<0||gr+dr>th){yn=!1;break}const Fn=g(e.id);if(!Fn){yn=!1;break}if(on<0||on>=Fn.tracks){yn=!1;break}const Xn=y(e.id,{bar:gr,track:on},dr),yt=Gt.isAltDrag?Xn:Xn.filter(Wt=>!Ut.has(Wt.id));if(yt.length>0&&ct===0){for(const Wt of yt)if(Et>0){const An=Wt.songPosition.bar-dr-xn.bar;Et=Math.min(Et,An)}else{const An=Wt.songPosition.bar+Wt.bars-xn.bar;Et=Math.max(Et,An)}Math.abs(Et)<1e-9&&(Et=0)}else if(yt.length>0){yn=!1;break}}if(yn){const xn={...Ie,bar:Gt.originBar+Et};if(we.current=!0,be.current=xn,re(xn),!Gt.isAltDrag){const Bn={};for(const dr of Gt.group)Bn[dr.id]={bar:dr.bar+Et,track:dr.track+ct};(rr=D.current)==null||rr.call(D,Bn)}}return Gt},{filterTaps:!0,preventDefault:!0}),Ue=vr(({first:rt,last:Tt,xy:Mt})=>{if(!R||rt)return;if(Tt){j();return}const Rt=m(t.id);if(!Rt)return;const Ct=r.current;Ct&&Ab(Ct,Mt[0],Mt[1]);const Gt=Ne(Mt[0],Mt[1]);if(!Gt)return;const Lt=Rt.songPosition.bar*i,$t=Gt.x-Lt;$t>i/2?k(t.id,Tr.Left,1):$t<-i/2&&C(t.id,Tr.Left,1)},{axis:"x",filterTaps:!0,preventDefault:!0}),Se=.25,ve=vr(({first:rt,last:Tt,xy:Mt})=>{if(!R||rt)return;if(Tt){j();return}const Rt=m(t.id);if(!Rt)return;const Ct=r.current;Ct&&Ab(Ct,Mt[0],Mt[1]);const Gt=Ne(Mt[0],Mt[1]);if(!Gt)return;const Lt=Math.max(Se,Gt.x/i-Rt.songPosition.bar);if(Lt!==Rt.bars&&!y(Rt.songId,Rt.songPosition,Lt).some(Qt=>Qt.id!==Rt.id)){const Qt=Rt.loopContentBars!=null&&Lt<=Rt.loopContentBars;v(t.id,{bars:Lt,...Qt?{loopContentBars:null}:{}})}},{axis:"x",filterTaps:!0,preventDefault:!0}),je=vr(({first:rt,last:Tt,xy:Mt})=>{if(!R||rt)return;if(Tt){j();return}const Rt=m(t.id);if(!Rt)return;const Ct=r.current;Ct&&Ab(Ct,Mt[0],Mt[1]);const Gt=Ne(Mt[0],Mt[1]);if(!Gt)return;const Lt=Math.max(Se,Gt.x/i-Rt.songPosition.bar);_(t.id,Lt)},{axis:"x",filterTaps:!0,preventDefault:!0}),Te=t.songPosition.track,ce=at(x.useCallback(rt=>rt.getBloobsInSong(e.id).filter(Tt=>Tt.songPosition.track===Te).map(Tt=>`${Tt.id}:${Tt.songPosition.bar}:${Tt.bars}`).sort().join("|"),[e.id,Te])),{hasLeftNeighbor:se,hasRightNeighbor:ye}=x.useMemo(()=>{const Tt=w(e.id).map($t=>{const Qt=a==null?void 0:a[$t.id];return Qt?{id:$t.id,bar:Qt.bar,track:Qt.track,bars:$t.bars}:{id:$t.id,bar:$t.songPosition.bar,track:$t.songPosition.track,bars:$t.bars}}),Mt=Tt.find($t=>$t.id===t.id);if(!Mt)return{hasLeftNeighbor:!1,hasRightNeighbor:!1};const Rt=Tt.filter($t=>$t.id!==t.id&&$t.track===Mt.track),Ct=Mt.bar+t.bars,Gt=Rt.some($t=>Math.abs($t.bar+$t.bars-Mt.bar)<1e-9),Lt=Rt.some($t=>Math.abs($t.bar-Ct)<1e-9);return{hasLeftNeighbor:Gt,hasRightNeighbor:Lt}},[t.id,t.bars,e.id,w,ce,a]),ke=se?0:3,ze=ye?0:3,qe=Math.max(24,t.bars*i-ke-ze),ot=O?V?"ring-2 ring-zinc-100 shadow-[0_0_6px_rgba(255,255,255,0.35)]":"ring-2 ring-zinc-800 shadow-[0_0_6px_rgba(0,0,0,0.35)]":"",Ze=n.length>0?qk(n[0].userId):null,_t=Ze||(O?V?"#f4f4f5":"#27272a":"rgba(0,0,0,0.2)"),tt=R?Ae():{},{onPointerDown:gt,onPointerMove:dt,onPointerUp:wt,onPointerCancel:Dt,...Kt}
911=tt,rn=de.bar*i,pn=de.track*s,cn=t.bars*i,kt=le?200:ge&&!te?40:Y?30:O?18:10;return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"absolute overflow-visible pointer-events-none",style:{left:rn,top:pn,width:cn,height:s,zIndex:kt},children:[c.jsx("div",{"data-immersed-bloob":!0,...Kt,className:"pointer-events-auto absolute top-[6px] touch-none select-none overflow-visible",style:{left:ke,width:qe,height:s-12,cursor:R?"grab":"default"},title:t.label,onPointerDown:rt=>{var Tt;rt.button===0&&(rt.target.closest("[data-immersed-resize-handle]")||((Tt=$.onPointerDown)==null||Tt.call($,rt),h({type:J.Bloob,id:t.id},rt.shiftKey),gt==null||gt(rt)))},onPointerMove:rt=>{var Tt;(Tt=$.onPointerMove)==null||Tt.call($,rt),dt==null||dt(rt)},onPointerUp:rt=>{var Tt;(Tt=$.onPointerUp)==null||Tt.call($,rt),wt==null||wt(rt)},onPointerCancel:rt=>{var Tt;(Tt=$.onPointerCancel)==null||Tt.call($,rt),Dt==null||Dt(rt)},onMouseDown:rt=>rt.stopPropagation(),onMouseEnter:()=>{n.length>0&&ne(!0)},onMouseLeave:()=>{ne(!1)},children:c.jsxs(et.div,{className:`h-full w-full border px-2 py-1 overflow-visible shadow-md ring-1 ring-white/15 dark:ring-black/30 ${ot}`,onClick:ie.onSingle,onDoubleClick:ie.onDouble,style:{backgroundColor:Q,borderColor:_t,borderRadius:`${se?Pb:6}px ${ye?Pb:6}px ${ye?Pb:6}px ${se?Pb:6}px`,opacity:ge&&!te?.95:oe?.7:1,transition:"background-color 150ms, opacity 150ms"},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:17,duration:.2},children:[c.jsxs("div",{className:"relative z-[1] flex items-center gap-1 text-[11px] font-semibold text-white drop-shadow-sm pointer-events-none min-w-0",children:[c.jsx("span",{className:"truncate",children:t.label}),t.muted&&c.jsx(Ih,{className:"size-2.5 flex-shrink-0 opacity-80"}),t.soloed&&c.jsx(Eh,{className:"size-2.5 flex-shrink-0 opacity-80"})]}),n.length>0&&c.jsxs("div",{className:"absolute top-1 right-1 z-[2] flex items-center gap-0.5 pointer-events-none",children:[n.slice(0,3).map(rt=>c.jsx("div",{className:"w-2 h-2 rounded-full border border-black/40",style:{backgroundColor:qk(rt.userId)},title:rt.name||rt.email||rt.userId},rt.userId)),n.length>3&&c.jsxs("span",{className:"text-[10px] text-white/85",children:["+",n.length-3]})]}),Y&&n.length>0&&c.jsxs("div",{className:"absolute -top-6 left-1/2 -translate-x-1/2 z-50 px-2 py-1 rounded-full shadow-md border text-[10px] flex items-center gap-1 max-w-[220px]",style:{backgroundColor:V?"rgba(24,24,27,0.98)":"rgba(250,250,250,0.98)",borderColor:V?"#3f3f46":"#d4d4d8"},onMouseEnter:rt=>{rt.stopPropagation(),n.length>0&&ne(!0)},onMouseLeave:rt=>{rt.stopPropagation(),ne(!1)},children:[n.slice(0,3).map(rt=>c.jsx("div",{className:"w-2 h-2 rounded-full border border-black/40 flex-shrink-0",style:{backgroundColor:qk(rt.userId)}},rt.userId)),c.jsxs("span",{className:`truncate ${V?"text-zinc-100":"text-zinc-800"}`,children:[n.slice(0,2).map(rt=>rt.name||rt.email||rt.userId).join(", "),n.length>2&&` +${n.length-2}`]})]}),c.jsx("div",{className:"pointer-events-none",children:o}),c.jsx(ape,{bloob:t,clipWidth:qe,clipHeight:s-12}),R&&c.jsxs(c.Fragment,{children:[c.jsx("div",{"data-immersed-resize-handle":!0,className:"absolute inset-y-0 left-0 w-4 -translate-x-1/2 z-[2] cursor-ew-resize touch-none pointer-events-auto",onPointerDown:rt=>rt.stopPropagation(),...Ue()}),c.jsx("div",{"data-immersed-resize-handle":!0,className:"absolute right-0 top-0 w-4 translate-x-1/2 z-[2] touch-none pointer-events-auto",style:{height:18,cursor:U},title:"Drag to loop",onPointerDown:rt=>rt.stopPropagation(),...je()}),c.jsx("div",{"data-immersed-resize-handle":!0,className:"absolute right-0 w-4 translate-x-1/2 z-[2] cursor-ew-resize touch-none pointer-events-auto",style:{to
911p:18,height:"calc(100% - 18px)"},onPointerDown:rt=>rt.stopPropagation(),...ve()})]})]})}),le&&c.jsx("div",{"data-bloob-develop-handles":!0,className:"absolute inset-0 overflow-visible z-[1] pointer-events-none [&_button]:pointer-events-auto [&_[data-radix-popper-content-wrapper]]:pointer-events-auto",onMouseDown:rt=>rt.stopPropagation(),onClick:rt=>rt.stopPropagation(),children:c.jsx(nL,{bloobId:t.id,setIsBeingDeveloped:W,layoutBarWidth:i,layoutTrackHeight:s})})]}),te&&ge&&c.jsx("div",{className:"absolute rounded-md border border-dashed pointer-events-none z-20 ring-1 ring-white/15 dark:ring-black/30",style:{left:ge.bar*i+3,top:ge.track*s+6,width:qe,height:s-12,backgroundColor:Q,borderColor:V?"#f4f4f5":"#27272a",opacity:.55},children:c.jsx("div",{className:"px-2 py-1 text-[11px] font-semibold text-white/70 drop-shadow-sm truncate",children:t.label})})]})},dpe=mr.memo(upe),hc=54,fpe=168,hf=th,hpe=[],bM=16,ppe=2,yM=2,vM=12,xM=127,mpe=56,Kk=224,gpe=14,bpe=({name:t,trackEntity:e,isSelected:n,canEdit:r,onRename:i})=>{const[s,o]=x.useState(!1),[a,l]=x.useState(t),u=x.useRef(null);x.useEffect(()=>{l(t)},[t]),x.useEffect(()=>{s&&u.current&&(u.current.focus(),u.current.select())},[s]);const d=x.useCallback(()=>{const f=a.trim();f&&f!==t&&e?i(f):l(t),o(!1)},[a,t,e,i]);return s?c.jsx("input",{ref:u,type:"text",value:a,onChange:f=>l(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur(),f.key==="Escape"&&(l(t),o(!1))},onClick:f=>f.stopPropagation(),className:"bg-transparent text-[11px] font-semibold text-zinc-700 dark:text-zinc-100 outline-none w-full min-w-0 truncate"}):c.jsx("span",{className:`text-[11px] font-semibold truncate min-w-0 block transition-colors ${n?"text-sky-600 dark:text-sky-300":"text-zinc-600 dark:text-zinc-300"}`,onDoubleClick:f=>{!r||!e||(f.stopPropagation(),o(!0))},title:r&&e?"Double-click to rename":t,children:t})},ype=()=>{const{immersedSongId:t,selectedCaiObjects:e,selectedSingleCaiObject:n,caiChatState:r,timelineCursorBar:i,immersedBarWidth:s}=Yn(),{closeImmersedSong:o,selectCaiObject:a,selectCaiObjects:l,setCaiChatState:u,setTimelineCursorBar:d,setTimelineLoopRegion:f,zoomImmersedTimeline:h}=cr(),{getSongById:m,bloobs:y,tracks:g,getNotesInBloob:w,noteDetails:v,getBloobsOverlappingWithPosition:S,findOpenSongPositionNear:C,getBloobById:k}=mn(),{updateBloobDetails:N,addBloob:_,addBarsToSong:j,deleteBloob:T,duplicateBloob:M,shiftBloob:V,splitBloob:H,ensureTrackEntity:P,updateTrackName:F}=Gn(),{commitToStore:I,undo:R,redo:U}=Ln(),{generalSettings:A}=bi(),W=A.bloobNudgeAmount??1/256,{mobileInspectorOpen:D,isDarkMode:B}=Pn(),{showHotkeys:L,closeMobileInspector:$,toggleVolumeAutomation:q}=Br(),{detailsBloobId:Z,selectedNoteIds:ie}=Ho(),{showBloobDetails:ge,closeBloobDetails:re,deselectAllNotes:Y}=Xs(),{focusCaiChat:ne,focusCanvas:be}=di(),{togglePlayStop:we,isPlaying:te}=zs(),{hasCmdModifier:fe}=Wl(),{currentUserId:O}=iE(),pe=x.useRef(null),he=x.useRef(null),le=x.useRef(null),oe=x.useRef(null),Q=400,de=t!==null?m(t):null,Ne=Vr(de?`song:${de.id}`:"global"),Ce=sE(t??-1),{isMobile:Ae}=Hn();x.useEffect(()=>{t!==null&&!de&&o()},[t,de,o]);const Ue=x.useMemo(()=>de?e.some(Me=>{if(Me.type!==J.Bloob)return!1;const Qe=y[Me.id];return(Qe==null?void 0:Qe.songId)===de.id}):!1,[de,e,y]),Se=x.useMemo(()=>de?e.some(Me=>{if(Me.type!==J.Track)return!1;const Qe=g[Me.id];return(Qe==null?void 0:Qe.songId)===de.id}):!1,[de,e,g]);x.useEffect(()=>{var Qe,ae;if(!de||Ue||Se)return;e.length===1&&((Qe=e[0])==null?void 0:Qe.type)===J.Song&&((ae=e[0])==null?void 0:ae.id)===de.id||a({type:J.Song,id:de.id})},[de,Ue,Se,e,a]);const ve=x.useMemo(()=>de?Array.from(de.bloobIds).map(Me=>y[Me]).filter(Me=>Me!==void 0).sort((Me,Qe)=>Me.songPosition.track!==Qe.songPosition.track?Me.songPosition.track-Qe.songPosition.track:Me.songPosition.bar-Qe.songPosition.bar):[],[de,y]),[je,Te]=x.useState(null),ce=x.useMemo(()=>{if(!de)return new Map;const Me=new Map;for(let ae=0;ae<de.tracks;ae++)Me.set(ae,{muted:0,soloed:0,total:0});for(const ae of ve){const K=Me.get(ae.songPosition.track);K&&(K.total++,ae.muted&&K.muted++,ae.soloed&&K.soloed++)}const Qe=new Map;for(const[ae,K]of Me)Qe.set(ae,{allMuted:K.total>0&&K.muted===K.total,allSoloed:K.total>0&&K.soloed===K.total});return Qe},[de,ve]),se=x.useMemo(()=>{const Me={};return Object.values(Ce).forEach(Qe=>{Qe.userId!==O&&typeof Qe.bloobId=="number"&&(Me[Qe.bloobId]||(Me[Qe.bloobId]=[]),Me[Qe.bloobId].push({userId:Qe.userId,name:Qe.name,email:Qe.email}))}),Me},[Ce,O]),ye=x.useMemo(()=>
911{if(Ae||!de||!n||n.type!==J.Bloob)return null;const Me=k(n.id);return!Me||Me.songId!==de.id?null:n.id},[Ae,de,n,k]),ke=x.useMemo(()=>{if(Ae||!de||!n||n.type!==J.Track)return null;const Me=g[n.id];return!Me||Me.songId!==de.id?null:n.id},[Ae,de,n,g]),ze=x.useMemo(()=>{if(!Ae||!de||!n||n.type!==J.Bloob)return null;const Me=k(n.id);return!Me||Me.songId!==de.id?null:n.id},[Ae,de,n,k]),qe=x.useMemo(()=>{if(!Ae||!de||!n||n.type!==J.Track)return null;const Me=g[n.id];return!Me||Me.songId!==de.id?null:n.id},[Ae,de,n,g]),ot=ye!==null||ke!==null;x.useEffect(()=>{if(!de)return;const Me=e.filter(Qe=>Qe.type===J.Bloob).map(Qe=>Qe.id).filter(Qe=>{const ae=k(Qe);return(ae==null?void 0:ae.songId)===de.id});Me.length!==0&&Me.forEach(Qe=>{tD(`song:${de.id}`,{kind:"bloob_selection",data:{bloobId:Qe}})})},[de,e,k]);const Ze=x.useCallback(Me=>{if(!de)return;const Qe=Array.from(de.trackIds??[]).map(K=>g[K]).find(K=>(K==null?void 0:K.trackIndex)===Me);if(Qe){a({type:J.Track,id:Qe.id});return}const ae=P(de.id,Me);a({type:J.Track,id:ae.id}),I()},[de,g,P,I,a]),_t=x.useCallback(Me=>{const Qe=ce.get(Me),ae=!((Qe==null?void 0:Qe.allMuted)??!1);for(const K of ve)K.songPosition.track===Me&&K.muted!==ae&&N(K.id,{muted:ae})},[ve,ce,N]),tt=x.useCallback(Me=>{const Qe=ce.get(Me),ae=!((Qe==null?void 0:Qe.allSoloed)??!1);for(const K of ve)K.songPosition.track===Me&&K.soloed!==ae&&N(K.id,{soloed:ae})},[ve,ce,N]),gt=hf*s,dt=de.timeSignature.beatsPerBar,wt=x.useMemo(()=>s>=500?8:s>=300?4:s>=150?2:1,[s]),Dt=s>=50,Kt=x.useCallback((Me,Qe,ae)=>{const K=s,ee=Dt?dt*wt:1,ue=[];for(let Ee=0;Ee<ee;Ee++){const Je=Ee/ee*K;let Ke;Ee===0?Ke=Me:wt>1&&Ee%wt===0?Ke=Qe:Ke=ae,ue.push(`transparent ${Je}px`),ue.push(`${Ke} ${Je}px`),ue.push(`${Ke} ${Je+1}px`),ue.push(`transparent ${Je+1}px`)}return`linear-gradient(90deg, ${ue.join(", ")})`},[s,dt,Dt,wt]),rn=x.useCallback(Me=>{const Qe=s,ae=Dt?dt*wt:1,K=[];for(let ee=0;ee<ae;ee++){const ue=ee/ae*Qe,Ee=ee===0?Me:"transparent";K.push(`transparent ${ue}px`),K.push(`${Ee} ${ue}px`),K.push(`${Ee} ${ue+1}px`),K.push(`transparent ${ue+1}px`)}return`linear-gradient(90deg, ${K.join(", ")})`},[s,dt,Dt,wt]),pn=x.useCallback(Me=>{const Qe=s,ae=Dt?dt*wt:1,K=[];for(let ee=0;ee<ae;ee++){const ue=ee/ae*Qe;let Ee="transparent";ee>0&&wt>1&&ee%wt===0&&(Ee=Me),K.push(`transparent ${ue}px`),K.push(`${Ee} ${ue}px`),K.push(`${Ee} ${ue+1}px`),K.push(`transparent ${ue+1}px`)}return`linear-gradient(90deg, ${K.join(", ")})`},[s,dt,Dt,wt]),cn=x.useCallback(Me=>{const Qe=s,ae=Dt?dt*wt:1,K=[];for(let ee=0;ee<ae;ee++){const ue=ee/ae*Qe,Ee=ee>0&&wt>1&&ee%wt===0,Je=wt>1&&ee>0&&!Ee&&ae>1?Me:"transparent";K.push(`transparent ${ue}px`),K.push(`${Je} ${ue}px`),K.push(`${Je} ${ue+1}px`),K.push(`transparent ${ue+1}px`)}return`linear-gradient(90deg, ${K.join(", ")})`},[s,dt,Dt,wt]),kt=x.useMemo(()=>({bar:B?"rgba(120,120,128,0.42)":"rgba(150,150,160,0.38)",beat:B?"rgba(120,120,128,0.2)":"rgba(150,150,160,0.2)",sub:B?"rgba(120,120,128,0.1)":"rgba(150,150,160,0.1)"}),[B]),rt=x.useMemo(()=>({backgroundImage:rn(kt.bar),backgroundSize:`${s}px 100%`,backgroundRepeat:"repeat-x"}),[rn,s,kt.bar]),Tt=x.useMemo(()=>({backgroundImage:pn(kt.beat),backgroundSize:`${s}px 100%`,backgroundRepeat:"repeat-x"}),[pn,s,kt.beat]),Mt=x.useMemo(()=>({top:gpe,backgroundImage:cn(kt.sub),backgroundSize:`${s}px 100%`,backgroundRepeat:"repeat-x"}),[cn,s,kt.sub]),Rt=x.useMemo(()=>{const Me=[],Qe=s<30?Math.ceil(30/s):1;for(let ae=0;ae<hf;ae+=Qe)Me.push(c.jsx("span",{className:"absolute ml-1 pt-1.5 text-[10px] font-semibold tabular-nums text-zinc-600 dark:text-zinc-300",style:{left:ae*s},children:ae+1},ae));return Me},[s]),Ct=x.useMemo(()=>{const Me=[];if(wt<=1||s<mpe*2)return Me;const Qe=wt;for(let ae=0;ae<hf;ae+=1)for(let K=1;K<Qe;K+=1){const ee=(ae+K/Qe)*s;Me.push(c.jsx("span",{className:"absolute pt-1.5 text-[9px] font-medium tabular-nums text-zinc-500 dark:text-zinc-400",style:{left:ee,transform:"translateX(-50%)"},children:`${ae+1} ${K}/${Qe}`},`immersed-fraction-${ae}-${K}-${Qe}`))}return Me},[s,wt]),Gt=x.useMemo(()=>({backgroundImage:Kt(B?"rgba(150,150,158,0.28)":"rgba(155,155,165,0.32)",B?"rgba(150,150,158,0.09)":"rgba(155,155,165,0.11)",B?"rgba(150,150,158,0.045)":"rgba(155,155,165,0.055)"),backgroundSize:`${s}px 100%`,backgroundRepeat:"repeat-x"}),[Kt,s,B]),Lt=x.useMemo(()=>Array.from({length:de.tracks}).map((Me,Qe)=>c.jsx("div",{className:`absolute left-0 right-0 border-b border-zinc-300/60 dark:border-zinc-700/80 ${Qe%2===1?"bg-zinc-100/70 dark:bg-zinc-900/35":"bg-zinc-50/40 dark:bg-zinc-950/20"}
911`,style:{top:Qe*hc,height:hc}},`track-row-${Qe}`)),[de.tracks]),$t=x.useCallback((Me,Qe)=>{const ae=w(Me.id);if(!ae||ae.length===0)return null;const K=ae.map(mt=>{const Ht=v[mt.noteDetailsHash];if(!Ht)return null;const fn=H_(Ht.pitch);return fn===null?null:{note:mt,details:Ht,midi:fn}}).filter(mt=>mt!==null);if(K.length===0)return null;let ee=Math.min(...K.map(mt=>mt.midi)),ue=Math.max(...K.map(mt=>mt.midi));ee=Math.max(0,ee-vM),ue=Math.min(xM,ue+vM);const Ee=Math.max(1,ue-ee),Je=Math.max(24,Me.bars*s-6),Ke=hc-12-bM-2,Oe=Ke*.8,ut=(Ke-Oe)/2,Be=Math.max(1,Me.bars*Qe.timeSignature.beatsPerBar),De=Me.loopContentBars,Xe=De?De*Qe.timeSignature.beatsPerBar:Be,Le=De&&De>0?Math.ceil(Me.bars/De):1,He=[];for(let mt=0;mt<Le;mt++){const Ht=mt*Xe,fn=mt>0;for(let Nn=0;Nn<K.length;Nn++){const{note:sr,details:$n,midi:ri}=K[Nn],wr=$n.startBeat+Ht;if(wr>=Be||De&&$n.startBeat>=Xe)continue;const ns=wr/Be*Je,rs=(Math.min(Be,wr+$n.durationInBeats)-wr)/Be*Je,er=Math.max(yM,rs),Yr=(ue-ri)/Ee*Oe+ut,Ai=$n.velocity/xM*.8+.2;He.push(c.jsx("div",{className:"absolute rounded-sm",style:{left:Number.isNaN(ns)?0:ns,width:Number.isNaN(er)?yM:er,top:Number.isNaN(Yr)?0:Yr,height:ppe,opacity:fn?Ai*.5:Ai,backgroundColor:fn?"rgba(255,255,255,0.55)":"rgba(255,255,255,0.9)"}},`immersed-midi-note-${Me.id}-${sr.id}-${mt}-${Nn}`))}}if(De&&De>0&&Me.bars>De)for(let mt=De;mt<Me.bars;mt+=De){const Ht=mt/Me.bars*Je;He.push(c.jsx("div",{className:"absolute top-0 bottom-0",style:{left:Ht,width:1,background:"repeating-linear-gradient(to bottom, rgba(255,255,255,0.4) 0px, rgba(255,255,255,0.4) 3px, transparent 3px, transparent 6px)"}},`loop-line-${Me.id}-${mt}`))}return c.jsx("div",{className:"absolute left-0 right-0 bottom-1",style:{to
911p:bM+2},children:He})},[w,v,s]),Qt=x.useRef(null),Ye=x.useRef(null),bt=x.useRef(null),Ie=x.useCallback(()=>{const Me=bt.current;Me&&(Qt.current&&(Qt.current.scrollLeft=Me.scrollLeft),Ye.current&&(Ye.current.scrollTop=Me.scrollTop))},[]),it=x.useRef(null),ct=x.useRef(null);x.useEffect(()=>{const Me=bt.current;if(!Me)return;const Qe=ae=>{if(!ae.ctrlKey)return;ae.preventDefault();const K=Me.getBoundingClientRect(),ee=ae.clientX-K.left,ue=at.getState().immersedBarWidth,Ee=(Me.scrollLeft+ee)/ue;ct.current?(ct.current.deltaY+=ae.deltaY,ct.current.cursorX=ee,ct.current.barUnderCursor=Ee):ct.current={deltaY:ae.deltaY,cursorX:ee,barUnderCursor:Ee},it.current===null&&(it.current=requestAnimationFrame(()=>{it.current=null;const Je=ct.current;if(!Je)return;ct.current=null,h(Je.deltaY);const Ke=at.getState().immersedBarWidth;Me.scrollLeft=Je.barUnderCursor*Ke-Je.cursorX,Ie()}))};return Me.addEventListener("wheel",Qe,{passive:!1}),()=>{Me.removeEventListener("wheel",Qe),it.current!==null&&cancelAnimationFrame(it.current)}},[h,Ie]);const{playheadPosition:Ut}=Dx(),{isRecording:Et}=Lo(),yn=x.useMemo(()=>!de||!Ut||Ut.songId!==de.id?null:Ut.bar*s,[de,Ut,s]),nn=x.useCallback((Me,Qe)=>{if(!de)return null;const ae=bt.current,K=m(de.id);if(!ae||!K)return null;const ee=ae.getBoundingClientRect(),ue=ae.scrollLeft+(Me-ee.left),Ee=ae.scrollTop+(Qe-ee.top),Je=A.dragSnapAmount,Ke=s*Je,Oe=Math.floor((ue+Ke/2)/Ke)*Je,ut=Math.floor((Ee+hc/2)/hc);return{bar:Math.max(0,Math.min(Oe,th-1)),track:Math.max(0,Math.min(ut,K.tracks-1))}},[de,m,A.dragSnapAmount,s]),rr=x.useCallback(Me=>{const Qe=Qt.current;if(!Qe)return 0;const ae=Qe.getBoundingClientRect(),ee=(Qe.scrollLeft+(Me-ae.left))/s;return Math.max(0,Math.min(ee,hf-1e-6))},[s]),xn=x.useCallback(Me=>{const Qe=Qt.current;if(!Qe)return 0;const ae=Qe.getBoundingClientRect(),ee=(Qe.scrollLeft+(Me-ae.left))/s;return Math.max(0,Math.min(ee,hf))},[s]),Bn=x.useCallback((Me,Qe)=>{const ae=Qt.current;if(!ae)return null;const K=ae.getBoundingClientRect(),ee=ae.scrollLeft+(Me-K.left);return F_(ee,Qe,s)},[s]),dr=x.useCallback(()=>s/2,[s]),{handlePointerDown:gr,handleDoubleClick:on,activeLoopRegion:Fn}=UE({clientXToBar:rr,clientXToExclusiveEndBar:xn,hitTestEdge:Bn,getDragThresholdPx:dr,songId:(de==null?void 0:de.id)??-1,totalBars:hf}),Xn=x.useMemo(()=>i===null?null:i*s,[i,s]),yt=yn??Xn,Wt=yn!==null,An=x.useMemo(()=>Fn?{left:Fn.startBar*s,width:(Fn.endBar-Fn.startBar)*s}:null,[Fn,s]),Un=x.useCallback(Me=>{if(Me.stopPropagation(),!de||!Ne)return;const Qe="clientX"in Me&&typeof Me.clientX=="number"?Me.clientX:"touches"in Me&&Me.touches.length>0?Me.touches[0].clientX:"changedTouches"in Me&&Me.changedTouches.length>0?Me.changedTouches[0].clientX:null,ae="clientY"in Me&&typeof Me.clientY=="number"?Me.clientY:"touches"in Me&&Me.touches.length>0?Me.touches[0].clientY:"changedTouches"in Me&&Me.changedTouches.length>0?Me.changedTouches[0].clientY:null;if(Qe===null||ae===null)return;const K=nn(Qe,ae);if(!K)return;const ee=x8(de.id,K,{getBloobsOverlappingWithPosition:S,maxBarExclusive:th});if(!ee)return;const ue=m(de.id);ue&&ee.position.bar+ee.bars>ue.bars&&j(de.id,Tr.Right,ee.position.bar+ee.bars-ue.bars);const Ee=_(de.id,{instrument:A.defaultInstrument},ee.bars,ee.position,"Bloob "+de.nextInSongId);a({type:J.Bloob,id:Ee}),ne(),I()},[de,Ne,nn,S,m,j,_,A.defaultInstrument,a,ne,I]),Rr=Xc({onDoubleClick:Un}),yr=x.useCallback(()=>{var Qe;if(document.activeElement&&(document.activeElement.tagName==="INPUT"||document.activeElement.tagName==="TEXTAREA"||document.activeElement.getAttribute("contenteditable")==="true"))return!0;const Me=((Qe=document.activeElement)==null?void 0:Qe.id)??"";return Me==="cai-chat-input"||Me==="cai-chat-expanded-input"||Me==="cai-chat-expanded-mobile-input"||Me==="prompt"},[]),Ps=x.useCallback(()=>{if(!de)return;const Me=e.filter(Qe=>Qe.type===J.Bloob).map(Qe=>Qe.id).filter(Qe=>{const ae=k(Qe);return(ae==null?void 0:ae.songId)===de.id});pe.current=Me.length>0?Me:null},[de,e,k]),Kr=x.useCallback(()=>{if(!de||!Ne)return;const Me=pe.current;if(!Me||Me.length===0)return;const Qe=[];if(Me.forEach(ae=>{const K=k(ae);if(!K||K.songId!==de.id)return;const ee=e.length===1&&e[0].type===J.Bloob?k(e[0].id):null,ue=C(de.id,(ee==null?void 0:ee.songPosition)??K.songPosition,(ee==null?void 0:ee.bars)??K.bars);if(!ue)return;const Ee=M(K.id,ue);Ee!==void 0&&Qe.push({type:J.Bloob,id:Ee})}),Qe.length>0){const ae=Qe[0];
911a(ae),Qe.slice(1).forEach(K=>a(K,!0)),I()}},[de,Ne,e,k,C,M,a,I]),xe=x.useCallback(()=>{if(!de||!Ne)return;const Me=e.filter(Qe=>Qe.type===J.Bloob).map(Qe=>Qe.id).filter(Qe=>{const ae=k(Qe);return(ae==null?void 0:ae.songId)===de.id});Me.length!==0&&(Me.forEach(Qe=>T(Qe)),a({type:J.Song,id:de.id}),I())},[de,Ne,e,k,T,a,I]),Re=x.useCallback(()=>{if(!de)return;const Me=ve.map(Qe=>({type:J.Bloob,id:Qe.id}));if(Me.length===0){a({type:J.Song,id:de.id});return}l(Me,!1)},[de,ve,a,l]),_e=x.useCallback(()=>{switch(r){case zn.DEFAULT:u(zn.MAXIMIZED);break;case zn.MAXIMIZED:u(zn.MINIMIZED);break;case zn.MINIMIZED:u(zn.DEFAULT);break}},[r,u]),Ve=x.useCallback(()=>{L()},[L]),Ge=x.useCallback(()=>de?e.filter(Me=>Me.type===J.Bloob).map(Me=>k(Me.id)).filter(Me=>!!Me).filter(Me=>Me.songId===de.id):[],[de,e,k]),Fe=x.useCallback(()=>{if(!Ne)return;const Me=Ge();if(Me.length===0)return;const Qe=Me.some(ae=>!ae.muted);Me.forEach(ae=>{N(ae.id,{muted:Qe})}),I()},[Ne,Ge,N,I]),pt=x.useCallback(()=>{if(!Ne)return;const Me=Ge();if(Me.length===0)return;const Qe=Me.some(ae=>!ae.soloed);Me.forEach(ae=>{N(ae.id,{soloed:Qe})}),I()},[Ne,Ge,N,I]),St=x.useCallback(()=>{if(!Ne||i===null)return;const Me=Ge();if(Me.length!==1)return;const Qe=Me[0],ae=Qe.songPosition.bar,K=ae+Qe.bars;i<=ae||i>=K||(H(Qe.id,i),I())},[Ne,i,Ge,H,I]),zt=x.useCallback(()=>{if(Z!==null){Y(),re(),be();return}const Me=Ge();if(Me.length!==1)return;const Qe=Me[0];ge(Qe.id)},[re,Y,Z,be,Ge,ge]),Nt=x.useCallback(()=>{if(n){if(te){we();return}if(Ne&&n.type===J.Bloob&&de){const Me=k(n.id);(Me==null?void 0:Me.songId)===de.id&&we(!0)}}},[n,te,Ne,de,k,we]),At=x.useCallback(Me=>{if(!Ne)return;const Qe=Ge();if(Qe.length===0)return;const ae=new Set(Qe.map(ee=>ee.id));for(const ee of Qe){let ue=ee.songPosition.bar,Ee=ee.songPosition.track;if(Me===jr.Up&&(Ee-=1),Me===jr.Down&&(Ee+=1),Me===jr.Left&&(ue-=W),Me===jr.Right&&(ue+=W),!de||Ee<0||Ee>=de.tracks||ue<0||ue+ee.bars>th||S(ee.songId,{bar:ue,track:Ee},ee.bars).filter(Ke=>!ae.has(Ke.id)).length>0&&(Me===jr.Up||Me===jr.Down))return}const K=[...Qe];Me===jr.Up?K.sort((ee,ue)=>ee.songPosition.track-ue.songPosition.track):Me===jr.Down?K.sort((ee,ue)=>ue.songPosition.track-ee.songPosition.track):Me===jr.Left?K.sort((ee,ue)=>ee.songPosition.bar-ue.songPosition.bar):Me===jr.Right&&K.sort((ee,ue)=>ue.songPosition.bar-ee.songPosition.bar),K.forEach(ee=>{V(ee.id,Me,W)}),I()},[Ne,Ge,de,W,S,V,I]);if(x.useEffect(()=>{const Me=K=>K.key===" "||K.code==="Space",Qe=K=>{if(!(yr()||ie.size>0&&Z!==null&&t!==null&&(()=>{const ue=k(Z);return!!(ue&&ue.songId===t&&ln(ue))})()&&(K.key==="ArrowUp"||K.key==="ArrowDown"||K.key==="ArrowLeft"||K.key==="ArrowRight"))){if(Me(K)){K.preventDefault(),document.activeElement instanceof HTMLButtonElement&&document.activeElement.blur(),!K.repeat&&oe.current===null&&(oe.current=Date.now());return}if(K.key==="Escape"){K.preventDefault(),d(null),f(null);return}if(K.key==="Backspace"){K.preventDefault(),xe();return}if(K.key==="ArrowUp"){K.preventDefault(),At(jr.Up);return}if(K.key==="ArrowRight"){K.preventDefault(),At(jr.Right);return}if(K.key==="ArrowDown"){K.preventDefault(),At(jr.Down);return}if(K.key==="ArrowLeft"){K.preventDefault(),At(jr.Left);return}if(K.key==="t"){K.preventDefault(),_e();return}if(K.key==="h"){K.preventDefault(),Ve();return}if(K.key==="m"){K.preventDefault(),Fe();return}if(K.code==="KeyS"&&K.altKey){K.preventDefault(),St();return}if(K.key==="s"&&!K.altKey){K.preventDefault(),pt();return}if(K.key==="d"&&!fe(K)){K.preventDefault(),zt();return}if(K.key==="r"){K.preventDefault(),Nt();return}if(K.key==="a"&&!fe(K)){K.preventDefault(),q();return}fe(K)&&(K.key==="z"?(K.preventDefault(),K.shiftKey?U():R()):K.key==="a"?(K.preventDefault(),Re()):K.key==="c"?(K.preventDefault(),Ps()):K.key==="v"&&(K.preventDefault(),Kr()))}},ae=K=>{if(!Me(K))return;const ee=oe.current;oe.current=null,!(ee===null||Date.now()-ee>=Q)&&(K.preventDefault(),K.stopImmediatePropagation(),!yr()&&(we(),setTimeout(()=>{window.dispatchEvent(new KeyboardEvent("keyup",{code:"Space",key:" ",bubbles:!0}))},0)))};return window.addEventListener("keydown",Qe,!0),window.addEventListener("keyup",ae,!0),()=>{window.removeEventListener("keydown",Qe,!0),window.removeEventListener("keyup",ae,!0)}},[fe,yr,we,xe,Re,Ps,Kr,_e,Ve,Fe,pt,St,zt,Nt,At,q,d,f,ie,Z,t,k,R,U]),!de)return null;const Zt=de.tracks*hc;return c.jsxs("div",{className:"flex-1 min-h-0 text-zinc-800 dark:text-zinc-100 bg-zinc-50/80 dark:bg-zinc-950/40 flex flex-row",children:[c.jsxs("div",{ref:he,className:`overflow-y-auto overflow-x-hidden shrink-0 transition-[width] duration-200 ease-in-out ${ot?"border-r border-zinc-300/70 dark:border-zinc-700":""}`,style:{width:ot?Kk:0},children:[ye!==null&&c.jsx("div",{className:"bg-glass py-3 px-3 h-full",style:{width:Kk},children:c.jsx(MC,{bloobId:ye,containerRef:he})}),ke!==null&&c.jsx("div",{className:"bg-glass py-3 px-3 h-full",style:{width:Kk},children:c.jsx(OC,{trackId:ke,showSongTitle:!1,showTrackMixControl
911s:!1})})]}),c.jsxs("div",{className:"flex-1 min-h-0 min-w-0",style:{display:"grid",gridTemplateColumns:`${fpe}px 1fr`,gridTemplateRows:"36px 1fr"},children:[c.jsx("div",{className:"border-r border-b border-zinc-300/70 dark:border-zinc-700 px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400 bg-gradient-to-b from-zinc-200/90 to-zinc-100/95 dark:from-zinc-800/95 dark:to-zinc-900/95 z-20"}),c.jsx("div",{ref:Qt,className:"overflow-hidden border-b border-zinc-300/60 dark:border-zinc-700/80 bg-gradient-to-b from-zinc-200/90 to-zinc-100/95 dark:from-zinc-800/95 dark:to-zinc-900/95 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.06)] dark:shadow-[inset_0_-1px_0_0_rgba(255,255,255,0.04)]",children:c.jsxs("div",{className:"relative select-none cursor-pointer touch-none",style:{width:gt,height:36,touchAction:"none"},onPointerDown:gr,onDoubleClick:on,children:[c.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 pointer-events-none",style:rt}),c.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 pointer-events-none",style:Tt}),c.jsx("div",{"aria-hidden":!0,className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:Mt}),Rt,Ct,An&&c.jsx("div",{"aria-hidden":!0,className:"absolute top-0 bottom-0 z-10 bg-sky-400/20 border-l border-r border-sky-400/60 pointer-events-none",style:{left:An.left,width:An.width}}),yt!==null&&c.jsx("div",{"aria-hidden":!0,className:`absolute top-0 bottom-0 z-30 w-0.5 -translate-x-1/2 pointer-events-none ${Et?"bg-red-500":Wt?"bg-zinc-500 dark:bg-white":"bg-zinc-400 dark:bg-white"}`,style:{left:yt},children:!Wt&&c.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[4px] border-r-[4px] border-t-[5px] border-l-transparent border-r-transparent border-t-zinc-400 dark:border-t-white"})})]})}),c.jsx("div",{ref:Ye,className:"overflow-hidden border-r border-zinc-300/70 dark:border-zinc-700",children:c.jsx("div",{style:{height:Zt},children:Array.from({length:de.tracks}).map((Me,Qe)=>{var Oe;const ae=ce.get(Qe),K=(ae==null?void 0:ae.allMuted)??!1,ee=(ae==null?void 0:ae.allSoloed)??!1,ue=ke!==null&&((Oe=g[ke])==null?void 0:Oe.trackIndex)===Qe,Ee=Array.from(de.trackIds??[]).map(ut=>g[ut]).find(ut=>(ut==null?void 0:ut.trackIndex)===Qe),Je=(Ee==null?void 0:Ee.name)||`Track ${Qe+1}`,Ke=Ee!=null&&Ee.instrumentLock?$l(Ee.instrumentLock):null;return c.jsxs("div",{className:`border-b border-zinc-300/60 dark:border-zinc-700/80 pl-1 pr-1 flex flex-col justify-center gap-0.5 min-w-0 ${ue?"bg-sky-100/90 dark:bg-sky-900/30":Qe%2===1?"bg-zinc-200/90 dark:bg-zinc-800/95":"bg-zinc-100/90 dark:bg-zinc-900/95"} cursor-pointer`,style:{height:hc},onClick:()=>Ze(Qe),children:[c.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[c.jsx("span",{className:`text-[8px] font-semibold tabular-nums w-3 shrink-0 text-center leading-none ${ue?"text-sky-600 dark:text-sky-300":"text-zinc-400 dark:text-zinc-500"}`,children:Qe+1}),c.jsx("div",{className:"min-w-0 flex-1",children:c.jsx(bpe,{name:Je,trackEntity:Ee,isSelected:ue,canEdit:Ne,onRename:ut=>{Ee&&(F(Ee.id,ut),I())}})})]}),c.jsxs("div",{className:"flex items-center gap-1 pl-4 min-w-0",children:[c.jsx("button",{type:"button",onClick:ut=>{ut.stopPropagation(),_t(Qe)},className:`w-5 h-4 rounded text-[9px] font-bold leading-none transition-colors duration-100 ${K?"bg-red-500/90 text-white shadow-sm":"bg-zinc-300/70 dark:bg-zinc-600/50 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-400/60 dark:hover:bg-zinc-500/50"}`,title:K?"Unmute track":"Mute track",children:"M"}),c.jsx("button",{type:"button",onClick:ut=>{ut.stopPropagation(),tt(Qe)},className:`w-5 h-4 rounded text-[9px] font-bold leading-none transition-colors duration-100 ${ee?"bg-amber-400/90 text-zinc-900 shadow-sm":"bg-zinc-300/70 dark:bg-zinc-600/50 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-400/60 dark:hover:bg-zinc-500/50"}`,title:ee?"Unsolo track":"Solo track",children:"S"}),Ke?c.jsx("span",{className:"text-[9px] leading-none px-1 py-0.5 rounded bg-zinc-300/70 dark:bg-zinc-700/70 text-zinc-600 dark:text-zinc-300 truncate max-w-[86px]",title:Ke,children:Ke}):null]})]},`track-label-${Qe}`)})})}),c.jsx("div",{ref:bt,className:"overflow-auto isolate",onScroll:Ie,children:c.jsxs("div",{className:"relative",style:{width:gt,height:Zt},onMouseDown:Me=>{const Qe=Me.target;Qe.closest("[data-immersed-bloob]")||Qe.closest("[data-bloob-develop-handles]")||a({type:J.Song,id:de.id})},onClick:Rr.onSingle,onDoubleClick:Rr.onDouble,children:[Lt,c.jsx("div",{className:"absolute inset-0 pointer-events-none",style:Gt}),ve.map(Me=>c.jsx(dpe,{bloob:Me,song:de,activeCollaborators:se[Me.id]??hpe,gridRef:bt,barWidth:s,trackHeight:hc,liveDragByBloobId:je,onImmersedLiveDragChange:Te,children:ln(Me)?$t(Me,de):En(Me)?c.jsx(ipe,{audioFileId:Me.audioFileId,clipPixelWidth:Me.bars*s,audioClipStartInSeconds:Me.audioClipStartInSeconds??0,clipDurationInSeconds:ua(Me.loopContentBars??Me.bars,de.timeSignature,de.bpm),loopContentBars:Me.loopContentBars,totalBars:Me.bars}):null},`immersed-bloob-${Me.id}
911`)),yt!==null&&c.jsx("div",{"aria-hidden":!0,className:`absolute top-0 bottom-0 z-40 w-0.5 -translate-x-1/2 pointer-events-none ${Et?"bg-red-500":Wt?"bg-zinc-500 dark:bg-white":"bg-zinc-400/70 dark:bg-white"}`,style:{left:yt}})]})})]}),Ae&&D&&ze!==null&&c.jsx(Wr,{onClose:$,children:c.jsx("div",{ref:le,className:"p-4 bg-glass border-glass max-h-[85vh] overflow-y-auto",children:c.jsx(MC,{bloobId:ze,containerRef:le})})}),Ae&&D&&qe!==null&&c.jsx(Wr,{onClose:$,children:c.jsx("div",{className:"p-4 bg-glass border-glass max-h-[85vh] overflow-y-auto",children:c.jsx(OC,{trackId:qe,showSongTitle:!1,showTrackMixControls:!1})})})]})},vpe=x.createContext(null),Yk={didCatch:!1,error:null};class xpe extends x.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Yk}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var n,r,i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:s,reason:"imperative-api"}),this.setState(Yk)}}componentDidCatch(e,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,e,n)}componentDidUpdate(e,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&wpe(e.resetKeys,i)){var s,o;(s=(o=this.props).onReset)===null||s===void 0||s.call(o,{next:i,prev:e.resetKeys,reason:"keys"}),this.setState(Yk)}}render(){const{children:e,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:s,error:o}=this.state;let a=e;if(s){const l={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=x.createElement(r,l);else if(i!==void 0)a=i;else throw o}return x.createElement(vpe.Provider,{value:{didCatch:s,error:o,resetErrorBoundary:this.resetErrorBoundary}},a)}}function wpe(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return t.length!==e.length||t.some((n,r)=>!Object.is(n,e[r]))}const kpe=({resetErrorBoundary:t})=>{const{undo:e,reset:n}=Ln(),{downloadStorageFile:r}=_d(),{theme:i}=Pn(),{caiPrimary:s}=oE(),o=i===gi.Dark,[a,l]=x.useState(!1),u=x.useCallback(()=>{e()?t():location.reload()},[t,e]),d=x.useCallback(()=>{const m=`cai-export-${new Date().toISOString().slice(0,10)}`;r(m)},[r]),f=()=>{l(!0)},h=()=>{n(),location.reload()};return c.jsxs(c.Fragment,{children:[c.jsx("style",{children:` 912 html, body { 913 overflow: auto !important; 914 position: static !important; 915 touch-action: auto !important; 916 height: auto !important; 917 -ms-overflow-style: none !important; /* IE and Edge */ 918 scrollbar-width: none !important; /* Firefox */ 919 } 920 ::-webkit-scrollbar {
921 display: none !important; /* Chrome, Safari, Opera */ 922 } 923 `}),c.jsxs("div",{className:"min-h-screen transition-colors duration-300 relative",style:{backgroundColor:s,msOverflowStyle:"none",scrollbarWidth:"none"},children:[c.jsxs("div",{className:"fixed inset-0 overflow-hidden pointer-events-none",children:[c.jsx("div",{className:"absolute -inset-10 opacity-20 bg-gradient-to-br from-caiBlue/20 via-caiGreen/20 to-caiPeach/20 animate-rotatingBackground bg-[length:400%_400%]"}),c.jsx("div",{className:"absolute top-1/4 left-1/4 w-64 h-64 rounded-full opacity-10 bg-gradient-to-r from-caiPeach to-caiGreen blur-3xl animate-pulse"}),c.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-80 h-80 rounded-full opacity-10 bg-gradient-to-r from-caiBlue to-caiPeach blur-3xl animate-pulse",style:{animationDelay:"1s"}})]}),c.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 py-4 sm:py-8",children:c.jsxs(et.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut"},className:"relative w-full max-w-sm sm:max-w-md lg:max-w-lg rounded-2xl shadow-2xl backdrop-blur-sm z-10 -mt-16 sm:mt-0",style:{background:o?"rgba(39, 39, 42, 0.9)":"rgba(255, 255, 255, 0.9)"},children:[c.jsx("div",{className:"absolute inset-0 rounded-2xl -z-10",style:{background:"linear-gradient(135deg, #6b88cc 0%, #7dc383 50%, #f8c291 100%)",padding:"2px"},children:c.jsx("div",{className:"rounded-2xl w-full h-full",style:{background:o?"rgba(39, 39, 42, 0.9)":"rgba(255, 255, 255, 0.9)"}})}),c.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 text-center",children:[c.jsx(et.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.2,duration:.4,ease:"easeOut"},className:"flex justify-center mb-4 sm:mb-6",children:c.jsx("div",{className:`p-3 sm:p-4 rounded-full shadow-lg ${o?"bg-zinc-700":"bg-zinc-100"}`,children:c.jsx(z0,{className:"w-8 h-8 sm:w-10 sm:h-10 text-red-500"})})}),c.jsxs(et.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3,duration:.4},className:"mb-6 sm:mb-8",children:[c.jsx("h1",{className:`text-2xl sm:text-3xl font-bold mb-2 sm:mb-3 ${o?"text-white":"text-zinc-900"}`,children:"Oops! Something went wrong"}),c.jsx("p",{className:`text-sm sm:text-base ${o?"text-zinc-300":"text-zinc-700"}`,children:"Donât worry, we can get you back on track. Try one of the options below."})]}),c.jsxs(et.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4,duration:.4},className:"space-y-3 sm:space-y-4",children:[c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:u,className:"w-full py-3 sm:py-4 px-4 sm:px-6 rounded-xl font-semibold text-white shadow-lg bg-gradient-to-r from-caiGreen to-caiBlue hover:from-caiGreen/90 hover:to-caiBlue/90 transition-all duration-200 flex items-center justify-center gap-2 sm:gap-3 text-sm sm:text-base",children:[c.jsx(CD,{className:"w-4 h-4 sm:w-5 sm:h-5"}),"Try Undo Last Action"]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 sm:gap-3",children:[c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98}
923,onClick:d,className:`py-2.5 sm:py-3 px-3 sm:px-4 rounded-lg border transition-all duration-200 flex items-center justify-center gap-2 text-xs sm:text-sm font-medium ${o?"border-zinc-600 hover:bg-zinc-700 text-zinc-300 hover:text-white":"border-zinc-300 hover:bg-zinc-100 text-zinc-700 hover:text-zinc-900"}`,children:[c.jsx(cd,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),"Export Data"]}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>window.location.reload(),className:`py-2.5 sm:py-3 px-3 sm:px-4 rounded-lg border transition-all duration-200 flex items-center justify-center gap-2 text-xs sm:text-sm font-medium ${o?"border-zinc-600 hover:bg-zinc-700 text-zinc-300 hover:text-white":"border-zinc-300 hover:bg-zinc-100 text-zinc-700 hover:text-zinc-900"}`,children:[c.jsx(tv,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),"Reload Page"]})]}),c.jsxs("div",{className:`pt-3 sm:pt-4 border-t ${o?"border-zinc-600":"border-zinc-300"}`,children:[c.jsx("p",{className:`text-xs mb-2 sm:mb-3 text-center ${o?"text-zinc-400":"text-zinc-600"}`,children:"Advanced recovery options"}),c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:f,className:"py-2 px-6 min-w-[10rem] rounded-lg border border-red-500/60 hover:bg-red-500/10 text-red-500 hover:border-red-500 transition-all duration-200 text-xs font-medium flex items-center justify-center gap-1",children:[c.jsx(js,{className:"w-3 h-3"}),"Clear Cache"]})})]})]})]}),c.jsxs(et.div,{initial:{opacity:0}
923,animate:{opacity:1},transition:{delay:.6,duration:.4},className:`px-4 sm:px-6 lg:px-8 py-4 sm:py-6 rounded-b-2xl text-center ${o?"bg-zinc-700/30 border-t border-zinc-600":"bg-zinc-100/30 border-t border-zinc-300"}`,children:[c.jsxs("p",{className:`text-xs mb-2 ${o?"text-zinc-300":"text-zinc-700"}`,children:["ð¡ ",c.jsx("strong",{children:"Need Help?"})," Contact us with your exported data."]}),c.jsxs("div",{className:"flex items-center justify-center gap-3 sm:gap-4 flex-wrap",children:[c.jsxs("a",{href:"mailto:[email protected]",className:"inline-flex items-center gap-1 text-xs font-medium transition-colors text-caiGreen hover:text-caiGreen/80",children:["Get Support on Mail",c.jsx(pi,{className:"w-3 h-3"})]}),c.jsx("span",{className:`text-xs ${o?"text-zinc-500":"text-zinc-400"}`,children:"|"}),c.jsxs("a",{href:"https://discord.gg/6NSDYZgNHf",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium transition-colors text-caiBlue hover:text-caiBlue/80",children:["Get Support on Discord",c.jsx(pi,{className:"w-3 h-3"})]})]})]})]})})]}),c.jsx(al,{isOpen:a,onClose:()=>l(!1),onConfirm:h,title:"Clear Cache",message:"Are you sure you want to clear your local cache? Any work not synced to the cloud will be lost.",confirmText:"Clear Cache",isDangerous:!0})]})},q0=()=>{const e=Kn(s=>({transform:s.transform})).transform,n=e[0],r=e[1],i=e[2];return{xOffset:n,yOffset:r,zoom:i}},Mb=1.5,wM=.5,Xk=2,Spe=({bars:t,beatsPerBar:e,songKey:n})=>{const{highlightedPitch:r}=Ho(),{isDarkMode:i}=Pn(),{xOffset:s,yOffset:o,zoom:a}=q0(),l=x.useMemo(()=>Array.from({length:t},(g,w)=>w).map(g=>c.jsx("rect",{x:Zi(g,e,0),y:"0",width:e*va,height:"100%",fill:g%2===0?i?It.zinc[700]:It.zinc[100]:i?It.zinc[600]:It.zinc[50],fillOpacity:g%2===0?.8:.65},`bar ${g}`)),[t,e,i]),u=x.useMemo(()=>{const y=Array.from({length:t},(w,v)=>v),g=Array.from({length:e},(w,v)=>v);return y.map(w=>g.map(v=>c.jsx("rect",{x:Zi(w,e,v)-Mb/2,y:"0",width:Mb,height:"100%",fill:i?It.zinc[500]:It.zinc[700],fillOpacity:1,"data-beat":`${w}.${v}`},`beat ${w}.${v}`)))},[t,e,i]),d=x.useMemo(()=>{const y=Array.from({length:t},(v,S)=>S),g=Array.from({length:e},(v,S)=>S),w=[.125,.25,.375,.5,.625,.75,.875];return y.map(v=>g.map(S=>w.map(C=>{const k=S+C,N=C===.5,_=C===.25||C===.75;let j=.15;return N?j=.7:_&&(j=.25),c.jsx("rect",{x:Zi(v,e,k)-wM/2,y:"0",width:wM,height:"100%",fill:It.zinc[600],fillOpacity:j,"data-subdivision":`${v}.${S}.${C}`},`subdivision ${v}.${S}.${C}`)})))},[t,e,i]),f=x.useMemo(()=>c.jsx("rect",{x:Zi(t,e,0)-Mb/2,y:"0",width:Mb,height:"100%",fill:i?It.zinc[500]:It.zinc[700],fillOpacity:1,"data-beat":`${t}.${e}`},"last bar marker"),[t,e,i]),h=x.useMemo(()=>rD(n).map(y=>c.jsx("rect",{x:"0",y:kh(y,n.chroma)-Xk/2,width:"100%",height:Xk,fill:i?It.zinc[500]:It.zinc[600],fillOpacity:"0.4","data-pitch":y},`pitch ${y}`)),[n,i]),m=x.useMemo(()=>{if(!r)return;const y=Xk+1;return c.jsx("rect",{x:"0",y:kh(r,n.chroma)-y/2,width:"100%",height:y,fill:i?It.zinc[400]:It.zinc[800],fillOpacity:1,"data-pitch":r})},[r,n.chroma,i]);return c.jsxs("svg",{className:"absolute top-0 left-0 overflow-visible",style:{width:Xh(t,e),height:eE,transform:`translate(${s}px, ${o}px) scale(${a})`,transformOrigin:"0 0"},children:[l,d,u,f,h,m]})},kM=2,SM=.005,Cpe=240,_pe=360,Epe=560,ZL=({bars:t,beatsPerBar:e,barOffset:n=0,songId:r})=>{const{xOffset:i,zoom:s}=q0(),o=x.useRef(null),a=e*va,l=x.useCallback(k=>{const N=o.current;if(!N)return n;const _=N.getBoundingClientRect(),T=(k-_.left-i)/s/a;return Math.max(n,Math.min(T+n,n+t-1e-6))},[i,s,a,n,t]),u=x.useCallback(k=>{const N=o.current;if(!N)return n;const _=N.getBoundingClientRect(),T=(k-_.left-i)/s/a;return Math.max(n,Math.min(T+n,n+t))},[i,s,a,n,t]),d=x.useCallback((k,N)=>{const _=o.current;if(!_)return null;const j=_.getBoundingClientRect(),T=(k-j.left-i)/s,M={startBar:N.startBar-n,endBar:N.endBar-n};return F_(T,M,a)},[i,s,n,a]),f=x.useCallback(()=>a*s/2,[a,s]),h=x.useMemo(()=>({clientXToBar:l,clientXToExclusiveEndBar:u,hitTestEdge:d,getDragThresholdPx:f,songId:r,totalBars:n+t}),[l,u,d,f,r,n,t]),{handlePointerDown:m,handleDoubleClick:y,activeLoopRegion:g}=UE(h),w=x.useMemo(()=>
923{if(!g)return null;const k=g.startBar-n,N=g.endBar-n,_=Math.max(0,k),j=Math.min(t,N);return j<=_?null:{left:_*a*s+i,width:(j-_)*a*s}},[g,n,t,a,s,i]),v=Array.from({length:t+1},(k,N)=>N).map(k=>{const _=Zi(k,e,0)*s+i-kM*s/2,j=kM*s;return c.jsx("div",{className:"absolute top-0 border-none",style:{left:_,borderLeftWidth:j,height:"100%"}},`bar ${k+1}`)}),S=x.useMemo(()=>{const k=[],N=n+1,_=n+t,j=Math.ceil(N-SM),T=Math.floor(_+SM);for(let M=j;M<=T;M+=1){const V=M-N;if(V<0||V>t)continue;const P=Zi(V,e,0)*s+i;k.push(c.jsx("span",{className:"absolute z-20 top-0 flex items-center text-zinc-300 dark:text-zinc-200 font-semibold tabular-nums pointer-events-none",style:{left:P,height:"100%",fontSize:`${Math.min(s*14,14)}px`,paddingLeft:`${Math.max(s*4,3)}px`},children:M},`whole-bar-label-${M}`))}return k},[n,t,e,s,i]),C=x.useMemo(()=>{const k=[],N=a*s;if(N<Cpe)return k;let _=2;N>=Epe?_=8:N>=_pe&&(_=4);const j=n+1,T=n+t,M=Math.floor(j),V=Math.ceil(T);for(let H=M;H<=V;H+=1)for(let P=1;P<_;P+=1){const I=H+P/_-j;if(I<=0||I>=t)continue;const U=Zi(I,e,0)*s+i;k.push(c.jsx("span",{className:"absolute z-10 top-0 flex items-center text-zinc-500 dark:text-zinc-400 font-medium tabular-nums pointer-events-none",style:{left:U,height:"100%",fontSize:`${Math.min(s*10,10)}px`,transform:"translateX(-50%)"},children:`${H} ${P}/${_}`},`fraction-label-${H}-${P}-${_}`))}return k},[a,n,t,e,s,i]);return c.jsxs("div",{ref:o,className:"absolute left-0 w-full h-8 sm:h-10 top-0 flex items-center cursor-pointer bg-zinc-800/45 dark:bg-zinc-800/55 border-b border-zinc-700/35 dark:border-zinc-600/30",onPointerDown:m,onDoubleClick:y,style:{touchAction:"none"},children:[c.jsxs("div",{className:"absolute inset-0 h-full overflow-hidden pointer-events-none",children:[v,S,C]}),w&&c.jsx("div",{"aria-hidden":!0,className:"absolute top-0 bottom-0 z-10 bg-sky-400/20 border-l border-r border-sky-400/60 pointer-events-none",style:{left:w.left,width:w.width}})]})},Npe=({songKey:t})=>{const{highlightedPitch:e}=Ho(),{highlightPitch:n}=Xs(),{isDarkMode:r}=Pn(),{yOffset:i,zoom:s}=q0(),o=x.useMemo(()=>rD(t).map(a=>{const{chroma:l}=Hh(a),u=p0(t.chroma,l),d=Bv(u),f=a===e,h=Zr*s,m=kh(a,t.chroma)*s-h/2+i;return c.jsxs("div",{className:`absolute flex justify-center items-center ${f?"text-3xl font-semibold":"text-2xl"}`,style:{top:m,height:h,width:"100%",fontSize:`${s*(f?24:16)}px`,lineHeight:`${h}px`,color:f?r?It.zinc[50]:It.white:r?It.zinc[400]:It.zinc[600]},onMouseOver:()=>n(a),children:[d,c.jsx("sup",{className:"italic text-xs",style:{fontSize:`${s*12}px`,color:f?r?It.zinc[200]:It.zinc[100]:It.zinc[500]},children:a})]},`ruler pitch ${a}`)}),[n,e,t,i,s,r]);return c.jsx("div",{className:"absolute left-0 top-0 shadow-md backdrop-blur-sm border-r",style:{width:70,height:"100%",backgroundColor:r?"rgba(39, 39, 42, 0.85)":"rgba(244, 244, 245, 0.85)",borderRightColor:r?It.zinc[600]:It.zinc[300]},children:o})},pf=3,pc=10,Ipe=({recordingNote:t,bloobId:e})=>{const{getBloobById:n,getSongById:r}=mn(),i=n(e),s=r(i.songId),o=xi,a=Zr/2,l=Math.PI/2-t.velocity/Vu*2*Math.PI,u=xi-1,d=o+u*Math.cos(l),f=a-u*Math.sin(l),h=t.velocity>Math.floor(Vu/2)?1:0,{playheadPosition:m}=Dx(),y=x.useMemo(()=>{const w=t.durationInBeats||(m.bar-i.songPosition.bar)*s.timeSignature.beatsPerBar-t.startBeat,v=Zi(0,s.timeSignature.beatsPerBar,w);return Math.max(v,0)},[i.songPosition.bar,s.timeSignature.beatsPerBar,m,t.durationInBeats,t.startBeat]),g=x.useMemo(()=>{const{chroma:w}=Hh(t.pitch),v=p0(s.key.chroma,w),S=Bv(v),k=p_(`${s.key.chroma} ${s.key.quality}`).intervals[S-1],N=h_(v,k);switch(f_(N)){case-2:return It.purple[500];case-1:return It.blue[300];case 0:return It.zinc[50];case 1:return It.red[300];case 2:return It.orange[500];default:return ar(`Recording note (${t.pitch} in the key of ${s.key.chroma} ${s.key.quality}) is an unexpectedly wide distance from the scale`),It.yellow[800]}},[s,t]);return c.jsxs("svg",{style:{width:y+xi,height:Zr},className:"overflow-visible","data-pitch":t.pitch,children:[c.jsx("rect",{x:xi,y:Zr/2-pc/2-pf,width:y+pf,height:pc+2*pf,rx:(pc+pf)/2,ry:(pc+pf)/2,fill:It.red[500]}),c.jsx("circle",{r:xi+pf,cx:o,cy:a,fill:It.red[500]}),c.jsx("rect",{x:xi,y:Zr/2-pc/2,width:y,height:pc,rx:pc/2,ry:pc/2,fill:g}),c.jsx("circle",{r:xi,cx:o,cy:a,fill:g}),t.velocity===Vu?c.jsx("circle",{r:u,cx:o,cy:a,stroke:It.zinc[800],strokeWidth:2,fill:It.zinc[600],opacity:"30%"}):c.jsx("path",{d:`M ${o},${a} 924 L ${o},${a-u} 925 A ${u},${u} 0 ${h}, 1 ${d},${f} 926 L ${o},${a}`,stroke:It.zinc[800],strokeWidth:2,strokeLinecap:"round",fill:It.zinc[600],opacity:"30%"})]})},JL=x.createContext(null),rN=()=>{const t=x.useContext(JL);if(!t)throw new Error("useRealtimePlayer must be used within a RealtimePlayerContext");return t},mc=10,mf=3,jpe=20,Tpe=({noteId:t,isOptionPressed:e,isBeingPlayed:n})=>{const{doesNoteExist:r}=mn();return r(t)?c.jsx(zpe,{noteId:t,isOptionPressed:e,isBeingPlayed:n}):null},zpe=({noteId:t,isOptionPressed:e,isBeingPlayed:n})=>{const r=lD(t),i=qc(r.bloobId),s=wd(i.songId),o=Vr(`song:${i.songId}`),{playNote:a}=rN();es();const{updateNoteDetails:l}=Gn(),{getNoteById:u,noteDetails:d}=mn(),{commitToStore:f}=Ln(),{hasCmdModifier:h}=Wl(),{isNoteSelected:m}=Ho(),{deselectNotes:y,deselectAllNotes:g,selectNotes:w}=Xs(),v=x.useRef(!1),S=d[r.noteDetailsHash],C=x.useMemo(()=>S?Zi(0,s.timeSignature.beatsPerBar,S.durationInBeats):0,[S,s.timeSignature.beatsPerBar]),k=x.useMemo(()=>
926{if(!S)return It.zinc[500];const{chroma:U}=Hh(S.pitch),A=p0(s.key.chroma,U),W=Bv(A),B=p_(`${s.key.chroma} ${s.key.quality}`).intervals[W-1],L=h_(A,B);switch(f_(L)){case-2:return It.purple[500];case-1:return It.blue[300];case 0:return It.zinc[50];case 1:return It.red[300];case 2:return It.orange[500];default:return ar(`Note ${r.id} (${S.pitch} in the key of ${s.key.chroma} ${s.key.quality}) is an unexpectedly wide distance from the scale`),It.yellow[800]}},[r,S,s]),N=x.useMemo(()=>S?i.bars*s.timeSignature.beatsPerBar-S.startBeat:0,[i.bars,S,s.timeSignature.beatsPerBar]),_=x.useCallback(U=>{if(!S)return;h(U)?m(r.id)?y([r.id]):w([r.id]):(g(),w([r.id]));const A=Oo(S.pitch);ln(i)&&a(A,S.velocity,i.instrument),U.stopPropagation()},[S,g,y,h,m,r.id,w,i,a]),j=vr(({first:U,last:A,delta:W})=>{if(!o||U)return;if(A){f();return}const B=W[0]/va,L=u(t),$=d[L.noteDetailsHash];if(!$)return;const q=Math.min(Math.max($.durationInBeats+B,0),N);l(t,{newDurationInBeats:q})},{axis:"x",filterTaps:!0,preventDefault:!0}),T=vr(({first:U,last:A,delta:W})=>{if(!o)return;if(U){v.current=e;return}else if(A){v.current&&f();return}if(!v.current)return;const D=W[1],B=-Math.round(D/2),L=u(t),$=d[L.noteDetailsHash];if(!$)return;const q=Math.min(Math.max($.velocity+B,0),Vu);l(t,{newVelocity:q})},{axis:"y",filterTaps:!0,preventDefault:!0});if(!S)return null;const M=xi,V=Zr/2,H=Math.PI/2-S.velocity/Vu*2*Math.PI,P=xi-1,F=M+P*Math.cos(H),I=V-P*Math.sin(H),R=S.velocity>Math.floor(Vu/2)?1:0;return c.jsxs("svg",{style:{width:C+xi,height:Zr},className:"overflow-visible",onClick:_,"data-pitch":S.pitch,children:[(m(r.id)||n)&&c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:xi,y:Zr/2-mc/2-mf,width:C+mf,height:mc+2*mf,rx:(mc+mf)/2,ry:(mc+mf)/2,fill:n?It.purple[500]:It.blue[500]}),c.jsx("circle",{r:xi+mf,cx:M,cy:V,fill:n?It.purple[500]:It.blue[500]})]}),c.jsx("rect",{x:xi,y:Zr/2-mc/2,width:C,height:mc,rx:mc/2,ry:mc/2,fill:k}),c.jsx("circle",{r:xi,cx:M,cy:V,fill:k}),S.velocity===Vu?c.jsx("circle",{className:"cursor-auto",r:P,cx:M,cy:V,stroke:It.zinc[800],strokeWidth:2,fill:It.zinc[600],opacity:"30%"}):c.jsx("path",{d:`M ${M},${V} 927 L ${M},${V-P} 928 A ${P},${P} 0 ${R}, 1 ${F},${I} 929 L ${M},${V}`,stroke:It.zinc[800],strokeWidth:2,strokeLinecap:"round",fill:It.zinc[600],opacity:"30%"}),c.jsx("circle",{className:`absolute ${o&&e?"cursor-ns-resize":""} fill-transparent touch-none`,r:xi,cx:M,cy:V,...T()}),c.jsx("rect",{className:`absolute ${o?"cursor-ew-resize":""} fill-transparent touch-none`,x:C,y:Zr/2-xi,width:jpe,height:xi*2,...j()})]})},Ppe=({shouldStack:t=!1,bgClassName:e})=>{const{dragMode:n}=Yn(),{setDragMode:r}=cr();return c.jsxs("div",{className:`${e} flex ${t?"flex-col":"justify-between"} items-center gap-4 py-2 px-3`,children:[c.jsx("button",{onClick:()=>r(Hs.MOVE),children:c.jsx(ev,{className:`size-5 ${n===Hs.MOVE?"text-zinc-900 dark:text-zinc-100":"text-zinc-400 dark:text-zinc-400"}`})}),c.jsx("button",{onClick:()=>r(Hs.SELECT),children:c.jsx(ED,{className:`size-5 ${n===Hs.SELECT?"text-zinc-900 dark:text-zinc-100":"text-zinc-400 dark:text-zinc-400"}`})})]})},Ape=({children:t,bloobId:e,currentlyPlayingNoteIds:n,handleNoteDragStart:r,handleNoteDrag:i,handleNoteDragStop:s,onGridDoubleClick:o,handlePianoRollMouseMove:a,handlePianoRollMouseLeave:l,onGridClick:u,isOptionPressed:d,dragMode:f})=>{const{isMobile:h}=Hn(),{isPlaying:m}=zs(),{generalSettings:y}=bi(),g=x.useRef(null);x.useEffect(()=>{var q;(q=g.current)==null||q.focus()},[g]);const w=qc(e),v=cD(e),{getSongById:S,noteDetails:C}=mn(),k=Vr(`song:${w.songId}`),{recordingNotes:N}=Lo(),_=S(w.songId),{selectedNoteIds:j}=Ho(),T=w.loopContentBars??w.bars,M=Xh(T,_.timeSignature.beatsPerBar),V=x.useMemo(()=>{let q;v.length===0?q=_.key.chroma+"4":q=KJ(v,C);const{chroma:Z,octave:ie}=Hh(q),ge=`${Z}${ie+1}`;return kh(ge,_.key.chroma)},[v,C,_.key.chroma]),H=x.useCallback(q=>{const Z=C[q.noteDetailsHash];return Z?{type:"Note",id:`Note-${q.id}`,position:{x:Zi(0,_.timeSignature.beatsPerBar,Z.startBeat)-xi,y:kh(Z.pitch,_.key.chroma)-Zr/2},measured:{width:Zi(0,_.timeSignature.beatsPerBar,Z.durationInBeats||T*_.timeSignature.beatsPerBar-Z.startBeat)+xi,height:Zr},data:{noteId:q.id,isOptionPressed:d,isBeingPlayed:n.has(q.id)}}:{type:"Note",id:`Note-${q.id}`,position:{x:0,y:0},measured:{width:0,height:Zr},data:{noteId:q.id,isOptionPressed:d,isBeingPlayed:n.has(q.id)}}},[T,n,d,_.key.chroma,_.timeSignature.beatsPerBar,C]),P=x.useCallback(q=>{const Z={...q,id:-1},ie=H(Z),ge=C[q.noteDetailsHash];return ge?ie.id=`recording-${q.noteDetailsHash}:${q.inputName}:${ge.pitchInt}:${ge.startBeat}:${ge.durationInBeats}:${ge.velocity}`:ie.id=`recording-${q.inputName}:${q.noteDetailsHash}`,ie.type="Recording Note",ie.data.recordingNote=q,ie},[H,C]),F=x.useMemo(()=>{const q=v.filter(ie=>ie&&ie.id!==void 0&&!j.has(ie.id)),Z=v.filter(ie=>ie&&ie.id!==void 0&&j.has(ie.id));return[...q.map(ie=>H(ie)),...Z.map(ie=>H(ie)),...N.filter(ie=>ie).map(ie=>P(ie))]},[v,N,j,H,P]),I=x.useMemo(()=>({Note:q=>c.jsx(Tpe,{noteId:q.data.noteId,isOptionPressed:q.data.isOptionPressed,isBeingPlayed:q.data.isBeingPlayed}),"Recording Note":q=>c.jsx(Ipe,{recordingNote:q.data.recordingNote,bloobId:e})}),[e]),R=x.useCallback(()=>{u()},[u]),U=x.useCallback(q=>{o(q)},[o]),A=x.useCallback((q,Z)=>{r(q,Z.data.noteId,Z.position)},[r]),W=x.useCallback((q,Z,ie)=>{const re=ie[0].position;i(re)},[i]),D=x.useCallback(()=>{s()},[s]),B=x.useCallback(q=>{a(q)},[a]),L=x.useCallback(()=>
929{l()},[l]),$=x.useMemo(()=>y.scrollPianorollDuringPlayback&&m?ba.Vertical:ba.Free,[y.scrollPianorollDuringPlayback,m]);return c.jsxs(c.Fragment,{children:[c.jsxs(z_,{nodes:F,nodeTypes:I,nodesFocusable:!1,nodesDraggable:k,panOnDrag:h&&f===Hs.MOVE,panOnScroll:!0,panOnScrollMode:$,zoomOnScroll:!1,zoomOnDoubleClick:!1,zoomOnPinch:!0,zoomActivationKeyCode:"asdfasdf",proOptions:{hideAttribution:!0},className:"bg-zinc-900/60 backdrop-blur-sm",translateExtent:[[-90,0],[M,eE]],defaultViewport:{x:tE,y:-1*V,zoom:1},onClick:R,onDoubleClick:U,onNodeDragStart:A,onNodeDrag:W,onNodeDragStop:D,onMouseMove:B,onMouseLeave:L,tabIndex:0,children:[c.jsx(Spe,{bars:T,beatsPerBar:_.timeSignature.beatsPerBar,songKey:_.key}),t]}),h&&c.jsx("div",{className:"absolute top-8 left-20 z-50",children:c.jsx(Ppe,{bgClassName:"bg-glass border-glass rounded-full",shouldStack:!1})}),c.jsx(ZL,{bars:T,beatsPerBar:_.timeSignature.beatsPerBar,barOffset:w.songPosition.bar,songId:w.songId}),c.jsx(Npe,{songKey:_.key})]})},eF=()=>{const{screenToFlowPosition:t,flowToScreenPosition:e,setViewport:n,getViewport:r}=k0(),i=x.useCallback(l=>t(l,{snapToGrid:!1}),[t]),s=x.useCallback(l=>e(l),[e]),o=x.useCallback(()=>r(),[r]),a=x.useCallback(l=>{const u={...l,zoom:r().zoom};n(u)},[r,n]);return{clientToPianoRollPosition:i,pianoRollToClientPosition:s,getPianoRollPosition:o,setPianoRollPosition:a}},CM=3,Mpe=200,tF=({bloob:t,beatsPerBar:e,clientWidth:n})=>{const{xOffset:r,zoom:i}=q0(),{getPianoRollPosition:s,setPianoRollPosition:o}=eF(),{playheadPosition:a}=Dx(),{isRecording:l}=Lo(),{isPlaying:u}=zs(),{timelineCursorBar:d,timelineCursorSongId:f}=Yn(),{getSongById:h}=mn(),{generalSettings:m}=bi(),y=x.useMemo(()=>{const C=h(t.songId),k=t.loopContentBars??t.bars;return Xh(k,C.timeSignature.beatsPerBar)},[t.loopContentBars,t.bars,t.songId,h]),g=u&&(a==null?void 0:a.songId)===t.songId?a.bar:f===t.songId?d:null,w=u&&(a==null?void 0:a.songId)===t.songId;if(x.useEffect(()=>{if(!w||!a||!m.scrollPianorollDuringPlayback||(y+tE)*i<=n)return;const C=-90*i,k=y-n,_=((a.bar-t.songPosition.bar)*va*e-Mpe)*i,j=Math.max(C,Math.min(_,k*i)),T=s().y;o({x:-1*j,y:T})},[w,e,t.songPosition.bar,s,a,o,m.scrollPianorollDuringPlayback,i,n,y]),g==null)return null;const v=g-t.songPosition.bar;if(v<0||v>t.bars)return null;const S=(v*va*e-CM/2)*i+r;return c.jsx("div",{id:"bloob-details-playhead",className:`absolute ${l?"bg-red-500":"bg-zinc-500 dark:bg-white"}`,style:{left:S,top:0,width:CM*i,height:"100%",zIndex:1e3},"data-testid":"bloob-details-playhead"})};function FC(){return FC=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},FC.apply(null,arguments)}var nF=["shift","alt","meta","mod","ctrl"],Bpe={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function zc(t){return(t&&Bpe[t]||t||"").trim().toLowerCase().replace(/key|digit|numpad|arrow/,"")}function Rpe(t){return nF.includes(t)}function Qk(t,e){return e===void 0&&(e=","),t.split(e)}function Zk(t,e,n){e===void 0&&(e="+");var r=t.toLocaleLowerCase().split(e).map(function(o){return zc(o)}),i={alt:r.includes("alt"),ctrl:r.includes("ctrl")||r.includes("control"),shift:r.includes("shift"),meta:r.includes("meta"),mod:r.includes("mod")},s=r.filter(function(o){return!nF.includes(o)});return FC({},i,{keys:s,description:n,hotkey:t})}(function(){typeof document<"u"&&(document.addEventListener("keydown",function(t){t.key!==void 0&&rF([zc(t.key),zc(t.code)])}),document.addEventListener("keyup",function(t){t.key!==void 0&&iF([zc(t.key),zc(t.code)])})),typeof window<"u"&&window.addEventListener("blur",function(){Pc.clear()})})();var Pc=new Set;function iN(t){return Array.isArray(t)}function Ope(t,e){e===void 0&&(e=",");var n=iN(t)?t:t.split(e);return n.every(function(r){return Pc.has(r.trim().toLowerCase())})}function rF(t){var e=Array.isArray(t)?t:[t];
929Pc.has("meta")&&Pc.forEach(function(n){return!Rpe(n)&&Pc.delete(n.toLowerCase())}),e.forEach(function(n){return Pc.add(n.toLowerCase())})}function iF(t){var e=Array.isArray(t)?t:[t];t==="meta"?Pc.clear():e.forEach(function(n){return Pc.delete(n.toLowerCase())})}function Dpe(t,e,n){(typeof n=="function"&&n(t,e)||n===!0)&&t.preventDefault()}function Lpe(t,e,n){return typeof n=="function"?n(t,e):n===!0||n===void 0}function Fpe(t){return sF(t,["input","textarea","select"])}function sF(t,e){e===void 0&&(e=!1);var n=t.target,r=t.composed,i=null;return $pe(n)&&r?i=t.composedPath()[0]&&t.composedPath()[0].tagName:i=n&&n.tagName,iN(e)?!!(i&&e&&e.some(function(s){var o;return s.toLowerCase()===((o=i)==null?void 0:o.toLowerCase())})):!!(i&&e&&e)}function $pe(t){return!!t.tagName&&!t.tagName.startsWith("-")&&t.tagName.includes("-")}function Upe(t,e){return t.length===0&&e?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):e?t.some(function(n){return e.includes(n)})||t.includes("*"):!0}var Vpe=function(e,n,r){r===void 0&&(r=!1);var i=n.alt,s=n.meta,o=n.mod,a=n.shift,l=n.ctrl,u=n.keys,d=e.key,f=e.code,h=e.ctrlKey,m=e.metaKey,y=e.shiftKey,g=e.altKey,w=zc(f),v=d.toLowerCase();if(!(u!=null&&u.includes(w))&&!(u!=null&&u.includes(v))&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(w))return!1;if(!r){if(i===!g&&v!=="alt"||a===!y&&v!=="shift")return!1;if(o){if(!m&&!h)return!1}else if(s===!m&&v!=="meta"&&v!=="os"||l===!h&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&(u.includes(v)||u.includes(w))?!0:u?Ope(u):!u},Hpe=x.createContext(void 0),Gpe=function(){return x.useContext(Hpe)};function oF(t,e){return t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(t).length===Object.keys(e).length&&Object.keys(t).reduce(function(n,r){return n&&oF(t[r],e[r])},!0):t===e}var Wpe=x.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),qpe=function(){return x.useContext(Wpe)};function Kpe(t){var e=x.useRef(void 0);return oF(e.current,t)||(e.current=t),e.current}var _M=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ype=typeof window<"u"?x.useLayoutEffect:x.useEffect;function EM(t,e,n,r){var i=x.useState(null),s=i[0],o=i[1],a=x.useRef(!1),l=n instanceof Array?r instanceof Array?void 0:r:n,u=iN(t)?t.join(l==null?void 0:l.splitKey):t,d=n instanceof Array?n:r instanceof Array?r:void 0,f=x.useCallback(e,d??[]),h=x.useRef(f);d?h.current=f:h.current=e;var m=Kpe(l),y=qpe(),g=y.enabledScopes,w=Gpe();return Ype(function(){if(!((m==null?void 0:m.enabled)===!1||!Upe(g,m==null?void 0:m.scopes))){var v=function(_,j){var T;if(j===void 0&&(j=!1),!(Fpe(_)&&!sF(_,m==null?void 0:m.enableOnFormTags))){if(s!==null){var M=s.getRootNode();if((M instanceof Document||M instanceof ShadowRoot)&&M.activeElement!==s&&!s.contains(M.activeElement)){_M(_);return}}(T=_.target)!=null&&T.isContentEditable&&!(m!=null&&m.enableOnContentEditable)||Qk(u,m==null?void 0:m.splitKey).forEach(function(V){var H,P=Zk(V,m==null?void 0:m.combinationKey);if(Vpe(_,P,m==null?void 0:m.ignoreModifiers)||(H=P.keys)!=null&&H.includes("*")){if(m!=null&&m.ignoreEventWhen!=null&&m.ignoreEventWhen(_)||j&&a.current)return;if(Dpe(_,P,m==null?void 0:m.preventDefault),!Lpe(_,P,m==null?void 0:m.enabled)){_M(_);return}h.current(_,P),j||(a.current=!0)}})}},S=function(_){_.key!==void 0&&(rF(zc(_.code)),((m==null?void 0:m.keydown)===void 0&&(m==null?void 0:m.keyup)!==!0||m!=null&&m.keydown)&&v(_))},C=function(_){_.key!==void 0&&(iF(zc(_.code)),a.current=!1,m!=null&&m.keyup&&v(_,!0))},k=s||(l==null?void 0:l.document)||document;return k.addEventListener("keyup",C),k.addEventListener("keydown",S),w&&Qk(u,m==null?void 0:m.splitKey).forEach(function(N){return w.addHotkey(Zk(N,m==null?void 0:m.combinationKey,m==null?void 0:m.description))}),function(){k.removeEventListener("keyup",C),k.removeEventListener("keydown",S),w&&Qk(u,m==null?void 0:m.splitKey).forEac
929h(function(N){return w.removeHotkey(Zk(N,m==null?void 0:m.combinationKey,m==null?void 0:m.description))})}}},[s,u,m,g]),o}const aF=({bloobId:t,bloobDetailsWrapperRef:e})=>{const{getSongById:n,getBloobById:r,getNoteById:i,getNotesInBloob:s,noteDetails:o,getNoteIdsInRect:a}=mn(),{deleteNotes:l,updateNoteDetails:u,addNotes:d,copyNotes:f}=Gn(),{undo:h,redo:m,commitToStore:y}=Ln(),{playNote:g}=rN(),{hasCmdModifier:w}=Wl(),v=r(t),S=s(t),C=n(v.songId),k=Vr(`song:${v.songId}`),N=v.loopContentBars??v.bars,_=x.useRef(null),j=x.useRef(null),T=x.useRef(null),M=wh*E0*Zr/(wh*12),{focusCanvas:V}=di(),{selectedNoteIds:H}=Ho(),{selectNotes:P,deselectAllNotes:F,highlightPitch:I,unhighlightPitch:R,closeBloobDetails:U}=Xs(),{togglePlayStop:A,currentlyPlayingNotes:W}=zs(),{clientToPianoRollPosition:D}=eF(),B=x.useRef(null),[L,$]=x.useState(0),{dragMode:q}=Yn(),{isMobile:Z}=Hn();x.useEffect(()=>{const se=B.current;se&&(se.focus(),$(se.clientWidth))},[B]);const ie=x.useCallback(se=>{const ye={x:se.clientX,y:se.clientY},ke=D(ye),ze=Zr*Math.round(ke.y/Zr),qe=pz(ze,C.key);I(qe)},[D,I,C.key]),ge=x.useCallback(()=>{R()},[R]),re=x.useMemo(()=>W[t]||new Set,[t,W]),Y=x.useCallback(()=>{F()},[F]),ne=x.useCallback(se=>{if(!k)return;const ye=D({x:se.clientX,y:se.clientY});if(ye.x<0||ye.x>Xh(N,C.timeSignature.beatsPerBar)||ye.y<0||ye.y>eE)return;const ke=Zr*Math.round(ye.y/Zr),ze=pz(ke,C.key),qe=Math.round(ye.x/va)*va,ot=qJ(qe);if(ot>=N*C.timeSignature.beatsPerBar)return;const _t=d(t,[{pitch:ze,velocity:100,startBeat:ot,durationInBeats:1}
929]);y(),P(_t);const tt=Oo(ze);g(tt,100,v.instrument,v.volume)},[k,d,N,v.instrument,v.volume,t,D,y,C.key,C.timeSignature.beatsPerBar,g,P]),be=x.useCallback((se,ye,ke)=>{if(!k||isNaN(ke.x)||isNaN(ke.y))return;let ze=Array.from(H);H.has(ye)||(P([ye],!1),ze=[ye]),se.altKey&&f(ze),_.current=ke.x,j.current=ke.y;const qe=new Map;H.forEach(ot=>{const Ze=i(ot),_t=Ze?o[Ze.noteDetailsHash]:void 0;_t&&typeof _t.pitchInt=="number"&&qe.set(ot,_t.pitchInt)}),T.current=qe},[k,f,P,H,i,o]),we=x.useCallback(se=>{const ye=_.current,ke=j.current;if(isNaN(se.x)||isNaN(se.y)||ye===null||isNaN(ye)||ke===null||isNaN(ke))return;const ze=se.x-ye,qe=se.y-ke,ot=Math.round(-qe/M);H.forEach(Ze=>{var rn;const _t=i(Ze),tt=_t?o[_t.noteDetailsHash]:void 0;if(!tt||typeof tt.startBeat!="number"||isNaN(tt.startBeat))return;const gt=(rn=T.current)==null?void 0:rn.get(Ze);if(gt===void 0)return;const dt=N*C.timeSignature.beatsPerBar-tt.durationInBeats,wt=Math.min(Math.max(tt.startBeat+ze/va,0),dt),Dt=gt+ot;if(Dt<0||Dt>127)return;const Kt=Km(Dt);Kt&&(isNaN(wt)||u(Ze,{newStartBeat:wt,newPitch:Kt}))}),_.current=se.x},[N,i,o,C.timeSignature.beatsPerBar,H,u,M]),te=x.useCallback(()=>{y(),_.current=null,j.current=null,T.current=null},[y]),fe=x.useCallback(()=>{const se=S.map(ye=>ye.id);se.length>0&&P(se,!1)},[S,P]),O=x.useCallback(()=>{k&&H.size!==0&&(l(Array.from(H),t),F(),y(),Ji.event({category:qs.USER_ACTIONS,action:Jt.DELET
929E_DETAILS_NOTE,label:bo.MANUAL_BLOOB_ACTS}))},[k,t,y,l,F,H]),pe=x.useCallback(()=>{A()},[A]),he=x.useCallback(()=>{k&&A(!0)},[k,A]),le=x.useCallback(se=>{if(w(se))if(se.shiftKey)m();else{const ye=new Set(s(t).map(ke=>ke.id));h(),setTimeout(()=>{const ze=s(t).filter(qe=>!ye.has(qe.id)).map(qe=>qe.id);ze.length>0?P(ze,!1):F()},0)}},[w,m,h,P,s,t,F]),oe=x.useCallback(se=>{if(!k)return;let ye;if(H.forEach(ke=>{const ze=S.find(Ze=>Ze.id===ke);if(!ze)return;const qe=o[ze.noteDetailsHash];if(!qe)return;let ot;w(se)?ot=mz(qe.pitch,C.key,!0):ot=Zy(qe.pitch,C.key,!0),u(ke,{newPitch:ot}),ye=ot}),y(),H.size===1){const ke=Oo(ye);g(ke,100,v.instrument,v.volume)}},[k,v.instrument,v.volume,y,w,S,C.key,g,H,o,u]),Q=x.useCallback(()=>{if(!k||H.size===0)return;const se=N*C.timeSignature.beatsPerBar;let ye=!1;S.forEach(ke=>{if(!H.has(ke.id))return;const ze=o[ke.noteDetailsHash];ze&&ze.startBeat>=se&&(ye=!0)}),!ye&&(H.forEach(ke=>{const ze=S.find(Ze=>Ze.id===ke);if(!ze)return;const qe=o[ze.noteDetailsHash];if(!qe)return;const ot=Math.floor(qe.startBeat+1);u(ke,{newStartBeat:ot})}),y())},[k,N,y,S,o,C.timeSignature.beatsPerBar,H,u]),de=x.useCallback(se=>{if(!k)return;let ye;if(H.forEach(ke=>{const ze=S.find(Ze=>Ze.id===ke);if(!ze)return;const qe=o[ze.noteDetailsHash];if(!qe)return;let ot;w(se)?ot=mz(qe.pitch,C.key,!1):ot=Zy(qe.pitch,C.key,!1),u(ke,{newPitch:ot}),ye=ot}),y(),H.size===1){const ke=Oo(ye);g(ke,100,v.instrument,v.volume)}},[k,v.instrument,v.volume,y,w,S,o,C.key,g,H,u]),Ne=x.useCallback(()=>{if(!k||H.size===0)return;let se=!1;S.forEach(ye=>{if(!H.has(ye.id))return;const ke=o[ye.noteDetailsHash];ke&&ke.startBeat<=0&&(se=!0)}),!se&&(H.forEach(ye=>{const ke=S.find(ot=>ot.id===ye);if(!ke)return;const ze=o[ke.noteDetailsHash];if(!ze)return;const qe=Math.ceil(ze.startBeat-1);u(ye,{newStartBeat:qe})}),y())},[k,y,S,o,H,u]),Ce=()=>{var ze,qe,ot,Ze,_t,tt,gt,dt;const se=document.activeElement;if(!se)return!1;if(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.getAttribute("contenteditable")==="true"){const wt=se.disabled,Dt=se.readOnly;if(!wt&&!Dt)return!0}if(se.id==="cai-chat-input"||se.id==="prompt"||(ze=se.id)!=null&&ze.includes("instrument-selector-search")||(qe=se.id)!=null&&qe.includes("instrument-selector-generation")||(ot=se.id)!=null&&ot.includes("custom-instrument-selector-input")||(Ze=se.id)!=null&&Ze.includes("bloob-label")||(_t=se.id)!=null&&_t.includes("song-label")||(tt=se.id)!=null&&tt.includes("song-key")||(gt=se.id)!=null&>.includes("volume-input")||(dt=se.id)!=null&&dt.includes("bpm-input"))return!0;const ye=document.querySelectorAll('[style*="z-index: 5"]');for(const wt of ye)if(wt.contains(se))return!0;const ke=document.querySelector('[data-testid="modal-dialog"]');return!!(ke&&ke.contains(se)&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.getAttribute("contenteditable")==="true"))},Ae=x.useCallback(se=>{if(!Ce())switch(se.key){case"Backspace":O();break;case" ":pe();break;case"r":he();break;case"z":le(se);break;case"a":w(se)&&(se.preventDefault(),fe());break;case"d":case"D":if(w(se))break;se.preventDefault(),F(),U(),V();break}},[O,fe,he,pe,le,w,F,U,V]);x.useEffect(()=>{const se=e.current;return se==null||se.addEventListener("keydown",Ae),()=>{se==null||se.removeEventListener("keydown",Ae)}},[e,Ae]),x.useEffect(()=>{if(H.size===0)return;const se=ye=>{if(!(ye.key!=="ArrowUp"&&ye.key!=="ArrowDown"&&ye.key!=="ArrowLeft"&&ye.key!=="ArrowRight")&&!Ce())switch(ye.preventDefault(),ye.stopImmediatePropagation(),ye.key){case"ArrowUp":oe(ye);break;case"ArrowRight":Q();break;case"ArrowDown":de(ye);break;case"ArrowLeft":Ne();break}};return window.addEventListener("keydown",se,!0),()=>{window.removeEventListener("keydown",se,!0)}},[H,oe,Q,de,Ne]);const[Ue,Se]=x.useState(!1);EM("alt",()=>Se(!0),{keydown:!0}),EM("alt",()=>Se(!1),{keyup:!0});const ve=x.useRef(null),[je,Te]=x.useState(null),ce=x.useRef(new Set);return vr(({event:se,first:ye,last:ke,xy:ze})=>{var Ze;if(!((Ze=se.target.classList)!=null&&Ze.contains("react-flow__pane")))return;const qe={x:ze[0],y:ze[1]},ot=D(qe);if(ye)ve.current=ot,ce.current=new Set(H);else if(ke)Te(null),ve.current=null;else{const _t=Math.min(ot.x,ve.current.x),tt=Math.min(ot.y,ve.current.y),gt=Math.abs(ot.x-ve.current.x),dt=Math.abs(ot.y-ve.current.y),wt={pianoRollPosition:{x:_t,y:tt},width:gt,height:dt};Te(wt);const Dt=a(t,wt);P(Dt,!1),Dt.forEach(Kt=>{if(!ce.current.has(Kt)){const rn=i(Kt),pn=rn?o[rn.noteDetailsHash]:void 0;pn&&g(pn.pitchInt,pn.velocity,v.instrument,v.volume),ce.current.add(Kt)}}
929),ce.current=new Set(Dt)}},{filterTaps:!0,target:B.current,touch:!0,delay:50,enabled:!Z||q===Hs.SELECT}),c.jsxs("div",{ref:B,tabIndex:-1,className:"relative w-full h-full overflow-hidden touch-none",children:[c.jsx(Ape,{bloobId:t,currentlyPlayingNoteIds:re,handleNoteDragStart:be,handleNoteDrag:we,handleNoteDragStop:te,onGridClick:Y,onGridDoubleClick:ne,handlePianoRollMouseMove:ie,handlePianoRollMouseLeave:ge,isOptionPressed:Ue,dragMode:q,children:c.jsx(tF,{bloob:v,beatsPerBar:C.timeSignature.beatsPerBar,clientWidth:L})}),c.jsx(QL,{rect:je})]})},Bb=1.25,NM=.5,$C=600,Xpe=200,Qpe=4e3,Zpe=2;function Jpe(t){let i="";t.forEach((s,o)=>{const a=o/t.length*100,l=50-s*50*.92;o===0?i+=`M ${a},50 L ${a},${l}`:i+=` L ${a},${l}`});for(let s=t.length-1;s>=0;s--){const o=s/t.length*100,a=50+t[s]*50*.92;i+=` L ${o},${a}`}return i+=" Z",i}const eme=({bars:t,beatsPerBar:e,audioFileId:n,audioClipStartInSeconds:r,clipDurationInSeconds:i})=>{const{isDarkMode:s}=Pn(),{xOffset:o,yOffset:a,zoom:l}=q0(),{getAudioFileData:u,isAudioFileAvailable:d,getAudioFileById:f}=mn(),[h,m]=x.useState(null),[y,g]=x.useState(l),w=x.useRef(null);x.useEffect(()=>(w.current=setTimeout(()=>g(l),80),()=>{w.current&&clearTimeout(w.current)}),[l]),x.useEffect(()=>{let P=!1,F=null;const I=async()=>{try{if(!await d(n)||P)return;const U=await u(n);if(P)return;m(U),F&&(clearInterval(F),F=null)}catch{}};return I(),F=setInterval(()=>void I(),500),()=>{P=!0,F&&clearInterval(F)}},[n,u,d]);const v=x.useMemo(()=>Xh(t,e),[t,e]),S=v*y,C=x.useMemo(()=>Math.max(Xpe,Math.min(Qpe,Math.round(S*Zpe))),[S]),k=x.useMemo(()=>{if(!h||h.length===0)return null;const P=f(n),F=(P==null?void 0:P.sampleRate)??44100,I=h[0].length,R=Math.min(I,Math.round(r*F)),U=i!=null?Math.min(I,R+Math.round(i*F)):I;if(R>=U)return null;const A=h.map(W=>W.subarray(R,U));return $y(A,C)},[h,n,r,i,C,f]),N=x.useMemo(()=>k!=null&&k.length?Jpe(k):null,[k]),_=x.useMemo(()=>Array.from({length:t},(P,F)=>c.jsx("rect",{x:Zi(F,e,0),y:"0",width:e*va,height:"100%",fill:F%2===0?s?It.zinc[800]:It.zinc[100]:s?It.zinc[700]:It.zinc[50],fillOpacity:F%2===0?.6:.4},`bar-${F}`)),[t,e,s]),j=x.useMemo(()=>Array.from({length:t},(P,F)=>Array.from({length:e},(I,R)=>c.jsx("rect",{x:Zi(F,e,R)-Bb/2,y:"0",width:Bb,height:"100%",fill:s?It.zinc[500]:It.zinc[700],fillOpacity:R===0?.42:.2},`beat-${F}.${R}`))),[t,e,s]),T=x.useMemo(()=>{const P=[.125,.25,.375,.5,.625,.75,.875];return Array.from({length:t},(F,I)=>Array.from({length:e},(R,U)=>P.map(A=>{const W=A===.5,D=A===.25||A===.75;let B=.09;return W?B=.28:D&&(B=.16),c.jsx("rect",{x:Zi(I,e,U+A)-NM/2,y:"0",width:NM,height:"100%",fill:It.zinc[600],fillOpacity:B},`sub-${I}.${U}.${A}`)})))},[t,e,s]),M=x.useMemo(()=>c.jsx("rect",{x:Zi(t,e,0)-Bb/2,y:"0",width:Bb,height:"100%",fill:s?It.zinc[500]:It.zinc[700],fillOpacity:.42}),[t,e,s]),V=o,H=v*l;return c.jsxs(c.Fragment,{children:[c.jsxs("svg",{className:"absolute top-0 left-0 overflow-visible",style:{width:v,height:$C,transform:`translate(${o}px, ${a}px) scale(${l})`,transformOrigin:"0 0"},children:[_,T,j,M]}),c.jsxs("svg",{className:"absolute top-0 pointer-events-none",style:{left:V,width:H,height:"100%"},viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[c.jsx("line",{x1:"0",y1:"50",x2:"100",y2:"50",stroke:s?It.zinc[500]:It.zinc[400],strokeWidth:.3,strokeDasharray:"1,1",opacity:.5,vectorEffect:"non-scaling-stroke"}),N&&c.jsx(c.Fragment,{children:c.jsx("path",{d:N,fill:"rgba(134, 239, 172, 0.2)",stroke:"rgba(134, 239, 172, 0.85)",strokeWidth:.8,vectorEffect:"non-scaling-stroke"})})]})]})},lF=({bloobId:t,bloobDetailsWrapperRef:e})=>{const{getSongById:n,getBloobById:r}=mn(),{deselectAllNotes:i,closeBloobDetails:s}=Xs(),{togglePlayStop:o,isPlaying:a}=zs(),{focusCanvas:l}=di(),{generalSettings:u}=bi(),d=x.useRef(null),[f,h]=x.useState(0),m=r(t),y=n(m.songId),{beatsPerBar:g}=y.timeSignature,w=m.loopContentBars??m.bars,v=x.useMemo(()=>Xh(w,g),[w,g]),S=x.useMemo(()=>ua(w,y.timeSignature,y.bpm),[w,y.timeSignature,y.bpm]),C=x.useMemo(()=>$C/2-150,[]);x.useEffect(()=>{const j=d.current;j&&(j.focus(),h(j.clientWidth))},[]);const k=()=>{var T,M;const j=document.activeElement;if(!j)return!1;if(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.getAttribute("contenteditable")==="true"){const V=j.disabled,H=j.readOnly;if(!V&&!H)return!0}return!!(j.id==="cai-chat-input"||j.id==="prompt"||(T=j.id)!=null&&T.includes("volume-input")||(M=j.id)!=null&&M.includes("bpm-input"))},N=x.useCallback(j=>{if(!k())switch(j.key){case" ":j.preventDefault(),o();break;case"d":case"D":if(j.metaKey||j.ctrlKey)break;j.preventDefault(),i(),s(),l();break}},[o,i,s,l]);x.useEffect(()=>{const j=e.current;return j==null||j.addEventListener("keydown",N),()=>j==null?void 0:j.removeEventListener("keydown",N)},[e,N]);const _=x.useMemo(()=>u.scrollPianorollDuringPlayback&&a?ba.Vertical:ba.Free,[u.scrollPianorollDuringPlayback,a]);
929return c.jsxs("div",{ref:d,tabIndex:-1,className:"relative w-full h-full overflow-hidden touch-none",children:[c.jsxs(z_,{nodes:[],nodeTypes:{},nodesFocusable:!1,nodesDraggable:!1,panOnScroll:!0,panOnScrollMode:_,zoomOnScroll:!1,zoomOnDoubleClick:!1,zoomOnPinch:!0,zoomActivationKeyCode:"asdfasdf",proOptions:{hideAttribution:!0},className:"bg-zinc-900/60 backdrop-blur-sm",translateExtent:[[-90,0],[v,$C]],defaultViewport:{x:tE,y:-1*C,zoom:1},tabIndex:0,children:[c.jsx(eme,{bars:w,beatsPerBar:g,audioFileId:m.audioFileId,audioClipStartInSeconds:m.audioClipStartInSeconds??0,clipDurationInSeconds:S}),c.jsx(tF,{bloob:m,beatsPerBar:g,clientWidth:f})]}),c.jsx(ZL,{bars:w,beatsPerBar:g,barOffset:m.songPosition.bar,songId:m.songId})]})},l0=({onClose:t,wrapperClassName:e,iconClassName:n,rotate:r,size:i=24,ariaLabel:s="Close"})=>c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:t,className:`${e} text-zinc-900 dark:text-zinc-100 group`,"aria-label":s,children:c.jsx(nr,{size:i,className:`${n} ${r?"transition-transform duration-150 group-hover:rotate-90":""}`})}),tme=()=>{const{focusCanvas:t}=di(),{updateBloobDetails:e,deleteNotes:n,updateNoteDetails:r}=Gn(),{commitToStore:i}=Ln(),{detailsBloobId:s,selectedNoteIds:o}=Ho(),{deselectAllNotes:a,closeBloobDetails:l}=Xs(),{getNotesInBloob:u,getSongById:d,noteDetails:f}=mn(),h=Hn(),m=x.useRef(null),{isAwaitingAudioLoad:y,isPlaying:g,togglePlayStop:w}=zs(),{isRecording:v}=Lo(),S=x.useRef(null),{showMobileRecordDetails:C}=Br(),k=x.useRef(null),N=qc(s),_=u(s),j=d(N.songId),T=Vr(`song:${N.songId}`),M=x.useMemo(()=>N.label||`Bloob ${N.id}`,[N.label,N.id]),[V,H]=x.useState(!1),[P,F]=x.useState(M),I=x.useRef(null),R=x.useCallback(fe=>{T&&e(s,{volume:fe})},[T,s,e]),U=x.useCallback(()=>{a(),l(),t()},[a,l,t]),A=x.useCallback(fe=>{F(fe.target.value),fe.stopPropagation()},[]),W=x.useCallback(()=>{if(T){if(P.trim()===""){F(M),H(!1);return}e(s,{label:P.trim()}),i(),H(!1)}},[T,P,M,s,e,i]),D=x.useCallback(async()=>{if(y){g&&w();return}w()},[y,g,w]),B=x.useMemo(()=>y?"Loading... (click to cancel)":g?"Stop":"Play",[y,g]),L=x.useCallback(()=>{T&&w(!0)},[T,w]),$=x.useCallback(()=>{C()},[C]),{bind:q}=V0({onShortPress:L,onLongPress:$}),Z=x.useCallback(()=>{T&&(e(s,{muted:!N.muted}),i())},[T,s,N.muted,e,i]),ie=x.useCallback(()=>{T&&(e(s,{soloed:!N.soloed}),i())},[T,s,N.soloed,e,i]),ge=x.useCallback(()=>{T&&o.size!==0&&(n(Array.from(o),s),a(),i())},[T,o,n,s,a,i]),re=x.useCallback(()=>{T&&(o.forEach(fe=>{const O=_.find(le=>le.id===fe);if(!O)return;const pe=f[O.noteDetailsHash];if(!pe)return;const he=Zy(pe.pitch,j.key,!0);r(fe,{newPitch:he})}),i())},[T,o,_,f,j.key,r,i]),Y=x.useCallback(()=>{T&&(o.forEach(fe=>{const O=_.find(le=>le.id===fe);if(!O)return;const pe=f[O.noteDetailsHash];if(!pe)return;const he=Zy(pe.pitch,j.key,!1);r(fe,{newPitch:he})}),i())},[T,o,_,f,j.key,r,i]),ne=x.useCallback(()=>{if(!T||o.size===0)return;let fe=!1;_.forEach(O=>{if(!o.has(O.id))return;const pe=f[O.noteDetailsHash];pe&&pe.startBeat<=0&&(fe=!0)}),!fe&&(o.forEach(O=>{const pe=_.find(oe=>oe.id===O);if(!pe)return;const he=f[pe.noteDetailsHash];if(!he)return;const le=Math.ceil(he.startBeat-1);r(O,{newStartBeat:le})}),i())},[T,o,_,f,r,i]),be=x.useCallback(()=>{if(!T||o.size===0)return;const fe=N.bars*j.timeSignature.beatsPerBar;let O=!1;_.forEach(pe=>{if(!o.has(pe.id))return;const he=f[pe.noteDetailsHash];he&&he.startBeat>=fe&&(O=!0)}),!O&&(o.forEach(pe=>{const he=_.find(Q=>Q.id===pe);
929if(!he)return;const le=f[he.noteDetailsHash];if(!le)return;const oe=Math.floor(le.startBeat+1);r(pe,{newStartBeat:oe})}),i())},[T,o,_,f,N.bars,j.timeSignature.beatsPerBar,r,i]),we=x.useCallback(()=>{if(!T)return;const fe=j.timeSignature.beatsPerBar*.0625;o.forEach(O=>{const pe=_.find(Q=>Q.id===O);if(!pe)return;const he=f[pe.noteDetailsHash];if(!he)return;const le=N.bars*j.timeSignature.beatsPerBar-he.startBeat,oe=Math.min(he.durationInBeats+fe,le);r(O,{newDurationInBeats:oe})}),i()},[T,o,_,f,j.timeSignature.beatsPerBar,N.bars,r,i]),te=x.useCallback(()=>{if(!T)return;const fe=j.timeSignature.beatsPerBar*.0625;o.forEach(O=>{const pe=_.find(oe=>oe.id===O);if(!pe)return;const he=f[pe.noteDetailsHash];if(!he)return;const le=Math.max(he.durationInBeats-fe,.25);r(O,{newDurationInBeats:le})}),i()},[T,o,_,j.timeSignature.beatsPerBar,r,i,f]);return x.useEffect(()=>{V&&I.current&&I.current.focus()},[V]),c.jsx("div",{ref:m,children:c.jsxs(Wr,{onClose:U,widthClass:h?"w-[93%]":"w-4/5",heightClass:h?"h-[84%]":"h-4/5",children:[c.jsx("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-3 px-2 py-2",style:{background:`linear-gradient(135deg, 930 color-mix(in srgb, ${N.color} 80%, black) 0%, 931 color-mix(in srgb, ${N.color} 90%, black) 50%, 932 color-mix(in srgb, ${N.color} 80%, black) 100% 933 )`,backdropFilter:"blur(1px)"},children:h?c.jsxs("div",{className:"flex flex-col w-full gap-2",children:[c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsx("div",{className:"text-left flex-1",children:c.jsx("input",{ref:I,type:"text",value:P,onChange:A,onBlur:W,onKeyDown:fe=>fe.key==="Enter"&&W(),className:"text-lg bg-transparent text-white outline-none",readOnly:!T})}),c.jsx(l0,{onClose:U,wrapperClassName:"",ariaLabel:"Close Details",rotate:!0,size:30})]}),c.jsxs("div",{className:"flex items-center gap-3 px-2",children:[c.jsx("div",{className:"flex-1",style:T?void 0:{pointerEvents:"none",opacity:.5},children:c.jsx(_s,{min:0,max:1,step:.01,value:N.volume,renderValue:fe=>Math.round(fe*100).toString(),adjustUserEnteredValue:fe=>fe/100,onChange:R,onAfterChange:i,title:"Volume",label:c.jsx(Ya,{className:"size-5 text-zinc-700 dark:text-zinc-100"}),id:`bloob-volume-${s}`,doubleClickValue:1})}),c.jsxs("div",{className:"flex items-center gap-2 bg-zinc-700 px-2 py-1 rounded-md",children:[c.jsx("button",{title:B,onClick:D,children:y?c.jsx(Sv,{size:22}):g?c.jsx(nv,{size:22,className:`hover:scale-110 transition-transform duration-150 ${v?"fill-red-500":""}`}):c.jsx(ka,{size:22,className:"hover:scale-110 transition-transform duration-150"})}),c.jsx("button",{ref:S,...q(),disabled:g||!T,children:c.jsx(ld,{size:22,className:`transition-transform duration-150 ${g||!T?"fill-red-300 opacity-20":"fill-red-500 hover:scale-110"}`})}),c.jsx("button",{title:N.muted?"Unmute":"Mute",onClick:Z,disabled:!T,children:c.jsx(Ih,{size:22,className:`hover:scale-110 transition-transform duration-150 ${T?N.muted?"text-zinc-50":"text-zinc-400":"text-zinc-600"}`})}),c.jsx("button",{title:N.soloed?"Unsolo":"Solo",onClick:ie,disabled:!T,children:c.jsx(Eh,{size:22,className:`hover:scale-110 transition-transform duration-150 ${T?N.soloed?"text-zinc-50":"text-zinc-400":"text-zinc-600"}`})}),c.jsx("button",{title:"Delete Selected Notes",onClick:ge,disabled:o.size===0||!T,children:c.jsx(js,{size:22,className:`hover:scale-110 transition-transform duration-150 ${o.size>0&&T?"text-red-500":"text-red-800"}`})})]})]}),c.jsx("div",{className:"w-full px-2",style:T?void 0:{pointerEvents:"none",opacity:.5},children:c.jsx(TC,{bloobId:s,borderColorClassName:"border-cai-secondary",arrowColorClassName:"text-cai-secondary"})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-left flex-1 w-full pl-2 my-auto",children:c.jsx("div",{className:"flex items-center",children:c.jsx("input",{ref:I,type:"text",value:P,onChange:A,onBlur:W,onKeyDown:fe=>fe.key==="Enter"&&W(),className:"text-lg bg-transparent text-white outline-none",readOnly:!T})})}),c.jsx("div",{className:"flex-1 justify-center my-auto",style:T?void 0:{pointerEvents:"none",opacity:.5},children:c.jsx("div",{className:"px-2 w-full",children:c.jsx(_s,{min:0,max:1,step:.
93301,value:N.volume,renderValue:fe=>Math.round(fe*100).toString(),adjustUserEnteredValue:fe=>fe/100,onChange:R,onAfterChange:i,title:"Volume",label:c.jsx(Ya,{className:"size-5 text-zinc-700 dark:text-zinc-100"}),id:`bloob-volume-${s}`,doubleClickValue:1})})}),c.jsx("div",{className:"flex-1 flex items-center justify-between",ref:k,children:c.jsx("div",{className:"flex-1",children:c.jsxs("div",{className:"flex items-center gap-3 w-fit mx-auto bg-zinc-700 px-3 py-1 rounded-md",children:[c.jsx("button",{title:y?"Loading...":g?"Stop":"Play",className:"w-6",onClick:D,disabled:y,children:y?c.jsx(Sv,{size:22}):g?c.jsx(nv,{className:`hover:scale-110 transition-transform duration-150 ${v?"fill-red-500":""}`}):c.jsx(ka,{className:"hover:scale-110 transition-transform duration-150"})}),c.jsx("button",{ref:S,onClick:L,disabled:g||!T,children:c.jsx(ld,{className:`hover:scale-110 transition-transform duration-150 ${g||!T?"fill-red-300":"fill-red-500"}`})}),c.jsx(xv,{hoverTriggerRef:S,positionAnchorRef:k,disabled:g||!T,placement:"bottom",mainAxisOffset:2}),c.jsx("button",{title:N.muted?"Unmute":"Mute",onClick:Z,disabled:!T,children:c.jsx(Ih,{className:`hover:scale-110 transition-transform duration-150 ${T?N.muted?"text-zinc-50":"text-zinc-400":"text-zinc-600"}`})}),c.jsx("button",{title:N.soloed?"Unsolo":"Solo",onClick:ie,disabled:!T,children:c.jsx(Eh,{className:`hover:scale-110 transition-transform duration-150 ${T?N.soloed?"text-zinc-50":"text-zinc-400":"text-zinc-600"}`})})]})})}),c.jsx("div",{className:"flex-1 my-auto",style:T?void 0:{pointerEvents:"none",opacity:.5},children:c.jsx("div",{className:"px-2 sm:px-8",children:c.jsx(TC,{bloobId:s,borderColorClassName:"border-cai-secondary",arrowColorClassName:"text-cai-secondary"})})}),c.jsx("div",{children:c.jsx(l0,{onClose:U,wrapperClassName:"ml-2",ariaLabel:"Close Details",rotate:!0,size:30})})]})}),c.jsxs("div",{className:"relative flex-1 bg-zinc-900/85 backdrop-blur-sm",children:[c.jsx(Kv,{children:En(N)?c.jsx(lF,{bloobId:s,bloobDetailsWrapperRef:m}):c.jsx(aF,{bloobId:s,bloobDetailsWrapperRef:m})}),o.size>0&&h&&T&&ln(N)&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-4 right-4 z-50",children:c.jsxs("div",{className:"grid grid-cols-3 gap-1 p-2 bg-black/20 backdrop-blur-md border border-white/20 rounded-lg",children:[c.jsx("div",{}),c.jsx("button",{onClick:re,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Move notes up",children:c.jsx(j0,{className:"size-4 text-white"})}),c.jsx("div",{}),c.jsx("button",{onClick:ne,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Move notes left",children:c.jsx(Sh,{className:"size-4 text-white"})}),c.jsx("div",{}),c.jsx("button",{onClick:be,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Move notes right",children:c.jsx(pi,{className:"size-4 text-white"})}),c.jsx("div",{}),c.jsx("button",{onClick:Y,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Move notes down",children:c.jsx(Vi,{className:"size-4 text-white"})}),c.jsx("div",{})]})}),c.jsx("div",{className:"absolute bottom-4 left-20 z-50",children:c.jsxs("div",{className:"flex gap-2 p-2 bg-black/20 backdrop-blur-md border border-white/20 rounded-lg",children:[c.jsx("button",{onClick:te,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Shorten notes (hold to repeat)",children:c.jsx(kD,{className:"size-4 text-white"})}),c.jsx("button",{onClick:we,className:"p-2 hover:brightness-110 rounded transition-all shadow-lg backdrop-blur-sm border border-white/10",style:{backgroundColor:`color-mix(in srgb, ${N.color} 80%, transparent)`},title:"Extend notes (hold to repeat)",children:c.jsx(Yf,{className:"size-4 text-white"})})]})})]})]})]})})},nme=mr.memo(tme),rme=350,ime=200,sme=600,ome=()=>{const{focusCanvas:t}=di(),{detailsBloobId:e}=Ho(),{deselectAllNotes:n,closeBloobDetails:r,showBloobDetails:i}=Xs(),{getSongById:s,getBloobById:o}=mn(),{selectedSingleCaiObject:a,caiChatState:l}=Yn(),{setCaiChatState:u}=cr(),d=x.useRef(null),f=qc(e),h=f==null?void 0:f.songId,m=h!=null?s(h):void 0,[y,g]=x.use
933State(rme),[w,v]=x.useState(!1),[S,C]=x.useState(!1);x.useEffect(()=>{f||(n(),r(),t())},[f,n,r,t]),x.useEffect(()=>{requestAnimationFrame(()=>C(!0)),l===zn.DEFAULT&&u(zn.MAXIMIZED)},[]),x.useEffect(()=>{if(a&&a.type===J.Bloob&&a.id!==e){const _=o(a.id);_&&(ln(_)||En(_))&&(n(),i(a.id))}},[a,e,o,i,n]);const k=x.useCallback(()=>{n(),r(),t()},[n,r,t]);x.useEffect(()=>{const _=j=>{if(j.key==="Escape"){if(document.getElementById("modal-dialog"))return;k()}};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[k]);const N=x.useCallback(_=>{_.preventDefault(),v(!0);const j=_.clientY,T=y,M=H=>{const P=j-H.clientY,F=Math.max(ime,Math.min(sme,T+P));g(F)},V=()=>{v(!1),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",V)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",V)},[y]);return!f||!m?null:c.jsxs("div",{ref:d,tabIndex:-1,style:{height:S?`${y}px`:"0px",transition:w?"none":"height 0.3s ease-in-out",flexShrink:0},className:"flex flex-col border-t border-zinc-700 overflow-hidden",children:[c.jsx("div",{className:"h-1.5 cursor-row-resize flex items-center justify-center bg-zinc-800 hover:bg-zinc-600 transition-colors shrink-0",onMouseDown:N,children:c.jsx(VS,{size:14,className:"text-zinc-500"})}),c.jsxs("div",{className:"relative flex-1 bg-zinc-900/85 backdrop-blur-sm overflow-y-auto",style:{minHeight:0},children:[c.jsx(l0,{onClose:k,wrapperClassName:"absolute top-1 right-1 z-50",ariaLabel:"Close Details",rotate:!0,size:22}),c.jsx(Kv,{children:En(f)?c.jsx(lF,{bloobId:e,bloobDetailsWrapperRef:d}):c.jsx(aF,{bloobId:e,bloobDetailsWrapperRef:d})})]})]})},ame=mr.memo(ome),lme=200,cme=120,ume=400,dme=5,fme=12,gc=20,yu=36,hme=()=>{const{selectedSingleCaiObject:t,caiChatState:e}=Yn(),{setCaiChatState:n}=cr(),{showVolumeAutomation:r}=Pn(),{toggleVolumeAutomation:i}=Br(),{updateBloobDetails:s}=Gn(),{commitToStore:o}=Ln(),a=(t==null?void 0:t.type)===J.Bloob?t.id:null,l=qc(a??-1),[u,d]=x.useState(lme),[f,h]=x.useState(!1),[m,y]=x.useState(!1),g=x.useRef(null),w=x.useRef(null),[v,S]=x.useState({width:0,height:0}),C=x.useRef(null);x.useLayoutEffect(()=>{const re=w.current;if(!re)return;const Y=()=>S({width:re.clientWidth,height:re.clientHeight});Y();const ne=new ResizeObserver(Y);return ne.observe(re),()=>ne.disconnect()},[l]),x.useEffect(()=>{requestAnimationFrame(()=>y(!0)),e===zn.DEFAULT&&n(zn.MAXIMIZED)},[]),x.useEffect(()=>{const re=Y=>{if(Y.key==="Escape"){if(document.getElementById("modal-dialog"))return;i()}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[i]),x.useEffect(()=>{l&&r&&(!l.volumeAutomation||l.volumeAutomation.length===0)&&(s(l.id,{volumeAutomation:[{bar:0,value:1},{bar:l.bars,value:1}]}),o())},[l==null?void 0:l.id,r]);const k=x.useCallback(re=>{re.preventDefault(),h(!0);const Y=re.clientY,ne=u,be=te=>{const fe=Y-te.clientY,O=Math.max(cme,Math.min(ume,ne+fe));d(O)},we=()=>{h(!1),document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",we)};document.addEventListener("mousemove",be),document.addEventListener("mouseup",we)},[u]),N=l==null?void 0:l.volumeAutomation,_=!!N&&N.length>0,j=x.useMemo(()=>_?[...N].sort((re,Y)=>re.bar-Y.bar):[],[_,N]),T=(l==null?void 0:l.bars)??1,M=Math.max(yu+48,v.width||320),V=Math.max(60,v.height||80),H=V-gc-8,P=x.useCallback(re=>yu+re/T*(M-yu),[T,M]),F=x.useCallback(re=>gc+(1-re)*H,[H]),I=x.useCallback(re=>{const Y=(re-yu)/(M-yu);return Math.max(0,Math.min(T,Y*T))},[T,M]),R=x.useCallback(re=>{const Y=(re-gc)/H;return Math.max(0,Math.min(1,1-Y))},[H]),U=x.useCallback(re=>{l&&s(l.id,{volumeAutomation:[...re].sort((Y,ne)=>Y.bar-ne.bar)})},[l,s]),A=x.useCallback(re=>{const Y=g.current;if(!Y)return{x:0,y:0};const ne=Y.createSVGPoint();ne.x=re.clientX,ne.y=re.clientY;const be=Y.getScreenCTM();if(!be)return{x:0,y:0};const we=ne.matrixTransform(be.inverse());return{x:we.x,y:we.y}},[]),W=x.useCallback(re=>{if(re.target.closest("[data-automation-point]"))return;const{x:Y,y:ne}=A(re),be={bar:Math.round(I(Y)*100)/100,value:Math.round(R(ne)*100)/100};U([...j,be]),o()},[A,I,R,j,U,o]),D=x.useCallback((re,Y)=>{re.stopPropagation(),re.preventDefault(),re.target.setPointerCapture(re.pointerId),C.current=Y},[]),B=x.useCallback(re=>{if(C.current===null)return;re.stopPropagation();const{x:Y,y:ne}=A(re),be=[...j];be[C.current]={bar:Math.round(I(Y)*100)/100,value:Math.round(R(ne)*100)/100},U(be)},[A,I,R,j,U]),L=x.useCallback(re=>{C.current!==null&&(re.stopPropagation(),C.current=null,o())},[o]),$=x.useCallback((re,Y)=>{if(re.stopPropagation(),j.length<=2)return;const ne=j.filter((be,we)=>we!==Y);U(ne),o()},[j,U,o]),q=x.useMemo(()=>{const re=[];for(let Y=0;Y<=T;Y++){const ne=P(Y);re.push(c.jsx("line",{x1:ne,y1:gc,x2:ne,y2:gc+H,stroke:"rgba(255,255,255,0.08)",strokeWidth:Y===0||Y===T?1.5:.5},`bar-${Y}`)),Y<T&&re.push(c.jsx("text",{x:ne+4,y:gc-6,fill:"rgba(255,255,255,0.4)",fontSize:10,
933children:Y+1},`label-${Y}`))}return re},[T,P,H]),Z=x.useMemo(()=>{const re=[];for(let Y=0;Y<=4;Y++){const ne=Y/4,be=F(ne);re.push(c.jsx("line",{x1:yu,y1:be,x2:M,y2:be,stroke:"rgba(255,255,255,0.06)",strokeWidth:.5},`vol-${Y}`)),re.push(c.jsx("text",{x:yu-4,y:be+3,fill:"rgba(255,255,255,0.35)",fontSize:9,textAnchor:"end",children:Math.round(ne*100)},`vol-label-${Y}`))}return re},[F,M]),ie=x.useMemo(()=>j.length===0?"":j.map(re=>`${P(re.bar)},${F(re.value)}`).join(" "),[j,P,F]),ge=x.useMemo(()=>{if(j.length===0)return"";const re=j.map(Y=>`${P(Y.bar)},${F(Y.value)}`);return[`${P(j[0].bar)},${gc+H}`,...re,`${P(j[j.length-1].bar)},${gc+H}`].join(" ")},[j,P,F,H]);return l?c.jsxs("div",{style:{height:m?`${u}px`:"0px",transition:f?"none":"height 0.3s ease-in-out",flexShrink:0},className:"flex flex-col border-t border-zinc-700 overflow-hidden",children:[c.jsx("div",{className:"h-1.5 cursor-row-resize flex items-center justify-center bg-zinc-800 hover:bg-zinc-600 transition-colors shrink-0",onMouseDown:k,children:c.jsx(VS,{size:14,className:"text-zinc-500"})}),c.jsxs("div",{className:"relative flex flex-1 flex-col w-full min-w-0 min-h-0 bg-zinc-900/85 backdrop-blur-sm overflow-hidden",style:{minHeight:0},children:[c.jsx(l0,{onClose:i,wrapperClassName:"absolute top-1 right-1 z-50",ariaLabel:"Close Automation Panel",rotate:!0,size:22}),c.jsxs("div",{className:"shrink-0 pl-2 pr-12 pt-1 pb-2.5 text-[10px] font-semibold text-zinc-400 uppercase tracking-wider select-none",children:["Vol Automation â ",l.label||`Bloob ${l.id}`]}),c.jsx("div",{ref:w,className:"relative min-h-0 min-w-0 flex-1 overflow-hidden",children:c.jsxs("svg",{ref:g,width:"100%",height:"100%",viewBox:`0 0 ${M} ${V}`,style:{cursor:"crosshair",display:"block"},onClick:W,onPointerMove:B,onPointerUp:L,children:[q,Z,_&&c.jsxs(c.Fragment,{children:[c.jsx("polygon",{points:ge,fill:"rgba(168,85,247,0.12)"}),c.jsx("polyline",{points:ie,fill:"none",stroke:"rgba(168,85,247,0.7)",strokeWidth:2,strokeLinejoin:"round"}),j.map((re,Y)=>c.jsx("circle",{"data-automation-point":!0,cx:P(re.bar),cy:F(re.value),r:dme,fill:"white",stroke:"rgba(168,85,247,0.8)",strokeWidth:2,style:{cursor:"grab"},onPointerDown:ne=>D(ne,Y),onDoubleClick:ne=>$(ne,Y),children:c.jsxs("title",{children:["Bar ",re.bar.toFixed(1),", Vol ",Math.round(re.value*100),"%"]})},Y)),j.map((re,Y)=>c.jsx("circle",{cx:P(re.bar),cy:F(re.value),r:fme,fill:"transparent",style:{cursor:"grab"},onPointerDown:ne=>D(ne,Y),onDoubleClick:ne=>$(ne,Y)},`hit-${Y}`))]})]})})]})]}):c.jsxs("div",{style:{height:m?`${u}px`:"0px",transition:f?"none":"height 0.3s ease-in-out",flexShrink:0},className:"flex flex-col border-t border-zinc-700 overflow-hidden",children:[c.jsx("div",{className:"h-1.5 cursor-row-resize flex items-center justify-center bg-zinc-800 hover:bg-zinc-600 transition-colors shrink-0",onMouseDown:k,children:c.jsx(VS,{size:14,className:"text-zinc-500"})}),c.jsxs("div",{className:"flex-1 flex items-center justify-center bg-zinc-900/85 backdrop-blur-sm",children:[c.jsx(l0,{onClose:i,wrapperClassName:"absolute top-1 right-1 z-50",ariaLabel:"Close Automation Panel",rotate:!0,size:22}),c.jsx("span",{className:"text-zinc-500 text-sm",children:"Select a bloob to edit volume automation"})]})]})},pme=mr.memo(hme);var Cy={exports:{}},mme=Cy.exports,IM;function gme(){return IM||(IM=1,function(t,e){(function(n,r){t.exports=r(Uh())})(mme,n=>(()=>{var r={9735:(a,l)=>{l.__esModule=!0,l.default={scheme:"apathy",author:"jannik siebert (https://github.com/janniks)",base00:"#031A16",base01:"#0B342D",base02:"#184E45",base03:"#2B685E",base04:"#5F9C92",base05:"#81B5AC",base06:"#A7CEC8",base07:"#D2E7E4",base08:"#3E9688",base09:"#3E7996",base0A:"#3E4C96",base0B:"#883E96",base0C:"#963E4C",base0D:"#96883E",base0E:"#4C963E",base0F:"#3E965B"},a.exports=l.default},294:(a,l)=>{l.__esModule=!0,l.default={scheme:"ashes",author:"jannik siebert (https://github.com/janniks)",base00:"#1C2023",base01:"#393F45",base02:"#565E65",base03:"#747C84",base04:"#ADB3BA",base05:"#C7CCD1",base06:"#DFE2E5",base07:"#F3F4F5",base08:"#C7AE95",base09:"#C7C795",base0A:"#AEC795",base0B:"#95C7AE",base0C:"#95AEC7",base0D:"#AE95C7",base0E:"#C795AE",base0F:"#C79595"},a.exports=l.default},1733:(a,l)=>
933{l.__esModule=!0,l.default={scheme:"atelier dune",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune)",base00:"#20201d",base01:"#292824",base02:"#6e6b5e",base03:"#7d7a68",base04:"#999580",base05:"#a6a28c",base06:"#e8e4cf",base07:"#fefbec",base08:"#d73737",base09:"#b65611",base0A:"#cfb017",base0B:"#60ac39",base0C:"#1fad83",base0D:"#6684e1",base0E:"#b854d4",base0F:"#d43552"},a.exports=l.default},8974:(a,l)=>{l.__esModule=!0,l.default={scheme:"atelier forest",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest)",base00:"#1b1918",base01:"#2c2421",base02:"#68615e",base03:"#766e6b",base04:"#9c9491",base05:"#a8a19f",base06:"#e6e2e0",base07:"#f1efee",base08:"#f22c40",base09:"#df5320",base0A:"#d5911a",base0B:"#5ab738",base0C:"#00ad9c",base0D:"#407ee7",base0E:"#6666ea",base0F:"#c33ff3"},a.exports=l.default},6933:(a,l)=>{l.__esModule=!0,l.default={scheme:"atelier heath",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath)",base00:"#1b181b",base01:"#292329",base02:"#695d69",base03:"#776977",base04:"#9e8f9e",base05:"#ab9bab",base06:"#d8cad8",base07:"#f7f3f7",base08:"#ca402b",base09:"#a65926",base0A:"#bb8a35",base0B:"#379a37",base0C:"#159393",base0D:"#516aec",base0E:"#7b59c0",base0F:"#cc33cc"},a.exports=l.default},523:(a,l)=>{l.__esModule=!0,l.default={scheme:"atelier lakeside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside/)",base00:"#161b1d",base01:"#1f292e",base02:"#516d7b",base03:"#5a7b8c",base04:"#7195a8",base05:"#7ea2b4",base06:"#c1e4f6",base07:"#ebf8ff",base08:"#d22d72",base09:"#935c25",base0A:"#8a8a0f",base0B:"#568c3b",base0C:"#2d8f6f",base0D:"#257fad",base0E:"#5d5db1",base0F:"#b72dd2"},a.exports=l.default},1223:(a,l)=>{l.__esModule=!0,l.default={scheme:"atelier seaside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside/)",base00:"#131513",base01:"#242924",base02:"#5e6e5e",base03:"#687d68",base04:"#809980",base05:"#8ca68c",base06:"#cfe8cf",base07:"#f0fff0",base08:"#e6193c",base09:"#87711d",base0A:"#c3c322",base0B:"#29a329",base0C:"#1999b3",base0D:"#3d62f5",base0E:"#ad2bee",base0F:"#e619c3"},a.exports=l.default},1233:(a,l)=>{l.__esModule=!0,l.default={scheme:"bespin",author:"jan t. sott",base00:"#28211c",base01:"#36312e",base02:"#5e5d5c",base03:"#666666",base04:"#797977",base05:"#8a8986",base06:"#9d9b97",base07:"#baae9e",base08:"#cf6a4c",base09:"#cf7d34",base0A:"#f9ee98",base0B:"#54be0d",base0C:"#afc4db",base0D:"#5ea6ea",base0E:"#9b859d",base0F:"#937121"},a.exports=l.default},2847:(a,l)=>{l.__esModule=!0,l.default={scheme:"brewer",author:"timothée poisot (http://github.com/tpoisot)",base00:"#0c0d0e",base01:"#2e2f30",base02:"#515253",base03:"#737475",base04:"#959697",base05:"#b7b8b9",base06:"#dadbdc",base07:"#fcfdfe",base08:"#e31a1c",base09:"#e6550d",base0A:"#dca060",base0B:"#31a354",base0C:"#80b1d3",base0D:"#3182bd",base0E:"#756bb1",base0F:"#b15928"},a.exports=l.default},8120:(a,l)=>{l.__esModule=!0,l.default={scheme:"bright",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#303030",base02:"#505050",base03:"#b0b0b0",base04:"#d0d0d0",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ffffff",base08:"#fb0120",base09:"#fc6d24",base0A:"#fda331",base0B:"#a1c659",base0C:"#76c7b7",base0D:"#6fb3d2",base0E:"#d381c3",base0F:"#be643c"},a.exports=l.default},6305:(a,l)=>{l.__esModule=!0,l.default={scheme:"chalk",author:"chris kempson (http://chriskempson.com)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#f5f5f5",base08:"#fb9fb1",base09:"#eda987",base0A:"#ddb26f",base0B:"#acc267",base0C:"#12cfc0",base0D:"#6fc2ef",base0E:"#e1a3ee",base0F:"#deaf8f"},a.exports=l.default},525:(a,l)=>{l.__esModule=!0,l.default={scheme:"codeschool",author:"brettof86",base00:"#232c31",base01:"#1c3657",base02:"#2a343a",base03:"#3f4944",base04:"#84898c",base05:"#9ea7a6",base06:"#a7cfa3",base07:"#b5d8f6",base08:"#2a5491",base09:"#43820d",base0A:"#a03b1e",base0B:"#237986",base0C:"#b02f30",base0D:"#484d79",base0E:"#c59820",base0F:"#c98344"},a.exports=l.default},4124:(a,l)=>
933{l.__esModule=!0,l.default={scheme:"colors",author:"mrmrs (http://clrs.cc)",base00:"#111111",base01:"#333333",base02:"#555555",base03:"#777777",base04:"#999999",base05:"#bbbbbb",base06:"#dddddd",base07:"#ffffff",base08:"#ff4136",base09:"#ff851b",base0A:"#ffdc00",base0B:"#2ecc40",base0C:"#7fdbff",base0D:"#0074d9",base0E:"#b10dc9",base0F:"#85144b"},a.exports=l.default},7167:(a,l)=>{l.__esModule=!0,l.default={scheme:"default",author:"chris kempson (http://chriskempson.com)",base00:"#181818",base01:"#282828",base02:"#383838",base03:"#585858",base04:"#b8b8b8",base05:"#d8d8d8",base06:"#e8e8e8",base07:"#f8f8f8",base08:"#ab4642",base09:"#dc9656",base0A:"#f7ca88",base0B:"#a1b56c",base0C:"#86c1b9",base0D:"#7cafc2",base0E:"#ba8baf",base0F:"#a16946"},a.exports=l.default},4582:(a,l)=>{l.__esModule=!0,l.default={scheme:"eighties",author:"chris kempson (http://chriskempson.com)",base00:"#2d2d2d",base01:"#393939",base02:"#515151",base03:"#747369",base04:"#a09f93",base05:"#d3d0c8",base06:"#e8e6df",base07:"#f2f0ec",base08:"#f2777a",base09:"#f99157",base0A:"#ffcc66",base0B:"#99cc99",base0C:"#66cccc",base0D:"#6699cc",base0E:"#cc99cc",base0F:"#d27b53"},a.exports=l.default},7096:(a,l)=>{l.__esModule=!0,l.default={scheme:"embers",author:"jannik siebert (https://github.com/janniks)",base00:"#16130F",base01:"#2C2620",base02:"#433B32",base03:"#5A5047",base04:"#8A8075",base05:"#A39A90",base06:"#BEB6AE",base07:"#DBD6D1",base08:"#826D57",base09:"#828257",base0A:"#6D8257",base0B:"#57826D",base0C:"#576D82",base0D:"#6D5782",base0E:"#82576D",base0F:"#825757"},a.exports=l.default},9887:(a,l)=>{l.__esModule=!0,l.default={scheme:"flat",author:"chris kempson (http://chriskempson.com)",base00:"#2C3E50",base01:"#34495E",base02:"#7F8C8D",base03:"#95A5A6",base04:"#BDC3C7",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ECF0F1",base08:"#E74C3C",base09:"#E67E22",base0A:"#F1C40F",base0B:"#2ECC71",base0C:"#1ABC9C",base0D:"#3498DB",base0E:"#9B59B6",base0F:"#be643c"},a.exports=l.default},7199:(a,l)=>{l.__esModule=!0,l.default={scheme:"google",author:"seth wright (http://sethawright.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#CC342B",base09:"#F96A38",base0A:"#FBA922",base0B:"#198844",base0C:"#3971ED",base0D:"#3971ED",base0E:"#A36AC7",base0F:"#3971ED"},a.exports=l.default},1985:(a,l)=>{l.__esModule=!0,l.default={scheme:"grayscale",author:"alexandre gavioli (https://github.com/alexx2/)",base00:"#101010",base01:"#252525",base02:"#464646",base03:"#525252",base04:"#ababab",base05:"#b9b9b9",base06:"#e3e3e3",base07:"#f7f7f7",base08:"#7c7c7c",base09:"#999999",base0A:"#a0a0a0",base0B:"#8e8e8e",base0C:"#868686",base0D:"#686868",base0E:"#747474",base0F:"#5e5e5e"},a.exports=l.default},8093:(a,l)=>{l.__esModule=!0,l.default={scheme:"green screen",author:"chris kempson (http://chriskempson.com)",base00:"#001100",base01:"#003300",base02:"#005500",base03:"#007700",base04:"#009900",base05:"#00bb00",base06:"#00dd00",base07:"#00ff00",base08:"#007700",base09:"#009900",base0A:"#007700",base0B:"#00bb00",base0C:"#005500",base0D:"#009900",base0E:"#00bb00",base0F:"#005500"},a.exports=l.default},1615:(a,l)=>{l.__esModule=!0,l.default={scheme:"harmonic16",author:"jannik siebert (https://github.com/janniks)",base00:"#0b1c2c",base01:"#223b54",base02:"#405c79",base03:"#627e99",base04:"#aabcce",base05:"#cbd6e2",base06:"#e5ebf1",base07:"#f7f9fb",base08:"#bf8b56",base09:"#bfbf56",base0A:"#8bbf56",base0B:"#56bf8b",base0C:"#568bbf",base0D:"#8b56bf",base0E:"#bf568b",base0F:"#bf5656"},a.exports=l.default},9063:(a,l)=>{l.__esModule=!0,l.default={scheme:"hopscotch",author:"jan t. sott",base00:"#322931",base01:"#433b42",base02:"#5c545b",base03:"#797379",base04:"#989498",base05:"#b9b5b8",base06:"#d5d3d5",base07:"#ffffff",base08:"#dd464c",base09:"#fd8b19",base0A:"#fdcc59",base0B:"#8fc13e",base0C:"#149b93",base0D:"#1290bf",base0E:"#c85e7c",base0F:"#b33508"},a.exports=l.default},9446:(a,l,u)=>
933{function d(te){return te&&te.__esModule?te.default:te}l.__esModule=!0;var f=u(1308);l.threezerotwofour=d(f);var h=u(9735);l.apathy=d(h);var m=u(294);l.ashes=d(m);var y=u(1733);l.atelierDune=d(y);var g=u(8974);l.atelierForest=d(g);var w=u(6933);l.atelierHeath=d(w);var v=u(523);l.atelierLakeside=d(v);var S=u(1223);l.atelierSeaside=d(S);var C=u(1233);l.bespin=d(C);var k=u(2847);l.brewer=d(k);var N=u(8120);l.bright=d(N);var _=u(6305);l.chalk=d(_);var j=u(525);l.codeschool=d(j);var T=u(4124);l.colors=d(T);var M=u(7167);l.default=d(M);var V=u(4582);l.eighties=d(V);var H=u(7096);l.embers=d(H);var P=u(9887);l.flat=d(P);var F=u(7199);l.google=d(F);var I=u(1985);l.grayscale=d(I);var R=u(8093);l.greenscreen=d(R);var U=u(1615);l.harmonic=d(U);var A=u(9063);l.hopscotch=d(A);var W=u(9033);l.isotope=d(W);var D=u(4112);l.marrakesh=d(D);var B=u(9600);l.mocha=d(B);var L=u(1240);l.monokai=d(L);var $=u(9768);l.ocean=d($);var q=u(8293);l.paraiso=d(q);var Z=u(3093);l.pop=d(Z);var ie=u(1951);l.railscasts=d(ie);var ge=u(6368);l.shapeshifter=d(ge);var re=u(2317);l.solarized=d(re);var Y=u(1091);l.summerfruit=d(Y);var ne=u(6943);l.tomorrow=d(ne);var be=u(5670);l.tube=d(be);var we=u(2536);l.twilight=d(we)},9033:(a,l)=>{l.__esModule=!0,l.default={scheme:"isotope",author:"jan t. sott",base00:"#000000",base01:"#404040",base02:"#606060",base03:"#808080",base04:"#c0c0c0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#ff0000",base09:"#ff9900",base0A:"#ff0099",base0B:"#33ff00",base0C:"#00ffff",base0D:"#0066ff",base0E:"#cc00ff",base0F:"#3300ff"},a.exports=l.default},4112:(a,l)=>{l.__esModule=!0,l.default={scheme:"marrakesh",author:"alexandre gavioli (http://github.com/alexx2/)",base00:"#201602",base01:"#302e00",base02:"#5f5b17",base03:"#6c6823",base04:"#86813b",base05:"#948e48",base06:"#ccc37a",base07:"#faf0a5",base08:"#c35359",base09:"#b36144",base0A:"#a88339",base0B:"#18974e",base0C:"#75a738",base0D:"#477ca1",base0E:"#8868b3",base0F:"#b3588e"},a.exports=l.default},9600:(a,l)=>{l.__esModule=!0,l.default={scheme:"mocha",author:"chris kempson (http://chriskempson.com)",base00:"#3B3228",base01:"#534636",base02:"#645240",base03:"#7e705a",base04:"#b8afad",base05:"#d0c8c6",base06:"#e9e1dd",base07:"#f5eeeb",base08:"#cb6077",base09:"#d28b71",base0A:"#f4bc87",base0B:"#beb55b",base0C:"#7bbda4",base0D:"#8ab3b5",base0E:"#a89bb9",base0F:"#bb9584"},a.exports=l.default},1240:(a,l)=>{l.__esModule=!0,l.default={scheme:"monokai",author:"wimer hazenberg (http://www.monokai.nl)",base00:"#272822",base01:"#383830",base02:"#49483e",base03:"#75715e",base04:"#a59f85",base05:"#f8f8f2",base06:"#f5f4f1",base07:"#f9f8f5",base08:"#f92672",base09:"#fd971f",base0A:"#f4bf75",base0B:"#a6e22e",base0C:"#a1efe4",base0D:"#66d9ef",base0E:"#ae81ff",base0F:"#cc6633"},a.exports=l.default},9768:(a,l)=>{l.__esModule=!0,l.default={scheme:"ocean",author:"chris kempson (http://chriskempson.com)",base00:"#2b303b",base01:"#343d46",base02:"#4f5b66",base03:"#65737e",base04:"#a7adba",base05:"#c0c5ce",base06:"#dfe1e8",base07:"#eff1f5",base08:"#bf616a",base09:"#d08770",base0A:"#ebcb8b",base0B:"#a3be8c",base0C:"#96b5b4",base0D:"#8fa1b3",base0E:"#b48ead",base0F:"#ab7967"},a.exports=l.default},8293:(a,l)=>{l.__esModule=!0,l.default={scheme:"paraiso",author:"jan t. sott",base00:"#2f1e2e",base01:"#41323f",base02:"#4f424c",base03:"#776e71",base04:"#8d8687",base05:"#a39e9b",base06:"#b9b6b0",base07:"#e7e9db",base08:"#ef6155",base09:"#f99b15",base0A:"#fec418",base0B:"#48b685",base0C:"#5bc4bf",base0D:"#06b6ef",base0E:"#815ba4",base0F:"#e96ba8"},a.exports=l.default},3093:(a,l)=>{l.__esModule=!0,l.default={scheme:"pop",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#eb008a",base09:"#f29333",base0A:"#f8ca12",base0B:"#37b349",base0C:"#00aabb",base0D:"#0e5a94",base0E:"#b31e8d",base0F:"#7a2d00"},a.exports=l.default},1951:(a,l)=>{l.__esModule=!0,l.default={scheme:"railscasts",author:"ryan bates (http://railscasts.com)",base00:"#2b2b2b",base01:"#272935",base02:"#3a4055",base03:"#5a647e",base04:"#d4cfc9",base05:"#e6e1dc",base06:"#f4f1ed",base07:"#f9f7f3",base08:"#da4939",base09:"#cc7833",base0A:"#ffc66d",base0B:"#a5c261",base0C:"#519f50",base0D:"#6d9cbe",base0E:"#b6b3eb",base0F:"#bc9458"},a.exports=l.default},6368:(a,l)=>
vendor: 5,007 bytes, line 933
933{l.__esModule=!0,l.default={scheme:"shapeshifter",author:"tyler benziger (http://tybenz.com)",base00:"#000000",base01:"#040404",base02:"#102015",base03:"#343434",base04:"#555555",base05:"#ababab",base06:"#e0e0e0",base07:"#f9f9f9",base08:"#e92f2f",base09:"#e09448",base0A:"#dddd13",base0B:"#0ed839",base0C:"#23edda",base0D:"#3b48e3",base0E:"#f996e2",base0F:"#69542d"},a.exports=l.default},2317:(a,l)=>{l.__esModule=!0,l.default={scheme:"solarized",author:"ethan schoonover (http://ethanschoonover.com/solarized)",base00:"#002b36",base01:"#073642",base02:"#586e75",base03:"#657b83",base04:"#839496",base05:"#93a1a1",base06:"#eee8d5",base07:"#fdf6e3",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"},a.exports=l.default},1091:(a,l)=>{l.__esModule=!0,l.default={scheme:"summerfruit",author:"christopher corley (http://cscorley.github.io/)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#B0B0B0",base05:"#D0D0D0",base06:"#E0E0E0",base07:"#FFFFFF",base08:"#FF0086",base09:"#FD8900",base0A:"#ABA800",base0B:"#00C918",base0C:"#1faaaa",base0D:"#3777E6",base0E:"#AD00A1",base0F:"#cc6633"},a.exports=l.default},1308:(a,l)=>{l.__esModule=!0,l.default={scheme:"threezerotwofour",author:"jan t. sott (http://github.com/idleberg)",base00:"#090300",base01:"#3a3432",base02:"#4a4543",base03:"#5c5855",base04:"#807d7c",base05:"#a5a2a2",base06:"#d6d5d4",base07:"#f7f7f7",base08:"#db2d20",base09:"#e8bbd0",base0A:"#fded02",base0B:"#01a252",base0C:"#b5e4f4",base0D:"#01a0e4",base0E:"#a16a94",base0F:"#cdab53"},a.exports=l.default},6943:(a,l)=>{l.__esModule=!0,l.default={scheme:"tomorrow",author:"chris kempson (http://chriskempson.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#cc6666",base09:"#de935f",base0A:"#f0c674",base0B:"#b5bd68",base0C:"#8abeb7",base0D:"#81a2be",base0E:"#b294bb",base0F:"#a3685a"},a.exports=l.default},5670:(a,l)=>{l.__esModule=!0,l.default={scheme:"london tube",author:"jan t. sott",base00:"#231f20",base01:"#1c3f95",base02:"#5a5758",base03:"#737171",base04:"#959ca1",base05:"#d9d8d8",base06:"#e7e7e8",base07:"#ffffff",base08:"#ee2e24",base09:"#f386a1",base0A:"#ffd204",base0B:"#00853e",base0C:"#85cebc",base0D:"#009ddc",base0E:"#98005d",base0F:"#b06110"},a.exports=l.default},2536:(a,l)=>{l.__esModule=!0,l.default={scheme:"twilight",author:"david hart (http://hart-dev.com)",base00:"#1e1e1e",base01:"#323537",base02:"#464b50",base03:"#5f5a60",base04:"#838184",base05:"#a7a7a7",base06:"#c3c3c3",base07:"#ffffff",base08:"#cf6a4c",base09:"#cda869",base0A:"#f9ee98",base0B:"#8f9d6a",base0C:"#afc4db",base0D:"#7587a6",base0E:"#9b859d",base0F:"#9b703f"},a.exports=l.default},6481:(a,l,u)=>{var d=u(4176),f={};for(var h in d)d.hasOwnProperty(h)&&(f[d[h]]=h);var m=a.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var y in m)if(m.hasOwnProperty(y)){if(!("channels"in m[y]))throw new Error("missing channels property: "+y);if(!("labels"in m[y]))throw new Error("missing channel labels property: "+y);if(m[y].labels.length!==m[y].channels)throw new Error("channel and label counts mismatch: "+y);var g=m[y].channels,w=m[y].labels;delete m[y].channels,delete m[y].labels,Object.defineProperty(m[y],"channels",{value:g}),Object.defineProperty(m[y],"labels",{value:w})}m.rgb.hsl=function(v){var S,C,k=v[0]/255,N=v[1]/255,_=v[2]/255,j=Math.min(k,N,_),T=Math.max(k,N,_),M=T-j;return T===j?S=0:k===T?S=(N-_)/M:N===T?S=2+(_-k)/M:_===T&&(S=4+(k-N)/M),(S=Math.min(60*S,360))<0&&(S+=360),C=(j+T)/2,[S,100*(T===j?0:C<=.5?M/(T+j):M/(2-T-j)),100*C]},m.rgb.hsv=function(v){var S,C,k,N,_,j=v[0]/255,T=v[1]/255,M=v[2]/255,V=Math.max(j,T,M),H=V-Math.min(j,T,M),P=function(F){return(V-F)/6/H+.5};return H===0?N=_=0:(_=H/V,S=P(j),C=P(T),k=P(M),j===V?N=k-C:T===V?N=.3333333333333333+S-k:M===V&&(N=.6666666666666666+C-S),N<0?N+=1:N>1&&(N-=1)),[360*N,100*_,100*V]},m.rgb.hwb=function(v){var S=v[0],C=v[1],k=v[2];return[m.rgb.hsl(v)[0],100*(.00392156862745098*Math.min(S,Math.min(C,k))),100*(k=1-.00392156862745098*Math.max(S,Math.max(C,k)))]},m.rgb.cmyk=function(v){var S,C=v[0]/255,k=v[1]/255,N=v[2]/255;return[100*((1-C-(S=Math.min(1-C,1-k,1-N)))/(1-S)||0),100*((1-k-S)/(1-S)||0),100*((1-N-S)/(1-S)||0),100*S]},m.rgb.keyword=function(v){var S=f[v];if(S)return S;var C,k,N,_=1/0;for(var j in d)if(d.hasOwnProperty(j)){var T=d[j],M=(k=v,N=T,Math.pow(k[0]-N[0],2)+Math.pow(k[1]-N[1],2)+Math.pow(k[2]-N[2],2));M<_&&(_=M,C=j)}return C}
vendor: 6,579 bytes, line 933
933,m.keyword.rgb=function(v){return d[v]},m.rgb.xyz=function(v){var S=v[0]/255,C=v[1]/255,k=v[2]/255;return[100*(.4124*(S=S>.04045?Math.pow((S+.055)/1.055,2.4):S/12.92)+.3576*(C=C>.04045?Math.pow((C+.055)/1.055,2.4):C/12.92)+.1805*(k=k>.04045?Math.pow((k+.055)/1.055,2.4):k/12.92)),100*(.2126*S+.7152*C+.0722*k),100*(.0193*S+.1192*C+.9505*k)]},m.rgb.lab=function(v){var S=m.rgb.xyz(v),C=S[0],k=S[1],N=S[2];return k/=100,N/=108.883,C=(C/=95.047)>.008856?Math.pow(C,.3333333333333333):7.787*C+.13793103448275862,[116*(k=k>.008856?Math.pow(k,.3333333333333333):7.787*k+.13793103448275862)-16,500*(C-k),200*(k-(N=N>.008856?Math.pow(N,.3333333333333333):7.787*N+.13793103448275862))]},m.hsl.rgb=function(v){var S,C,k,N,_,j=v[0]/360,T=v[1]/100,M=v[2]/100;if(T===0)return[_=255*M,_,_];S=2*M-(C=M<.5?M*(1+T):M+T-M*T),N=[0,0,0];for(var V=0;V<3;V++)(k=j+.3333333333333333*-(V-1))<0&&k++,k>1&&k--,_=6*k<1?S+6*(C-S)*k:2*k<1?C:3*k<2?S+(C-S)*(.6666666666666666-k)*6:S,N[V]=255*_;return N},m.hsl.hsv=function(v){var S=v[0],C=v[1]/100,k=v[2]/100,N=C,_=Math.max(k,.01);return C*=(k*=2)<=1?k:2-k,N*=_<=1?_:2-_,[S,100*(k===0?2*N/(_+N):2*C/(k+C)),100*((k+C)/2)]},m.hsv.rgb=function(v){var S=v[0]/60,C=v[1]/100,k=v[2]/100,N=Math.floor(S)%6,_=S-Math.floor(S),j=255*k*(1-C),T=255*k*(1-C*_),M=255*k*(1-C*(1-_));switch(k*=255,N){case 0:return[k,M,j];case 1:return[T,k,j];case 2:return[j,k,M];case 3:return[j,T,k];case 4:return[M,j,k];case 5:return[k,j,T]}},m.hsv.hsl=function(v){var S,C,k,N=v[0],_=v[1]/100,j=v[2]/100,T=Math.max(j,.01);return k=(2-_)*j,C=_*T,[N,100*(C=(C/=(S=(2-_)*T)<=1?S:2-S)||0),100*(k/=2)]},m.hwb.rgb=function(v){var S,C,k,N,_,j,T,M=v[0]/360,V=v[1]/100,H=v[2]/100,P=V+H;switch(P>1&&(V/=P,H/=P),k=6*M-(S=Math.floor(6*M)),1&S&&(k=1-k),N=V+k*((C=1-H)-V),S){default:case 6:case 0:_=C,j=N,T=V;break;case 1:_=N,j=C,T=V;break;case 2:_=V,j=C,T=N;break;case 3:_=V,j=N,T=C;break;case 4:_=N,j=V,T=C;break;case 5:_=C,j=V,T=N}return[255*_,255*j,255*T]},m.cmyk.rgb=function(v){var S=v[0]/100,C=v[1]/100,k=v[2]/100,N=v[3]/100;return[255*(1-Math.min(1,S*(1-N)+N)),255*(1-Math.min(1,C*(1-N)+N)),255*(1-Math.min(1,k*(1-N)+N))]},m.xyz.rgb=function(v){var S,C,k,N=v[0]/100,_=v[1]/100,j=v[2]/100;return C=-.9689*N+1.8758*_+.0415*j,k=.0557*N+-.204*_+1.057*j,S=(S=3.2406*N+-1.5372*_+-.4986*j)>.0031308?1.055*Math.pow(S,.4166666666666667)-.055:12.92*S,C=C>.0031308?1.055*Math.pow(C,.4166666666666667)-.055:12.92*C,k=k>.0031308?1.055*Math.pow(k,.4166666666666667)-.055:12.92*k,[255*(S=Math.min(Math.max(0,S),1)),255*(C=Math.min(Math.max(0,C),1)),255*(k=Math.min(Math.max(0,k),1))]},m.xyz.lab=function(v){var S=v[0],C=v[1],k=v[2];return C/=100,k/=108.883,S=(S/=95.047)>.008856?Math.pow(S,.3333333333333333):7.787*S+.13793103448275862,[116*(C=C>.008856?Math.pow(C,.3333333333333333):7.787*C+.13793103448275862)-16,500*(S-C),200*(C-(k=k>.008856?Math.pow(k,.3333333333333333):7.787*k+.13793103448275862))]},m.lab.xyz=function(v){var S,C,k,N=v[0];S=v[1]/500+(C=(N+16)/116),k=C-v[2]/200;var _=Math.pow(C,3),j=Math.pow(S,3),T=Math.pow(k,3);return C=_>.008856?_:(C-.13793103448275862)/7.787,S=j>.008856?j:(S-.13793103448275862)/7.787,k=T>.008856?T:(k-.13793103448275862)/7.787,[S*=95.047,C*=100,k*=108.883]},m.lab.lch=function(v){var S,C=v[0],k=v[1],N=v[2];return(S=360*Math.atan2(N,k)/2/Math.PI)<0&&(S+=360),[C,Math.sqrt(k*k+N*N),S]},m.lch.lab=function(v){var S,C=v[0],k=v[1];return S=v[2]/360*2*Math.PI,[C,k*Math.cos(S),k*Math.sin(S)]},m.rgb.ansi16=function(v){var S=v[0],C=v[1],k=v[2],N=1 in arguments?arguments[1]:m.rgb.hsv(v)[2];if((N=Math.round(N/50))===0)return 30;var _=30+(Math.round(k/255)<<2|Math.round(C/255)<<1|Math.round(S/255));return N===2&&(_+=60),_},m.hsv.ansi16=function(v){return m.rgb.ansi16(m.hsv.rgb(v),v[2])},m.rgb.ansi256=function(v){var S=v[0],C=v[1],k=v[2];return S===C&&C===k?S<8?16:S>248?231:Math.round((S-8)/247*24)+232:16+36*Math.round(S/255*5)+6*Math.round(C/255*5)+Math.round(k/255*5)},m.ansi16.rgb=function(v){var S=v%10;if(S===0||S===7)return v>50&&(S+=3.5),[S=S/10.5*255,S,S];var C=.5*(1+~~(v>50));return[(1&S)*C*255,(S>>1&1)*C*255,(S>>2&1)*C*255]},m.ansi256.rgb=function(v){if(v>=232){var S=10*(v-232)+8;return[S,S,S]}var C;return v-=16,[Math.floor(v/36)/5*255,Math.floor((C=v%36)/6)/5*255,C%6/5*255]},m.rgb.hex=function(v){var S=(((255&Math.round(v[0]))<<16)+((255&Math.round(v[1]))<<8)+(255&Math.round(v[2]))).toString(16).toUpperCase();return"000000".substring(S.length)+S},m.hex.rgb=function(v){var S=v.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!S)return[0,0,0];var C=S[0];S[0].length===3&&(C=C.split("").map(function(N){return N+N}).join(""));var k=parseInt(C,16);return[k>>16&255,k>>8&255,255&k]},m.rgb.hcg=function(v){var S,C=v[0]/255,k=v[1]/255,N=v[2]/255,_=Math.max(Math.max(C,k),N),j=Math.min(Math.min(C,k),N),T=_-j;return S=T<=0?0:_===C?(k-N)/T%6:_===k?2+(N-C)/T:4+(C-k)/T+4,S/=6,[360*(S%=1),100*T,100*(T<1?j/(1-T):0)]},m.hsl.hcg=function(v){var S=v[1]/100,C=v[2]/100,k=1,N=0;return(k=C<.5?2*S*C:2*S*(1-C))<1&&(N=(C-.5*k)/(1-k)),[v[0],100*k,100*N]},m.hsv.hcg=function(v){var S=v[1]/100,C=v[2]/100,k=S*C,N=0;return k<1&&(N=(C-k)/(1-k)),[v[0],100*k,100*N]},m.hcg.rgb=function(v){var S=v[0]/360,C=v[1]/100,k=v[2]/100;if(C===0)return[255*k,255*k,255*k];var N,_=[0,0,0],j=S%1*6,T=j%1,M=1-T;switch(Math.floor(j)){case 0:_[0]=1,_[1]=T,_[2]=0;break;case 1:_[0]=M,_[1]=1,_[2]=0;break;case 2:_[0]=0,_[1]=1,_[2]=T;break;case 3:_[0]=0,_[1]=M,_[2]=1;break;case 4:_[0]=T,_[1]=0,_[2]=1;break;default:_[0]=1,_[1]=0,_[2]=M}return N=(1-C)*k,[255*(C*_[0]+N),255*(C*_[1]+N),255*(C*_[2]+N)]},m.hcg.hsv=function(v){var S=v[1]/100,C=S+v[2]/100*(1-S),k=0;return C>0&&(k=S/C),[v[0],100*k,100*C]},m.hcg.hsl=function(v){var S=v[1]/100,C=v[2]/100*(1-S)+.5*S,k=0;return C>0&&C<.5?k=S/(2*C):C>=.5&&C<1&&(k=S/(2*(1-C))),[v[0],100*k,100*C]},m.hcg.hwb=function(v){var S=v[1]/100,C=S+v[2]/100*(1-S);return[v[0],100*(C-S),100*(1-C)]},m.hwb.hcg=function(v){var S=v[1]/100,C=1-v[2]/100,k=C-S,N=0;return k<1&&(N=(C-k)/(1-k)),[v[0],100*k,100*N]},m.apple.rgb=function(v){return[v[0]/65535*255,v[1]/65535*255,v[2]/65535*255]},m.rgb.apple=function(v){return[v[0]/255*65535,v[1]/255*65535,v[2]/255*65535]},m.gray.rgb=function(v){return[v[0]/100*255,v[0]/100*255,v[0]/100*255]},m.gray.hsl=m.gray.hsv=function(v){return[0,0,v[0]]},m.gray.hwb=function(v){return[0,100,v[0]]},m.gray.cmyk=function(v){return[0,0,0,v[0]]},m.gray.lab=function(v){return[v[0],0,0]},m.gray.hex=function(v){var S=255&Math.round(v[0]/100*255),C=((S<<16)+(S<<8)+S).toString(16).toUpperCase();return"000000".substring(C.length)+C},m.rgb.gray=function(v){return[(v[0]+v[1]+v[2])/3/255*100]}},4732:(a,l,u)=>{var d=u(6481),f=u(1157),h={};
933Object.keys(d).forEach(function(m){h[m]={},Object.defineProperty(h[m],"channels",{value:d[m].channels}),Object.defineProperty(h[m],"labels",{value:d[m].labels});var y=f(m);Object.keys(y).forEach(function(g){var w=y[g];h[m][g]=function(v){var S=function(C){if(C==null)return C;arguments.length>1&&(C=Array.prototype.slice.call(arguments));var k=v(C);if(typeof k=="object")for(var N=k.length,_=0;_<N;_++)k[_]=Math.round(k[_]);return k};return"conversion"in v&&(S.conversion=v.conversion),S}(w),h[m][g].raw=function(v){var S=function(C){return C==null?C:(arguments.length>1&&(C=Array.prototype.slice.call(arguments)),v(C))};return"conversion"in v&&(S.conversion=v.conversion),S}(w)})}),a.exports=h},1157:(a,l,u)=>{var d=u(6481);function f(y){var g=function(){for(var j={},T=Object.keys(d),M=T.length,V=0;V<M;V++)j[T[V]]={distance:-1,parent:null};return j}(),w=[y];for(g[y].distance=0;w.length;)for(var v=w.pop(),S=Object.keys(d[v]),C=S.length,k=0;k<C;k++){var N=S[k],_=g[N];_.distance===-1&&(_.distance=g[v].distance+1,_.parent=v,w.unshift(N))}return g}function h(y,g){return function(w){return g(y(w))}}function m(y,g){for(var w=[g[y].parent,y],v=d[g[y].parent][y],S=g[y].parent;g[S].parent;)w.unshift(g[S].parent),v=h(d[g[S].parent][S],v),S=g[S].parent;return v.conversion=w,v}a.exports=function(y){for(var g=f(y),w={},v=Object.keys(g),S=v.length,C=0;C<S;C++){var k=v[C];g[k].parent!==null&&(w[k]=m(k,g))}return w}},4176:a=>{a.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87
vendor: 6,297 bytes, line 933
933],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},4877:a=>{a.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},6138:(a,l,u)=>{var d=u(4877),f=u(301),h=Object.hasOwnProperty,m=Object.create(null);for(var y in d)h.call(d,y)&&(m[d[y]]=y);var g=a.exports={to:{},get:{}};function w(S,C,k){return Math.min(Math.max(C,S),k)}function v(S){var C=Math.round(S).toString(16).toUpperCase();return C.length<2?"0"+C:C}g.get=function(S){var C,k;switch(S.substring(0,3).toLowerCase()){case"hsl":C=g.get.hsl(S),k="hsl";break;case"hwb":C=g.get.hwb(S),k="hwb";break;default:C=g.get.rgb(S),k="rgb"}return C?{model:k,value:C}:null},g.get.rgb=function(S){if(!S)return null;var C,k,N,_=[0,0,0,1];if(C=S.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(N=C[2],C=C[1],k=0;k<3;k++){var j=2*k;_[k]=parseInt(C.slice(j,j+2),16)}N&&(_[3]=parseInt(N,16)/255)}else if(C=S.match(/^#([a-f0-9]{3,4})$/i)){for(N=(C=C[1])[3],k=0;k<3;k++)_[k]=parseInt(C[k]+C[k],16);N&&(_[3]=parseInt(N+N,16)/255)}else if(C=S.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(k=0;k<3;k++)_[k]=parseInt(C[k+1],0);C[4]&&(C[5]?_[3]=.01*parseFloat(C[4]):_[3]=parseFloat(C[4]))}else{if(!(C=S.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(C=S.match(/^(\w+)$/))?C[1]==="transparent"?[0,0,0,0]:h.call(d,C[1])?((_=d[C[1]])[3]=1,_):null:null;for(k=0;k<3;k++)_[k]=Math.round(2.55*parseFloat(C[k+1]));C[4]&&(C[5]?_[3]=.01*parseFloat(C[4]):_[3]=parseFloat(C[4]))}for(k=0;k<3;k++)_[k]=w(_[k],0,255);return _[3]=w(_[3],0,1),_},g.get.hsl=function(S){if(!S)return null;var C=S.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(C){var k=parseFloat(C[4]);return[(parseFloat(C[1])%360+360)%360,w(parseFloat(C[2]),0,100),w(parseFloat(C[3]),0,100),w(isNaN(k)?1:k,0,1)]}return null},g.get.hwb=function(S){if(!S)return null;var C=S.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(C){var k=parseFloat(C[4]);return[(parseFloat(C[1])%360+360)%360,w(parseFloat(C[2]),0,100),w(parseFloat(C[3]),0,100),w(isNaN(k)?1:k,0,1)]}return null},g.to.hex=function(){var S=f(arguments);return"#"+v(S[0])+v(S[1])+v(S[2])+(S[3]<1?v(Math.round(255*S[3])):"")},g.to.rgb=function(){var S=f(arguments);
933return S.length<4||S[3]===1?"rgb("+Math.round(S[0])+", "+Math.round(S[1])+", "+Math.round(S[2])+")":"rgba("+Math.round(S[0])+", "+Math.round(S[1])+", "+Math.round(S[2])+", "+S[3]+")"},g.to.rgb.percent=function(){var S=f(arguments),C=Math.round(S[0]/255*100),k=Math.round(S[1]/255*100),N=Math.round(S[2]/255*100);return S.length<4||S[3]===1?"rgb("+C+"%, "+k+"%, "+N+"%)":"rgba("+C+"%, "+k+"%, "+N+"%, "+S[3]+")"},g.to.hsl=function(){var S=f(arguments);return S.length<4||S[3]===1?"hsl("+S[0]+", "+S[1]+"%, "+S[2]+"%)":"hsla("+S[0]+", "+S[1]+"%, "+S[2]+"%, "+S[3]+")"},g.to.hwb=function(){var S=f(arguments),C="";return S.length>=4&&S[3]!==1&&(C=", "+S[3]),"hwb("+S[0]+", "+S[1]+"%, "+S[2]+"%"+C+")"},g.to.keyword=function(S){return m[S.slice(0,3)]}},3639:(a,l,u)=>{var d=u(6138),f=u(4732),h=[].slice,m=["keyword","gray","hex"],y={};Object.keys(f).forEach(function(k){y[h.call(f[k].labels).sort().join("")]=k});var g={};function w(k,N){if(!(this instanceof w))return new w(k,N);if(N&&N in m&&(N=null),N&&!(N in f))throw new Error("Unknown model: "+N);var _,j;if(k==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(k instanceof w)this.model=k.model,this.color=k.color.slice(),this.valpha=k.valpha;else if(typeof k=="string"){var T=d.get(k);if(T===null)throw new Error("Unable to parse color from string: "+k);this.model=T.model,j=f[this.model].channels,this.color=T.value.slice(0,j),this.valpha=typeof T.value[j]=="number"?T.value[j]:1}else if(k.length){this.model=N||"rgb",j=f[this.model].channels;var M=h.call(k,0,j);this.color=C(M,j),this.valpha=typeof k[j]=="number"?k[j]:1}else if(typeof k=="number")k&=16777215,this.model="rgb",this.color=[k>>16&255,k>>8&255,255&k],this.valpha=1;else{this.valpha=1;var V=Object.keys(k);"alpha"in k&&(V.splice(V.indexOf("alpha"),1),this.valpha=typeof k.alpha=="number"?k.alpha:0);var H=V.sort().join("");if(!(H in y))throw new Error("Unable to parse color from object: "+JSON.stringify(k));this.model=y[H];var P=f[this.model].labels,F=[];for(_=0;_<P.length;_++)F.push(k[P[_]]);this.color=C(F)}if(g[this.model])for(j=f[this.model].channels,_=0;_<j;_++){var I=g[this.model][_];I&&(this.color[_]=I(this.color[_]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function v(k,N,_){return(k=Array.isArray(k)?k:[k]).forEach(function(j){(g[j]||(g[j]=[]))[N]=_}),k=k[0],function(j){var T;return arguments.length?(_&&(j=_(j)),(T=this[k]()).color[N]=j,T):(T=this[k]().color[N],_&&(T=_(T)),T)}}function S(k){return function(N){return Math.max(0,Math.min(k,N))}}function C(k,N){for(var _=0;_<N;_++)typeof k[_]!="number"&&(k[_]=0);return k}w.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(k){var N=this.model in d.to?this:this.rgb(),_=(N=N.round(typeof k=="number"?k:1)).valpha===1?N.color:N.color.concat(this.valpha);return d.to[N.model](_)},percentString:function(k){var N=this.rgb().round(typeof k=="number"?k:1),_=N.valpha===1?N.color:N.color.concat(this.valpha);return d.to.rgb.percent(_)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var k={},N=f[this.model].channels,_=f[this.model].labels,j=0;j<N;j++)k[_[j]]=this.color[j];return this.valpha!==1&&(k.alpha=this.valpha),k},unitArray:function(){var k=this.rgb().color;return k[0]/=255,k[1]/=255,k[2]/=255,this.valpha!==1&&k.push(this.valpha),k},unitObject:function(){var k=this.rgb().object();return k.r/=255,k.g/=255,k.b/=255,this.valpha!==1&&(k.alpha=this.valpha),k},round:function(k){return k=Math.max(k||0,0),new w(this.color.map(function(N){return function(_){return function(j,T){return Number(j.toFixed(T))}(_,N)}}(k)).concat(this.valpha),this.model)},alpha:function(k){return arguments.length?new w(this.color.concat(Math.max(0,Math.min(1,k))),this.model):this.valpha},red:v("rgb",0,S(255)),green:v("rgb",1,S(255)),blue:v("rgb",2,S(255)),hue:v(["hsl","hsv","hsl","hwb","hcg"],0,function(k){return(k%360+360)%360}),saturationl:v("hsl",1,S(100)),lightness:v("hsl",2,S(100)),saturationv:v("hsv",1,S(100)),value:v("hsv",2,S(100)),chroma:v("hcg",1,S(100)),gray:v("hcg",2,S(100)),white:v("hwb",1,S(100)),wblack:v("hwb",2,S(100)),cyan:v("cmyk",0,S(100)),magenta:v("cmyk",1,S(100)),yellow:v("cmyk",2,S(100)),black:v("cmyk",3,S(100)),x:v("xyz",0,S(100)),y:v("xyz",1,S(100)),z:v("xyz",2,S(100)),l:v("lab",0,S(100)),a:v("lab",1),b:v("lab",2),keyword:function(k){return arguments.length?new w(k):f[this.model].keyword(this.color)},hex:function(k){return arguments.length?new w(k):d.to.hex(this.rgb().round().color)},rgbNumber:function(){var k=this.rgb().color;return(255&k[0])<<16|(255&k[1])<<8|255&k[2]},luminosity:function(){for(var k=this.rgb().color,N=[],_=0;_<k.length;_++){var j=k[_]/255;N[_]=j<=.03928?j/12.92:Math.pow((j+.055)/1.055,2.4)}return .2126*N[0]+.7152*N[1]+.0722*N[2]},contrast:function(k){var N=this.luminosity(),_=k.luminosity();return N>_?(N+.05)/(_+.05):(_+.05)/(N+.05)},level:function(k){var N=this.contrast(k);return N>=7.1?"AAA":N>=4.5?"AA":""},isDark:function(){var k=this.rgb().color;return(299*k[0]+587*k[1]+114*k[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var k=this.rgb(),N=0;N<3;N++)k.color[N]=255-k.color[N];return k},lighten:function(k){var N=this.hsl();return N.color[2]+=N.color[2]*k,N},darken:function(k){var N=this.hsl();return N.color[2]-=N.color[2]*k,N},saturate:function(k){var N=this.hsl();return N.color[1]+=N.color[1]*k,N},desaturate:function(k){var N=this.hsl();return N.color[1]-=N.color[1]*k,N},whiten:function(k){var N=this.hwb();return N.color[1]+=N.color[1]*k,N},blacken:function(k){var N=this.hwb();return N.color[2]+=N.color[2]*k,N},grayscale:function(){var k=this.rgb().color,N=.3*k[0]+.59*k[1]+.11*k[2];return w.rgb(N,N,N)},fade:function(k){return this.alpha(this.valpha-this.valpha*k)},opaquer:function(k){return this.alpha(this.valpha+this.valpha*k)},rotate:function(k){var N=this.hsl(),_=N.color[0];return _=(_=(_+k)%360)<0?360+_:_,N.color[0]=_,N},mix:function(k,N){if(!k||!k.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof k);var _=k.rgb(),j=this.rgb(),T=N===void 0?.5:N,M=2*T-1,V=_.alpha()-j.alpha(),H=((M*V==-1?M:(M+V)/(1+M*V))+1)/2,P=1-H;return w.rgb(H*_.red()+P*j.red(),H*_.green()+P*j.green(),H*_.blue()+P*j.blue(),_.alpha()*T+j.alpha()*(1-T))}},Object.keys(f).forEach(function(k){if(m.indexOf(k)===-1){var N=f[k].channels;w.prototype[k]=function(){if(this.model===k)return new w(this);if(arguments.length)return new w(arguments,k);var _,j=typeof arguments[N]=="number"?N:this.valpha;return new w((_=f[this.model][k].raw(this.color),Array.isArray(_)?_:[_]).concat(j),k)},w[k]=function(_){return typeof _=="number"&&(_=C(h.call(arguments),N)),new w(_,k)}}}),a.exports=w},9784:a=>{var l,u=typeof Reflect=="object"?Reflect:null,d=u&&typeof u.apply=="function"?u.apply:function(j,T,M){return Function.prototype.apply.call(j,T,M)};l=u&&typeof u.ownKeys=="function"?u.ownKeys:Object.getOwnPropertySymbols?function(j){return Object.getOwnPropertyNames(j).concat(Object.getOwnPropertySymbols(j))}:function(j){return Object.getOwnPropertyNames(j)};var f=Number.isNaN||function(j){return j!=j};function h(){h.init.call(this)}a.exports=h,a.exports.once=function(j,T){return new Promise(function(M,V){function H(F){j.removeListener(T,P),V(F)}function P(){typeof j.removeListener=="function"&&j.removeListener("error",H),M([].slice.call(arguments))}_(j,T,P,{once:!0}),T!=="error"&&function(F,I,R){typeof F.on=="function"&&_(F,"error",I,R)}(j,H,{once:!0})})},h.EventEmitter=h,h.prototype._events=void 0,h.prototype._eventsCount=0,h.prototype._maxListeners=void 0;var m=10;function y(j){if(typeof j!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof j)}function g(j){return j._maxListeners===void 0?h.defaultMaxListeners:j._maxListeners}function w(j,T,M,V){var H,P,F,I;if(y(M),(P=j._events)===void 0?(P=j._events=Object.create(null),j._eventsCount=0):(P.newListener!==void 0&&(j.emit("newListener",T,M.listener?M.listener:M),P=j._events),F=P[T]),F===void 0)F=P[T]=M,++j._eventsCount;else if(typeof F=="function"?F=P[T]=V?[M,F]:[F,M]:V?F.unshift(M):F.push(M),(H=g(j))>0&&F.length>H&&!F.warned){F.warned=!0;var R=new Error("Possible EventEmitter memory leak detected. "+F.length+" "+String(T)+" listeners added. Use emitter.setMaxListeners() to increase limit");R.name="MaxListenersExceededWarning",R.emitter=j,R.type=T,R.count=F.length,I=R,console&&console.warn&&console.warn(I)}return j}function v(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(j,T,M){var V={fired:!1,wrapFn:void 0,target:j,type:T,listener:M},H=v.bind(V);return H.listener=M,V.wrapFn=H,H}function C(j,T,M){var V=j._events;if(V===void 0)return[];var H=V[T];return H===void 0?[]:typeof H=="function"?M?[H.listener||H]:[H]:M?function(P){for(var F=new Array(P.length),I=0;I<F.length;++I)F[I]=P[I].listener||P[I];return F}(H):N(H,H.length)}function k(j){var T=this._events;if(T!==void 0){var M=T[j];if(typeof M=="function")return 1;if(M!==void 0)return M.length}return 0}function N(j,T){for(var M=new Array(T),V=0;V<T;++V)M[V]=j[V];return M}function _(j,T,M,V){if(typeof j.on=="function")V.once?j.once(T,M):j.on(T,M);else{if(typeof j.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof j);j.addEventListener(T,function H(P){V.once&&j.removeEventListener(T,H),M(P)})}}Object.defineProperty(h,"defaultMaxListeners",{enumerable:!0,get:function(){return m},set:function(j){if(typeof j!="number"||j<0||f(j))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+j+".");m=j}}),h.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},h.prototype.setMaxListeners=function(j){if(typeof j!="number"||j<0||f(j))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+j+".");return this._maxListeners=j,this},h.prototype.getMaxListeners=function(){return g(this)},h.prototype.emit=function(j){for(var T=[],M=1;M<arguments.length;M++)T.push(arguments[M]);var V=j==="error",H=this._events;if(H!==void 0)V=V&&H.error===void 0;else if(!V)return!1;if(V){var P;if(T.length>0&&(P=T[0]),P instanceof Error)throw P;var F=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw F.context=P,F}var I=H[j];if(I===void 0)return!1;if(typeof I=="function")d(I,this,T);else{var R=I.length,U=N(I,R);for(M=0;M<R;++M)d(U[M],this,T)}return!0},h.prototype.addListener=function(j,T){return w(this,j,T,!1)},h.prototype.on=h.prototype.addListener,h.prototype.prependListener=function(j,T){return w(this,j,T,!0)},h.prototype.once=function(j,T){return y(T),this.on(j,S(this,j,T)),this},h.prototype.prependOnceListener=function(j,T){return y(T),this.prependListener(j,S(this,j,T)),this},h.prototype.removeListener=function(j,T){var M,V,H,P,F;if(y(T),(V=this._events)===void 0)return this;if((M=V[j])===void 0)return this;if(M===T||M.listener===T)--this._eventsCount==0?this._events=Object.create(null):(delete V[j],V.removeListener&&this.emit
933("removeListener",j,M.listener||T));else if(typeof M!="function"){for(H=-1,P=M.length-1;P>=0;P--)if(M[P]===T||M[P].listener===T){F=M[P].listener,H=P;break}if(H<0)return this;H===0?M.shift():function(I,R){for(;R+1<I.length;R++)I[R]=I[R+1];I.pop()}(M,H),M.length===1&&(V[j]=M[0]),V.removeListener!==void 0&&this.emit("removeListener",j,F||T)}return this},h.prototype.off=h.prototype.removeListener,h.prototype.removeAllListeners=function(j){var T,M,V;if((M=this._events)===void 0)return this;if(M.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):M[j]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete M[j]),this;if(arguments.length===0){var H,P=Object.keys(M);for(V=0;V<P.length;++V)(H=P[V])!=="removeListener"&&this.removeAllListeners(H);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(T=M[j])=="function")this.removeListener(j,T);else if(T!==void 0)for(V=T.length-1;V>=0;V--)this.removeListener(j,T[V]);return this},h.prototype.listeners=function(j){return C(this,j,!0)},h.prototype.rawListeners=function(j){return C(this,j,!1)},h.listenerCount=function(j,T){return typeof j.listenerCount=="function"?j.listenerCount(T):k.call(j,T)},h.prototype.listenerCount=k,h.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]}},8336:a=>{a.exports=function(l){return!(!l||typeof l=="string")&&(l instanceof Array||Array.isArray(l)||l.length>=0&&(l.splice instanceof Function||Object.getOwnPropertyDescriptor(l,l.length-1)&&l.constructor.name!=="String"))}},3989:(a,l,u)=>{var d="__lodash_placeholder__",f=32,h=1/0,m=NaN,y=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",f],["partialRight",64],["rearg",256]],g="[object Function]",w="[object GeneratorFunction]",v=/^\s+|\s+$/g,S=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,C=/\{\n\/\* \[wrapped with (.+)\] \*/,k=/,? & /,N=/^[-+]0x[0-9a-f]+$/i,_=/^0b[01]+$/i,j=/^\[object .+?Constructor\]$/,T=/^0o[0-7]+$/i,M=/^(?:0|[1-9]\d*)$/,V=parseInt,H=typeof u.g=="object"&&u.g&&u.g.Object===Object&&u.g,P=typeof self=="object"&&self&&self.Object===Object&&self,F=H||P||Function("return this")();function I(ce,se,ye){switch(ye.length){case 0:return ce.call(se);case 1:return ce.call(se,ye[0]);case 2:return ce.call(se,ye[0],ye[1]);case 3:return ce.call(se,ye[0],ye[1],ye[2])}return ce.apply(se,ye)}function R(ce,se){return!!(ce&&ce.length)&&function(ye,ke,ze){if(ke!=ke)return function(Ze,_t,tt,gt){for(var dt=Ze.length,wt=tt+-1;++wt<dt;)if(_t(Ze[wt],wt,Ze))return wt;return-1}(ye,U,ze);for(var qe=ze-1,ot=ye.length;++qe<ot;)if(ye[qe]===ke)return qe;return-1}(ce,se,0)>-1}function U(ce){return ce!=ce}function A(ce,se){for(var ye=-1,ke=ce.length,ze=0,qe=[];++ye<ke;){var ot=ce[ye];ot!==se&&ot!==d||(ce[ye]=d,qe[ze++]=ye)}return qe}var W,D,B,L=Function.prototype,$=Object.prototype,q=F["__core-js_shared__"],Z=(W=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+W:"",ie=L.toString,ge=$.hasOwnProperty,re=$.toString,Y=RegExp("^"+ie.call(ge).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ne=Object.create,be=Math.max,we=Math.min,te=(D=Q(Object,"defineProperty"),(B=Q.name)&&B.length>2?D:void 0);function fe(ce){if(!ve(ce)||function(ye){return!!Z&&Z in ye}(ce))return!1;var se=function(ye){var ke=ve(ye)?re.call(ye):"";return ke==g||ke==w}(ce)||function(ye){var ke=!1;if(ye!=null&&typeof ye.toString!="function")try{ke=!!(ye+"")}catch{}return ke}(ce)?Y:j;return se.test(function(ye){if(ye!=null){try{return ie.call(ye)}catch{}try{return ye+""}catch{}}return""}(ce))}function O(ce){return function(){var se=arguments;switch(se.length){case 0:return new ce;case 1:return new ce(se[0]);case 2:return new ce(se[0],se[1]);case 3:return new ce(se[0],se[1],se[2]);case 4:return new ce(se[0],se[1],se[2],se[3]);case 5:return new ce(se[0],se[1],se[2],se[3],se[4]);case 6:return new ce(se[0],se[1],se[2],se[3],se[4],se[5]);case 7:return new ce(se[0],se[1],se[2],se[3],se[4],se[5],se[6])}var ye,ke=ve(ye=ce.prototype)?ne(ye):{},ze=ce.apply(ke,se);return ve(ze)?ze:ke}}function pe(ce,se,ye,ke,ze,qe,ot,Ze,_t,tt){var gt=128&se,dt=1&se,wt=2&se,Dt=24&se,Kt=512&se,rn=wt?void 0:O(ce);return function pn(){for(var cn=arguments.length,kt=Array(cn),rt=cn;rt--;)kt[rt]=arguments[rt];if(Dt)var Tt=oe(pn),Mt=function(Lt,$t){for(var Qt=Lt.length,Ye=0;Qt--;)Lt[Qt]===$t&&Ye++;return Ye}(kt,Tt);if(ke&&(kt=function(Lt,$t,Qt,Ye){for(var bt=-1,Ie=Lt.length,it=Qt.length,ct=-1,Ut=$t.length,Et=be(Ie-it,0),yn=Array(Ut+Et),nn=!Ye;++ct<Ut;)yn[ct]=$t[ct];for(;++bt<it;)(nn||bt<Ie)&&(yn[Qt[bt]]=Lt[bt]);for(;Et--;
933)yn[ct++]=Lt[bt++];return yn}(kt,ke,ze,Dt)),qe&&(kt=function(Lt,$t,Qt,Ye){for(var bt=-1,Ie=Lt.length,it=-1,ct=Qt.length,Ut=-1,Et=$t.length,yn=be(Ie-ct,0),nn=Array(yn+Et),rr=!Ye;++bt<yn;)nn[bt]=Lt[bt];for(var xn=bt;++Ut<Et;)nn[xn+Ut]=$t[Ut];for(;++it<ct;)(rr||bt<Ie)&&(nn[xn+Qt[it]]=Lt[bt++]);return nn}(kt,qe,ot,Dt)),cn-=Mt,Dt&&cn<tt){var Rt=A(kt,Tt);return he(ce,se,pe,pn.placeholder,ye,kt,Rt,Ze,_t,tt-cn)}var Ct=dt?ye:this,Gt=wt?Ct[ce]:ce;return cn=kt.length,Ze?kt=function(Lt,$t){for(var Qt=Lt.length,Ye=we($t.length,Qt),bt=function(it,ct){var Ut=-1,Et=it.length;for(ct||(ct=Array(Et));++Ut<Et;)ct[Ut]=it[Ut];return ct}(Lt);Ye--;){var Ie=$t[Ye];Lt[Ye]=Ce(Ie,Qt)?bt[Ie]:void 0}return Lt}(kt,Ze):Kt&&cn>1&&kt.reverse(),gt&&_t<cn&&(kt.length=_t),this&&this!==F&&this instanceof pn&&(Gt=rn||O(Gt)),Gt.apply(Ct,kt)}}function he(ce,se,ye,ke,ze,qe,ot,Ze,_t,tt){var gt=8&se;se|=gt?f:64,4&(se&=~(gt?64:f))||(se&=-4);var dt=ye(ce,se,ze,gt?qe:void 0,gt?ot:void 0,gt?void 0:qe,gt?void 0:ot,Ze,_t,tt);return dt.placeholder=ke,Ae(dt,ce,se)}function le(ce,se,ye,ke,ze,qe,ot,Ze){var _t=2&se;if(!_t&&typeof ce!="function")throw new TypeError("Expected a function");var tt=ke?ke.length:0;if(tt||(se&=-97,ke=ze=void 0),ot=ot===void 0?ot:be(Te(ot),0),Ze=Ze===void 0?Ze:Te(Ze),tt-=ze?ze.length:0,64&se){var gt=ke,dt=ze;ke=ze=void 0}var wt=[ce,se,ye,ke,ze,gt,dt,qe,ot,Ze];if(ce=wt[0],se=wt[1],ye=wt[2],ke=wt[3],ze=wt[4],!(Ze=wt[9]=wt[9]==null?_t?0:ce.length:be(wt[9]-tt,0))&&24&se&&(se&=-25),se&&se!=1)Dt=se==8||se==16?function(Kt,rn,pn){var cn=O(Kt);return function kt(){for(var rt=arguments.length,Tt=Array(rt),Mt=rt,Rt=oe(kt);Mt--;)Tt[Mt]=arguments[Mt];var Ct=rt<3&&Tt[0]!==Rt&&Tt[rt-1]!==Rt?[]:A(Tt,Rt);return(rt-=Ct.length)<pn?he(Kt,rn,pe,kt.placeholder,void 0,Tt,Ct,void 0,void 0,pn-rt):I(this&&this!==F&&this instanceof kt?cn:Kt,this,Tt)}}(ce,se,Ze):se!=f&&se!=33||ze.length?pe.apply(void 0,wt):function(Kt,rn,pn,cn){var kt=1&rn,rt=O(Kt);return function Tt(){for(var Mt=-1,Rt=arguments.length,Ct=-1,Gt=cn.length,Lt=Array(Gt+Rt),$t=this&&this!==F&&this instanceof Tt?rt:Kt;++Ct<Gt;)Lt[Ct]=cn[Ct];for(;Rt--;)Lt[Ct++]=arguments[++Mt];return I($t,kt?pn:this,Lt)}}(ce,se,ye,ke);else var Dt=function(Kt,rn,pn){var cn=1&rn,kt=O(Kt);return function rt(){return(this&&this!==F&&this instanceof rt?kt:Kt).apply(cn?pn:this,arguments)}}(ce,se,ye);return Ae(Dt,ce,se)}function oe(ce){return ce.placeholder}function Q(ce,se){var ye=function(ke,ze){return ke==null?void 0:ke[ze]}(ce,se);return fe(ye)?ye:void 0}function de(ce){var se=ce.match(C);return se?se[1].split(k):[]}function Ne(ce,se){var ye=se.length,ke=ye-1;return se[ke]=(ye>1?"& ":"")+se[ke],se=se.join(ye>2?", ":" "),ce.replace(S,`{ 934/* [wrapped with `+se+`] */ 935`)}function Ce(ce,se){return!!(se=se??9007199254740991)&&(typeof ce=="number"||M.test(ce))&&ce>-1&&ce%1==0&&ce<se}var Ae=te?function(ce,se,ye){var ke,ze=se+"";return te(ce,"toString",{configurable:!0,enumerable:!1,value:(ke=Ne(ze,Ue(de(ze),ye)),function(){return ke})})}:function(ce){return ce};function Ue(ce,se){return function(ye,ke){for(var ze=-1,qe=ye?ye.length:0;++ze<qe&&ke(ye[ze],ze,ye)!==!1;);}(y,function(ye){var ke="_."+ye[0];se&ye[1]&&!R(ce,ke)&&ce.push(ke)}),ce.sort()}function Se(ce,se,ye){var ke=le(ce,8,void 0,void 0,void 0,void 0,void 0,se=ye?void 0:se);return ke.placeholder=Se.placeholder,ke}function ve(ce){var se=typeof ce;return!!ce&&(se=="object"||se=="function")}function je(ce){return ce?(ce=function(se){if(typeof se=="number")return se;if(function(ze){return typeof ze=="symbol"||function(qe){return!!qe&&typeof qe=="object"}(ze)&&re.call(ze)=="[object Symbol]"}(se))return m;if(ve(se)){var ye=typeof se.valueOf=="function"?se.valueOf():se;se=ve(ye)?ye+"":ye}if(typeof se!="string")return se===0?se:+se;se=se.replace(v,"");var ke=_.test(se);return ke||T.test(se)?V(se.slice(2),ke?2:8):N.test(se)?m:+se}(ce))===h||ce===-1/0?17976931348623157e292*(ce<0?-1:1):ce==ce?ce:0:ce===0?ce:0}function Te(ce){var se=je(ce),ye=se%1;return se==se?ye?se-ye:se:0}Se.placeholder={},a.exports=Se},301:(a,l,u)=>{var d=u(8336),f=Array.prototype.concat,h=Array.prototype.slice,m=a.exports=function(y){for(var g=[],w=0,v=y.length;w<v;w++){var S=y[w];d(S)?g=f.call(g,h.call(S)):g.push(S)}return g};m.wrap=function(y){return function(){return y(m(arguments))}}},4119:a=>{a.exports=n}},i={};function s(a){var l=i[a];if(l!==void 0)return l.exports;var u=i[a]={exports:{}};return r[a](u,u.exports,s),u.exports}s.n=a=>{var l=a&&a.__esModule?()=>a.default:()=>a;return s.d(l,{a:l}),l},s.d=(a,l)=>{for(var u in l)s.o(l,u)&&!s.o(a,u)&&Object.defineProperty(a,u,{enumerable:!0,get:l[u]})},s.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}
935}(),s.o=(a,l)=>Object.prototype.hasOwnProperty.call(a,l),s.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var o={};return(()=>{function a(ae){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},a(ae)}function l(ae){var K=function(ee,ue){if(a(ee)!="object"||!ee)return ee;var Ee=ee[Symbol.toPrimitive];if(Ee!==void 0){var Je=Ee.call(ee,ue);if(a(Je)!="object")return Je;throw new TypeError("@@toPrimitive must return a primitive value.")}return(ue==="string"?String:Number)(ee)}(ae,"string");return a(K)=="symbol"?K:K+""}function u(ae,K,ee){return(K=l(K))in ae?Object.defineProperty(ae,K,{value:ee,enumerable:!0,configurable:!0,writable:!0}):ae[K]=ee,ae}function d(ae,K){var ee=Object.keys(ae);if(Object.getOwnPropertySymbols){var ue=Object.getOwnPropertySymbols(ae);K&&(ue=ue.filter(function(Ee){return Object.getOwnPropertyDescriptor(ae,Ee).enumerable})),ee.push.apply(ee,ue)}return ee}function f(ae){for(var K=1;K<arguments.length;K++){var ee=arguments[K]!=null?arguments[K]:{};K%2?d(Object(ee),!0).forEach(function(ue){u(ae,ue,ee[ue])}):Object.getOwnPropertyDescriptors?Object.defineProperties(ae,Object.getOwnPropertyDescriptors(ee)):d(Object(ee)).forEach(function(ue){Object.defineProperty(ae,ue,Object.getOwnPropertyDescriptor(ee,ue))})}return ae}function h(ae,K){if(!(ae instanceof K))throw new TypeError("Cannot call a class as a function")}function m(ae,K){for(var ee=0;ee<K.length;ee++){var ue=K[ee];ue.enumerable=ue.enumerable||!1,ue.configurable=!0,"value"in ue&&(ue.writable=!0),Object.defineProperty(ae,l(ue.key),ue)}}function y(ae,K,ee){return K&&m(ae.prototype,K),ee&&m(ae,ee),Object.defineProperty(ae,"prototype",{writable:!1}),ae}function g(ae){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(K){return K.__proto__||Object.getPrototypeOf(K)},g(ae)}function w(){try{var ae=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(w=function(){return!!ae})()}function v(ae,K){if(K&&(a(K)=="object"||typeof K=="function"))return K;if(K!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(ee){if(ee===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return ee}(ae)}function S(ae,K,ee){return K=g(K),v(ae,w()?Reflect.construct(K,ee||[],g(ae).constructor):K.apply(ae,ee))}function C(ae,K){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ee,ue){return ee.__proto__=ue,ee},C(ae,K)}function k(ae,K){if(typeof K!="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");ae.prototype=Object.create(K&&K.prototype,{constructor:{value:ae,writable:!0,configurable:!0}}),Object.defineProperty(ae,"prototype",{writable:!1}),K&&C(ae,K)}s.r(o),s.d(o,{default:()=>Qe});var N=s(4119),_=s.n(N);function j(){var ae=this.constructor.getDerivedStateFromProps(this.props,this.state);ae!=null&&this.setState(ae)}function T(ae){this.setState((function(K){var ee=this.constructor.getDerivedStateFromProps(ae,K);return ee??null}).bind(this))}function M(ae,K){try{var ee=this.props,ue=this.state;this.props=ae,this.state=K,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(ee,ue)}finally{this.props=ee,this.state=ue}}function V(ae){var K=ae.prototype;if(!K||!K.isReactComponent)throw new Error("Can only polyfill class components");if(typeof ae.getDerivedStateFromProps!="function"&&typeof K.getSnapshotBeforeUpdate!="function")return ae;var ee=null,ue=null,Ee=null;if(typeof K.componentWillMount=="function"?ee="componentWillMount":typeof K.UNSAFE_componentWillMount=="function"&&(ee="UNSAFE_componentWillMount"),typeof K.componentWillReceiveProps=="function"?ue="componentWillReceiveProps":typeof K.UNSAFE_componentWillReceiveProps=="function"&&(ue="UNSAFE_componentWillReceiveProps"),typeof K.componentWillUpdate=="function"?Ee="componentWillUpdate":typeof K.UNSAFE_componentWillUpdate=="function"&&(Ee="UNSAFE_componentWillUpdate"),ee!==null||ue!==null||Ee!==null){var Je=ae.dis
935playName||ae.name,Ke=typeof ae.getDerivedStateFromProps=="function"?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error(`Unsafe legacy lifecycles will not be called for components using new component APIs. 936 937`+Je+" uses "+Ke+" but also contains the following legacy lifecycles:"+(ee!==null?` 938 `+ee:"")+(ue!==null?` 939 `+ue:"")+(Ee!==null?` 940 `+Ee:"")+` 941 942The above lifecycles should be removed. Learn more about this warning here: 943https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof ae.getDerivedStateFromProps=="function"&&(K.componentWillMount=j,K.componentWillReceiveProps=T),typeof K.getSnapshotBeforeUpdate=="function"){if(typeof K.componentDidUpdate!="function")throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");K.componentWillUpdate=M;var Oe=K.componentDidUpdate;K.componentDidUpdate=function(ut,Be,De){var Xe=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:De;Oe.call(this,ut,Be,Xe)}}return ae}function H(ae,K){if(ae==null)return{};var ee={};for(var ue in ae)if({}.hasOwnProperty.call(ae,ue)){if(K.includes(ue))continue;ee[ue]=ae[ue]}return ee}function P(ae,K){if(ae==null)return{};var ee,ue,Ee=H(ae,K);if(Object.getOwnPropertySymbols){var Je=Object.getOwnPropertySymbols(ae);for(ue=0;ue<Je.length;ue++)ee=Je[ue],K.includes(ee)||{}.propertyIsEnumerable.call(ae,ee)&&(Ee[ee]=ae[ee])}return Ee}function F(ae,K){var ee;if(K&&(ae==null||(ee=ae.constructor)===null||ee===void 0?void 0:ee.name)===(K==null?void 0:K.name))return"bigNumber";var ue=function(Ee){return{}.toString.call(Ee).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}(ae);return ue==="number"&&(ue=isNaN(ae)?"nan":(0|ae)!=ae?"float":"integer"),ue}function I(ae){return ae.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/\f/g,"\\f")}j.__suppressDeprecationWarning=!0,T.__suppressDeprecationWarning=!0,M.__suppressDeprecationWarning=!0;var R={scheme:"rjv-default",author:"mac gainor",base00:"rgba(0, 0, 0, 0)",base01:"rgb(245, 245, 245)",base02:"rgb(235, 235, 235)",base03:"#93a1a1",base04:"rgba(0, 0, 0, 0.3)",base05:"#586e75",base06:"#073642",base07:"#002b36",base08:"#d33682",base09:"#cb4b16",base0A:"#dc322f",base0B:"#859900",base0C:"#6c71c4",base0D:"#586e75",base0E:"#2aa198",base0F:"#268bd2"},U={scheme:"rjv-grey",author:"mac gainor",base00:"rgba(1, 1, 1, 0)",base01:"rgba(1, 1, 1, 0.1)",base02:"rgba(0, 0, 0, 0.2)",base03:"rgba(1, 1, 1, 0.3)",base04:"rgba(0, 0, 0, 0.4)",base05:"rgba(1, 1, 1, 0.5)",base06:"rgba(1, 1, 1, 0.6)",base07:"rgba(1, 1, 1, 0.7)",base08:"rgba(1, 1, 1, 0.8)",base09:"rgba(1, 1, 1, 0.8)",base0A:"rgba(1, 1, 1, 0.8)",base0B:"rgba(1, 1, 1, 0.8)",base0C:"rgba(1, 1, 1, 0.8)",base0D:"rgba(1, 1, 1, 0.8)",base0E:"rgba(1, 1, 1, 0.8)",base0F:"rgba(1, 1, 1, 0.8)"};const A={globalFontFamily:"monospace",globalCursor:"default",braceFontWeight:"bold",braceCursor:"pointer",ellipsisFontSize:"18px",ellipsisLineHeight:"10px",ellipsisCursor:"pointer",keyMargin:"0px 5px",keyLetterSpacing:"0.5px",keyFontStyle:"none",keyVerticalAlign:"top",keyOpacity:"0.85",keyOpacityHover:"1",keyValPaddingTop:"3px",keyValPaddingBottom:"3px",keyValPaddingRight:"5px",keyValBorderLeft:"1px solid",keyValBorderHover:"2px solid",pushedContentMarginLeft:"6px",variableValuePaddingRight:"6px",nullFontSize:"11px",nullFontWeight:"bold",nullPadding:"1px 2px",nullBorderRadius:"3px",nanFontSize:"11px",nanFontWeight:"bold",nanPadding:"1px 2px",nanBorderRadius:"3px",undefinedFontSize:"11px",undefinedPadding:"1px 2px",undefinedBorderRadius:"3px",dataTypeFontSize:"11px",dataTypeMarginRight:"4px",datatypeOpacity:"0.8",objectSizeBorderRadius:"3px",objectSizeFontStyle:"italic",objectSizeMargin:"0px 6px 0px 0px",clipboardCursor:"pointer",clipboardCheckMarginLeft:"-12px",metaDataPadding:"0px 0px 0px 10px",arrayGroupMetaPadding:"0px 0px 0px 4px",iconContainerWidth:"17px",tooltipPadding:"4px",editInputMinWidth:"130px",editInputBorderRadius:"2px",editInputPadding:"5px",editInputMarginRight:"4px",editInputFontFamily:"monospace",iconCursor:"pointer",iconFontSize:"15px",iconPaddingRight:"1px",dateValueMarginLeft:"2px",iconMarginRight:"3px",detectedRowPaddingTop:"3px",addKeyCoverBackgroun
943d:"rgba(255, 255, 255, 0.3)",addKeyCoverPosition:"absolute",addKeyCoverPositionPx:"0px",addKeyModalWidth:"200px",addKeyModalMargin:"auto",addKeyModalPadding:"10px",addKeyModalRadius:"3px"};function W(ae,K){(K==null||K>ae.length)&&(K=ae.length);for(var ee=0,ue=Array(K);ee<K;ee++)ue[ee]=ae[ee];return ue}function D(ae,K){if(ae){if(typeof ae=="string")return W(ae,K);var ee={}.toString.call(ae).slice(8,-1);return ee==="Object"&&ae.constructor&&(ee=ae.constructor.name),ee==="Map"||ee==="Set"?Array.from(ae):ee==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ee)?W(ae,K):void 0}}function B(ae,K){return function(ee){if(Array.isArray(ee))return ee}(ae)||function(ee,ue){var Ee=ee==null?null:typeof Symbol<"u"&&ee[Symbol.iterator]||ee["@@iterator"];if(Ee!=null){var Je,Ke,Oe,ut,Be=[],De=!0,Xe=!1;try{if(Oe=(Ee=Ee.call(ee)).next,ue===0){if(Object(Ee)!==Ee)return;De=!1}else for(;!(De=(Je=Oe.call(Ee)).done)&&(Be.push(Je.value),Be.length!==ue);De=!0);}catch(Le){Xe=!0,Ke=Le}finally{try{if(!De&&Ee.return!=null&&(ut=Ee.return(),Object(ut)!==ut))return}finally{if(Xe)throw Ke}}return Be}}(ae,K)||D(ae,K)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 944In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}var L=s(9446),$=s(3639),q=s.n($),Z=s(3989),ie=s.n(Z);function ge(ae,K){var ee=Object.keys(ae);if(Object.getOwnPropertySymbols){var ue=Object.getOwnPropertySymbols(ae);K&&(ue=ue.filter(function(Ee){return Object.getOwnPropertyDescriptor(ae,Ee).enumerable})),ee.push.apply(ee,ue)}return ee}function re(ae){for(var K=1;K<arguments.length;K++){var ee=arguments[K]!=null?arguments[K]:{};K%2?ge(Object(ee),!0).forEach(function(ue){u(ae,ue,ee[ue])}):Object.getOwnPropertyDescriptors?Object.defineProperties(ae,Object.getOwnPropertyDescriptors(ee)):ge(Object(ee)).forEach(function(ue){Object.defineProperty(ae,ue,Object.getOwnPropertyDescriptor(ee,ue))})}return ae}var Y=L.default,ne=Object.keys(Y),be=function(ae){var K,ee=function(ut){var Be=ut[0]/255,De=ut[1]/255,Xe=ut[2]/255;return[.299*Be+.587*De+.114*Xe,-.14713*Be+-.28886*De+.436*Xe,.615*Be+-.51499*De+-.10001*Xe]}(q()(ae).array()),ue=B(ee,3),Ee=ue[0],Je=ue[1],Ke=ue[2],Oe=function(ut){var Be,De,Xe,Le=ut[0],He=ut[1],mt=ut[2];return Be=1*Le+0*He+1.13983*mt,De=1*Le+-.39465*He+-.5806*mt,Xe=1*Le+2.02311*He+0*mt,[255*(Be=Math.min(Math.max(0,Be),1)),255*(De=Math.min(Math.max(0,De),1)),255*(Xe=Math.min(Math.max(0,Xe),1))]}([(K=Ee,K<.25?1:K<.5?.9-K:1.1-K),Je,Ke]);return q().rgb(Oe).hex()},we=function(ae){return function(K){return{className:[K.className,ae.className].filter(Boolean).join(" "),style:re(re({},K.style||{}),ae.style||{})}}},te=function(ae,K){var ee=Object.keys(K);for(var ue in ae)ee.indexOf(ue)===-1&&ee.push(ue);return ee.reduce(function(Ee,Je){return Ee[Je]=function(Ke,Oe){if(Ke===void 0)return Oe;if(Oe===void 0)return Ke;var ut=a(Ke),Be=a(Oe);switch(ut){case"string":switch(Be){case"string":return[Oe,Ke].filter(Boolean).join(" ");case"object":return we({className:Ke,style:Oe});case"function":return function(De){for(var Xe=arguments.length,Le=new Array(Xe>1?Xe-1:0),He=1;He<Xe;He++)Le[He-1]=arguments[He];return we({className:Ke})(Oe.apply(void 0,[De].concat(Le)))}}break;case"object":switch(Be){case"string":return we({className:Oe,style:Ke});case"object":return re(re({},Oe),Ke);case"function":return function(De){for(var Xe=arguments.length,Le=new Array(Xe>1?Xe-1:0),He=1;He<Xe;He++)Le[He-1]=arguments[He];return we({style:Ke})(Oe.apply(void 0,[De].concat(Le)))}}break;case"function":switch(Be){case"string":return function(De){for(var Xe=arguments.length,Le=new Array(Xe>1?Xe-1:0),He=1;He<Xe;He++)Le[He-1]=arguments[He];return Ke.apply(void 0,[we(De)({className:Oe})].concat(Le))};case"object":return function(De){for(var Xe=arguments.length,Le=new Array(Xe>1?Xe-1:0),He=1;He<Xe;He++)Le[He-1]=arguments[He];return Ke.apply(void 0,[we(De)({style:Oe})].concat(Le))};case"function":return function(De){for(var Xe=arguments.length,Le=new Array(Xe>1?Xe-1:0),He=1;He<Xe;He++)Le[He-1]=arguments[He];return Ke.apply(void 0,[Oe.apply(void 0,[De].concat(Le))].concat(Le))}}}}(ae[Je],K[Je]),Ee},{})},fe=function(ae,K){for(var ee=arguments.length,ue=new Array(ee>2?ee-2:0),Ee=2;Ee<ee;Ee++)ue[Ee-2]=arguments[Ee];if(K===null)return ae;Array.isArray(K)||(K=[K]);var Je=K.map(function(Ke){return ae[Ke]}
944).filter(Boolean).reduce(function(Ke,Oe){return typeof Oe=="string"?Ke.className=[Ke.className,Oe].filter(Boolean).join(" "):a(Oe)==="object"?Ke.style=re(re({},Ke.style),Oe):typeof Oe=="function"&&(Ke=re(re({},Ke),Oe.apply(void 0,[Ke].concat(ue)))),Ke},{className:"",style:{}});return Je.className||delete Je.className,Object.keys(Je.style).length===0&&delete Je.style,Je},O=function(ae){return Object.keys(ae).reduce(function(K,ee){return K[ee]=/^base/.test(ee)?be(ae[ee]):ee==="scheme"?ae[ee]+":inverted":ae[ee],K},{})},pe=ie()(function(ae){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ue=K.defaultBase16,Ee=ue===void 0?Y:ue,Je=K.base16Themes,Ke=le(ee,Je===void 0?null:Je);Ke&&(ee=re(re({},Ke),ee));for(var Oe=ne.reduce(function(mt,Ht){return mt[Ht]=ee[Ht]||Ee[Ht],mt},{}),ut=Object.keys(ee).reduce(function(mt,Ht){return ne.indexOf(Ht)===-1&&(mt[Ht]=ee[Ht]),mt},{}),Be=ae(Oe),De=te(ut,Be),Xe=arguments.length,Le=new Array(Xe>3?Xe-3:0),He=3;He<Xe;He++)Le[He-3]=arguments[He];return ie()(fe,2).apply(void 0,[De].concat(Le))},3),he=function(ae){return!!ae.extend},le=function(ae,K){if(ae&&he(ae)&&ae.extend&&(ae=ae.extend),typeof ae=="string"){var ee=B(ae.split(":"),2),ue=ee[0],Ee=ee[1];ae=K?K[ue]:L[ue],Ee==="inverted"&&(ae=O(ae))}return ae&&Object.prototype.hasOwnProperty.call(ae,"base00")?ae:void 0},oe=function(ae){var K=function(ee){return{backgroundColor:ee.base00,ellipsisColor:ee.base09,braceColor:ee.base07,expandedIcon:ee.base0D,collapsedIcon:ee.base0E,keyColor:ee.base07,arrayKeyColor:ee.base0C,objectSize:ee.base04,copyToClipboard:ee.base0F,copyToClipboardCheck:ee.base0D,objectBorder:ee.base02,dataTypes:{boolean:ee.base0E,date:ee.base0D,float:ee.base0B,function:ee.base0D,integer:ee.base0F,string:ee.base09,nan:ee.base08,null:ee.base0A,undefined:ee.base05,regexp:ee.base0A,background:ee.base02,bigNumber:ee.base09},editVariable:{editIcon:ee.base0E,cancelIcon:ee.base09,removeIcon:ee.base09,addIcon:ee.base0E,checkIcon:ee.base0E,background:ee.base01,color:ee.base0A,border:ee.base07},addKeyModal:{background:ee.base05,border:ee.base04,color:ee.base0A,labelColor:ee.base01},validationFailure:{background:ee.base09,iconColor:ee.base01,fontColor:ee.base01}}}(ae);return{"app-container":{fontFamily:A.globalFontFamily,cursor:A.globalCursor,backgroundColor:K.backgroundColor,position:"relative"},ellipsis:{display:"inline-block",color:K.ellipsisColor,fontSize:A.ellipsisFontSize,lineHeight:A.ellipsisLineHeight,cursor:A.ellipsisCursor},"brace-row":{display:"inline-block",cursor:"pointer"},brace:{display:"inline-block",cursor:A.braceCursor,fontWeight:A.braceFontWeight,color:K.braceColor},"expanded-icon":{color:K.expandedIcon},"collapsed-icon":{color:K.collapsedIcon},colon:{display:"inline-block",margin:A.keyMargin,color:K.keyColor,verticalAlign:"top"},objectKeyVal:function(ee,ue){return{style:f({paddingTop:A.keyValPaddingTop,paddingRight:A.keyValPaddingRight,paddingBottom:A.keyValPaddingBottom,borderLeft:A.keyValBorderLeft+" "+K.objectBorder,":hover":{paddingLeft:ue.paddingLeft-1+"px",borderLeft:A.keyValBorderHover+" "+K.objectBorder}},ue)}},"object-key-val-no-border":{padding:A.keyValPadding},"pushed-content":{marginLeft:A.pushedContentMarginLeft},variableValue:function(ee,ue){return{style:f({display:"inline-block",paddingRight:A.variableValuePaddingRight,position:"relative"},ue)}},"object-name":{display:"inline-block",color:K.keyColor,letterSpacing:A.keyLetterSpacing,fontStyle:A.keyFontStyle,verticalAlign:A.keyVerticalAlign,opacity:A.keyOpacity,":hover":{opacity:A.keyOpacityHover}},"array-key":{display:"inline-block",color:K.arrayKeyColor,letterSpacing:A.keyLetterSpacing,fontStyle:A.keyFontStyle,verticalAlign:A.keyVerticalAlign,opacity:A.keyOpacity,":hover":{opacity:A.keyOpacityHover}},"object-size":{color:K.objectSize,borderRadius:A.objectSizeBorderRadius,fontStyle:A.objectSizeFontStyle,margin:A.objectSizeMargin,cursor:"default"},"data-type-label":{fontSize:A.dataTypeFontSize,marginRight:A.dataTypeMarginRight,opacity:A.datatypeOpacity},boolean:{display:"inline-block",color:K.dataTypes.boolean},date:{display:"inline-block",color:K.dataTypes.date},"date-value":{marginLeft:A.dateValueMarginLeft},float:{display:"inline-block",color:K.dataTypes.float},function:{display:"inline-block",color:K.dataTypes.function,cursor:"pointer",whiteSpace:"pre-line"},"function-value":{fontStyle:"italic"},integer:{display:"inline-block",color:K.dataTypes.integer},bigNumber:{display:"inline-block",color:K.dataTypes.bigNumber},string:{display:"inline-block",color:K.dataTypes.string},nan:{display:"inline-block",color:K.dataTypes.nan,fontSize:A.nanFontSize,fontWeight:A.nanFontWeight,backgroundColor:K.dataTypes.background,padding:A.nanPadding,borderRadius:A.nanBorderRadius},null:{display:"inline-block",color:K.dataTypes.null,fontSize:A.nullFontSize,fontWeight:A.nullFontWeight,backgroundColor:K.dataTypes.background,padding:A.nullPadding,borderRadius:A.nullBorderRadius},undefined:{display:"inline-block",color:K.dataTypes.undefined,fontSize:A.undefinedFontSize,padding:A.undefinedPadding,borderRadius:A.undefinedBorderRadius,backgroundColor:K.dataTypes.background}
944,regexp:{display:"inline-block",color:K.dataTypes.regexp},"copy-to-clipboard":{cursor:A.clipboardCursor},"copy-icon":{color:K.copyToClipboard,fontSize:A.iconFontSize,marginRight:A.iconMarginRight,verticalAlign:"top"},"copy-icon-copied":{color:K.copyToClipboardCheck,marginLeft:A.clipboardCheckMarginLeft},"array-group-meta-data":{display:"inline-block",padding:A.arrayGroupMetaPadding},"object-meta-data":{display:"inline-block",padding:A.metaDataPadding},"icon-container":{display:"inline-block",width:A.iconContainerWidth},tooltip:{padding:A.tooltipPadding},removeVarIcon:{verticalAlign:"top",display:"inline-block",color:K.editVariable.removeIcon,cursor:A.iconCursor,fontSize:A.iconFontSize,marginRight:A.iconMarginRight},addVarIcon:{verticalAlign:"top",display:"inline-block",color:K.editVariable.addIcon,cursor:A.iconCursor,fontSize:A.iconFontSize,marginRight:A.iconMarginRight},editVarIcon:{verticalAlign:"top",display:"inline-block",color:K.editVariable.editIcon,cursor:A.iconCursor,fontSize:A.iconFontSize,marginRight:A.iconMarginRight},"edit-icon-container":{display:"inline-block",verticalAlign:"top"},"check-icon":{display:"inline-block",cursor:A.iconCursor,color:K.editVariable.checkIcon,fontSize:A.iconFontSize,paddingRight:A.iconPaddingRight},"cancel-icon":{display:"inline-block",cursor:A.iconCursor,color:K.editVariable.cancelIcon,fontSize:A.iconFontSize,paddingRight:A.iconPaddingRight},"edit-input":{display:"inline-block",minWidth:A.editInputMinWidth,borderRadius:A.editInputBorderRadius,backgroundColor:K.editVariable.background,color:K.editVariable.color,padding:A.editInputPadding,marginRight:A.editInputMarginRight,fontFamily:A.editInputFontFamily},"detected-row":{paddingTop:A.detectedRowPaddingTop},"key-modal-request":{position:A.addKeyCoverPosition,top:A.addKeyCoverPositionPx,left:A.addKeyCoverPositionPx,right:A.addKeyCoverPositionPx,bottom:A.addKeyCoverPositionPx,backgroundColor:A.addKeyCoverBackground},"key-modal":{width:A.addKeyModalWidth,backgroundColor:K.addKeyModal.background,marginLeft:A.addKeyModalMargin,marginRight:A.addKeyModalMargin,padding:A.addKeyModalPadding,borderRadius:A.addKeyModalRadius,marginTop:"15px",position:"relative"},"key-modal-label":{color:K.addKeyModal.labelColor,marginLeft:"2px",marginBottom:"5px",fontSize:"11px"},"key-modal-input-container":{overflow:"hidden"},"key-modal-input":{width:"100%",padding:"3px 6px",fontFamily:"monospace",color:K.addKeyModal.color,border:"none",boxSizing:"border-box",borderRadius:"2px"},"key-modal-cancel":{backgroundColor:K.editVariable.removeIcon,position:"absolute",top:"0px",right:"0px",borderRadius:"0px 3px 0px 3px",cursor:"pointer"},"key-modal-cancel-icon":{color:K.addKeyModal.labelColor,fontSize:A.iconFontSize,transform:"rotate(45deg)"},"key-modal-submit":{color:K.editVariable.addIcon,fontSize:A.iconFontSize,position:"absolute",right:"2px",top:"3px",cursor:"pointer"},"function-ellipsis":{display:"inline-block",color:K.ellipsisColor,fontSize:A.ellipsisFontSize,lineHeight:A.ellipsisLineHeight,cursor:A.ellipsisCursor},"validation-failure":{float:"right",padding:"3px 6px",borderRadius:"2px",cursor:"pointer",color:K.validationFailure.fontColor,backgroundColor:K.validationFailure.background},"validation-failure-label":{marginRight:"6px"},"validation-failure-clear":{position:"relative",verticalAlign:"top",cursor:"pointer",color:K.validationFailure.iconColor,fontSize:A.iconFontSize,transform:"rotate(45deg)"}}};function Q(ae,K,ee){return ae||console.error("theme has not been set"),function(ue){var Ee=R;return ue!==!1&&ue!=="none"||(Ee=U),pe(oe,{defaultBase16:Ee})(ue)}(ae)(K,ee)}var de=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=(ee.rjvId,ee.type_name),Ee=ee.displayDataTypes,Je=ee.theme;return Ee?_().createElement("span",Object.assign({className:"data-type-label"},Q(Je,"data-type-label")),ue):null}}])}(_().PureComponent),Ne=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"boolean"),_().createElement(de,Object.assign({type_name:"bool"},ee)),ee.value?"true":"false")}}])}(_().PureComponent),Ce=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"date"),_().createElement(de,Object.assign({type_name:"date"},ee)),_().createElement("span",Object.assign({className:"date-value"},Q(ee.theme,"date-value")),ee.value.toLocaleTimeString("en-us",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})))}}])}(_().PureComponent),Ae=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"float"),_().createElement(de,Object.assign({type_name:"float"},ee)),this.props.value)}}])}(_().PureComponent);function Ue(ae){return function(K){if(Array.isArray(K))return W(K)}(ae)||function(K){if(typeof Symbol<"u"&&K[Symbol.iterator]!=null||K["@@iterator"]!=null)return Array.from(K)}(ae)||D(ae)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 945In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}var Se=s(9784),ve=function(){return y(function ae(){h(this,ae),this.handler=function(){}},[{key:"register",value:function(ae){this.handler=ae}},{key:"dispatch",value:function(ae){var K;(K=this.handler)===null||K===void 0||K.call(this,ae)}}])}();globalThis.__globalDispatcherInstance||(globalThis.__globalDispatcherInstance=new ve);const je=globalThis.__globalDispatcherInstance;var Te=new(function(ae){function K(){var ee;h(this,K);for(var ue=arguments.length,Ee=new Array(ue),Je=0;Je<ue;Je++)Ee[Je]=arguments[Je];return(ee=S(this,K,[].concat(Ee))).objects={},ee.set=function(Ke,Oe,ut,Be){ee.objects[Ke]===void 0&&(ee.objects[Ke]={}),ee.objects[Ke][Oe]===void 0&&(ee.objects[Ke][Oe]={}),ee.objects[Ke][Oe][ut]=Be},ee.get=function(Ke,Oe,ut,Be){return ee.objects[Ke]===void 0||ee.objects[Ke][Oe]===void 0||ee.objects[Ke][Oe][ut]==null?Be:ee.objects[Ke][Oe][ut]},ee.handleAction=function(Ke){var Oe=Ke.rjvId,ut=Ke.data;switch(Ke.name){case"RESET":ee.emit("reset-"+Oe);break;case"VARIABLE_UPDATED":Ke.data.updated_src=ee.updateSrc(Oe,ut),ee.set(Oe,"action","variable-update",f(f({},ut),{},{type:"variable-edited"})),ee.emit("variable-update-"+Oe);break;case"VARIABLE_REMOVED":Ke.data.updated_src=ee.updateSrc(Oe,ut),ee.set(Oe,"action","variable-update",f(f({},ut),{},{type:"variable-removed"})),ee.emit("variable-update-"+Oe);break;case"VARIABLE_ADDED":Ke.data.updated_src=ee.updateSrc(Oe,ut),ee.set(Oe,"action","variable-update",f(f({},ut),{},{type:"variable-added"})),ee.emit("variable-update-"+Oe);break;case"ADD_VARIABLE_KEY_REQUEST":ee.set(Oe,"action","new-key-request",ut),ee.emit("add-key-request-"+Oe)}},ee.updateSrc=function(Ke,Oe){var ut=Oe.name,Be=Oe.namespace,De=Oe.new_value,Xe=(Oe.existing_value,Oe.variable_removed);Be.shift();var Le,He=ee.get(Ke,"global","src"),mt=ee.deepCopy(He,Ue(Be)),Ht=mt,fn=function(Nn,sr){var $n=typeof Symbol<"u"&&Nn[Symbol.iterator]||Nn["@@iterator"];if(!$n){if(Array.isArray(Nn)||($n=D(Nn))||sr){$n&&(Nn=$n);var ri=0,wr=function(){};return{s:wr,n:function(){return ri>=Nn.length?{done:!0}:{done:!1,value:Nn[ri++]}},e:function(Yr){throw Yr},f:wr}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. 946In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ns,rs=!0,er=!1;return{s:function(){$n=$n.call(Nn)},n:function(){var Yr=$n.next();return rs=Yr.done,Yr},e:function(Yr){er=!0,ns=Yr},f:function(){try{rs||$n.return==null||$n.return()}finally{if(er)throw ns}}}}(Be);try{for(fn.s();!(Le=fn.n()).done;)Ht=Ht[Le.value]}catch(Nn){fn.e(Nn)}finally{fn.f()}return Xe?F(Ht)=="array"?Ht.splice(ut,1):delete Ht[ut]:ut!==null?Ht[ut]=De:mt=De,ee.set(Ke,"global","src",mt),mt},ee.deepCopy=function(Ke,Oe){var ut,Be=F(Ke),De=Oe.shift();return Be=="array"?ut=Ue(Ke):Be=="object"&&(ut=f({},Ke)),De!==void 0&&(ut[De]=ee.deepCopy(Ke[De],Oe)),ut},ee}return k(K,ae),y(K)}(Se.EventEmitter));je.register(Te.handleAction.bind(Te));const ce=Te;var se=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).toggleCollapsed=function(){ue.setState({collapsed:!ue.state.collapsed},function(){ce.set(ue.props.rjvId,ue.props.namespace,"collapsed",ue.state.collapsed)})},ue.getFunctionDisplay=function(Ee){var Je=ue.props;return Ee?_().createElement("span",null,ue.props.value.toString().slice(9,-1).replace(/\{[\s\S]+/,""),_().createElement("span",{className:"function-collapsed",style:{fontWeight:"bold"}},_().createElement("span",null,"{"),_().createElement("span",Q(Je.theme,"ellipsis"),"..."),_().createElement("span",null,"}"))):ue.props.value.toString().slice(9,-1)},ue.state={collapsed:ce.get(ee.rjvId,ee.namespace,"collapsed",!0)},ue}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=this.state.collapsed;return _().createElement("div",Q(ee.theme,"function"),_().createElement(de,Object.assign({type_name:"function"},ee)),_().createElement("span",Object.assign({},Q(ee.theme,"function-value"),{className:"rjv-function-container",onClick:this.toggleCollapsed}),this.getFunctionDisplay(ue)))}}])}(_().PureComponent),ye=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){return _().createElement("div",Q(this.props.theme,"nan"),"NaN")}}])}(_().PureComponent),ke=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){return _().createElement("div",Q(this.props.theme,"null"),"NULL")}}])}(_().PureComponent),ze=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"integer"),_().createElement(de,Object.assign({type_name:"int"},ee)),this.props.value)}}])}(_().PureComponent),qe=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"regexp"),_().createElement(de,Object.assign({type_name:"regexp"},ee)),this.props.value.toString())}}])}(_().PureComponent),ot=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).toggleCollapsed=function(){ue.setState({collapsed:!ue.state.collapsed},function(){ce.set(ue.props.rjvId,ue.props.namespace,"collapsed",ue.state.collapsed)})},ue.state={collapsed:ce.get(ee.rjvId,ee.namespace,"collapsed",!0)},ue}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.state.collapsed,ue=this.props,Ee=ue.collapseStringsAfterLength,Je=ue.theme,Ke=ue.escapeStrings,Oe=ue.value,ut=F(Ee)==="integer",Be={style:{cursor:"default"}};return Ke&&(Oe=I(Oe)),ut&&Oe.length>Ee&&(Be.style.cursor="pointer",ee&&(Oe=_().createElement("span",null,Oe.substring(0,Ee),_().createElement("span",Q(Je,"ellipsis")," ...")))),_().createElement("div",Q(Je,"string"),_().createElement(de,Object.assign({type_name:"string"},ue)),_().createElement("span",Object.assign({className:"string-value"},Be,{onClick:this.toggleCollapsed}),'"',Oe,'"'))}}])}(_().PureComponent),Ze=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){return _().createElement("div",Q(this.props.theme,"undefined"),"undefined")}}])}(_().PureComponent),_t=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props;return _().createElement("div",Q(ee.theme,"bigNumber"),_().createElement(de,Object.assign({type_name:"bigNumber"},ee)),this.props.value.toString())}}])}(_().PureComponent);function tt(){return tt=Object.assign?Object.assign.bind():function(ae){for(var K=1;K<arguments.length;K++){var ee=arguments[K];for(var ue in ee)({}).hasOwnProperty.call(ee,ue)&&(ae[ue]=ee[ue])}return ae},tt.apply(null,arguments)}const gt=N.useLayoutEffect;var dt=function(ae,K){typeof ae!="function"?ae.current=K:ae(K)};const wt=function(ae,K){var ee=(0,N.useRef)();return(0,N.useCallback)(function(ue){ae.current=ue,ee.current&&dt(ee.current,null),ee.current=K,K&&dt(K,ue)},[K])};var Dt={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},Kt=function(ae){Object.keys(Dt).forEach(function(K){ae.style.setProperty(K,Dt[K],"important")})},rn=null,pn=function(){},cn=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],kt=!!document.documentElement.currentStyle,rt=function(ae){var K,ee,ue=(K=ae,ee=N.useRef(K),gt(function(){ee.current=K}),ee);(0,N.useLayoutEffect)(function(){var Ee=function(Je){ue.current(Je)};return window.addEventListener("resize",Ee),function(){window.removeEventListener("resize",Ee)}},[])},Tt=function(ae,K){var ee=ae.cacheMeasurements,ue=ae.maxRows,Ee=ae.minRows,Je=ae.onChange,Ke=Je===void 0?pn:Je,Oe=ae.onHeightChange,ut=Oe===void 0?pn:Oe,Be=H(ae,["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"]),De=Be.value!==void 0,Xe=(0,N.useRef)(null),Le=wt(Xe,K),He=(0,N.useRef)(0),mt=(0,N.useRef)(),Ht=function(){var fn=Xe.current,Nn=ee&&mt.current?mt.current:function(wr){var ns=window.getComputedStyle(wr);if(ns===null)return null;var rs,er=(rs=ns,cn.reduce(function(Ai,ys){return Ai[ys]=rs[ys],Ai},{})),Yr=er.boxSizing;return Yr===""?null:(kt&&Yr==="border-box"&&(er.width=parseFloat(er.width)+parseFloat(er.borderRightWidth)+parseFloat(er.borderLeftWidth)+parseFloat(er.paddingRight)+parseFloat(er.paddingLeft)+"px"),{sizingStyle:er,paddingSize:parseFloat(er.paddingBottom)+parseFloat(er.paddingTop),borderSize:parseFloat(er.borderBottomWidth)+parseFloat(er.borderTopWidth)})}(fn);if(Nn){mt.current=Nn;var sr=function(wr,ns,rs,er){rs===void 0&&(rs=1),er===void 0&&(er=1/0),rn||((rn=document.createElement("textarea")).setAttribute("tabindex","-1"),rn.setAttribute("aria-hidden","true"),Kt(rn)),rn.parentNode===null&&document.body.appendChild(rn);var Yr=wr.paddingSize,Ai=wr.borderSize,ys=wr.sizingStyle,Id=ys.boxSizing;
946Object.keys(ys).forEach(function(ql){var Ni=ql;rn.style[Ni]=ys[Ni]}),Kt(rn),rn.value=ns;var ul=function(ql,Ni){var jd=ql.scrollHeight;return Ni.sizingStyle.boxSizing==="border-box"?jd+Ni.borderSize:jd-Ni.paddingSize}(rn,wr);rn.value="x";var Na=rn.scrollHeight-Yr,Wo=Na*rs;Id==="border-box"&&(Wo=Wo+Yr+Ai),ul=Math.max(Wo,ul);var Gi=Na*er;return Id==="border-box"&&(Gi=Gi+Yr+Ai),[ul=Math.min(Gi,ul),Na]}(Nn,fn.value||fn.placeholder||"x",Ee,ue),$n=sr[0],ri=sr[1];He.current!==$n&&(He.current=$n,fn.style.setProperty("height",$n+"px","important"),ut($n,{rowHeight:ri}))}};return(0,N.useLayoutEffect)(Ht),rt(Ht),(0,N.createElement)("textarea",tt({},Be,{onChange:function(fn){De||Ht(),Ke(fn)},ref:Le}))};const Mt=(0,N.forwardRef)(Tt);function Rt(ae,K){ae=ae.trim();try{if((ae=structuredClone(ae))[0]==="[")return Ct("array",JSON.parse(ae));if(ae[0]==="{")return Ct("object",JSON.parse(ae));if(ae.match(/\-?\d+\.\d+/)&&ae.match(/\-?\d+\.\d+/)[0]===ae)return K&&parseFloat(ae).toString()!==ae?Ct("bigNumber",ae):Ct("float",parseFloat(ae));if(ae.match(/\-?\d+e-\d+/)&&ae.match(/\-?\d+e-\d+/)[0]===ae)return Ct("float",Number(ae));if(ae.match(/\-?\d+/)&&ae.match(/\-?\d+/)[0]===ae)return K&&parseInt(ae).toString()!==ae?Ct("bigNumber",ae):Ct("integer",parseInt(ae));if(ae.match(/\-?\d+e\+\d+/)&&ae.match(/\-?\d+e\+\d+/)[0]===ae)return Ct("integer",Number(ae))}catch{}switch(ae=ae.toLowerCase()){case"undefined":return Ct("undefined",void 0);case"nan":return Ct("nan",NaN);case"null":return Ct("null",null);case"true":return Ct("boolean",!0);case"false":return Ct("boolean",!1);default:if(ae=Date.parse(ae))return Ct("date",new Date(ae))}return Ct(!1,null)}function Ct(ae,K){return{type:ae,value:K}}var Gt=["style"],Lt=["style"],$t=["style"],Qt=["style"],Ye=["style"],bt=["style"],Ie=["style"],it=["style"],ct=["style"],Ut=["style"],Et=["style"],yn=["style"],nn=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Gt);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M7,13H17V11H7"})))}}])}(_().PureComponent),rr=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Lt);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,7H11V11H7V13H11V17H13V13H17V11H13V7Z"})))}}])}(_().PureComponent),xn=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,$t),Je=Un(ue).style;return _().createElement("span",Ee,_().createElement("svg",{fill:Je.color,width:Je.height,height:Je.width,style:Je,viewBox:"0 0 1792 1792"},_().createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}])}(_().PureComponent),Bn=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Qt),Je=Un(ue).style;return _().createElement("span",Ee,_().createElement("svg",{fill:Je.color,width:Je.height,height:Je.width,style:Je,viewBox:"0 0 1792 1792"},_().createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-352v352q0 14-9 23t-23 9h-64q-14 0-23-9t-9-23v-352h-352q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h352v-352q0-14 9-23t23-9h64q14 0 23 9t9 23v352h352q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}])}(_().PureComponent),dr=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Ye);return _().createElement("span",Ee,_().createElement("svg",{style:f(f({},Un(ue).style),{},{paddingLeft:"2px",verticalAlign:"top"}
946),viewBox:"0 0 15 15",fill:"currentColor"},_().createElement("path",{d:"M0 14l6-6-6-6z"})))}}])}(_().PureComponent),gr=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,bt);return _().createElement("span",Ee,_().createElement("svg",{style:f(f({},Un(ue).style),{},{paddingLeft:"2px",verticalAlign:"top"}),viewBox:"0 0 15 15",fill:"currentColor"},_().createElement("path",{d:"M0 5l6 6 6-6z"})))}}])}(_().PureComponent),on=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Ie);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m30 35h-25v-22.5h25v7.5h2.5v-12.5c0-1.4-1.1-2.5-2.5-2.5h-7.5c0-2.8-2.2-5-5-5s-5 2.2-5 5h-7.5c-1.4 0-2.5 1.1-2.5 2.5v27.5c0 1.4 1.1 2.5 2.5 2.5h25c1.4 0 2.5-1.1 2.5-2.5v-5h-2.5v5z m-20-27.5h2.5s2.5-1.1 2.5-2.5 1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5 1.3 2.5 2.5 2.5h2.5s2.5 1.1 2.5 2.5h-20c0-1.5 1.1-2.5 2.5-2.5z m-2.5 20h5v-2.5h-5v2.5z m17.5-5v-5l-10 7.5 10 7.5v-5h12.5v-5h-12.5z m-17.5 10h7.5v-2.5h-7.5v2.5z m12.5-17.5h-12.5v2.5h12.5v-2.5z m-7.5 5h-5v2.5h5v-2.5z"}))))}}])}(_().PureComponent),Fn=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,it);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m28.6 25q0-0.5-0.4-1l-4-4 4-4q0.4-0.5 0.4-1 0-0.6-0.4-1.1l-2-2q-0.4-0.4-1-0.4-0.6 0-1 0.4l-4.1 4.1-4-4.1q-0.4-0.4-1-0.4-0.6 0-1 0.4l-2 2q-0.5 0.5-0.5 1.1 0 0.5 0.5 1l4 4-4 4q-0.5 0.5-0.5 1 0 0.7 0.5 1.1l2 2q0.4 0.4 1 0.4 0.6 0 1-0.4l4-4.1 4.1 4.1q0.4 0.4 1 0.4 0.6 0 1-0.4l2-2q0.4-0.4 0.4-1z m8.7-5q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}])}(_().PureComponent),Xn=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,ct);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m30.1 21.4v-2.8q0-0.6-0.4-1t-1-0.5h-5.7v-5.7q0-0.6-0.4-1t-1-0.4h-2.9q-0.6 0-1 0.4t-0.4 1v5.7h-5.7q-0.6 0-1 0.5t-0.5 1v2.8q0 0.6 0.5 1t1 0.5h5.7v5.7q0 0.5 0.4 1t1 0.4h2.9q0.6 0 1-0.4t0.4-1v-5.7h5.7q0.6 0 1-0.5t0.4-1z m7.2-1.4q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}])}(_().PureComponent),yt=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Ut);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m31.6 21.6h-10v10h-3.2v-10h-10v-3.2h10v-10h3.2v10h10v3.2z"}))))}}])}(_().PureComponent),Wt=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,Et);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m19.8 26.4l2.6-2.6-3.4-3.4-2.6 2.6v1.3h2.2v2.1h1.2z m9.8-16q-0.3-0.4-0.7 0l-7.8 7.8q-0.4 0.4 0 0.7t0.7 0l7.8-7.8q0.4-0.4 0-0.7z m1.8 13.2v4.3q0 2.6-1.9 4.5t-4.5 1.9h-18.6q-2.6 0-4.5-1.9t-1.9-4.5v-18.6q0-2.7 1.9-4.6t4.5-1.8h18.6q1.4 0 2.6 0.5 0.3 0.2 0.4 0.5 0.1 0.4-0.2 0.7l-1.1 1.1q-0.3 0.3-0.7 0.1-0.5-0.1-1-0.1h-18.6q-1.4 0-2.5 1.1t-1 2.5v18.6q0 1.4 1 2.5t2.5 1h18.6q1.5 0 2.5-1t1.1-2.5v-2.9q0-0.2
9460.2-0.4l1.4-1.5q0.3-0.3 0.8-0.1t0.4 0.6z m-2.1-16.5l6.4 6.5-15 15h-6.4v-6.5z m9.9 3l-2.1 2-6.4-6.4 2.1-2q0.6-0.7 1.5-0.7t1.5 0.7l3.4 3.4q0.6 0.6 0.6 1.5t-0.6 1.5z"}))))}}])}(_().PureComponent),An=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.style,Ee=P(ee,yn);return _().createElement("span",Ee,_().createElement("svg",Object.assign({},Un(ue),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),_().createElement("g",null,_().createElement("path",{d:"m31.7 16.4q0-0.6-0.4-1l-2.1-2.1q-0.4-0.4-1-0.4t-1 0.4l-9.1 9.1-5-5q-0.5-0.4-1-0.4t-1 0.4l-2.1 2q-0.4 0.4-0.4 1 0 0.6 0.4 1l8.1 8.1q0.4 0.4 1 0.4 0.6 0 1-0.4l12.2-12.1q0.4-0.4 0.4-1z m5.6 3.6q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}])}(_().PureComponent);function Un(ae){return ae||(ae={}),{style:f(f({verticalAlign:"middle"},ae),{},{color:ae.color?ae.color:"#000000",height:"1em",width:"1em"})}}var Rr=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).copiedTimer=null,ue.copyToClipboardFallback=function(Ee){var Je=document.createElement("textarea");Je.value=Ee,document.body.appendChild(Je),Je.select(),document.execCommand("copy"),document.body.removeChild(Je)},ue.handleCopy=function(){var Ee=ue.props,Je=Ee.clickCallback,Ke=Ee.src,Oe=Ee.namespace,ut=JSON.stringify(ue.clipboardValue(Ke),null," ");navigator.clipboard?navigator.clipboard.writeText(ut).catch(function(){ue.copyToClipboardFallback(ut)}):ue.copyToClipboardFallback(ut),ue.copiedTimer=setTimeout(function(){ue.setState({copied:!1})},5500),ue.setState({copied:!0},function(){typeof Je=="function"&&Je({src:Ke,namespace:Oe,name:Oe[Oe.length-1]})})},ue.getClippyIcon=function(){var Ee=ue.props.theme;return ue.state.copied?_().createElement("span",null,_().createElement(on,Object.assign({className:"copy-icon"},Q(Ee,"copy-icon"))),_().createElement("span",Q(Ee,"copy-icon-copied"),"â")):_().createElement(on,Object.assign({className:"copy-icon"},Q(Ee,"copy-icon")))},ue.clipboardValue=function(Ee){switch(F(Ee)){case"function":case"regexp":return Ee.toString();default:return Ee}},ue.state={copied:!1},ue}return k(K,ae),y(K,[{key:"componentWillUnmount",value:function(){this.copiedTimer&&(clearTimeout(this.copiedTimer),this.copiedTimer=null)}},{key:"render",value:function(){var ee=this.props,ue=(ee.src,ee.theme),Ee=ee.hidden,Je=ee.rowHovered,Ke=Q(ue,"copy-to-clipboard").style,Oe="inline";return Ee&&(Oe="none"),_().createElement("span",{className:"copy-to-clipboard-container",title:"Copy to clipboard",style:{verticalAlign:"top",display:Je?"inline-block":"none"}},_().createElement("span",{style:f(f({},Ke),{},{display:Oe}),onClick:this.handleCopy},this.getClippyIcon()))}}])}(_().PureComponent);const yr=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).getEditIcon=function(){var Ee=ue.props,Je=Ee.variable,Ke=Ee.theme;return _().createElement("div",{className:"click-to-edit",style:{verticalAlign:"top",display:ue.state.hovered?"inline-block":"none"}},_().createElement(Wt,Object.assign({className:"click-to-edit-icon"},Q(Ke,"editVarIcon"),{onClick:function(){ue.prepopInput(Je)}})))},ue.prepopInput=function(Ee){if(ue.props.onEdit!==!1){var Je=function(Oe,ut){var Be;switch(F(Oe,ut)){case"undefined":Be="undefined";break;case"nan":Be="NaN";break;case"string":Be=Oe;break;case"bigNumber":case"date":case"function":case"regexp":Be=Oe.toString();break;default:try{Be=JSON.stringify(Oe,null," ")}catch{Be=""}}return Be}(Ee.value,ue.props.bigNumber),Ke=Rt(Je,ue.props.bigNumber);ue.setState({editMode:!0,editValue:Je,parsedInput:{type:Ke.type,value:Ke.value}})}},ue.getRemoveIcon=function(){var Ee=ue.props,Je=Ee.variable,Ke=Ee.namespace,Oe=Ee.theme,ut=Ee.rjvId;return _().createElement("div",{className:"click-to-remove",style:{verticalAlign:"top",display:ue.state.hovered?"inline-block":"none"}},_().createElement(Fn,Object.assign({className:"click-to-remove-icon"},Q(Oe,"removeVarIcon"),{onClick:function(){je.dispatch({name:"VARIABLE_REMOVED",rjvId:ut,data:{name:Je.name,namespace:Ke,existing_value:Je.value,variable_removed:!0}})}})))},ue.getValue=function(Ee,Je){var Ke=!Je&&Ee.type,Oe=ue.props;switch(Ke){case!1:return ue.getEditInput();case"string":return _().createElement(ot,Object.assign({value:Ee.value},Oe));case"integer":return _().createElement(ze,Object.assign({value:Ee.value},Oe));case"float":return _().createElement(Ae,Object.assign({value:Ee.value},Oe));case"boolean":return _().createElement(Ne,Object.assign({value:Ee.value},Oe));case"function":return _().createElement(se,Object.assign({value:Ee.value},Oe));case"null":return _().createElement(ke,Oe);case"nan":return _().createElement(ye,Oe);case"undefined":return _().createElement(Ze,Oe);case"date":return _().createElement(Ce,Object.assign({value:Ee.value},Oe));case"regexp":return _().createElement(qe,Object.assign({value:Ee.value},Oe));case"bigNumber":return _().createElement(_t,Object.assign({value:Ee.value},Oe));default:return _().createElement("div",{className:"object-value"},JSON.stringify(Ee.value))}},ue.getEditInput=function(){var Ee=ue.props,Je=Ee.keyModifier,Ke=Ee.selectOnFocus,Oe=Ee.theme,ut=ue.state.editValue;return _().createElement("div",null,_().createElement(Mt,Object.assign({type:"text",ref:function(Be){Be&&Be[Ke?"select":"focus"]()},value:ut,className:"variable-editor",onChange:function(Be){var De=Be.target.value,Xe=Rt(De,ue.props.bigNumber);
946ue.setState({editValue:De,parsedInput:{type:Xe.type,value:Xe.value}})},onKeyDown:function(Be){switch(Be.key){case"Escape":ue.setState({editMode:!1,editValue:""});break;case"Enter":Je(Be,"submit")&&ue.submitEdit(!0)}Be.stopPropagation()},placeholder:"update this value",minRows:2},Q(Oe,"edit-input"))),_().createElement("div",Q(Oe,"edit-icon-container"),_().createElement(Fn,Object.assign({className:"edit-cancel"},Q(Oe,"cancel-icon"),{onClick:function(Be){Be&&Be.stopPropagation(),ue.setState({editMode:!1,editValue:""})}})),_().createElement(An,Object.assign({className:"edit-check string-value"},Q(Oe,"check-icon"),{onClick:function(Be){Be&&Be.stopPropagation(),ue.submitEdit()}})),_().createElement("div",null,ue.showDetected())))},ue.submitEdit=function(Ee){var Je=ue.props,Ke=Je.variable,Oe=Je.namespace,ut=Je.rjvId,Be=Je.bigNumber,De=ue.state,Xe=De.editValue,Le=De.parsedInput,He=Xe;Ee&&Le.type&&(He=Le.value,Be&&Le.type==="bigNumber"&&(He=new Be(He))),ue.setState({editMode:!1}),je.dispatch({name:"VARIABLE_UPDATED",rjvId:ut,data:{name:Ke.name,namespace:Oe,existing_value:Ke.value,new_value:He,variable_removed:!1}})},ue.showDetected=function(){var Ee=ue.props,Je=Ee.theme,Ke=(Ee.variable,Ee.namespace,Ee.rjvId,ue.state.parsedInput),Oe=(Ke.type,Ke.value,ue.getDetectedInput());if(Oe)return _().createElement("div",null,_().createElement("div",Q(Je,"detected-row"),Oe,_().createElement(An,{className:"edit-check detected",style:f({verticalAlign:"top",paddingLeft:"3px"},Q(Je,"check-icon").style),onClick:function(ut){ut&&ut.stopPropagation(),ue.submitEdit(!0)}})))},ue.getDetectedInput=function(){var Ee=ue.state.parsedInput,Je=Ee.type,Ke=Ee.value,Oe=ue.props,ut=Oe.theme;if(Je!==!1)switch(Je.toLowerCase()){case"object":return _().createElement("span",null,_().createElement("span",{style:f(f({},Q(ut,"brace").style),{},{cursor:"default"})},"{"),_().createElement("span",{style:f(f({},Q(ut,"ellipsis").style),{},{cursor:"default"})},"..."),_().createElement("span",{style:f(f({},Q(ut,"brace").style),{},{cursor:"default"})},"}"));case"array":return _().createElement("span",null,_().createElement("span",{style:f(f({},Q(ut,"brace").style),{},{cursor:"default"})},"["),_().createElement("span",{style:f(f({},Q(ut,"ellipsis").style),{},{cursor:"default"})},"..."),_().createElement("span",{style:f(f({},Q(ut,"brace").style),{},{cursor:"default"})},"]"));case"string":return _().createElement(ot,Object.assign({value:Ke},Oe));case"integer":return _().createElement(ze,Object.assign({value:Ke},Oe));case"float":return _().createElement(Ae,Object.assign({value:Ke},Oe));case"boolean":return _().createElement(Ne,Object.assign({value:Ke},Oe));case"function":return _().createElement(se,Object.assign({value:Ke},Oe));case"null":return _().createElement(ke,Oe);case"nan":return _().createElement(ye,Oe);case"undefined":return _().createElement(Ze,Oe);case"date":return _().createElement(Ce,Object.assign({value:new Date(Ke)},Oe));case"bignumber":return _().createElement(_t,Object.assign({value:Ke},Oe))}},ue.state={editMode:!1,editValue:"",hovered:!1,renameKey:!1,parsedInput:{type:!1,value:null}},ue}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this,ue=this.props,Ee=ue.variable,Je=ue.singleIndent,Ke=ue.type,Oe=ue.theme,ut=ue.namespace,Be=ue.indentWidth,De=ue.enableClipboard,Xe=ue.onEdit,Le=ue.onDelete,He=ue.onSelect,mt=ue.displayArrayKey,Ht=ue.quotesOnKeys,fn=ue.keyModifier,Nn=this.state.editMode;return _().createElement("div",Object.assign({},Q(Oe,"objectKeyVal",{paddingLeft:Be*Je}),{onMouseEnter:function(){return ee.setState(f(f({},ee.state),{},{hovered:!0}))},onMouseLeave:function(){return ee.setState(f(f({},ee.state),{},{hovered:!1}))},className:"variable-row",key:Ee.name}),Ke=="array"?mt?_().createElement("span",Object.assign({},Q(Oe,"array-key"),{key:Ee.name+"_"+ut}),Ee.name,_().createElement("div",Q(Oe,"colon"),":")):null:_().createElement("span",null,_().createElement("span",Object.assign({},Q(Oe,"object-name"),{className:"object-key",key:Ee.name+"_"+ut}),!!Ht&&_().createElement("span",{style:{verticalAlign:"top"}},'"'),_().createElement("span",{style:{display:"inline-block"}},I(Ee.name)),!!Ht&&_().createElement("span",{style:{verticalAlign:"top"}},'"')),_().createElement("span",Q(Oe,"colon"),":")),_().createElement("div",Object.assign({className:"variable-value",onClick:He===!1&&Xe===!1?null:function(sr){var $n=Ue(ut);fn(sr,"edit")&&Xe!==!1?ee.prepopInput(Ee):He!==!1&&($n.shift(),He(f(f({},Ee),{},{namespace:$n})))}},Q(Oe,"variableValue",{cursor:He===!1?"default":"pointer"})),this.getValue(Ee,Nn)),De?_().createElement(Rr,{rowHovered:this.state.hovered,hidden:Nn,src:Ee.value,clickCallback:De,theme:Oe,namespace:[].
946concat(Ue(ut),[Ee.name])}):null,Xe!==!1&&Nn==0?this.getEditIcon():null,Le!==!1&&Nn==0?this.getRemoveIcon():null)}}])}(_().PureComponent);var Ps=function(ae){function K(){var ee;h(this,K);for(var ue=arguments.length,Ee=new Array(ue),Je=0;Je<ue;Je++)Ee[Je]=arguments[Je];return(ee=S(this,K,[].concat(Ee))).getObjectSize=function(){var Ke=ee.props,Oe=Ke.size,ut=Ke.theme;if(Ke.displayObjectSize)return _().createElement("span",Object.assign({className:"object-size"},Q(ut,"object-size")),Oe," item",Oe===1?"":"s")},ee.getAddAttribute=function(Ke){var Oe=ee.props,ut=Oe.theme,Be=Oe.namespace,De=Oe.name,Xe=Oe.src,Le=Oe.rjvId,He=Oe.depth;return _().createElement("span",{className:"click-to-add",style:{verticalAlign:"top",display:Ke?"inline-block":"none"}},_().createElement(Xn,Object.assign({className:"click-to-add-icon"},Q(ut,"addVarIcon"),{onClick:function(){var mt={name:He>0?De:null,namespace:Be.splice(0,Be.length-1),existing_value:Xe,variable_removed:!1,key_name:null};F(Xe)==="object"?je.dispatch({name:"ADD_VARIABLE_KEY_REQUEST",rjvId:Le,data:mt}):je.dispatch({name:"VARIABLE_ADDED",rjvId:Le,data:f(f({},mt),{},{new_value:[].concat(Ue(Xe),[null])})})}})))},ee.getRemoveObject=function(Ke){var Oe=ee.props,ut=Oe.theme,Be=(Oe.hover,Oe.namespace),De=Oe.name,Xe=Oe.src,Le=Oe.rjvId;if(Be.length!==1)return _().createElement("span",{className:"click-to-remove",style:{display:Ke?"inline-block":"none"}},_().createElement(Fn,Object.assign({className:"click-to-remove-icon"},Q(ut,"removeVarIcon"),{onClick:function(){je.dispatch({name:"VARIABLE_REMOVED",rjvId:Le,data:{name:De,namespace:Be.splice(0,Be.length-1),existing_value:Xe,variable_removed:!0}})}})))},ee.render=function(){var Ke=ee.props,Oe=Ke.theme,ut=Ke.onDelete,Be=Ke.onAdd,De=Ke.enableClipboard,Xe=Ke.src,Le=Ke.namespace,He=Ke.rowHovered;return _().createElement("div",Object.assign({},Q(Oe,"object-meta-data"),{className:"object-meta-data",onClick:function(mt){mt.stopPropagation()}}),ee.getObjectSize(),De?_().createElement(Rr,{rowHovered:He,clickCallback:De,src:Xe,theme:Oe,namespace:Le}):null,Be!==!1?ee.getAddAttribute(He):null,ut!==!1?ee.getRemoveObject(He):null)},ee}return k(K,ae),y(K)}(_().PureComponent);function Kr(ae){var K=ae.parent_type,ee=ae.namespace,ue=ae.quotesOnKeys,Ee=ae.theme,Je=ae.jsvRoot,Ke=ae.name,Oe=ae.displayArrayKey,ut=ae.name?ae.name:"";return!Je||Ke!==!1&&Ke!==null?K=="array"?Oe?_().createElement("span",Object.assign({},Q(Ee,"array-key"),{key:ee}),_().createElement("span",{className:"array-key"},ut),_().createElement("span",Q(Ee,"colon"),":")):_().createElement("span",null):_().createElement("span",Object.assign({},Q(Ee,"object-name"),{key:ee}),_().createElement("span",{className:"object-key"},ue&&_().createElement("span",{style:{verticalAlign:"top"}},'"'),_().createElement("span",null,ut),ue&&_().createElement("span",{style:{verticalAlign:"top"}},'"')),_().createElement("span",Q(Ee,"colon"),":")):_().createElement("span",null)}function xe(ae){var K=ae.theme;switch(ae.iconStyle){case"triangle":return _().createElement(gr,Object.assign({},Q(K,"expanded-icon"),{className:"expanded-icon"}));case"square":return _().createElement(xn,Object.assign({},Q(K,"expanded-icon"),{className:"expanded-icon"}));default:return _().createElement(nn,Object.assign({},Q(K,"expanded-icon"),{className:"expanded-icon"}))}}function Re(ae){var K=ae.theme;switch(ae.iconStyle){case"triangle":return _().createElement(dr,Object.assign({},Q(K,"collapsed-icon"),{className:"collapsed-icon"}));case"square":return _().createElement(Bn,Object.assign({},Q(K,"collapsed-icon"),{className:"collapsed-icon"}));default:return _().createElement(rr,Object.assign({},Q(K,"collapsed-icon"),{className:"collapsed-icon"}))}}var _e=["src","groupArraysAfterLength","depth","name","theme","jsvRoot","namespace","parent_type"],Ve=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).toggleCollapsed=function(Ee){var Je=[];for(var Ke in ue.state.expanded)Je.push(ue.state.expanded[Ke]);Je[Ee]=!Je[Ee],ue.setState({expanded:Je})},ue.state={expanded:[]},ue}return k(K,ae),y(K,[{key:"getExpandedIcon",value:function(ee){var ue=this.props,Ee=ue.theme,Je=ue.iconStyle;return this.state.expanded[ee]?_().createElement(xe,{theme:Ee,iconStyle:Je}):_().createElement(Re,{theme:Ee,iconStyle:Je})}},{key:"render",value:function(){var ee=this,ue=this.props,Ee=ue.src,Je=ue.groupArraysAfterLength,Ke=(ue.depth,ue.name),Oe=ue.theme,ut=ue.jsvRoot,Be=ue.namespace,De=(ue.parent_type,P(ue,_e)),Xe=0,Le=5*this.props.indentWidth;ut||(Xe=5*this.props.indentWidth);var He=Je,mt=Math.ceil(Ee.length/He);return _().createElement("div",Object.assign({className:"object-key-val"},Q(Oe,ut?"jsv-root":"objectKeyVal",{paddingLeft:Xe})),_().createElement(Kr,this.props),_().createElement("span",null,_().createElement(Ps,Object.assign({size:Ee.length},this.props))),Ue(Array(mt)).map(function(Ht,fn){return _().createElement("div",Object.assign({key:fn,className:"object-key-val array-group"},Q(Oe,"objectKeyVal",{marginLeft:6,paddingLeft:Le})),_().createElement("span",Q(Oe,"brace-row"),_().createElement("div",Object.assign({className:"icon-container"},Q(Oe,"icon-container"),{onClick:function(Nn){ee.toggleCollapsed(fn)}}),ee.getExpandedIcon(fn)),ee.state.expanded[fn]?_().createElement(St,Object.assign({key:Ke+fn,depth:0,name:!1,collapsed:!1,groupArraysAfterLength:He,index_offset:fn*He,src:Ee.slice(fn
946*He,fn*He+He),namespace:Be,type:"array",parent_type:"array_group",theme:Oe},De)):_().createElement("span",Object.assign({},Q(Oe,"brace"),{onClick:function(Nn){ee.toggleCollapsed(fn)},className:"array-group-brace"}),"[",_().createElement("div",Object.assign({},Q(Oe,"array-group-meta-data"),{className:"array-group-meta-data"}),_().createElement("span",Object.assign({className:"object-size"},Q(Oe,"object-size")),fn*He," - ",fn*He+He>Ee.length?Ee.length:fn*He+He)),"]")))}))}}])}(_().PureComponent),Ge=["depth","src","namespace","name","type","parent_type","theme","jsvRoot","iconStyle"],Fe=function(ae){function K(ee){var ue;h(this,K),(ue=S(this,K,[ee])).toggleCollapsed=function(){ue.setState({expanded:!ue.state.expanded},function(){ce.set(ue.props.rjvId,ue.props.namespace,"expanded",ue.state.expanded)})},ue.getObjectContent=function(Je,Ke,Oe){return _().createElement("div",{className:"pushed-content object-container"},_().createElement("div",Object.assign({className:"object-content"},Q(ue.props.theme,"pushed-content")),ue.renderObjectContents(Ke,Oe)))},ue.getEllipsis=function(){return ue.state.size===0?null:_().createElement("div",Object.assign({},Q(ue.props.theme,"ellipsis"),{className:"node-ellipsis",onClick:ue.toggleCollapsed}),"...")},ue.getObjectMetaData=function(Je){var Ke=ue.props,Oe=(Ke.rjvId,Ke.theme,ue.state),ut=Oe.size,Be=Oe.hovered;return _().createElement(Ps,Object.assign({rowHovered:Be,size:ut},ue.props))},ue.renderObjectContents=function(Je,Ke){var Oe,ut=ue.props,Be=ut.depth,De=ut.parent_type,Xe=ut.index_offset,Le=ut.groupArraysAfterLength,He=ut.namespace,mt=ue.state.object_type,Ht=[],fn=Object.keys(Je||{});return ue.props.sortKeys&&mt!=="array"&&(fn=fn.sort()),fn.forEach(function(Nn){if(Oe=new pt(Nn,Je[Nn],Ke.bigNumber),De==="array_group"&&Xe&&(Oe.name=parseInt(Oe.name)+Xe),Object.prototype.hasOwnProperty.call(Je,Nn))if(Oe.type==="object")Ht.push(_().createElement(St,Object.assign({key:Oe.name,depth:Be+1,name:Oe.name,src:Oe.value,namespace:He.concat(Oe.name),parent_type:mt},Ke)));else if(Oe.type==="array"){var sr=St;Le&&Oe.value.length>Le&&(sr=Ve),Ht.push(_().createElement(sr,Object.assign({key:Oe.name,depth:Be+1,name:Oe.name,src:Oe.value,namespace:He.concat(Oe.name),type:"array",parent_type:mt},Ke)))}else Ht.push(_().createElement(yr,Object.assign({key:Oe.name+"_"+He,variable:Oe,singleIndent:5,namespace:He,type:ue.props.type},Ke)))}),Ht};var Ee=K.getState(ee);return ue.state=f(f({},Ee),{},{prevProps:{}}),ue}return k(K,ae),y(K,[{key:"getBraceStart",value:function(ee,ue){var Ee=this,Je=this.props,Ke=Je.src,Oe=Je.theme,ut=Je.iconStyle;if(Je.parent_type==="array_group")return _().createElement("span",null,_().createElement("span",Q(Oe,"brace"),ee==="array"?"[":"{"),ue?this.getObjectMetaData(Ke):null);var Be=ue?xe:Re;return _().createElement("span",null,_().createElement("span",Object.assign({onClick:function(De){Ee.toggleCollapsed()}},Q(Oe,"brace-row")),_().createElement("div",Object.assign({className:"icon-container"},Q(Oe,"icon-container")),_().createElement(Be,{theme:Oe,iconStyle:ut})),_().createElement(Kr,this.props),_().createElement("span",Q(Oe,"brace"),ee==="array"?"[":"{")),ue?this.getObjectMetaData(Ke):null)}},{key:"render",value:function(){var ee=this,ue=this.props,Ee=ue.depth,Je=ue.src,Ke=(ue.namespace,ue.name,ue.type,ue.parent_type),Oe=ue.theme,ut=ue.jsvRoot,Be=ue.iconStyle,De=P(ue,Ge),Xe=this.state,Le=Xe.object_type,He=Xe.expanded,mt={};return ut||Ke==="array_group"?Ke==="array_group"&&(mt.borderLeft=0,mt.display="inline"):mt.paddingLeft=5*this.props.indentWidth,_().createElement("div",Object.assign({className:"object-key-val",onMouseEnter:function(){return ee.setState(f(f({},ee.state),{},{hovered:!0}))},onMouseLeave:function(){return ee.setState(f(f({},ee.state),{},{hovered:!1}))}},Q(Oe,ut?"jsv-root":"objectKeyVal",mt)),this.getBraceStart(Le,He),He?this.getObjectContent(Ee,Je,f({theme:Oe,iconStyle:Be},De)):this.getEllipsis(),_().createElement("span",{className:"brace-row"},_().createElement("span",{style:f(f({},Q(Oe,"brace").style),{},{paddingLeft:He?"3px":"0px"})},Le==="array"?"]":"}"),He?null:this.getObjectMetaData(Je)))}}],[{key:"getDerivedStateFromProps",value:function(ee,ue){var Ee=ue.prevProps;return ee.src!==Ee.src||ee.collapsed!==Ee.collapsed||ee.name!==Ee.name||ee.namespace!==Ee.namespace||ee.rjvId!==Ee.rjvId?f(f({},K.getState(ee)),{},{prevProps:ee}):null}}])}(_().PureComponent);Fe.getState=function(ae){var K=Object.keys(ae.src).length,ee=(ae.collapsed===!1||ae.collapsed!==!0&&ae.collapsed>ae.depth)&&(!ae.shouldCollapse||ae.shouldCollapse({name:ae.name,src:ae.src,type:F(ae.src),namespace:ae.namespace})===!1)&&K!==0;return{expanded:ce.get(ae.rjvId,ae.namespace,"expanded",ee),object_type:ae.type==="array"?"array":"object",parent_type:ae.type==="array"?"array":"object",size:K,hovered:!1}};var pt=y(function ae(K,ee,ue){h(this,ae),this.name=K,this.value=ee,this.type=F(ee,ue)});V(Fe);const St=Fe;var zt=function(ae){function K(){var ee;h(this,K);for(var ue=arguments.length,Ee=new Array(ue),Je=0;Je<ue;Je++)Ee[Je]=arguments[Je];return(ee=S(this,K,[].concat(Ee))).render=function(){var Ke,Oe,ut,Be,De=ee.props,Xe=[De.name],Le=St;return typeof De.name!="object"||Array.isArray(De.name)||(Xe=[((Ke=De.name)===null||Ke===void 0?void 0:Ke.displayName)||((Oe=De.name)===null||Oe===void 0?void 0:Oe.name)||((ut=De.name)===null||ut===void 0||(Be=ut.type)===null||Be===void 0?void 0:Be.name)||"Anonymous"]),Array.isArray(De.src)&&De.groupArraysAfterLength&&De.src.length>De.groupArraysAfterLength&&(Le=Ve),_().createElement("div",{className:"pretty-json-container object-container"},_().createElement("div",{className:"object-content"},_().createElement(Le,Object.assign({namespace:Xe,depth:0,jsvRoot:!0},De))))},ee}return k(K,ae),y(K)}(_().PureComponent),Nt=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).closeModal=function(){je.dispatch({rjvId:ue.props.rjvId,name:"RESET"})},ue.submit=function(){ue.props.submit(ue.state.input)},ue.state={input:ee.input?ee.input:""},ue}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this,ue=this.props,Ee=ue.theme,Je=ue.rjvId,Ke=ue.isValid,Oe=this.state.input,ut=Ke(Oe);return _().createElement("div",Object.assign({className:"key-modal-request"},Q(Ee,"key-modal-request"),{onClick:this.closeModal}),_().createElement("div",Object.assign({},Q(Ee,"key-modal"),{onClick:function(Be){Be.stopPropagation()}}),_().createElement("div",Q(Ee,"key-modal-label"),"Key Name:"),_().createElement("div",{style:{position:"relative"}}
946,_().createElement("input",Object.assign({},Q(Ee,"key-modal-input"),{className:"key-modal-input",ref:function(Be){return Be&&Be.focus()},spellCheck:!1,value:Oe,placeholder:"...",onChange:function(Be){ee.setState({input:Be.target.value})},onKeyPress:function(Be){ut&&Be.key==="Enter"?ee.submit():Be.key==="Escape"&&ee.closeModal()}})),ut?_().createElement(An,Object.assign({},Q(Ee,"key-modal-submit"),{className:"key-modal-submit",onClick:function(Be){return ee.submit()}})):null),_().createElement("span",Q(Ee,"key-modal-cancel"),_().createElement(yt,Object.assign({},Q(Ee,"key-modal-cancel-icon"),{className:"key-modal-cancel",onClick:function(){je.dispatch({rjvId:Je,name:"RESET"})}})))))}}])}(_().PureComponent),At=function(ae){function K(){var ee;h(this,K);for(var ue=arguments.length,Ee=new Array(ue),Je=0;Je<ue;Je++)Ee[Je]=arguments[Je];return(ee=S(this,K,[].concat(Ee))).isValid=function(Ke){var Oe=ee.props.rjvId,ut=ce.get(Oe,"action","new-key-request");return Ke!=""&&Object.keys(ut.existing_value).indexOf(Ke)===-1},ee.submit=function(Ke){var Oe=ee.props.rjvId,ut=ce.get(Oe,"action","new-key-request");ut.new_value=f({},ut.existing_value),ut.new_value[Ke]=ee.props.defaultValue,je.dispatch({name:"VARIABLE_ADDED",rjvId:Oe,data:ut})},ee}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.active,Ee=ee.theme,Je=ee.rjvId;return ue?_().createElement(Nt,{rjvId:Je,theme:Ee,isValid:this.isValid,submit:this.submit}):null}}])}(_().PureComponent),Zt=function(ae){function K(){return h(this,K),S(this,K,arguments)}return k(K,ae),y(K,[{key:"render",value:function(){var ee=this.props,ue=ee.message,Ee=ee.active,Je=ee.theme,Ke=ee.rjvId;return Ee?_().createElement("div",Object.assign({className:"validation-failure"},Q(Je,"validation-failure"),{onClick:function(){je.dispatch({rjvId:Ke,name:"RESET"})}}),_().createElement("span",Q(Je,"validation-failure-label"),ue),_().createElement(yt,Q(Je,"validation-failure-clear"))):null}}])}(_().PureComponent),Me=function(ae){function K(ee){var ue;return h(this,K),(ue=S(this,K,[ee])).rjvId=Date.now().toString()+Math.random().toString(36).slice(2),ue.getListeners=function(){return{reset:ue.resetState,"variable-update":ue.updateSrc,"add-key-request":ue.addKeyRequest}},ue.updateSrc=function(){var Ee,Je=ce.get(ue.rjvId,"action","variable-update"),Ke=Je.name,Oe=Je.namespace,ut=Je.new_value,Be=Je.existing_value,De=Je.updated_src,Xe=Je.type,Le=ue.props,He=Le.onEdit,mt=Le.onDelete,Ht=Le.onAdd,fn={existing_src:ue.state.src,new_value:ut,updated_src:De,name:Ke,namespace:Oe,existing_value:Be};switch(Xe){case"variable-added":Ee=Ht(fn);break;case"variable-edited":Ee=He(fn);break;case"variable-removed":Ee=mt(fn)}Ee!==!1?(ce.set(ue.rjvId,"global","src",De),ue.setState({src:De})):ue.setState({validationFailure:!0})},ue.addKeyRequest=function(){ue.setState({addKeyRequest:!0})},ue.resetState=function(){ue.setState({validationFailure:!1,addKeyRequest:!1})},ue.state={addKeyRequest:!1,editKeyRequest:!1,validationFailure:!1,src:K.defaultProps.src,name:K.defaultProps.name,theme:K.defaultProps.theme,validationMessage:K.defaultProps.validationMessage,prevSrc:K.defaultProps.src,prevName:K.defaultProps.name,prevTheme:K.defaultProps.theme},ue}return k(K,ae),y(K,[{key:"componentDidMount",value:function(){ce.set(this.rjvId,"global","src",this.state.src);var ee=this.getListeners();for(var ue in ee)ce.on(ue+"-"+this.rjvId,ee[ue]);this.setState({addKeyRequest:!1,editKeyRequest:!1})}},{key:"componentDidUpdate",value:function(ee,ue){ue.addKeyRequest!==!1&&this.setState({addKeyRequest:!1}),ue.editKeyRequest!==!1&&this.setState({editKeyRequest:!1}),ee.src!==this.state.src&&ce.set(this.rjvId,"global","src",this.state.src)}},{key:"componentWillUnmount",value:function(){var ee=this.getListeners();for(var ue in ee)ce.removeListener(ue+"-"+this.rjvId,ee[ue])}},{key:"render",value:function(){var ee=this.state,ue=ee.validationFailure,Ee=ee.validationMessage,Je=ee.addKeyRequest,Ke=ee.theme,Oe=ee.src,ut=ee.name,Be=this.props,De=Be.style,Xe=Be.defaultValue;return _().createElement("div",{className:"react-json-view",style:f(f({},Q(Ke,"app-container").style),De)},_().createElement(Zt,{message:Ee,active:ue,theme:Ke,rjvId:this.rjvId}),_().createElement(zt,Object.assign({},this.props,{src:Oe,name:ut,theme:Ke,type:F(Oe),rjvId:this.rjvId})),_().createElement(At,{active:Je,theme:Ke,rjvId:this.rjvId,defaultValue:Xe}))}}],[{key:"getDerivedStateFromProps",value:function(ee,ue){if(ee.src!==ue.prevSrc||ee.name!==ue.prevName||ee.theme!==ue.prevTheme){var Ee={src:ee.src,name:ee.name,theme:ee.theme,validationMessage:ee.validationMessage,prevSrc:ee.src,prevName:ee.name,prevTheme:ee.theme};return K.validateState(Ee)}return null}}])}(_().PureComponent);Me.defaultProps={src:{},name:"root",theme:"rjv-default",collapsed:!1,collapseStringsAfterLength:!1,shouldCollapse:!1,sortKeys:!1,quotesOnKeys:!0,groupArraysAfterLength:100,indentWidth:4,enableClipboard:!0,escapeStrings:!0,displayObjectSize:!0,displayDataTypes:!0,onEdit:!1,onDelete:!1,onAdd:!1,onSelect:!1,iconStyle:"triangle",style:{},validationMessage:"Validation Error",defaultValue:null,displayArrayKey:!0,selectOnFocus:!1,keyModifier:function(ae){return ae.metaKey||ae.ctrlKey},bigNumber:null},Me.validateState=function(ae){var K={};return F(ae.theme)!=="object"||function(ee){var ue=["base00","base01","base02","base03","base04","base05","base06","base07","base08","base09","base0A","base0B","base0C","base0D","base0E","base0F"];if(F(ee)==="object"){for(var Ee=0;Ee<ue.length;Ee++)if(!(ue[Ee]in ee))return!1;return!0}return!1}(ae.theme)||(console.error("react-json-view error:","theme prop must be a theme name or val
946id base-16 theme object.",'defaulting to "rjv-default" theme'),K.theme="rjv-default"),F(ae.src)!=="object"&&F(ae.src)!=="array"&&(console.error("react-json-view error:","src property must be a valid json object"),K.name="ERROR",K.src={message:"src property must be a valid json object"}),f(f({},ae),K)},V(Me);const Qe=Me})(),o})())}(Cy)),Cy.exports}var bme=gme();const yme=Vo(bme),cF=({children:t})=>c.jsx(c.Fragment,{children:_W.createPortal(t,document.getElementById("modal-dialog")||document.body)});function Cv(...t){return K3(U3(t))}const vme=1/3,Ba=1/6,Jk=t=>Math.floor(t)|0,e2=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function xme(t=Math.random){const e=wme(t),n=new Float64Array(e).map(s=>e2[s%12*3]),r=new Float64Array(e).map(s=>e2[s%12*3+1]),i=new Float64Array(e).map(s=>e2[s%12*3+2]);return function(o,a,l){let u,d,f,h;const m=(o+a+l)*vme,y=Jk(o+m),g=Jk(a+m),w=Jk(l+m),v=(y+g+w)*Ba,S=y-v,C=g-v,k=w-v,N=o-S,_=a-C,j=l-k;let T,M,V,H,P,F;N>=_?_>=j?(T=1,M=0,V=0,H=1,P=1,F=0):N>=j?(T=1,M=0,V=0,H=1,P=0,F=1):(T=0,M=0,V=1,H=1,P=0,F=1):_<j?(T=0,M=0,V=1,H=0,P=1,F=1):N<j?(T=0,M=1,V=0,H=0,P=1,F=1):(T=0,M=1,V=0,H=1,P=1,F=0);const I=N-T+Ba,R=_-M+Ba,U=j-V+Ba,A=N-H+2*Ba,W=_-P+2*Ba,D=j-F+2*Ba,B=N-1+3*Ba,L=_-1+3*Ba,$=j-1+3*Ba,q=y&255,Z=g&255,ie=w&255;let ge=.6-N*N-_*_-j*j;if(ge<0)u=0;else{const be=q+e[Z+e[ie]];ge*=ge,u=ge*ge*(n[be]*N+r[be]*_+i[be]*j)}let re=.6-I*I-R*R-U*U;if(re<0)d=0;else{const be=q+T+e[Z+M+e[ie+V]];re*=re,d=re*re*(n[be]*I+r[be]*R+i[be]*U)}let Y=.6-A*A-W*W-D*D;if(Y<0)f=0;else{const be=q+H+e[Z+P+e[ie+F]];Y*=Y,f=Y*Y*(n[be]*A+r[be]*W+i[be]*D)}let ne=.6-B*B-L*L-$*$;if(ne<0)h=0;else{const be=q+1+e[Z+1+e[ie+1]];ne*=ne,h=ne*ne*(n[be]*B+r[be]*L+i[be]*$)}return 32*(u+d+f+h)}}function wme(t){const n=new Uint8Array(512);for(let r=0;r<512/2;r++)n[r]=r;for(let r=0;r<512/2-1;r++){const i=r+~~(t()*(256-r)),s=n[r];n[r]=n[i],n[i]=s}for(let r=256;r<512;r++)n[r]=n[r-256];return n}const jM=[{h:222,s:48,l:61},{h:120,s:31,l:63},{h:25,s:83,l:77},{h:0,s:0,l:98}],uF=t=>{const e=x.useRef(null),n=x.useRef(null),r=x.useRef(void 0),i=t.particleCount||700,s=11,o=i*s,a=t.rangeX||100,l=t.rangeY||100,u=150,d=300,f=t.baseSpeed||.1,h=t.rangeSpeed||.5,m=t.baseRadius||.025,y=t.rangeRadius||2,g=t.useChatBoundaryCutoff!==!1,w=1,v=25e-5,S=25e-5,C=1e-4,k=xme(),N=x.useRef(new Float32Array(o)),_=x.useRef([0,0]),j=x.useRef(0),T=x.useCallback(()=>{var ne,be;if(!t.attractionElementRef||!t.attractionElementRef.current){r.current=void 0;return}const ie=t.attractionElementRef.current;ie.offsetHeight;const ge=ie.getBoundingClientRect(),re=((ne=window.visualViewport)==null?void 0:ne.offsetLeft)||0,Y=((be=window.visualViewport)==null?void 0:be.offsetTop)||0;r.current={x:ge.left+ge.width/2+re,y:ge.top+ge.height/2+Y}},[t.attractionElementRef]);x.useEffect(()=>{const ie=()=>{T()};return window.addEventListener("resize",ie),window.visualViewport&&(window.visualViewport.addEventListener("resize",ie),window.visualViewport.addEventListener("scroll",ie)),window.addEventListener("orientationchange",ie),()=>{window.removeEventListener("resize",ie),window.visualViewport&&(window.visualViewport.removeEventListener("resize",ie),window.visualViewport.removeEventListener("scroll",ie)),window.removeEventListener("orientationchange",ie)}},[T]);const M=2*Math.PI,V=x.useCallback(ie=>ie*Math.random(),[]),H=x.useCallback(ie=>ie-V(2*ie),[V]),P=x.useCallback((ie,ge)=>{const re=.5*ge;return Math.abs((ie+re)%ge-re)/re},[]),F=x.useCallback((ie,ge,re)=>(1-re)*ie+re*ge,[]),I=x.useCallback(()=>jM[Math.floor(Math.random()*jM.length)],[]),R=x.useCallback(ie=>{if(!e.current)return;const re=I(),Y={x:_.current[1]+H(a),y:_.current[1]+H(l),vx:0,vy:0,life:0,ttl:u+V(d),speed:f+V(h),radius:m+V(y),color:re};N.current.set([Y.x,Y.y,Y.vx,Y.vy,Y.life,Y.ttl,Y.speed,Y.radius,Y.color.h,Y.color.s,Y.color.l],ie)},[I,V,H,a,l,u,d,f,h,m,y]),U=(ie,ge,re,Y,ne,be,we,te,fe)=>{const O=P(ne,be);fe.save(),fe.globalCompositeOperation="lighter",fe.lineCap="round",fe.lineWidth=we,fe.strokeStyle=`hsla(${te.h}, ${te.s}%, ${te.l}%, ${O})`,fe.beginPath(),fe.moveTo(ie,ge),fe.lineTo(re,Y),fe.stroke(),fe.restore(
946),fe.save(),fe.globalCompositeOperation="lighter",fe.lineCap="round",fe.lineWidth=we*5,fe.strokeStyle=`hsla(${te.h}, ${te.s}%, ${te.l}%, ${O*.05})`,fe.beginPath(),fe.moveTo(ie,ge),fe.lineTo(re,Y),fe.stroke(),fe.restore()},A=x.useCallback((ie,ge)=>{if(!g||!r.current)return!1;const re=r.current.x,Y=r.current.y,ne=650,be=80,we=20,te=10,fe=(ne+we)/2,O=(be+te)/2,pe=Math.abs(ie-re),he=Math.abs(ge-Y),le=pe/fe,oe=he/O;return le*le+oe*oe<=1},[g]),W=(ie,ge)=>{const re=e.current;if(!re)return;const Y=N.current,ne=1+ie,be=2+ie,we=3+ie,te=4+ie,fe=5+ie,O=6+ie,pe=7+ie,he=8+ie,le=9+ie,oe=10+ie,Q=Y[ie],de=Y[ne];if(A(Q,de)){R(ie);return}const Ne=k(Q*v,de*S,j.current*C)*w*M;let Ce=F(Y[be],Math.cos(Ne),.5),Ae=F(Y[we],Math.sin(Ne),.5);const Ue=Y[te],Se=Y[fe],ve=Y[O];if(r.current){const qe=t.attractionStrength||.001,ot=r.current.x-Q,Ze=r.current.y-de,_t=Math.sqrt(ot*ot+Ze*Ze);if(_t>0){Ce+=ot/_t*qe,Ae+=Ze/_t*qe;const tt=t.swirlStrength||5,gt=-Ze/_t,dt=ot/_t;Ce+=gt*tt,Ae+=dt*tt}}const je=Q+Ce*ve,Te=de+Ae*ve;if(A(je,Te)){R(ie);return}const ce=Y[pe],se=Y[he],ye=Y[le],ke=Y[oe];U(Q,de,je,Te,Ue,Se,ce,{h:se,s:ye,l:ke},ge),Y[ie]=je,Y[ne]=Te,Y[be]=Ce,Y[we]=Ae,Y[te]=Ue+1,(B(Q,de,re)||Ue>Se)&&R(ie)},D=ie=>{for(let ge=0;ge<o;ge+=s)W(ge,ie)},B=(ie,ge,re)=>ie>re.width||ie<0||ge>re.height||ge<0,L=ie=>{ie.width=window.innerWidth,ie.height=window.innerHeight,_.current=[.5*ie.width,.5*ie.height]},$=(ie,ge)=>{ge.save(),ge.globalCompositeOperation="lighter",ge.drawImage(ie,0,0),ge.restore()},q=(ie,ge)=>{j.current++,T(),ge.clearRect(0,0,ie.width,ie.height),D(ge),$(ie,ge),window.requestAnimationFrame(()=>q(ie,ge))},Z=()=>{const ie=e.current;if(!ie)return;const ge=ie.getContext("2d");if(ge){L(ie);for(let re=0;re<o;re+=s)R(re);q(ie,ge)}};return x.useEffect(()=>{Z();const ie=()=>{const ge=e.current;ge&&L(ge)};return window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),c.jsx("div",{className:Cv("fixed z-0",t.containerClassName),children:c.jsx(et.div,{initial:{opacity:0}
946,animate:{opacity:1},ref:n,children:c.jsx("canvas",{ref:e})})})},_v=({message:t="Loading"})=>{const{isDarkMode:e}=Pn(),{isMobile:n}=Hn(),r=x.useRef(null),[i,s]=x.useState(!1),[o,a]=x.useState("..."),l=100;return x.useEffect(()=>(s(!0),()=>{s(!1)}),[]),x.useEffect(()=>{const u=["",".","..","..."];let d=0;const f=setInterval(()=>{a(u[d]),d=(d+1)%u.length},150);return()=>{clearInterval(f)}},[]),c.jsx(cF,{children:c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",children:c.jsxs("div",{className:"relative w-full h-full",children:[c.jsx("div",{ref:r,className:"absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2",children:c.jsx(Vn,{children:i&&c.jsx(et.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.8,ease:"easeInOut"},children:c.jsx("div",{className:"text-2xl font-bold text-white tracking-wider drop-shadow-lg flex justify-center",children:c.jsxs("div",{className:"relative",children:[c.jsx("span",{children:t}),c.jsx("span",{className:"absolute left-full w-12",children:o})]})})})})}),c.jsx(uF,{containerClassName:"absolute inset-0 z-10",particleCount:100,baseSpeed:.85,rangeSpeed:.2,baseRadius:.75,rangeRadius:1.5,attractionElementRef:r,attractionStrength:.3,swirlStrength:.25,rangeX:window.innerHeight/2*1.5,rangeY:window.innerHeight/2},`vortex-${l}-${e?"dark":"light"}`)]})})})},kme=()=>{const{closeInspectStorage:t}=Br(),{retrieveStorage:e,downloadStorageFile:n,replaceStorageFile:r}=_d(),{theme:i}=Pn(),[s,o]=x.useState(null),[a,l]=x.useState(!1),[u,d]=x.useState(!0),{focusCanvas:f}=di(),{isMobile:h}=Hn(),m=i===gi.Dark;x.useEffect(()=>{(async()=>{try{const v=await e();o(v)}catch{o("{}")}finally{d(!1)}})()},[e]);const y=()=>{const w=document.createElement("input");w.type="file",w.accept=".cai",w.onchange=v=>{var C;const S=(C=v.target.files)==null?void 0:C[0];if(S){const k=new FileReader;k.onload=async N=>{var j;const _=(j=N.target)==null?void 0:j.result;l(!0),await r(_),l(!1)},k.readAsText(S)}},w.click()},g=()=>{t(),f()};return u||s===null?c.jsx(_v,{}):c.jsx(Wr,{onClose:g,widthClass:h?"w-[93%]":"w-2/5",heightClass:h?"h-[84%]":"h-4/5",blurBackground:!0,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors backdrop-blur-sm ${m?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 text-zinc-100":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 text-zinc-800"}`,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${m?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm border-zinc-800":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 backdrop-blur-sm border-zinc-200"}`,children:[c.jsx("h1",{className:"text-2xl font-semibold",children:"Inspect Storage"}),c.jsx("button",{onClick:g,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${m?"hover:bg-zinc-100":"hover:bg-zinc-900"}`,"aria-label":"Close inspect storage",children:c.jsx(nr,{size:20})})]}),c.jsxs("div",{className:`flex-1 p-4 flex flex-col space-y-4 overflow-hidden ${m?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsx("div",{className:`flex-1 overflow-auto rounded-lg p-4 border ${m?"bg-gradient-to-br from-zinc-900/50 to-zinc-800/25 backdrop-blur-sm border-zinc-700":"bg-gradient-to-br from-zinc-200/50 to-zinc-300/25 backdrop-blur-sm border-zinc-200"}`,children:c.jsx(yme,{src:JSON.parse(s),theme:m?"monokai":"rjv-default",enableClipboard:!1,style:{backgroundColor:"transparent"}})}),c.jsxs("div",{className:"flex gap-3 justify-center",children:[c.jsx("button",{onClick:()=>n(),className:`px-4 py-2 rounded-lg border transition-all duration-200 hover:scale-105 ${m?"bg-gradient-to-br from-zinc-800/80 to-zinc-700/50 backdrop-blur-sm border-zinc-600 text-zinc-200 hover:bg-zinc-700/50":"bg-gradient-to-br from-zinc-100/80 to-zinc-200/50 backdrop-blur-sm border-zinc-300 text-zinc-900 hover:bg-zinc-200/50"}`,children:"Download Storage"}),c.jsx("button",{onClick:y,className:`px-4 py-2 rounded-lg border transition-all duration-200 hover:scale-105 ${m?"bg-gradient-to-br from-zinc-800/80 to-zinc-700/50 backdrop-blur-sm border-zinc-600 text-zinc-200 hover:bg-zinc-700/50":"bg-gradient-to-br from-zinc-100/80 to-zinc-200/50 backdrop-blur-sm border-zinc-300 text-zinc-900 hover:bg-zinc-200/50"}`,children:"Upload Storage"})]}),a&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-lg backdrop-blur-sm",children:c.jsx(_v,{})})]})]})})},TM=({active:t,setActive:e,disabled:n=!1,"aria-label":r})=>c.jsxs("button",{onClick:()=>e(!t),disabled:n,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-caiBlue-500 focus:ring-offset-2 ${n?"opacity-50 cursor-not-allowed":""} ${t?"bg-caiBlue-500 dark:bg-caiBlue-600":"bg-zinc-300 dark:bg-zinc-600"}`,role:"switch","aria-checked":t,"aria-label":r||"Toggle setting",children:[c.jsx("span",{className:"sr-only",children:r||"Toggle setting"}),c.jsx("span",{"aria-hidden":"true",className:"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition-transform duration-200 ease-in-out",style:{willChange:"transform",transform:t?"translateX(20px)":"translateX(0px)"}})]}),Sme=4,Cme=40,zM=Sme*Cme,dm=({options:t,selectedOption:e,onOptionChange:n,formatOption:r=f=>f,label:i,icon:s,description:o=null,isDarkMode:a,allowCustomValues:l=!1,customValuePrefix:u="",parseCustomValue:d=null})=>{const[f,h]=x.useState(!1),[m,y]=x.useState(null),[g,w]=x.useState(t),[v,S]=x.useState(""),[C,k]=x.useState(null),N=x.useRef(null),_=x.useRef(null),j=x.useCallback(async H=>{H!==e&&(y(H),await n(H),y(null)),h(!1),S(""),k(null)},[e,n]),T=x.useCallback(()=>{var H;f?(H=_.current)==null||H.focus():(h(!0),S(""),w(t))},[f,t]),M=x.useCallback(H=>{const P=H.target.value;S(P);const F=t.filter(I=>{const R=r(I).toLowerCase(),U=I.toString().toLowerCase(),A=P.toLowerCase();return R.includes(A)||U.includes(A)});
946if(w(F),l&&d){const I=d(P);I!==null&&!t.includes(I)?k(I):k(null)}else k(null)},[t,r,l,d]),V=x.useCallback(H=>{var P,F;H.key==="Enter"?(C!==null?j(C):g.length>0&&j(g[0]),(P=_.current)==null||P.blur()):H.key==="Escape"&&(h(!1),S(""),k(null),(F=_.current)==null||F.blur())},[g,j,C]);return x.useEffect(()=>{const H=P=>{N.current&&!N.current.contains(P.target)&&(h(!1),S(""),k(null))};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]),x.useEffect(()=>{f||(S(""),k(null)),w(t)},[f,t]),[...g],c.jsxs("div",{className:"w-full mb-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s&&c.jsx("span",{className:"text-zinc-400",children:s}),c.jsx("label",{className:"font-medium text-zinc-800 dark:text-zinc-200",children:i})]}),o&&c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 mb-2",children:o}),c.jsxs("div",{ref:N,className:"relative",children:[f?c.jsxs("div",{className:`flex items-center justify-between w-full px-4 py-2.5 rounded-lg border transition-colors ${a?"bg-zinc-800 border-zinc-700 text-zinc-200 hover:bg-zinc-700":"bg-zinc-100 border-zinc-300 text-zinc-800 hover:bg-zinc-200"}`,children:[c.jsx("input",{ref:_,type:"text",value:v,onChange:M,onKeyDown:V,placeholder:"Search options...",className:"bg-transparent text-inherit outline-none flex-1",autoFocus:!0}),c.jsx(Vi,{size:18,className:"ml-2 transition-transform duration-300 rotate-180"})]}):c.jsxs("button",{onClick:T,className:`flex items-center justify-between w-full px-4 py-2.5 rounded-lg border transition-colors ${a?"bg-zinc-800 border-zinc-700 text-zinc-200 hover:bg-zinc-700":"bg-zinc-100 border-zinc-300 text-zinc-800 hover:bg-zinc-200"}`,children:[c.jsx("span",{children:r(e)}),c.jsx(Vi,{size:18,className:"ml-2"})]}),f&&c.jsxs(c.Fragment,{children:[c.jsx(WL,{onClick:()=>{h(!1),S(""),k(null)}}),c.jsx("div",{className:`absolute z-[9999] mt-1 rounded-lg overflow-hidden shadow-lg border w-full ${a?"bg-zinc-800 border-zinc-700":"bg-white border-zinc-300"}`,style:{maxHeight:`${zM}px`},children:c.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:`${zM}px`},children:[C!==null&&c.jsx("div",{className:`px-4 py-2 cursor-pointer flex items-center justify-between border-b ${a?"bg-caiGreen-900/40 text-caiGreen-200 border-zinc-700":"bg-caiGreen-100 text-caiGreen-800 border-zinc-300"}`,onClick:()=>j(C),children:c.jsxs("span",{className:"italic",children:[u," ",r(C)]})}),g.length>0?g.map((H,P)=>c.jsxs("div",{className:`px-4 py-2 cursor-pointer flex items-center justify-between ${H===e?a?"bg-caiBlue-900/40 text-caiBlue-200":"bg-caiBlue-100 text-caiBlue-800":a?"hover:bg-zinc-700 text-zinc-200":"hover:bg-zinc-100 text-zinc-700"}`,onClick:()=>j(H),children:[c.jsx("span",{className:`${m===H?"animate-pulse":""}`,children:r(H)}),H===e&&c.jsx(Ml,{size:16,className:a?"text-caiBlue-300":"text-caiBlue-600"})]},`dropdown-option-${P}-${H}`)):C===null&&c.jsx("div",{className:"px-4 py-2 text-zinc-500 dark:text-zinc-400 text-sm",children:"No options found"})]})})]})]})]})},PM=({selectedInstrument:t,onInstrumentChange:e,label:n,icon:r,description:i=null,isDarkMode:s})=>{const{loadBloobAudio:o}=es(),a=x.useCallback(async l=>{try{await o(l),e(l)}catch{}},[o,e]);return c.jsx(dm,{label:n,icon:r,description:i,options:yh(),formatOption:l=>$l(l),selectedOption:t,onOptionChange:a,isDarkMode:s})},gf=({title:t,icon:e,children:n,defaultExpanded:r=!0,isDarkMode:i})=>{const[s,o]=x.useState(r);return c.jsxs("div",{className:`mb-4 rounded-lg border ${i?"border-zinc-700":"border-zinc-200"}`,children:[c.jsxs("button",{onClick:()=>o(!s),className:`w-full px-4 py-3 flex items-center justify-between transition-colors rounded-t-lg ${i?s?"bg-gradient-to-r from-caiGreen-700/100 to-caiBlue-700/50 text-zinc-100":"bg-zinc-800 text-zinc-300 hover:bg-zinc-700":s?"bg-gradient-to-r from-caiGreen-100/100 to-caiBlue-100/50 text-zinc-800":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"} ${s?"":"rounded-b-lg"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[e,c.jsx("h2",{className:"font-medium",children:t})]}),c.jsx(Vi,{size:18,className:`transition-transform duration-300 ${s?"rotate-180":""}`})]}),s&&c.jsx("div",{className:"rounded-b-lg bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 dark:from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm",children:c.jsx("div",{className:"p-4 space-y-6 pb-6",children:n})})]})},_me=({isDarkMode:t,setTheme:e,setUseSystemTheme:n,useSystemTheme:r})=>c.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-2",children:[c.jsxs(et.button,{whileHover:{scale:1.03},whileTap:{scale:.97},onClick:()=>{e(gi.Light),n(!1)},className:`flex flex-col items-center justify-center p-3 rounded-lg border transition-colors ${!t&&!r?"bg-gradient-to-r from-caiGreen-100 to-caiBlue-100 border-caiBlue-300 text-caiBlue-800":"bg-white border-zinc-200 text-zinc-800 hover:bg-zinc-100"}`,children:[c.jsx(ID,{size:22,className:"mb-1"}),c.jsx("span",{className:"text-sm font-medium",children:"Light"})]}),c.jsxs(et.button,{whileHover:{scale:1.03},whileTap:{scale:.97},onClick:()=>{e(gi.Dark),n(!1)},className:`flex flex-col items-center justify-center p-3 rounded-lg border transition-colors ${t&&!r?"bg-gradient-to-r from-caiBlue-900/40 to-caiGreen-900/40 border-caiBlue-800/40 text-caiBlue-200":"bg-zinc-800 border-zinc-700 text-zinc-100 hover:bg-zinc-700"}`,children:[c.jsx(vne,{size:22,className:"mb-1"}),c.jsx("span",{className:"text-sm font-medium",children:"Dark"})]}),c.jsxs(et.button,{whileHover:{scale:1.03},whileTap:{scale:.97},onClick:()=>n(!0),className:`flex flex-col items-center justify-center p-3 rounded-lg border transition-colors ${r?t?"bg-gradient-to-r from-caiBlue-900/40 to-caiGreen-900/40 border-caiBlue-800/40 text-caiBlue-200":"bg-gradient-to-r from-caiBlue-100 to-caiGreen-100 border-caiBlue-300 text-caiBlue-800":t?"bg-zinc-800 border-zinc-700 text-zinc-300 hover:bg-zinc-700":"bg-zinc-100 border-zinc-200 text-zinc-600 hover:bg-zinc-200"}`,children:[c.jsx(ND,{size:22,className:"mb-1"}),c.jsx("span",{className:"text-sm font-medium",children:"Auto"})]})]}),Eme=()=>Array.from({length:107},(e,n)=>C$(n+21,{pitchClass:!1,sharps:!0})),Nme=({onSignOut:t})=>{const{focusCanvas:e}=di(),{theme:n,useSystemTheme:r}=Pn(),{setTheme:i,setUseSystemTheme:s}=Br(),{generalSettings:o,audioSettings:a,appearanceSettings:l}=bi(),{closeSettings:u,setDefaultInstrument:d,setMetronomeSound:f,setMetronomePitch:h,setMetronomeActive:m,setMetronomeVolume:y,setMasterVolume:g,setScrollPianorollDuringPlayback:w,setShowBloobIds:v,setDragSnapAmount:S,setBloobNudgeAmou
946nt:C}=il(),{reset:k}=Ln(),{showBanner:N}=ts(),{isMobile:_}=Hn(),j=n===gi.Dark,[T,M]=x.useState("general"),[V,H]=x.useState(!1),P=x.useCallback(()=>{u(),e()},[u,e]),F=x.useCallback(async()=>{if(V){k();try{await WE(),t()}catch(D){throw N("There was an issue signing out"),D}}else H(!0),setTimeout(()=>H(!1),3e3)},[t,V,N,k]),I=[{id:"general",label:"General",icon:c.jsx(mx,{size:16})},{id:"audio",label:"Audio",icon:c.jsx(Mn,{size:16})},{id:"appearance",label:"Appearance",icon:c.jsx(ID,{size:16})},{id:"advanced",label:"Advanced",icon:c.jsx(Kc,{size:16})}],R=x.useMemo(()=>[8,4,2,1,.5,.25,.125,.0625,1/32,1/64,1/128,1/256,1/512,1/1024],[]),U=x.useCallback(D=>{if(D===8)return"8 Bars";if(D===4)return"4 Bars";if(D===2)return"2 Bars";if(D===1)return"Whole Bar";if(D===.5)return"Half Bar";if(D===.25)return"Quarter Bar";if(D===.125)return"Eighth Bar";if(D===.0625)return"1/16 Bar";const B=Math.round(1/D);return Math.abs(D-1/B)<1e-9?`1/${B} Bar`:D===Math.floor(D)?D===1?"Whole Bar":`${D} Bars`:`${D} Bar${D===1?"":"s"}`},[]),A=x.useCallback(D=>{const B=Oo(D);return`${D} / midi ${B}`},[]),W=x.useCallback(D=>{const B=D.trim(),L=parseFloat(B);return!isNaN(L)&&L>0&&L<=16?L:null},[]);return c.jsx(Wr,{onClose:P,widthClass:_?"w-[93%]":"w-2/5",heightClass:_?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40 rounded-md shadow-sm transition-all duration-200 text-zinc-900 dark:text-zinc-100",children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${j?"border-zinc-800 bg-gradient-to-br from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(cE,{size:20,className:j?"text-caiBlue-400":"text-caiBlue-600"}),c.jsx("h1",{className:"text-2xl font-semibold",children:"Settings"})]}),c.jsx("button",{onClick:P,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${j?"hover:bg-white":"hover:bg-black"}`,"aria-label":"Close settings",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:`flex gap-1 p-2 border-b overflow-x-auto scrollbar-hide ${j?"border-zinc-800 bg-gradient-to-br from-zinc-900/50 to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:I.map(D=>c.jsxs("button",{onClick:()=>M(D.id),className:`flex items-center gap-1.5 px-3 py-2 rounded-lg whitespace-nowrap transition-colors ${T===D.id?j?"bg-zinc-800/75 text-caiBlue-300":"bg-zinc-100/75 text-caiBlue-600":j?"text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-300":"text-zinc-600 hover:bg-zinc-100/50 hover:text-zinc-800"}`,children:[D.icon,c.jsx("span",{className:"font-medium",children:D.label})]},D.id))}),c.jsx("div",{className:"relative flex-1 overflow-y-auto",children:c.jsxs("div",{className:"relative z-10 p-4",children:[T==="general"&&c.jsxs(gf,{title:"General",icon:c.jsx(Mn,{size:18}),isDarkMode:j,children:[c.jsx(PM,{label:"Default Instrument",icon:c.jsx(Mn,{size:16}),description:"Used when creating new bloobs and for playback.",selectedInstrument:o.defaultInstrument,onInstrumentChange:d,isDarkMode:j}),c.jsx(dm,{label:"Drag Snap Grid",icon:c.jsx(ev,{size:16}),description:"Choose how precisely bloobs snap when dragging.",options:R,selectedOption:o.dragSnapAmount,onOptionChange:S,formatOption:U,isDarkMode:j,allowCustomValues:!0,customValuePrefix:"Make bloob drag",parseCustomValue:W}),c.jsx(dm,{label:"Arrow Key Nudge",icon:c.jsx(ev,{size:16}),description:"Choose how far bloobs move horizontally when using arrow keys.",options:R,selectedOption:o.bloobNudgeAmount??1/256,onOptionChange:C,formatOption:U,isDarkMode:j,allowCustomValues:!0,customValuePrefix:"Make arrow nudge",parseCustomValue:W}),c.jsxs("div",{className:"flex items-center justify-between mb-12",children:[c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qte,{size:16,className:"text-zinc-400"}),c.jsx("label",{className:"font-medium text-zinc-800 dark:text-zinc-200",children:"Scroll Piano Roll During Playback"})]}),c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:"Automatically scroll the piano roll during playback"})]})}),c.jsx(TM,{active:o.scrollPianorollDuringPlayback,setActive:w})]})]}),T==="audio"&&c.jsxs(c.Fragment,{children:[c.jsxs(gf,{title:"Master Volume",icon:c.jsx(Ya,{size:18}),isDarkMode:j,children:[c.jsxs("div",{className:"mb-1",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(Ya,{size:16,className:"text-zinc-400"}),c.jsx("label",{className:"font-medium text-zinc-800 dark:text-zinc-200",children:"Master Volume"})]}),c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 mb-2",children:"Control the overall volume for all audio in the application."})]}
946),c.jsx(_s,{min:0,max:1,step:.01,value:a.masterVolume,renderValue:D=>Math.round(D*100).toString(),onChange:g,onAfterChange:()=>{},doubleClickValue:.5,id:"master-volume-slider"})]}),c.jsxs(gf,{title:"Metronome",icon:c.jsx(tv,{size:18}),isDarkMode:j,children:[c.jsx(dm,{label:"Toggle Metronome",icon:c.jsx(tv,{size:16}),description:"Control when the metronome is active.",options:Object.values(ls),selectedOption:a.metronome.active,onOptionChange:m,isDarkMode:j}),c.jsx(PM,{label:"Metronome Sound",icon:c.jsx(Mn,{size:16}),description:"Choose the instrument sound for metronome clicks.",selectedInstrument:a.metronome.sound,onInstrumentChange:f,isDarkMode:j}),c.jsx(dm,{label:"Metronome Pitch",icon:c.jsx(Mn,{size:16}),description:"Select the pitch for metronome clicks.",options:Eme(),selectedOption:a.metronome.pitch,onOptionChange:h,formatOption:A,isDarkMode:j}),c.jsx("div",{className:"mb-1",children:c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(Ya,{size:16,className:"text-zinc-400"}),c.jsx("label",{className:"font-medium text-zinc-800 dark:text-zinc-200",children:"Metronome Volume"})]})}),c.jsx(_s,{min:0,max:127,step:1,value:a.metronome.volume,onChange:y,onAfterChange:()=>{},doubleClickValue:100,id:"metronome-volume-slider"})]})]}),T==="appearance"&&c.jsxs(c.Fragment,{children:[c.jsxs(gf,{title:"Theme",icon:c.jsx(ND,{size:18}),isDarkMode:j,children:[c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 mb-3",children:"Choose your preferred visual theme or let your system decide."}),c.jsx(_me,{isDarkMode:j,setTheme:i,setUseSystemTheme:s,useSystemTheme:r})]}),c.jsx(gf,{title:"Displays",icon:c.jsx(jD,{size:18}),isDarkMode:j,children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 min-w-0 mr-4",children:[c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("label",{className:"font-medium text-zinc-800 dark:text-zinc-200",children:"Display Bloob IDs"})}),c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:"Display the IDs of the bloobs. Using the IDs in the requests generally leads to more accurate results."})]}),c.jsx("div",{className:"flex-shrink-0",children:c.jsx(TM,{active:l.showBloobIds,setActive:v})})]})})]}),T==="advanced"&&c.jsx(gf,{title:"Data Management",icon:c.jsx(CD,{size:18}),isDarkMode:j,children:c.jsxs("div",{className:`p-4 border rounded-lg mb-4 ${V?"bg-red-500/10 border-red-500/30":j?"bg-zinc-800/50 border-zinc-700":"bg-zinc-50 border-zinc-200"}`,children:[c.jsx("h3",{className:`font-medium mb-1 ${V?"text-red-500":j?"text-zinc-200":"text-zinc-800"}`,children:"Reset All Data"}),c.jsx("p",{className:`text-sm mb-3 ${V?"text-red-400 dark:text-red-300":"text-zinc-500 dark:text-zinc-400"}`,children:"This will delete all songs, bloobs, settings, and you will be signed out. This action cannot be undone."}),c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:F,className:`w-full py-2 px-4 rounded-lg transition-colors ${V?"bg-red-600 text-white":j?"bg-zinc-700 text-zinc-200 hover:bg-zinc-600":"bg-zinc-200 text-zinc-700 hover:bg-zinc-300"}`,children:V?"Are you sure? Click to confirm":"Reset All Data"})]})})]})})]})})},dF=()=>{const{addBloob:t,addNotes:e,addSong:n,addAudioBloob:r,addAudioFile:i,addVisualMediaNode:s}=Gn(),{getSongById:o,getBloobsInSong:a}=mn(),{commitToStore:l}=Ln(),{loadBloobAudio:u,getCurrentAudioContext:d}=es(),f=x.useCallback(async S=>{const k=await d().decodeAudioData(await S.arrayBuffer());return await i(S.name,k)},[i,d]),h=x.useCallback(async(S,C)=>{if(!C)return;const k=a(C.id);let _=(k.length>0?Math.max(...k.map(j=>j.songPosition.track)):-1)+1;await Promise.all(S.map(async j=>{const T=await j.arrayBuffer(),M=new wv.Midi(T);for(let V=0;V<M.tracks.length;V++){const H=M.tracks[V],P={bar:1,track:_};_++;const F=[...H.notes].sort((Z,ie)=>ie.ticks+ie.durationTicks-(Z.ticks+Z.durationTicks))[0],I=F?(F.ticks+F.durationTicks)/M.header.ppq:4,R=Math.ceil(I/C.timeSignature.beatsPerBar)||4,U=j.name.toLowerCase().endsWith(".mid")?j.name.slice(0,-4):j.name,A=H.name?H.name:U,W=Bc(ft.AcousticGrandPiano),D=nO(W),L=D[Math.floor(Math.random()*D.length)],$=t(C.id,{instrument:L},R,P,A),q=H.notes.map(Z=>({pitch:`${Z.pitch}${Z.octave}
946`,velocity:Math.round(Z.velocity*127),startBeat:Z.ticks/M.header.ppq,durationInBeats:Z.durationTicks/M.header.ppq}));e($,q),u($)}})),l()},[a,l,t,e,u]),m=x.useCallback(async(S,C)=>{if(!C)return;const k=a(C.id);let _=(k.length>0?Math.max(...k.map(j=>j.songPosition.track)):-1)+1;await Promise.all(S.map(async j=>{const T=await f(j),M=await v(j),V=60/C.bpm,H=M/V,P=Math.ceil(H/C.timeSignature.beatsPerBar)||1,F={bar:1,track:_};_++;const I=j.name,R=I.toLowerCase().endsWith(".mp3")||I.toLowerCase().endsWith(".wav")?I.slice(0,-4):I;r(C.id,T,P,F,R)}))},[r,f,a]),y=x.useCallback(async(S,C)=>{var P,F,I,R,U,A,W,D,B;if(S.length===0)return;const k=S.filter(L=>L.type==="audio/midi"||L.name.endsWith(".mid")),N=S.filter(L=>L.type==="audio/mp3"||L.name.endsWith(".mp3")||L.type==="audio/wav"||L.name.endsWith(".wav")||L.type==="audio/mpeg"||L.type==="audio/x-wav"||L.type==="audio/mp4"||L.type==="audio/m4a"||L.name.endsWith(".m4a")),_=[...k,...N];if(_.length===0)return;let j={beatsPerBar:4,beatDuration:4},T=120;const M=_[0].name.replace(/\.[^/.]+$/,"");if(k.length>0)try{const L=await k[0].arrayBuffer(),$=new wv.Midi(L);((F=(P=$.header)==null?void 0:P.timeSignatures)==null?void 0:F.length)>0&&(j={beatsPerBar:((R=(I=$.header.timeSignatures[0])==null?void 0:I.timeSignature)==null?void 0:R[0])??4,beatDuration:((A=(U=$.header.timeSignatures[0])==null?void 0:U.timeSignature)==null?void 0:A[1])??4}),((D=(W=$.header)==null?void 0:W.tempos)==null?void 0:D.length)>0&&(T=Math.round(((B=$.header.tempos[0])==null?void 0:B.bpm)||120))}catch{}const V=n({chroma:"C",quality:"Major"},T,j,C,M),H=o(V);k.length>0&&await h(k,H),N.length>0&&await m(N,H)},[n,o,h,m]),g=x.useCallback(async(S,C)=>{const k=S.filter(T=>T.type==="audio/midi"||T.name.endsWith(".mid")||T.type==="audio/mp3"||T.name.endsWith(".mp3")||T.type==="audio/wav"||T.name.endsWith(".wav")||T.type==="audio/mpeg"||T.type==="audio/x-wav"||T.type==="audio/mp4"||T.type==="audio/m4a"||T.name.endsWith(".m4a")),N=C.x,_=C.y,j=300;for(let T=0;T<k.length;T++){const M={x:N+T*j,y:_};await y([k[T]],M)}},[y]),w=x.useCallback(async(S,C)=>{for(let N=0;N<S.length;N++){const _=S[N],j=URL.createObjectURL(_),T={x:C.x+N*50,y:C.y+N*50};s(T,_.name.replace(/\.[^/.]+$/,""),j)}},[s]),v=S=>new Promise(C=>{const k=new Audio;k.onloadedmetadata=()=>{C(k.duration)},k.onerror=()=>{C(8)},k.src=URL.createObjectURL(S)});return{addBloobsToSongFromMidiFiles:h,addAudioBloobsToSong:m,createSongFromFiles:y,createSongsFromFiles:g,addVisualMediaToCanvas:w}};var _r=(t=>(t.ToExistingSong="Upload files to existing song",t.ToNewSong="Upload files to new single song",t.ToMultipleNewSongs="Upload files to multiple new songs",t.ToVisualMedia="Add visual media to canvas",t.ToNotes="Add notes to canvas",t.ToLinks="Add links to canvas",t))(_r||{});const Ime=()=>{const{focusCanvas:t}=di(),{isDarkMode:e,uploadOpen:n}=Pn(),{closeUpload:r}=Br(),[i,s]=x.useState([]),[o,a]=x.useState(!1),[l,u]=x.useState("general"),[d,f]=x.useState(""),[h,m]=x.useState(""),{commitToStore:y}=Ln(),{addVisualMediaNode:g,addTextNode:w,addEmbeddingNode:v}=Gn(),{addBloobsToSongFromMidiFiles:S,addAudioBloobsToSong:C,createSongFromFiles:k,createSongsFromFiles:N}=dF(),{getRandomViewportCenteredCanvasPosition:_}=sl(),[j,T]=x.useState(!1),{showBanner:M}=ts(),{replaceStorageFile:V}=_d(),[H,P]=x.useState(null),[F,I]=x.useState(!1),R=x.useRef(null),U=Se=>{const ve=Array.from(Se.target.files||[]).filter(ce=>ce.type==="audio/midi"||ce.name.endsWith(".mid")||ce.type==="audio/mp3"||ce.name.endsWith(".mp3")||ce.type==="audio/wav"||ce.name.endsWith(".wav")||ce.type==="audio/mpeg"||ce.type==="audio/x-wav"||ce.type==="audio/mp4"||ce.type==="audio/m4a"||ce.name.endsWith(".m4a")||ce.type==="audio/aiff"||ce.type==="audio/x-aiff"||ce.name.toLowerCase().endsWith(".aif")||ce.name.toLowerCase().endsWith(".aiff")||ce.type==="audio/flac"||ce.name.toLowerCase().endsWith(".flac")||ce.type==="audio/ogg"||ce.name.toLowerCase().endsWith(".ogg")||ce.type==="audio/webm"||ce.name.toLowerCase().endsWith(".webm")||ce.type==="audio/aac"||ce.name.toLowerCase().endsWith(".aac")||ce.type==="audio/x-ms-wma"||ce.name.toLowerCase().endsWith(".wma")||ce.type.startsWith("image/")||ce.type.startsWith("video/")||ce.type==="text/plain"||ce.name.toLowerCase().endsWith(".txt")||ce.name.toLowerCase().endsWith(".md")||ce.name.toLowerCase().endsWith(".rtf")||ce.name.toLowerCase().endsWith(".cai")||ce.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|mp4|mov|avi|mkv|webm|m4v)$/)),je=ve.filter(ce=>ce.name.toLowerCase().endsWith(".cai")),Te=ve.filter(ce=>!ce.name.toLowerCase().endsWith(".cai"));je.length>0&&(P(je[0]),u("cai")),Te.length>0&&s(ce=>[...ce,...Te])},A=Se=>{Se.preventDefault(),Se.stopPropagation(),a(!0)},W=Se=>{Se.preventDefault(),Se.stopPropagation(),Se.currentTarget.contains(Se.relatedTarget)||a(!1)},D=Se=>{var ce,se;if(Se.preventDefault(),Se.stopPropagation(),a(!1),!((se=(ce=Se.dataTransfer)==null?void 0:ce.files)!=null&&se.length))return;const ve=Array.from(Se.dataTransfer.files).filter(ye=>ye.type==="audio/midi"||ye.name.endsWith(".mid")||ye.type==="audio/mp3"||ye.name.endsWith(".mp3")||ye.type==="audio/wav"||ye.name.endsWith(".wav")||ye.type==="audio/mpeg"||ye.type==="audio/x-wav"||ye.type==="audio/mp4"||ye.type==="audio/m4a"||ye.name.endsWith(".m4a")||ye.type==="audio/aiff"||ye.type==="audio/x-aiff"||ye.name.toLowerCase().endsWith(".aif")||ye.name.toLowerCase().endsWith(".aiff")||ye.type==="audio/flac"||ye.name.toLowerCase().endsWith(".flac")||ye.type==="audio/ogg"||ye.name.toLowerCase().endsWith(".ogg")||ye.type==="audio/webm"||ye.name.toLowerCase().endsWith(".webm")||ye.type==="audio/aac"||ye.name.toLowerCase().endsWith(".aac")||ye.type==="audio/x-ms-wma"||ye.name.toLowerCase().endsWith(".wma")||ye.type.startsWith("image/")||ye.type.startsWith("video/")||ye.type==="text/plain"||ye.name.toLowerCase().endsWith(".txt")||ye.name.toLowerCase().endsWith(".md")||ye.name.toLowerCase().endsWith(".rtf")||ye.name.toLowerCase().endsWith(".cai")||ye.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|mp4|mov|avi|mkv|webm|m4v)$/));if(ve.length===0){M("Please drop only MIDI (.mid), audio files, image, video, text, or .cai project files");return}const je=ve.filter(ye=>ye.name.toLowerCase().endsWith(".cai")),Te=ve.filter(ye=>!ye.name.toLowerCase().endsWith(".cai"));je.length>0&&(P(je[0]),u("cai")),Te.length>0&&s(ye=>[...ye,...Te])},{selectedCaiObjects:B}
946=Yn(),{getSongById:L}=mn(),$=x.useMemo(()=>{if(B.length!==1)return null;const Se=B[0];return Se.type===J.Song?L(Se.id):null},[L,B]),{isMobile:q}=Hn(),Z=x.useCallback(()=>{T(!1),s([]),a(!1),u("general"),f(""),m(""),P(null),I(!1),t(),r()},[t,r]),ie=Se=>{const ve=Se.filter(se=>se.type==="audio/midi"||se.name.endsWith(".mid")),je=Se.filter(se=>se.type==="audio/mp3"||se.name.endsWith(".mp3")||se.type==="audio/wav"||se.name.endsWith(".wav")||se.type==="audio/mpeg"||se.type==="audio/x-wav"||se.type==="audio/mp4"||se.type==="audio/m4a"||se.name.endsWith(".m4a")||se.type==="audio/aiff"||se.type==="audio/x-aiff"||se.name.toLowerCase().endsWith(".aif")||se.name.toLowerCase().endsWith(".aiff")||se.type==="audio/flac"||se.name.toLowerCase().endsWith(".flac")||se.type==="audio/ogg"||se.name.toLowerCase().endsWith(".ogg")||se.type==="audio/webm"||se.name.toLowerCase().endsWith(".webm")||se.type==="audio/aac"||se.name.toLowerCase().endsWith(".aac")||se.type==="audio/x-ms-wma"||se.name.toLowerCase().endsWith(".wma")),Te=Se.filter(se=>se.type.startsWith("image/")||se.type.startsWith("video/")||se.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|mp4|mov|avi|mkv|webm|m4v)$/)),ce=Se.filter(se=>se.type==="text/plain"||se.name.toLowerCase().endsWith(".txt")||se.name.toLowerCase().endsWith(".md")||se.name.toLowerCase().endsWith(".rtf"));return{midiFiles:ve,audioFiles:je,visualMediaFiles:Te,textFiles:ce}},ge=async Se=>{T(!0);try{const{midiFiles:ve,audioFiles:je,visualMediaFiles:Te,textFiles:ce}=ie(i);if(Se===_r.ToExistingSong&&$){if(ve.length>0&&await S(ve,$),je.length>0&&await C(je,$),Te.length>0){const se=_();await re(Te,se)}if(ce.length>0){const se=_();await Y(ce,se)}}else if(Se===_r.ToNewSong){const se=_(),ye=[...ve,...je];ye.length>0&&await k(ye,se),Te.length>0&&await re(Te,se),ce.length>0&&await Y(ce,se)}else if(Se===_r.ToMultipleNewSongs){const se=_(),ye=[...ve,...je];ye.length>0&&await N(ye,se),Te.length>0&&await re(Te,se),ce.length>0&&await Y(ce,se)}else if(Se===_r.ToVisualMedia){const se=_();await re(Te,se)}else if(Se===_r.ToNotes){const se=_();ce.length>0&&await Y(ce,se),d.trim()&&await ne(d,se)}else if(Se===_r.ToLinks){const se=_();h.trim()&&await be(h,se)}y()}catch{M("There was an issue uploading files")}finally{Z()}},re=async(Se,ve)=>{for(let Te=0;Te<Se.length;Te++){const ce=Se[Te];try{const se=new FileReader,ye=await new Promise((ze,qe)=>{se.onload=ot=>{var Ze;return ze((Ze=ot.target)==null?void 0:Ze.result)},se.onerror=qe,se.readAsDataURL(ce)}),ke={x:ve.x+Te*50,y:ve.y+Te*50};g(ke,ce.name.replace(/\.[^/.]+$/,""),ye)}catch(se){pr(`Error processing visual media file ${ce.name}:`,se)}}},Y=async(Se,ve)=>{for(let Te=0;Te<Se.length;Te++){const ce=Se[Te];try{const se=await ce.text(),ye=se.split(` 947`).map(ze=>ze.trim()).filter(ze=>ze.length>0);if(ye.every(ze=>ze.startsWith("http://")||ze.startsWith("https://")||ze.includes("youtube.com")||ze.includes("youtu.be")||ze.includes("spotify.com")||ze.includes("soundcloud.com")||ze.includes("music.apple.com")||ze.includes("bandcamp.com")||ze.includes("tidal.com")||ze.includes("deezer.com")||ze.includes("music.amazon.com")||ze.includes("pandora.com"))&&ye.length>0)for(let ze=0;ze<ye.length;ze++){const qe=ye[ze],ot={x:ve.x+(Te+ze)*50,y:ve.y+(Te+ze)*50};v(ot,void 0,qe)}else{const ze={x:ve.x+Te*50,y:ve.y+Te*50};w(ze,ce.name.replace(/\.[^/.]+$/,""),se)}}catch(se){pr(`Error reading text file ${ce.name}:`,se);const ye={x:ve.x+Te*50,y:ve.y+Te*50};w(ye,ce.name.replace(/\.[^/.]+$/,""),`Error reading file: ${ce.name}`)}}},ne=async(Se,ve)=>{w(ve,void 0,Se)},be=async(Se,ve)=>{const Te=Se.split(` 948`).map(ce=>ce.trim()).filter(ce=>ce.length>0);for(let ce=0;ce<Te.length;ce++){const se=Te[ce],ye={x:ve.x+ce*50,y:ve.y+ce*50};let ke="Link";try{const qe=new URL(se).hostname.replace("www.","");qe.includes("youtube.com")||qe.includes("youtu.be")?ke="YouTube":qe.includes("spotify.com")?ke="Spotify":qe.includes("soundcloud.com")?ke="SoundCloud":qe.includes("music.apple.com")?ke="Apple Music":qe.includes("bandcamp.com")?ke="Bandcamp":qe.includes("tidal.com")?ke="Tidal":qe.includes("deezer.com")?ke="Deezer":qe.includes("music.amazon.com")?ke="Amazon Music":qe.includes("pandora.com")?ke="Pandora":ke=qe.charAt(0).toUpperCase()+qe.slice(1)}catch{ke=se.length>30?se.substring(0,30)+"...":se}v(ye,ke,se)}},we=()=>e?"border-zinc-700":"border-zinc-200",te=()=>e?"bg-gradient-to-r from-caiGreen-700/100 to-caiBlue-700/50 text-zinc-100":"bg-gradient-to-r from-caiGreen-100/100 to-caiBlue-100/50 text-zinc-800",fe=Se=>Se.type==="audio/midi"||Se.name.endsWith(".mid")?{icon:c.jsx(Mn,{size:16,className:"mr-2 flex-shrink-0"}),type:"MIDI"}:Se.type.startsWith("audio/")?{icon:c.jsx(Mn,{size:16,className:"mr-2 flex-shrink-0"}),type:"Audio"}:Se.type.startsWith("image/")?{icon:c.jsx(Gs,{size:16,className:"mr-2 flex-shrink-0"}),type:"Image"}:Se.type.startsWith("video/")?{icon:c.jsx(Ul,{size:16,className:"mr-2 flex-shrink-0"}),type:"Video"}:Se.type==="text/plain"||Se.name.toLowerCase().match(/\.(txt|md|rtf)$/)?{icon:c.jsx($i,{size:16,className:"mr-2 flex-shrink-0"}),type:"Text"}:{icon:c.jsx($i,{size:16,className:"mr-2 flex-shrink-0"}),type:"File"},O=()=>{switch(l){case"single":return _r.ToNewSong;case"multiple":return _r.ToMultipleNewSongs;case"existing":return _r.ToExistingSong;case"visual":return _r.ToVisualMedia;case"notes":return _r.ToNotes;case"links":return _r.ToLinks;default:return null}},pe=x.useMemo(()=>{const{midiFiles:Se,audioFiles:ve,visualMediaFiles:je,textFiles:Te}=ie(i),ce=Se.length>0||ve.length>0,se=je.length>0,ye=Te.length>0,ke=[{id:"general",label:"General",icon:c.jsx(gx,{size:16})},{id:"cai",label:"Cai Project",icon:c.jsx(vm,{size:16})}];return(ce||i.length===0)&&(ke.push({id:"single",label:"Single Song",icon:c.jsx(Mn,{size:16})},{id:"multiple",label:"Multiple Songs",icon:c.jsx(nk,{size:16})}
948),$&&ke.push({id:"existing",label:"To Existing",icon:c.jsx(Yf,{size:16})})),(se||i.length===0)&&ke.push({id:"visual",label:"Visual Media",icon:c.jsx(Gs,{size:16})}),(ye||i.length===0)&&ke.push({id:"notes",label:"Notes",icon:c.jsx(Tl,{size:16})}),ke.push({id:"links",label:"Links",icon:c.jsx(Ka,{size:16})}),ke},[$,i]),he=()=>{const Se=O(),{midiFiles:ve,audioFiles:je,visualMediaFiles:Te,textFiles:ce}=ie(i);if(!Se)return null;switch(l){case"single":return{text:"Create Single Song",icon:c.jsx(Ml,{size:18}),action:()=>ge(_r.ToNewSong),disabled:ve.length===0&&je.length===0};case"multiple":return{text:"Create Multiple Songs",icon:c.jsx(nk,{size:18}),action:()=>ge(_r.ToMultipleNewSongs),disabled:ve.length===0&&je.length===0};case"existing":return{text:`Upload to "${$==null?void 0:$.label}"`,icon:c.jsx(wc,{size:18}),action:()=>ge(_r.ToExistingSong),disabled:ve.length===0&&je.length===0};case"visual":return{text:"Add Visual Media",icon:c.jsx(Gs,{size:18}),action:()=>ge(_r.ToVisualMedia),disabled:Te.length===0};case"notes":return{text:"Add Notes",icon:c.jsx(Tl,{size:18}),action:()=>ge(_r.ToNotes),disabled:ce.length===0&&!d.trim()};case"links":return{text:"Add Links",icon:c.jsx(Ka,{size:18}),action:()=>ge(_r.ToLinks),disabled:!h.trim()};default:return null}},le=x.useCallback(async Se=>{if(!Se.name.toLowerCase().endsWith(".cai")){M("Please upload a .cai file only");return}T(!0);try{const ve=await Se.text();await V(ve),M("Project loaded successfully"),Z()}catch{M("Error loading project file. Please try again.")}finally{T(!1)}},[Z,V,M]),oe=x.useCallback(()=>{var Se;(Se=R.current)==null||Se.click()},[]),Q=x.useCallback(Se=>{var je;const ve=(je=Se.target.files)==null?void 0:je[0];ve&&P(ve),R.current&&(R.current.value="")},[]),de=x.useCallback(Se=>{Se.preventDefault(),Se.stopPropagation(),Se.dataTransfer.items.length===1&&Se.dataTransfer.items[0].kind==="file"&&I(!0)},[]),Ne=x.useCallback(Se=>{Se.preventDefault(),Se.stopPropagation(),Se.dataTransfer.items.length===1&&Se.dataTransfer.items[0].kind==="file"&&I(!0)},[]),Ce=x.useCallback(Se=>{Se.preventDefault(),Se.stopPropagation(),Se.currentTarget.contains(Se.relatedTarget)||I(!1)},[]),Ae=x.useCallback(Se=>{if(Se.preventDefault(),Se.stopPropagation(),I(!1),Se.dataTransfer.files.length===0)return;if(Se.dataTransfer.files.length>1){M("Please upload only one .cai file");return}const ve=Se.dataTransfer.files[0];if(!ve.name.toLowerCase().endsWith(".cai")){M("Please upload a .cai file only");return}P(ve)},[M]),Ue=x.useCallback(()=>{H&&le(H)},[H,le]);return c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:".mid,audio/midi,.mp3,audio/mp3,.wav,audio/wav,.m4a,audio/m4a,audio/mp4,.aif,.aiff,audio/aiff,audio/x-aiff,.flac,audio/flac,.ogg,audio/ogg,.webm,audio/webm,.aac,audio/aac,.wma,audio/x-ms-wma,image/*,video/*,.jpg,.jpeg,.png,.gif,.bmp,.webp,.svg,.mp4,.mov,.avi,.mkv,.webm,.m4v,.txt,.md,.rtf,text/plain,.cai",multiple:!0,id:"fileInput",style:{display:"none"},onChange:U}),c.jsx("input",{ref:R,type:"file",accept:".cai",onChange:Q,className:"hidden","aria-label":"Upload .cai file"}),c.jsx(Vn,{children:n&&c.jsx(Wr,{onClose:Z,widthClass:q?"w-[93%]":"w-2/5",heightClass:q?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-800 dark:text-zinc-100",onDragOver:A,onDragLeave:W,onDrop:D,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${e?"border-zinc-800 bg-gradient-to-br from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(wc,{size:20,className:e?"text-caiBlue-400":"text-caiBlue-600"}),c.jsx("h1",{className:"text-2xl font-semibold",children:"Upload Files"})]}),c.jsx("button",{onClick:Z,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${e?"hover:bg-white":"hover:bg-black"}`,"aria-label":"Close upload",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:`flex gap-1 p-2 border-b overflow-x-auto scrollbar-hide ${e?"border-zinc-800 bg-gradient-to-br from-zinc-900/50 to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:pe.map(Se=>c.jsxs("button",{onClick:()=>u(Se.id),className:`flex items-center gap-1.5 px-3 py-2 rounded-lg whitespace-nowrap transition-colors ${l===Se.id?e?"bg-zinc-800/75 text-caiBlue-300":"bg-zinc-100/75 text-caiBlue-600":e?"text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-300":"text-zinc-600 hover:bg-zinc-100/50 hover:text-zinc-800"}`,children:[Se.icon,c.jsx("span",{className:"font-medium",children:Se.label})]},Se.id))}),c.jsxs("div",{className:"flex-1 w-full flex flex-col items-center justify-center bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-800 dark:text-zinc-100",children:[l==="cai"&&c.jsxs("div",{className:"w-[95%] h-full flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 mb-4 rounded-t-lg ${te()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($i,{size:18}),c.jsx("h2",{className:"text-lg font-medium",children:H?"File Selected":"No File Selected"})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${we()} p-4 flex flex-col items-center justify-center bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,onDragEnter:de,onDragOver:Ne,onDragLeave:Ce,onDrop:Ae,children:[c.jsx(et.div,{initial:{scale:.8,opacity:0}
948,animate:{scale:1,opacity:1},transition:{duration:.5},className:"mb-4",children:H?c.jsx(vm,{size:70,className:"text-caiGreen-500 dark:text-caiGreen-400"}):F?c.jsx(wc,{size:70,className:"text-caiBlue-500 dark:text-caiBlue-400"}):c.jsx(wc,{size:70,className:`${e?"text-zinc-100/70":"text-zinc-800/70"}`})}),c.jsx("p",{className:"text-base mb-4 w-3/4 text-center",children:H?`Selected: ${H.name}`:F?"Drop your .cai file to upload it":"Upload a previously saved .cai file to restore your project. This will replace your current canvas."}),!F&&c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:oe,disabled:j,className:` 949 px-6 py-3 rounded-lg 950 flex items-center justify-center gap-2 951 font-medium shadow-md 952 ${j?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 953 `,children:[c.jsx(wz,{size:20}),H?"Choose Different File":"Browse Files"]})]})]}),l==="notes"&&c.jsxs("div",{className:"w-[95%] h-full flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 mb-4 rounded-t-lg ${te()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Tl,{size:18}),c.jsx("h2",{className:"text-lg font-medium",children:"Create Notes"})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${we()} p-4 flex flex-col bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,children:[c.jsxs("div",{className:"flex-1 flex flex-col",children:[c.jsx("label",{className:"text-sm font-medium mb-2",children:"Note Content:"}),c.jsx("textarea",{value:d,onChange:Se=>f(Se.target.value),placeholder:"Enter your note content here...",className:`flex-1 p-3 border rounded-lg resize-none ${e?"bg-zinc-800/50 border-zinc-600 text-zinc-100 placeholder-zinc-400":"bg-white/50 border-zinc-300 text-zinc-900 placeholder-zinc-500"}`})]}),c.jsxs("div",{className:"mt-4 pt-4 border-t border-zinc-300 dark:border-zinc-600",children:[c.jsx("p",{className:"text-sm mb-2",children:"Or upload text files:"}),c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{var Se;return(Se=document.getElementById("fileInput"))==null?void 0:Se.click()},className:` 954 px-4 py-2 rounded-lg 955 flex items-center gap-2 956 font-medium shadow-sm 957 ${e?"bg-zinc-800/80 hover:bg-zinc-700/80 text-zinc-100":"bg-zinc-100/80 hover:bg-zinc-200/80 text-zinc-800"} 958 `,children:[c.jsx(Yf,{size:16}),"Browse Text Files"]})]})]})]}),l==="links"&&c.jsxs("div",{className:"w-[95%] h-full flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 mb-4 rounded-t-lg ${te()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ka,{size:18}),c.jsx("h2",{className:"text-lg font-medium",children:"Add Links"})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${we()} p-4 flex flex-col bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,children:[c.jsxs("div",{className:"flex-1 flex flex-col",children:[c.jsx("label",{className:"text-sm font-medium mb-2",children:"URLs (one per line):"}),c.jsx("textarea",{value:h,onChange:Se=>m(Se.target.value),placeholder:`https://youtube.com/watch?v=... 959https://spotify.com/track/... 960https://soundcloud.com/...`,className:`flex-1 p-3 border rounded-lg resize-none ${e?"bg-zinc-800/50 border-zinc-600 text-zinc-100 placeholder-zinc-400":"bg-white/50 border-zinc-300 text-zinc-900 placeholder-zinc-500"}`})]}),c.jsx("div",{className:"mt-4 pt-4 border-t border-zinc-300 dark:border-zinc-600",children:c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Supported platforms: YouTube, Spotify, SoundCloud, Apple Music, Bandcamp, Tidal, Deezer, Amazon Music, Pandora, and more."})})]})]}),i.length===0&&l!=="notes"&&l!=="links"&&l!=="cai"&&c.jsxs("div",{className:"w-[95%] h-full flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 mb-4 rounded-t-lg ${te()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($i,{size:18}),c.jsx("h2",{className:"text-lg font-medium",children:"No Files Selected"})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${we()} p-4 flex flex-col items-center justify-center bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,children:[c.jsx(et.div,{initial:{scale:.8,opacity:0}
960,animate:{scale:1,opacity:1},transition:{duration:.5},className:"mb-4",children:o?c.jsx(wc,{size:70,className:`${e?"text-zinc-100/70":"text-zinc-800/70"}`}):c.jsx(wc,{size:70,className:`${e?"text-zinc-100/70":"text-zinc-800/70"}`})}),c.jsx("p",{className:"text-base mb-4 w-3/4 text-center",children:o?"Drop your files to upload them":l==="single"?"Choose your MIDI (.mid), audio files, or media files to create one song containing all audio files, or drag and drop them anywhere in this window.":l==="multiple"?"Choose your MIDI (.mid), audio files, or media files to create separate songs for each audio file, or drag and drop them anywhere in this window.":l==="existing"?`Choose your MIDI (.mid), audio files, or media files to add to "${$==null?void 0:$.label}", or drag and drop them anywhere in this window.`:l==="visual"?"Choose your image or video files to add to the canvas, or drag and drop them anywhere in this window.":l==="notes"?"Use the text area above to create notes or upload text files.":l==="links"?"Use the text area above to paste links for embedding.":"Please choose your MIDI (.mid), audio files (MP3, WAV, FLAC, OGG, AAC, WMA, AIF), image, video, text, or .cai project files below, or drag and drop them anywhere in this window."}),!o&&c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{var Se;return(Se=document.getElementById("fileInput"))==null?void 0:Se.click()},className:` 961 px-6 py-3 rounded-lg 962 flex items-center justify-center gap-2 963 font-medium shadow-md 964 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 965 `,children:[c.jsx(wz,{size:20}),"Browse Files"]})]})]}),i.length>0&&l!=="notes"&&l!=="links"&&l!=="cai"&&c.jsxs("div",{className:"w-[95%] h-full flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 rounded-t-lg ${te()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($i,{size:18}),c.jsxs("h2",{className:"text-lg font-medium",children:["Selected Files (",i.length,")"]})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${we()} p-4 flex flex-col bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,children:[c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx("div",{className:"space-y-2",children:i.map((Se,ve)=>{const{icon:je,type:Te}=fe(Se);return c.jsxs(et.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,delay:ve*.05},className:`flex items-center justify-between p-3 rounded-lg shadow-sm ${e?"bg-zinc-700/80 hover:bg-zinc-600/80 text-zinc-100":"bg-white/80 hover:bg-zinc-100/80 text-zinc-800"}`,children:[c.jsxs("div",{className:"flex items-center w-4/5 truncate",children:[je,c.jsx("span",{className:"truncate",children:Se.name}),c.jsx("span",{className:`ml-2 text-xs px-2 py-0.5 rounded-full ${Te==="MIDI"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":Te==="Audio"?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":Te==="Image"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":Te==="Video"?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":Te==="Text"?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200"}`,children:Te})]}),c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.9},onClick:()=>{s(i.filter(ce=>ce.name!==Se.name))},className:`flex items-center justify-center p-1.5 rounded-lg ${e?"bg-red-600/20 hover:bg-red-600/30":"bg-red-100 hover:bg-red-200"}`,children:c.jsx(nr,{size:16,className:"text-red-600"})})]},`file-${ve}`)})})}),c.jsx("div",{className:"w-full flex items-center justify-center mt-4",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{var Se;return(Se=document.getElementById("fileInput"))==null?void 0:Se.click()},className:` 966 px-4 py-2 rounded-lg 967 flex items-center gap-2 968 font-medium shadow-sm 969 ${e?"bg-zinc-800/80 hover:bg-zinc-700/80 text-zinc-100":"bg-zinc-100/80 hover:bg-zinc-200/80 text-zinc-800"} 970 `,children:[c.jsx(Yf,{size:16}),"Add More Files"]})})]})]})]}),l==="cai"&&H&&c.jsx("div",{className:`w-full p-4 ${e?"bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-100 border-t border-zinc-800":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 backdrop-blur-sm text-zinc-800 border-t border-zinc-200"}`,children:c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:Ue,disabled:j,className:` 971 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 972 flex items-center justify-center gap-2 973 font-medium shadow-md 974 ${j?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 975 `,children:[c.jsx(vm,{size:18}),j?"Loading...":"Load Project"]})})}),(i.length>0&&l!=="notes"&&l!=="links"&&l!=="cai"||l==="notes"&&(i.some(Se=>Se.type==="text/plain"||Se.name.toLowerCase().match(/\.(txt|md|rtf)$/))||d.trim())||l==="links"&&h.trim())&&c.jsxs("div",{className:`w-full p-4 ${e?"bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-100 border-t border-zinc-800":"bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 backdrop-blur-sm text-zinc-800 border-t border-zinc-200"}`,children:[l==="general"&&(()=>{const{midiFiles:Se,audioFiles:ve,visualMediaFiles:je,textFiles:Te}=ie(i),ce=Se.length>0||ve.length>0,se=je.length>0,ye=Te.length>0;return ce&&(se||ye)?c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>ge($?_r.ToExistingSong:_r.ToNewSong),className:` 976 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 977 flex items-center justify-center gap-2 978 font-medium shadow-md 979 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 980 `,children:[c.jsx(Ml,{size:18}),$?"Upload All Files":"Create Song & Add Content"]})}):ce&&!$?c.jsxs("div",{className:"flex flex-col sm:flex-row justify-center items-center gap-3",children:[c.jsxs(et.button,{whileHover:{scale:1.03},whileTap:{scale:.97},disabled:i.length<2,onClick:()=>ge(_r.ToMultipleNewSongs),className:` 981 w-full sm:w-auto px-6 py-3 rounded-lg 982 flex items-center justify-center gap-2 983 font-medium shadow-md 984 ${i.length<2?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 985 `,children:[c.jsx(nk,{size:18}),"Create Separate Songs"]}),c.jsxs(et.button,{whileHover:{scale:1.03},whileTap:{scale:.97},onClick:()=>ge(_r.ToNewSong),className:` 986 w-full sm:w-auto px-6 py-3 rounded-lg 987 flex items-center justify-center gap-2 988 font-medium shadow-md 989 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 990 `,children:[c.jsx(Ml,{size:18}),"Create Single Song"]})]}):ce&&$?c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>ge(_r.ToExistingSong),className:` 991 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 992 flex items-center justify-center gap-2 993 font-medium shadow-md 994 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 995 `,children:[c.jsx(wc,{size:18}),"Upload to Song"]})}):se?c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>ge(_r.ToVisualMedia),className:` 996 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 997 flex items-center justify-center gap-2 998 font-medium shadow-md 999 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 1000 `,children:[c.jsx(Gs,{size:18}),"Add Visual Media"]})}):ye?c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>ge(_r.ToNotes),className:` 1001 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 1002 flex items-center justify-center gap-2 1003 font-medium shadow-md 1004 ${e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 1005 `,children:[c.jsx(Tl,{size:18}),"Add Notes"]})}):null})(),l!=="general"&&(()=>{const Se=he();return Se?c.jsx("div",{className:"flex justify-center",children:c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:Se.action,disabled:Se.disabled,className:` 1006 w-3/4 sm:w-1/2 lg:w-1/3 px-6 py-3 rounded-lg 1007 flex items-center justify-center gap-2 1008 font-medium shadow-md 1009 ${Se.disabled?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white"} 1010 `,children:[Se.icon,Se.text]})}):null})()]})]})},"upload-modal")}),c.jsx(Vn,{children:j&&c.jsx(_v,{},"loading-spinner")})]})},fF=({progress:t,className:e="",variant:n="gradient",showPercentage:r=!0})=>{const i=()=>{switch(n){case"gradient":return c.jsx("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${t}%`,background:"linear-gradient(90deg, #3B82F6 0%, #10B981 50%, #F59E0B 100%)",backgroundSize:"200% 100%",animation:"gradientShift 3s ease-in-out infinite"}});case"solid":return c.jsx("div",{className:"h-full rounded-full transition-all duration-300 ease-out bg-blue-500",style:{width:`${t}%`}});
1010case"minimal":return c.jsx("div",{className:"h-full rounded-full transition-all duration-300 ease-out bg-zinc-600 dark:bg-zinc-400",style:{width:`${t}%`}});default:return null}};return c.jsxs("div",{className:`w-full ${e}`,children:[c.jsxs("div",{className:"relative w-full h-3 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:[i(),(n==="gradient"||r)&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("span",{className:"text-xs font-semibold text-white drop-shadow-sm",children:[Math.round(t),"%"]})})]}),n==="gradient"&&c.jsx("style",{children:` 1011 @keyframes gradientShift { 1012 0%, 1013 100% { 1014 background-position: 0% 50%; 1015 } 1016 50% { 1017 background-position: 100% 50%; 1018 } 1019 } 1020 `})]})},AM=async(t,e,n)=>{try{const r={...e,bloobIds:e.bloobIds instanceof Set?Array.from(e.bloobIds):e.bloobIds},i=new Set;n.forEach(w=>{ln(w)&&DY(w.instrument)&&i.add(w.instrument)});const s={};if(i.size>0)for(const w of i){const v=await at.getState().getRender(w);v?s[w]=v:ar(`No render found for: ${w}`)}const o=await at.getState().getAudioFileDataRelevantToSongs([t]),a={};for(const[w,v]of Object.entries(o)){const S={};if(v&&v.length>0){const C=v[0];for(let k=0;k<C.length;k++)S[k.toString()]=C[k]}a[w]=[S]}const l=Object.keys(a).length,u={songId:t,song:r,bloobs:n,generatedInstrumentRenders:Object.keys(s).length>0?s:void 0,audioFileIdToAudioData:l>0?a:void 0},d=await tr.post("/api/v0/export-audio",u,{responseType:"blob"}),f=d.headers["content-disposition"];let h=`${e.label||`song_${t}`}.wav`;if(f){const w=f.match(/filename\*?=(?:UTF-8'')?["']?([^"';]+)["']?/i);w&&w[1]&&(h=decodeURIComponent(w[1]))}const m=new Blob([d.data],{type:"audio/wav"}),y=window.URL.createObjectURL(m),g=document.createElement("a");g.href=y,g.download=h,document.body.appendChild(g),g.click(),document.body.removeChild(g),window.URL.revokeObjectURL(y)}catch(r){throw r}},jme=()=>{const{focusCanvas:t}=di(),{isDarkMode:e,exportOpen:n}=Pn(),{closeExport:r}=Br(),[i,s]=x.useState(!1),[o,a]=x.useState(!1),[l,u]=x.useState(""),[d,f]=x.useState(null),{showBanner:h}=ts(),{downloadStorageFile:m}=_d(),{handleExportToFiles:y}=VL(),{isMobile:g}=Hn(),{selectedCaiObjects:w,selectedSingleCaiObject:v}=Yn(),{getSongById:S,getBloobById:C,getBloobsInSong:k,getNotesInBloob:N}=mn(),_=x.useMemo(()=>{if(w.length===0)return{type:"none",label:"No Selection",description:"Export your entire project as a .cai file.",canExportFiles:!1,canExportAudio:!1,canExportBloobAudio:!1,canExportBloobMidi:!1,canExportProject:!0};if(w.length===1&&v){if(v.type===J.Song){const $=S(v.id),q=k(v.id),Z=q.some(ge=>ln(ge)),ie=q.some(ge=>En(ge));return{type:"song",label:($==null?void 0:$.label)||"Song",description:`Export "${($==null?void 0:$.label)||"Song"}" as rendered audio, MIDI/audio files, or save entire project.`,canExportFiles:Z||ie,canExportAudio:!0,canExportBloobAudio:!1,canExportBloobMidi:!1,canExportProject:!0,hasMidi:Z,hasAudio:ie}}if(v.type===J.Bloob){const $=C(v.id),q=ln($),Z=En($);return{type:"bloob",label:($==null?void 0:$.label)||"Bloob",description:`Export selected bloob "${($==null?void 0:$.label)||"Bloob"}" as ${q?"MIDI":"audio"} file, or save entire project.`,canExportFiles:!1,canExportAudio:!1,canExportBloobAudio:!0,canExportBloobMidi:q,canExportProject:!0,isMidi:q,isAudio:Z}}}return{type:"multiple",label:`${w.length} Items Selected`,description:"Multiple items selected. Export your entire project.",canExportFiles:!1,canExportAudio:!1,canExportBloobAudio:!1,canExportBloobMidi:!1,canExportProject:!0}},[w,v,S,C,k]),j=x.useMemo(()=>{if(!v)return"";if(v.type===J.Song)return`song:${v.id}`;if(v.type===J.Bloob){const $=C(v.id);return $?`song:${$.songId}`:""}return""},[v,C]),T=dD(j),M=kd(j),V=at($=>$.domainRoleByChannel),H=at($=>$.domainPolicyByChannel);x.useMemo(()=>{for(const[$,q]of Object.entries(V)){if(q.toLowerCase()==="owner")continue;const Z=H[$];if(!(Z!=null&&Z.allowExport))return!1}return!0},[V,H]);const P=M!==void 0&&M!=="owner"&&!T,F=x.useMemo(()=>{if(_.type==="bloob"&&v){const $=C(v.id);return $?$.color:void 0}},[_,v,C]),I=x.useCallback(()=>{s(!1),a(!1),u(""),f(null),t(),r()},[r,t]),R=x.useCallback(async()=>{s(!0);try{await y(),h("Files exported successfully")}catch{h("Error exporting files. Please try again.")}finally{s(!1)}},[y,h]),U=x.useCallback(async()=>
1020{if((v==null?void 0:v.type)!==J.Song){h("No song selected");return}const $=S(v.id);if(!$){h("No song to export");return}s(!0);try{const Z=k($.id).map(ie=>({...ie,notes:ie.bloobType===Us.Midi?N(ie.id):[]}));await AM($.id,$,Z),h(`Audio exported for "${$.label}"`)}catch{h("Error exporting audio. Please try again.")}finally{s(!1)}},[v,S,k,N,h]),A=x.useCallback(async()=>{if((v==null?void 0:v.type)!==J.Bloob){h("No bloob selected");return}const $=C(v.id),q=S($.songId);if(!q||!$){h("Bloob or parent song not found");return}s(!0);try{const Z={...q,label:$.label},ie={...$,notes:$.bloobType===Us.Midi?N($.id):[]};await AM(q.id,Z,[ie]),h(`Bloob "${$.label}" exported as audio`)}catch{h("Error exporting bloob audio. Please try again.")}finally{s(!1)}},[v,C,S,N,h]),W=x.useCallback(async()=>{if((v==null?void 0:v.type)!==J.Bloob){h("No bloob selected");return}s(!0);try{await y(),h("Bloob exported as MIDI")}catch{h("Error exporting bloob MIDI. Please try again.")}finally{s(!1)}},[v,y,h]);x.useCallback(async()=>{a(!0)},[]);const D=x.useCallback(async()=>{if(!l.trim()){h("Please enter a file name");return}a(!1),s(!0);try{await m(l.trim()),h("Project exported successfully")}catch{h("Error exporting project. Please try again.")}finally{s(!1)}},[m,h,l]),B=()=>e?"bg-gradient-to-r from-caiGreen-700/100 to-caiBlue-700/50 text-zinc-100":"bg-gradient-to-r from-caiGreen-100/100 to-caiBlue-100/50 text-zinc-800",L=()=>e?"border-zinc-700":"border-zinc-200";return c.jsxs(c.Fragment,{children:[c.jsx(Vn,{children:n&&c.jsx(Wr,{onClose:I,widthClass:g?"w-[93%]":"w-2/5",heightClass:g?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-800 dark:text-zinc-100",children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${e?"border-zinc-800 bg-gradient-to-br from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(cd,{size:20,className:e?"text-caiBlue-400":"text-caiBlue-600"}),c.jsx("h1",{className:"text-2xl font-semibold",children:"Export"})]}),c.jsx("button",{onClick:I,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${e?"hover:bg-white":"hover:bg-black"}`,"aria-label":"Close export",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:"flex-1 w-full flex flex-col items-center overflow-y-auto bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-800 dark:text-zinc-100",children:c.jsxs("div",{className:"w-[95%] flex-1 flex flex-col p-4",children:[c.jsx("div",{className:`px-4 py-3 mb-4 rounded-t-lg ${B()}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(cd,{size:18}),c.jsx("h2",{className:"text-lg font-medium",children:_.label})]})}),c.jsxs("div",{className:`flex-1 border rounded-b-lg ${L()} p-4 flex flex-col bg-gradient-to-br from-zinc-100/25 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm`,children:[c.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-6",children:_.description}),P&&_.type==="song"&&c.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic mb-4",children:"The owner has restricted export for this song."}),c.jsxs("div",{className:"flex-1 flex flex-col gap-4",children:[!1,_.canExportFiles&&!P&&c.jsx("div",{onClick:()=>f($=>$==="files"?null:"files"),className:`w-full p-4 rounded-lg border transition-all ${d==="files"?e?"bg-gradient-to-r from-caiGreen-900/40 to-caiBlue-900/40 border-caiGreen-500 cursor-pointer shadow-lg":"bg-gradient-to-r from-caiGreen-50 to-caiBlue-50 border-caiGreen-500 cursor-pointer shadow-lg":e?"border-zinc-600 hover:border-caiGreen-500 hover:bg-zinc-800/50 cursor-pointer":"border-zinc-400 hover:border-caiGreen-500 hover:bg-zinc-50 cursor-pointer"}`,children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(kz,{size:24,className:"text-caiGreen-500"}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium",children:"Export Song Files"}),c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:"Export all MIDI/audio files as ZIP"})]})]}),c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:$=>{$.stopPropagation(),R()},disabled:i,className:` 1021 px-4 py-2 rounded-lg 1022 flex items-center justify-center gap-2 1023 font-medium shadow-sm 1024 ${i?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white cursor-pointer":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white cursor-pointer"} 1025 `,children:[c.jsx(kz,{size:16}),i?"Exporting...":"Export"]})]})}),_.canExportAudio&&!P&&c.jsxs("div",{onClick:()=>f($=>$==="audio"?null:"audio"),className:`w-full p-4 rounded-lg border transition-all ${d==="audio"?e?"bg-gradient-to-r from-caiBlue-900/40 to-caiGreen-900/40 border-caiBlue-500 cursor-pointer shadow-lg":"bg-gradient-to-r from-caiBlue-50 to-caiGreen-50 border-caiBlue-500 cursor-pointer shadow-lg":e?"border-zinc-600 hover:border-caiBlue-500 hover:bg-zinc-800/50 cursor-pointer":"border-zinc-400 hover:border-caiBlue-500 hover:bg-zinc-50 cursor-pointer"}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(gb,{size:24,className:"text-caiBlue-500"}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium",children:"Export Song Audio"}),c.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:"Render song as WAV audio file"})]})]}),c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:$=>{$.stopPropagation(),U()},disabled:i,className:` 1026 px-4 py-2 rounded-lg 1027 flex items-center justify-center gap-2 1028 font-medium shadow-sm 1029 ${i?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white cursor-pointer":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white cursor-pointer"} 1030 `,children:[c.jsx(gb,{size:16}),i?"Rendering...":"Export"]})]}),i&&_.canExportAudio&&c.jsx("div",{className:"mt-3 pt-3 border-t border-zinc-300 dark:border-zinc-600",children:c.jsxs("div",{className:"space-y-1",children:[c.jsx("span",{className:"text-xs text-zinc-600 dark:text-zinc-400",children:"Rendering audio..."}),c.jsx(fF,{progress:50,variant:"gradient"})]})})]}),_.canExportBloobMidi&&c.jsx("div",{onClick:()=>f($=>$==="bloobMidi"?null:"bloobMidi"),className:`w-full p-4 rounded-lg border transition-all ${d==="bloobMidi"?e?"bg-gradient-to-r from-indigo-900/40 to-violet-900/40 border-indigo-500 cursor-pointer shadow-lg":"bg-gradient-to-r from-indigo-50 to-violet-50 border-indigo-500 cursor-pointer shadow-lg":e?"border-zinc-600 hover:border-indigo-500 hover:bg-zinc-800/50 cursor-pointer":"border-zinc-400 hover:border-indigo-500 hover:bg-zinc-50 cursor-pointer"}`,children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Mn,{size:24,style:{color:F}}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium",children:"Export Bloob as MIDI"}),c.jsxs("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:['Export "',_.label,'" as MIDI file']})]})]}),c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:$=>{$.stopPropagation(),W()},disabled:i,className:` 1031 px-4 py-2 rounded-lg 1032 flex items-center justify-center gap-2 1033 font-medium shadow-sm 1034 ${i?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white cursor-pointer":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white cursor-pointer"} 1035 `,children:[c.jsx(Mn,{size:16}),i?"Exporting...":"Export"]})]})}),_.canExportBloobAudio&&c.jsx("div",{onClick:()=>f($=>$==="bloobAudio"?null:"bloobAudio"),className:`w-full p-4 rounded-lg border transition-all ${d==="bloobAudio"?e?"bg-gradient-to-r from-purple-900/40 to-pink-900/40 border-purple-500 cursor-pointer shadow-lg":"bg-gradient-to-r from-purple-50 to-pink-50 border-purple-500 cursor-pointer shadow-lg":e?"border-zinc-600 hover:border-purple-500 hover:bg-zinc-800/50 cursor-pointer":"border-zinc-400 hover:border-purple-500 hover:bg-zinc-50 cursor-pointer"}`,children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(gb,{size:24,style:{color:F}}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium",children:"Export Bloob as WAV"}),c.jsxs("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:['Render "',_.label,'" as WAV audio file']})]})]}),c.jsxs(et.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:$=>{$.stopPropagation(),A()},disabled:i,className:` 1036 px-4 py-2 rounded-lg 1037 flex items-center justify-center gap-2 1038 font-medium shadow-sm 1039 ${i?"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100":e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 text-white cursor-pointer":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 text-white cursor-pointer"} 1040 `,children:[c.jsx(gb,{size:16}),i?"Rendering...":"Export"]})]})})]})]})]})})]})},"export-modal")}),c.jsx(Vn,{children:i}),c.jsx(Vn,{children:o&&c.jsx(et.div,{initial:{opacity:0}
1040,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[200]",onClick:()=>a(!1),children:c.jsxs(et.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},onClick:$=>$.stopPropagation(),className:`${g?"w-[85%]":"w-[400px]"} rounded-lg shadow-2xl overflow-hidden ${e?"bg-gradient-to-br from-zinc-800/95 to-zinc-900/95 backdrop-blur-xl border border-zinc-700/50":"bg-gradient-to-br from-white/95 to-zinc-50/95 backdrop-blur-xl border border-zinc-200/50"}`,children:[c.jsx("div",{className:`px-6 py-4 border-b ${e?"border-zinc-700/50 bg-gradient-to-r from-zinc-800/50 to-zinc-900/50":"border-zinc-200/50 bg-gradient-to-r from-zinc-50/50 to-zinc-100/50"}`,children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(vm,{size:20,className:"text-orange-500"}),c.jsx("h2",{className:"text-lg font-semibold",children:"Export Project"})]}),c.jsx("button",{onClick:()=>a(!1),className:`p-1.5 rounded-lg transition-colors ${e?"hover:bg-zinc-700/50 text-zinc-400 hover:text-zinc-200":"hover:bg-zinc-200/50 text-zinc-600 hover:text-zinc-900"}`,"aria-label":"Close modal",children:c.jsx(nr,{size:18})})]})}),c.jsxs("div",{className:"px-6 py-5",children:[c.jsx("label",{htmlFor:"cai-file-name",className:"block text-sm font-medium mb-2",children:"Project Name"}),c.jsx("input",{id:"cai-file-name",type:"text",value:l,onChange:$=>u($.target.value),onKeyDown:$=>{$.key==="Enter"?D():$.key==="Escape"&&a(!1)},placeholder:"Enter project name...",autoFocus:!0,className:`w-full px-4 py-2.5 rounded-lg border transition-all ${e?"bg-zinc-800/50 border-zinc-600 text-zinc-100 placeholder-zinc-500 focus:border-caiBlue-500 focus:bg-zinc-800/70 focus:ring-2 focus:ring-caiBlue-500/20":"bg-white/70 border-zinc-300 text-zinc-900 placeholder-zinc-400 focus:border-caiBlue-500 focus:bg-white focus:ring-2 focus:ring-caiBlue-500/20"} focus:outline-none backdrop-blur-sm`}),c.jsx("p",{className:"mt-2 text-xs text-zinc-500 dark:text-zinc-400",children:"The .cai extension will be added automatically"})]}),c.jsxs("div",{className:`px-6 py-4 border-t ${e?"border-zinc-700/50 bg-gradient-to-r from-zinc-800/30 to-zinc-900/30":"border-zinc-200/50 bg-gradient-to-r from-zinc-50/30 to-zinc-100/30"} flex justify-end gap-3`,children:[c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>a(!1),className:`px-4 py-2 rounded-lg font-medium transition-all ${e?"bg-zinc-700/70 hover:bg-zinc-600/70 text-zinc-200 border border-zinc-600/50":"bg-zinc-200/70 hover:bg-zinc-300/70 text-zinc-800 border border-zinc-300/50"} backdrop-blur-sm`,children:"Cancel"}),c.jsxs(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:D,disabled:!l.trim(),className:`px-4 py-2 rounded-lg font-medium shadow-md flex items-center gap-2 transition-all ${l.trim()?e?"bg-gradient-to-r from-caiGreen-600 to-caiBlue-600 hover:from-caiGreen-500 hover:to-caiBlue-500 text-white shadow-caiBlue-500/20":"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 hover:from-caiGreen-400 hover:to-caiBlue-400 text-white shadow-caiBlue-500/30":"bg-zinc-500/80 opacity-50 cursor-not-allowed text-zinc-100"}`,children:[c.jsx(vm,{size:16}),"Export"]})]})]},"file-name-modal-content")},"file-name-modal-overlay")})]})},Rb={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,ease:"easeOut"}}},t2=({children:t,isDarkMode:e})=>c.jsxs("div",{className:"relative p-[2px] rounded-lg overflow-hidden",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-[#6b88cc] via-[#7dc383] to-[#f8c291] animate-gradient"}),c.jsx("div",{className:`relative rounded-lg p-6 h-full border ${e?"border-zinc-800 bg-gradient-to-br from-zinc-800/95 to-zinc-900/95 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/95 to-zinc-200/95 backdrop-blur-sm"}`,children:t})]}),UC=({onClose:t})=>{const{closeAbout:e}=Br(),{focusCanvas:n}=di(),{isMobile:r}=Hn(),{theme:i}=Pn(),s=i===gi.Dark,o=()=>{n(),e(),t&&t()};return c.jsx(Wr,{onClose:o,widthClass:r?"w-[93%]":"w-[80%]",heightClass:r?"h-[84%]":"h-[90%]",blurBackgroun
1040d:!0,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors ${s?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm text-zinc-100":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm text-zinc-800"}`,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${s?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm border-zinc-800":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm border-zinc-200"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Kc,{className:s?"text-caiBlue-400":"text-caiBlue-600",size:24}),c.jsx("h1",{className:"text-2xl font-semibold",children:"About Cai"})]}),c.jsx("button",{onClick:o,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${s?"hover:bg-zinc-100":"hover:bg-zinc-900"}`,"aria-label":"Close about section",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:`flex-1 overflow-y-auto p-6 ${s?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:c.jsxs("div",{className:"space-y-6",children:[c.jsxs(et.div,{variants:Rb,initial:"hidden",animate:"visible",className:"text-center mb-8",children:[c.jsx("h2",{className:`text-4xl font-bold bg-gradient-to-r from-[#6b88cc] via-[#7dc383] to-[#f8c291] 1041 text-transparent bg-clip-text animate-gradient`,children:"Cai: Intelligent Music Creation"}),c.jsx("p",{className:"text-base mt-4 opacity-90",children:"Cai brings the world's most powerful music producer to your fingertips. With advanced musical intelligence, Cai understands your words, your style, and your unique voice, turning anyone with a story into a musician."})]}),c.jsx(t2,{isDarkMode:s,children:c.jsxs(et.div,{variants:Rb,initial:"hidden",animate:"visible",className:"space-y-4",children:[c.jsx("h3",{className:`text-2xl font-bold bg-gradient-to-r from-[#6b88cc] to-[#7dc383] 1042 text-transparent bg-clip-text`,children:"Our Product"}),c.jsx("p",{className:"leading-relaxed",children:"Cai is a fast, intelligent, and intuitive end-to-end music platform where users can create, refine, and arrange music using text, voice, and even sung melodies. By seamlessly blending advanced machine learning with intuitive design, Cai empowers users to bring their musical vision to life."})]})}),c.jsx(t2,{isDarkMode:s,children:c.jsxs(et.div,{variants:Rb,initial:"hidden",animate:"visible",className:"space-y-4",children:[c.jsx("h3",{className:`text-2xl font-bold bg-gradient-to-r from-[#7dc383] to-[#f8c291] 1043 text-transparent bg-clip-text`,children:"Our Technology"}),c.jsx("p",{className:"leading-relaxed",children:"Cai is powered by a suite of proprietary machine learning models and techniques that enable powerful natural language understanding and state-of-the-art music generation. It runs on the latest cloud infrastructure with speed, security, and privacy in mind, ensuring that you can create music anywhere, anytime, with peace of mind."})]})}),c.jsx(t2,{isDarkMode:s,children:c.jsxs(et.div,{variants:Rb,initial:"hidden",animate:"visible",className:"space-y-4",children:[c.jsx("h3",{className:`text-2xl font-bold bg-gradient-to-r from-[#f8c291] to-[#6b88cc] 1044 text-transparent bg-clip-text`,children:"Our Vision"}),c.jsx("p",{className:"leading-relaxed",children:"We believe in a future where music creation is accessible to everyone. Our platform transforms artificial intelligence from a black box into a creative partner, ensuring that the user's voice and vision remain at the forefront of the process. We're committed to making music creation intuitive and enjoyable while maintaining the depth and authenticity that gives art its life."})]})})]})})]})})},Tme=({isOpen:t,onClose:e,plan:n=Nr.PRO})=>{const{usage:r,subscription:i}=tl(),{theme:s}=Pn(),{isMobile:o}=Hn(),a=s===gi.Dark,l=mC[n],u=n===Nr.KIPP_CAPITAL,d=f=>{switch(f){case Nr.PRO:return c.jsx(WS,{size:32,className:"text-caiBlue-500"});case Nr.KIPP_CAPITAL:return c.jsx(Sz,{size:32,className:"text-caiPeach-500"});default:return c.jsx(Qf,{size:32,className:"text-gray-500"})}};return c.jsx(Vn,{children:t&&c.jsx(Wr,{onClose:e,widthClass:o?"w-[93%]":"w-2/5",heightClass:o?"h-[84%]":"h-4/5",children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-900 dark:text-zinc-100",children:[c.jsxs("div",{className:`flex items-center justify-between p-6 border-b ${a?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:[c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx($S,{size:32,className:u?"text-caiPeach-500":"text-caiGreen-500"}),c.jsxs("div",{children:[c.jsx("h2",{className:`text-2xl font-bold ${a?"text-zinc-100":"text-zinc-900"}`,children:"Welcome to Cai Pro!"}),c.jsx("p",{className:`text-sm ${a?"text-zinc-300":"text-zinc-600"}`,children:u?"":"Your subscription is now active"})]})]}),c.jsx("button",{onClick:e,className:`p-2 rounded-lg transition-colors ${a?"hover:bg-zinc-800 text-zinc-400 hover:text-zinc-200":"hover:bg-zinc-100 text-zinc-600 hover:text-zinc-800"}`,children:c.jsx(nr,{size:24})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-6 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:[u&&c.jsx("div",{className:"flex justify-center mb-4",children:c.jsxs("div",{className:"inline-flex items-center space-x-2 bg-gradient-to-r from-caiPeach-500 to-caiPeach-600 text-white px-4 py-2 rounded-full text-sm font-semibold",children:[c.jsx(Sz,{size:16}),c.jsx("span",{children:"KIPP Capital Program"})]})}),c.jsxs("div",{className:"text-center mb-6",children:[c.jsx("div",{className:"flex justify-center mb-4",children:d(n)}),c.jsx("h3",{className:`text-xl font-bold mb-2 ${a?"text-zinc-100":"text-zinc-900"}`,children:u?"Your Pro Subscription is Activated!":`${l.name} Plan Activated`}),c.jsx("p",{className:`${a?"text-zinc-300":"text-zinc-600"}`,children:u?`You now have access to all Pro features and ${l.takes_limit} Takes total through your school's partnership with Cai.`:`You now have access to all Pro features and ${l.takes_limit} Takes per month.`}),u&&(i==null?void 0:i.subscription_end_date)&&c.jsxs("p",{className:`text-sm mt-2 ${a?"text-caiPeach-400":"text-caiPeach-600"}`,children:["Valid until"," ",new Date(i.subscription_end_date).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("h4",{className:`font-semibold mb-3 ${a?"text-zinc-100":"text-zinc-900"}`,children:u?"Your subscription benefits:":"Your new benefits:"}),c.jsx("ul",{className:"space-y-2",children:l.features.map((f,h)=>c.jsxs("li",{className:"flex items-center space-x-2 text-sm",children:[c.jsx($S,{size:16,className:`flex-shrink-0 ${u?"text-caiPeach-500":"text-caiGreen-500"}`}),c.jsx("span",{className:a?"text-zinc-300":"text-zinc-700",children:f})]},h))})]}),u&&c.jsx("div",{className:`rounded-lg p-4 mb-6 border ${a?"bg-gradient-to-br from-caiPeach-900/20 to-caiPeach-800/10 border-caiPeach-500/50":"bg-gradient-to-br from-caiPeach-100/50 to-caiPeach-50/25 border-caiPeach-300"}`,children:c.jsxs("p",{className:`text-sm ${a?"text-zinc-300":"text-zinc-700"}`,children:[c.jsx("strong",{className:a?"text-caiPeach-400":"text-caiPeach-600",children:"This is a sponsored subscription"})," ","provided through KIPP Capital. You have"," ",l.takes_limit," Takes for the duration of your subscription. If you have questions, please contact your organization administrator."]})}),r&&c.jsxs("div",{className:`rounded-lg p-4 mb-6 bg-gradient-to-br from-zinc-200/50 to-zinc-300/25 dark:from-zinc-900/50 dark:to-zinc-800/25 backdrop-blur-sm border ${a?"border-zinc-700":"border-zinc-200"}`,children:[c.jsx("h4",{className:`font-semibold mb-2 ${a?"text-zinc-100":"text-zinc-900"}`,children:u?"Your total usage:":"Your usage this month:"}),c.jsxs("div",{className:"flex justify-between items-center mb-2",children:[c.jsxs("span",{className:`text-sm ${a?"text-zinc-300":"text-zinc-600"}`,children:["Takes used: ",r.takes_used]}),c.jsxs("span",{className:`text-sm ${a?"text-zinc-300":"text-zinc-600"}`,children:["Remaining: ",r.takes_quota-r.takes_used]})]}),c.jsx("div",{className:`w-full rounded-full h-2 ${a?"bg-zinc-700":"bg-zinc-200"}`,children:c.jsx("div",{className:"bg-gradient-to-r from-caiBlue-500 to-caiGreen-500 h-2 rounded-full transition-all duration-300",style:{width:`${Math.min(r.takes_used/r.takes_quota*100,100)}%`}})})]})]}),c.jsx("div",{className:`p-6 border-t ${a?"border-zinc-800 bg-gradient-to-br from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm":"border-zinc-200 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm"}`,children:c.jsx(et.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:e,className:`w-full font-medium py-3 px-6 rounded-lg transition-all duration-200 shadow-lg hover:shadow-xl text-white ${u?"bg-gradient-to-r from-caiPeach-500 to-caiPeach-600 hover:from-caiPeach-600 hover:to-caiPeach-700":"bg-gradient-to-r from-caiBlue-500 to-caiGreen-500 hover:from-caiBlue-600 hover:to-caiGreen-600"}`,children:u?"Start Creating Music ð":"Start Creating Music"})})]})})})},MM=4e6,n2=8e4,zme=200,r2=({text:t,className:e,onVanishComplete:n,triggerVanish:r=!1,duration:i=.5})=>{const s=x.useRef(null),o=x.useRef(null),[a,l]=x.useState(!1),[u,d]=x.useState(!1),f=x.useRef([]),h=x.useCallback(()=>{const y=s.current,g=o.current;if(!y||!g)return;const w=g.getContext("2d");if(!w)return;const v=y.offsetWidth,S=y.offsetHeight;if(v===0||S===0)return;const C=window.devicePixelRatio||1;let k=Math.min(C,2);v*k*S*k>MM&&(k=Math.sqrt(MM/(v*S))),g.width=Math.round(v*k),g.height=Math.round(S*k),g.style.width=`${v}px`,g.style.height=`${S}px`,w.scale(k,k);const _=getComputedStyle(y),j=parseFloat(_.getPropertyValue("font-size"));w.clearRect(0,0,v,S);const T=w.createLinearGradient(0,0,v,0);T.addColorStop(0,"#f8c291"),T.addColorStop(.33,"#7dc383"),T.addColorStop(.66,"#6b88cc"),T.addColorStop(1,"#f8c291"),w.font=`${j}px ${_.fontFamily}`,w.fillStyle=T,w.textAlign="center",w.textBaseline="middle",w.fillText(t,v*.5,S*.5),w.setTransform(1,0,0,1,0,0);let M;try{M=w.getImageData(0,0,g.width,g.height)}catch{d(!0);return}const{data:V}=M,H=g.width,P=g.height,I=H*P>n2*4?2:1,R=[],U=20*k,A=1e-7/k;for(let W=0;W<P;W+=I){for(let D=0;D<H;D+=I){const B=(W*H+D)*4,L=V[B+3];if(L>10){const $=Math.random()*1e3,q=U*Math.sin((W+$)*A),Z=D+q,ie=I>1?I:k>2?k/2:1;if(R.push({x:D,y:W,vanishX:Z,r:ie,color:`rgba(${V[B]}, ${V[B+1]}, ${V[B+2]}, ${L})`}),R.length>=n2)break}}if(R.length>=n2)break}f.current=R,w.clearRect(0,0,H,P);for(const W of R)w.beginPath(),w.rect(W.x,W.y,W.r,W.r),w.fillStyle=W.color,w.fill();d(!0)},[t]),m=x.useCallback(y=>{const g=w=>{requestAnimationFrame(()=>{const v=f.current,S=[];for(let k=0;k<v.length;k++){const N=v[k];N.vanishX<w?S.push(N):(N.x+=Math.random()>.5?1:-1,N.y+=Math.random()>.5?1:-1,N.r-=.065*Math.random(),N.r>0&&S.push(N))}f.current=S;const C=o.current;if(C){const k=C.getContext("2d");if(k){k.clearRect(w,0,C.width-w,C.height);for(const N of S)N.vanishX>=w&&(k.beginPath(),k.rect(N.x,N.y,N.r,N.r),k.fillStyle=N.color,k.fill())}}if(f.current.length>0){const k=window.devicePixelRatio>2?30:20;g(w-k)}else l(!1),n==null||n()})};g(y)},[n]);return x.useEffect(()=>{if(r&&!a&&u){l(!0);const y=f.current.reduce((g,w)=>Math.max(g,w.vanishX),0);m(y)}},[r,m,a,u]),x.useLayoutEffect(()=>{h();let y=null;const g=()=>{y&&clearTimeout(y),y=setTimeout(h,zme)};return window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g),y&&clearTimeout(y)}}
vendor: 47,474 bytes, line 1044
1044,[h]),c.jsxs("div",{className:Cv("relative w-full h-full flex items-center justify-center",e),children:[c.jsx("div",{ref:s,className:"absolute invisible pointer-events-none",style:{whiteSpace:"nowrap"},children:t}),c.jsx(et.canvas,{ref:o,initial:{opacity:0,filter:"blur(10px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:i},className:"pointer-events-none"})]})},Ku="generated",Pme="pointerdown",Ame="pointerup",VC="pointerleave",Mme="pointerout",pd="pointermove",Bme="touchstart",BM="touchend",Rme="touchmove",Ome="touchcancel",Dme="resize",Lme="visibilitychange",$o="tsParticles - Error",Ac=100,Pi=.5,hs=1e3,ds={x:0,y:0,z:0},Ob={a:1,b:0,c:0,d:1},Rh="random",_y="mid",ps=2,Fme=Math.PI*ps,i2=60,hF="true",RM="false",s2="canvas",OM=0,Nl=2,DM=4,$me=1,LM=1,FM=1,Ume=4,pF=1,Ey=255,Yu=360,HC=100,GC=100,$M=0,WC=0,Vme=60,Hme=0,qC=.25,UM=Pi+qC,VM=0,Gme=1,Wme=0,qme=0,Kme=1,sN=1,Yme=1,HM=1,Ev=0,mF=1,Xme=0,Qme=120,Zme=0,Jme=0,e0e=1e4,t0e=0,n0e=1,Nv=0,gF=1,r0e=1,i0e=0,GM=1,s0e=0,o0e=0,WM=-.25,qM=1.5,KM=0,a0e=1,l0e=0,KC=0,c0e=0,bF=1,u0e=1,Iv=1,d0e=500,YM=50,f0e=0,YC=1,yF=0,h0e=1,p0e=0,vu=255,o2=3,a2=6,m0e=1,g0e=1,b0e=0,y0e=0,v0e=0,x0e=0;var Yi;(function(t){t.bottom="bottom",t.bottomLeft="bottom-left",t.bottomRight="bottom-right",t.left="left",t.none="none",t.right="right",t.top="top",t.topLeft="top-left",t.topRight="top-right",t.outside="outside",t.inside="inside"})(Yi||(Yi={}));function vF(t){return typeof t=="boolean"}function Hc(t){return typeof t=="string"}function Gc(t){return typeof t=="number"}function Vf(t){return typeof t=="object"&&t!==null}function ll(t){return Array.isArray(t)}function Yt(t){return t==null}class oo{constructor(e,n,r){if(this._updateFromAngle=(i,s)=>{this.x=Math.cos(i)*s,this.y=Math.sin(i)*s},!Gc(e)&&e){this.x=e.x,this.y=e.y;const i=e;this.z=i.z?i.z:ds.z}else if(e!==void 0&&n!==void 0)this.x=e,this.y=n,this.z=r??ds.z;else throw new Error(`${$o} Vector3d not initialized correctly`)}static get origin(){return oo.create(ds.x,ds.y,ds.z)}get angle(){return Math.atan2(this.y,this.x)}set angle(e){this._updateFromAngle(e,this.length)}get length(){return Math.sqrt(this.getLengthSq())}set length(e){this._updateFromAngle(this.angle,e)}static clone(e){return oo.create(e.x,e.y,e.z)}static create(e,n,r){return new oo(e,n,r)}add(e){return oo.create(this.x+e.x,this.y+e.y,this.z+e.z)}addTo(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}copy(){return oo.clone(this)}distanceTo(e){return this.sub(e).length}distanceToSq(e){return this.sub(e).getLengthSq()}div(e){return oo.create(this.x/e,this.y/e,this.z/e)}divTo(e){this.x/=e,this.y/=e,this.z/=e}getLengthSq(){return this.x**Nl+this.y**Nl}mult(e){return oo.create(this.x*e,this.y*e,this.z*e)}multTo(e){this.x*=e,this.y*=e,this.z*=e}normalize(){const e=this.length;e!=Nv&&this.multTo(pF/e)}rotate(e){return oo.create(this.x*Math.cos(e)-this.y*Math.sin(e),this.x*Math.sin(e)+this.y*Math.cos(e),ds.z)}setTo(e){this.x=e.x,this.y=e.y;const n=e;this.z=n.z?n.z:ds.z}sub(e){return oo.create(this.x-e.x,this.y-e.y,this.z-e.z)}subFrom(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}}class Hi extends oo{constructor(e,n){super(e,n,ds.z)}static get origin(){return Hi.create(ds.x,ds.y)}static clone(e){return Hi.create(e.x,e.y)}static create(e,n){return new Hi(e,n)}}let w0e=Math.random;const xF={nextFrame:t=>requestAnimationFrame(t),cancel:t=>cancelAnimationFrame(t)};function Ar(){return Uo(w0e(),0,1-Number.EPSILON)}function k0e(t){return xF.nextFrame(t)}function S0e(t){xF.cancel(t)}function Uo(t,e,n){return Math.min(Math.max(t,e),n)}function l2(t,e,n,r){return Math.floor((t*n+e*r)/(n+r))}function ho(t){const e=Wa(t),n=0;let r=Lx(t);return e===r&&(r=n),Ar()*(e-r)+r}function vn(t){return Gc(t)?t:ho(t)}function Lx(t){return Gc(t)?t:t.min}function Wa(t){return Gc(t)?t:t.max}function lr(t,e){if(t===e||e===void 0&&Gc(t))return t;const n=Lx(t),r=Wa(t);return e!==void 0?{min:Math.min(n,e),max:Math.max(r,e)}:lr(n,r)}function Ts(t,e){const n=t.x-e.x,r=t.y-e.y,i=2;return{dx:n,dy:r,distance:Math.sqrt(n**i+r**i)}}function vo(t,e){return Ts(t,e).distance}function Lc(t){return t*Math.PI/180}function C0e(t,e,n){if(Gc(t))return Lc(t);switch(t){case Yi.top:return-Math.PI*Pi;case Yi.topRight:return-Math.PI*qC;case Yi.right:return Hme;case Yi.bottomRight:return Math.PI*qC;case Yi.bottom:return Math.PI*Pi;case Yi.bottomLeft:return Math.PI*UM;case Yi.left:return Math.PI;case Yi.topLeft:return-Math.PI*UM;case Yi.inside:return Math.atan2(n.y-e.y,n.x-e.x);case Yi.outside:return Math.atan2(e.y-n.y,e.x-n.x);default:return Ar()*Fme}}function _0e(t){const e=Hi.origin;return e.length=1,e.angle=t,e}function XM(t,e,n,r){return Hi.create(t.x*(n-r)/(n+r)+e.x*ps*r/(n+r),t.y)}function E0e(t){var e,n;return{x:((e=t.position)==null?void 0:e.x)??Ar()*t.size.width,y:((n=t.position)==null?void 0:n.y)??Ar()*t.size.height}}function wF(t){return t?t.endsWith("%")?parseFloat(t)/Ac:parseFloat(t):1}var Xu;(function(t){t.auto="auto",t.increase="increase",t.decrease="decrease",t.random="random"})(Xu||(Xu={}));var ki;(function(t){t.increasing="increasing",t.decreasing="decreasing"})(ki||(ki={}));var md;(function(t){t.none="none",t.max="max",t.min="min"})(md||(md={}));var Zn;(function(t){t.bottom="bottom",t.left="left",t.right="right",t.top="top"})(Zn||(Zn={}));var Oh;(function(t){t.precise="precise",t.percent="percent"})(Oh||(Oh={}));var nh;(function(t){t.max="max",t.min="min",t.random="random"})(nh||(nh={}));const N0e={debug:console.debug,error:console.error,info:console.info,log:console.log,verbose:console.log,warning:console.warn};function gd(){return N0e}function I0e(t){const e=new Map;return(...n)=>{const r=JSON.stringify(n);if(e.has(r))return e.get(r);const i=t(...n);return e.set(r,i),i}}function QM(t){const e={bounced:!1},{pSide:n,pOtherSide:r,rectSide:i,rectOtherSide:s,velocity:o,factor:a}=t;return r.min<s.min||r.min>s.max||r.max<s.min||r.max>s.max||(n.max>=i.min&&n.max<=(i.max+i.min)*Pi&&o>VM||n.min<=i.max&&n.min>(i.max+i.min)*Pi&&o<VM)&&(e.velocity=o*-a,e.bounced=!0),e}function j0e(t,e){const n=Go(e,r=>t.matches(r));return ll(n)?n.some(r=>r):n}function bd(){return typeof window>"u"||!window||typeof window.document>"u"||!window.document}function T0e(){return!bd()&&typeof matchMedia<"u"}function kF(t){if(T0e())return matchMedia(t)}function z0e(t){if(!(bd()||typeof IntersectionObserver>"u"))return new IntersectionObserver(t)}function P0e(t){if(!(bd()||typeof MutationObserver>"u"))return new MutationObserver(t)}function mi(t,e){return t===e||ll(e)&&e.indexOf(t)>-1}async function ZM(t,e){try{await document.fonts.load(`${e??"400"} 36px '${t??"Verdana"}'`)}catch{}}function A0e(t){return Math.floor(Ar()*t.length)}function Fx(t,e,n=!0){return t[e!==void 0&&n?e%t.length:A0e(t)]}function oN(t,e,n,r,i){return M0e(K0(t,r??0),e,n,i)}function M0e(t,e,n,r){let i=!0;return(!r||r===Zn.bottom)&&(i=t.top<e.height+n.x),i&&(!r||r===Zn.left)&&(i=t.right>n.x),i&&(!r||r===Zn.right)&&(i=t.left<e.width+n.y),i&&(!r||r===Zn.top)&&(i=t.bottom>n.y),i}function K0(t,e){return{bottom:t.y+e,left:t.x-e,right:t.x+e,top:t.y-e}}function Ys(t,...e){for(const n of e){if(n==null)continue;if(!Vf(n)){t=n;continue}const r=Array.isArray(n);r&&(Vf(t)||!t||!Array.isArray(t))?t=[]:!r&&(Vf(t)||!t||Array.isArray(t))&&(t={});for(const i in n){if(i==="__proto__")continue;const s=n,o=s[i],a=t;a[i]=Vf(o)&&Array.isArray(o)?o.map(l=>Ys(a[i],l)):Ys(a[i],o)}}return t}function aN(t,e){return!!_F(e,n=>n.enable&&mi(t,n.mode))}function lN(t,e,n){Go(e,r=>{const i=r.mode;r.enable&&mi(t,i)&&B0e(r,n)})}function B0e(t,e){const n=t.selectors;Go(n,r=>{e(r,t)})}function SF(t,e){if(!(!e||!t))return _F(t,n=>j0e(e,n.selectors))}function XC(t){return{position:t.getPosition(),radius:t.getRadius(),mass:t.getMass(),velocity:t.velocity,factor:Hi.create(vn(t.options.bounce.horizontal.value),vn(t.options.bounce.vertical.value))}}function CF(t,e){const{x:n,y:r}=t.velocity.sub(e.velocity),[i,s]=[t.position,e.position],{dx:o,dy:a}=Ts(s,i);if(n*o+r*a<0)return;const u=-Math.atan2(a,o),d=t.mass,f=e.mass,h=t.velocity.rotate(u),m=e.velocity.rotate(u),y=XM(h,m,d,f),g=XM(m,h,d,f),w=y.rotate(-u),v=g.rotate(-u);t.velocity.x=w.x*t.factor.x,t.velocity.y=w.y*t.factor.y,e.velocity.x=v.x*e.factor.x,e.velocity.y=v.y*e.factor.y}function R0e(t,e){const n=t.getPosition(),r=t.getRadius(),i=K0(n,r),s=t.options.bounce,o=QM({pSide:{min:i.left,max:i.right},pOtherSide:{min:i.top,max:i.bottom},rectSide:{min:e.left,max:e.right},rectOtherSide:{min:e.top,max:e.bottom},velocity:t.velocity.x,factor:vn(s.horizontal.value)});o.bounced&&(o.velocity!==void 0&&(t.velocity.x=o.velocity),o.position!==void 0&&(t.position.x=o.position));const a=QM({pSide:{min:i.top,max:i.bottom},pOtherSide:{min:i.left,max:i.right},rectSide:{min:e.top,max:e.bottom},rectOtherSide:{min:e.left,max:e.right},velocity:t.velocity.y,factor:vn(s.vertical.value)});a.bounced&&(a.velocity!==void 0&&(t.velocity.y=a.velocity),a.position!==void 0&&(t.position.y=a.position))}function Go(t,e){return ll(t)?t.map((r,i)=>e(r,i)):e(t,0)}function ma(t,e,n){return ll(t)?Fx(t,e,n):t}function _F(t,e){return ll(t)?t.find((r,i)=>e(r,i)):e(t,0)?t:void 0}function EF(t,e){const n=t.value,r=t.animation,i={delayTime:vn(r.delay)*hs,enable:r.enable,value:vn(t.value)*e,max:Wa(n)*e,min:Lx(n)*e,loops:0,maxLoops:vn(r.count),time:0},s=1;if(r.enable){switch(i.decay=s-vn(r.decay),r.mode){case Xu.increase:i.status=ki.increasing;break;case Xu.decrease:i.status=ki.decreasing;break;case Xu.random:i.status=Ar()>=Pi?ki.increasing:ki.decreasing;break}const o=r.mode===Xu.auto;switch(r.startValue){case nh.min:i.value=i.min,o&&(i.status=ki.increasing);break;case nh.max:i.value=i.max,o&&(i.status=ki.decreasing);break;case nh.random:default:i.value=ho(i),o&&(i.status=Ar()>=Pi?ki.increasing:ki.decreasing);break}}return i.initialValue=i.value,i}function O0e(t,e){if(!(t.mode===Oh.percent)){const{mode:i,...s}=t;return s}return"x"in t?{x:t.x/Ac*e.width,y:t.y/Ac*e.height}:{width:t.width/Ac*e.width,height:t.height/Ac*e.height}}function NF(t,e){return O0e(t,e)}function D0e(t,e,n,r,i){switch(e){case md.max:n>=i&&t.destroy();break;case md.min:n<=r&&t.destroy();break}}function cN(t,e,n,r,i){if(t.destroyed||!e||!e.enable||(e.maxLoops??0)>0&&(e.loops??0)>(e.maxLoops??0))return;const d=(e.velocity??0)*i.factor,f=e.min,h=e.max,m=e.decay??1;if(e.time||(e.time=0),(e.delayTime??0)>0&&e.time<(e.delayTime??0)&&(e.time+=i.value),!((e.delayTime??0)>0&&e.time<(e.delayTime??0))){switch(e.status){case ki.increasing:e.value>=h?(n?e.status=ki.decreasing:e.value-=h,e.loops||(e.loops=0),e.loops++):e.value+=d;break;case ki.decreasing:e.value<=f?(n?e.status=ki.increasing:e.value+=h,e.loops||(e.loops=0),e.loops++):e.value-=d}e.velocity&&m!==1&&(e.velocity*=m),D0e(t,r,e.value,f,h),t.destroyed||(e.value=Uo(e.value,f,h))}}function L0e(t){var n,r,i,s;const e=document.createElement("div").style;if(!t)return e;for(const o in t){const a=t[o];if(!Object.prototype.hasOwnProperty.call(t,o)||Yt(a))continue;const l=(n=t.getPropertyValue)==null?void 0:n.call(t,a);if(!l)continue;const u=(r=t.getPropertyPriority)==null?void 0:r.call(t,a);u?(s=e.setProperty)==null||s.call(e,a,l,u):(i=e.setProperty)==null||i.call(e,a,l)}return e}function F0e(t){const e=document.createElement("div").style,n=10,r={width:"100%",height:"100%",margin:"0",padding:"0",borderWidth:"0",position:"fixed",zIndex:t.toString(n),"z-index":t.toString(n),top:"0",left:"0"};for(const i in r){const s=r[i];e.setProperty(i,s)}return e}const $0e=I0e(F0e);var QC;(function(t){t.darken="darken",t.enlighten="enlighten"})(QC||(QC={}));function U0e(t,e){if(e){for(const n of t.colorManagers.values())if(e.startsWith(n.stringPrefix))return n.parseString(e)}}function xa(t,e,n,r=!0){if(!e)return;const i=Hc(e)?{value:e}:e;if(Hc(i.value))return IF(t,i.value,n,r);if(ll(i.value))return xa(t,{value:Fx(i.value,n,r)});for(const s of t.colorManagers.values()){const o=s.handleRangeColor(i);if(o)return o}}function IF(t,e,n,r=!0){if(!e)return;const i=Hc(e)?{value:e}:e;if(Hc(i.value))return i.value===Rh?TF():V0e(t,i.value);if(ll(i.value))return IF(t,{value:Fx(i.value,n,r)});for(const s of t.colorManagers.values()){const o=s.handleColor(i);if(o)return o}}function c0(t,e,n,r=!0){const i=xa(t,e,n,r);return i?jF(i):void 0}function jF(t){const e=t.r/Ey,n=t.g/Ey,r=t.b/Ey,i=Math.max(e,n,r),s=Math.min(e,n,r),o={h:$M,l:(i+s)*Pi,s:WC};return i!==s&&(o.s=o.l<Pi?(i-s)/(i+s):(i-s)/(ps-i-s),o.h=e===i?(n-r)/(i-s):o.h=n===i?ps+(r-e)/(i-s):ps*ps+(e-n)/(i-s)),o.l*=GC,o.s*=HC,o.h*=Vme,o.h<$M&&(o.h+=Yu),o.h>=Yu&&(o.h-=Yu),o}function V0e(t,e){return U0e(t,e)}function Dh(t){const e=(t.h%Yu+Yu)%Yu,n=Math.max(WC,Math.min(HC,t.s)),r=Math.max(p0e,Math.min(GC,t.l)),i=e/Yu,s=n/HC,o=r/GC;if(n===WC){const y=Math.round(o*vu);return{r:y,g:y,b:y}}const a=(y,g,w)=>{if(w<0&&w++,w>1&&w--,w*a2<1)return y+(g-y)*a2*w;if(w*ps<1)return g;if(w*o2<1*ps){const C=ps/o2;return y+(g-y)*(C-w)*a2}return y},l=o<Pi?o*(m0e+s):o+s-o*s,u=ps*o-l,d=g0e/o2,f=Math.min(vu,vu*a(u,l,i+d)),h=Math.min(vu,vu*a(u,l,i)),m=Math.min(vu,vu*a(u,l,i-d));return{r:Math.round(f),g:Math.round(h),b:Math.round(m)}}function H0e(t){const e=Dh(t);return{a:t.a,b:e.b,g:e.g,r:e.r}}function TF(t){const e=b0e,n=Ey+YC;return{b:Math.floor(ho(lr(e,n))),g:Math.floor(ho(lr(e,n))),r:Math.floor(ho(lr(e,n)))}}function Dl(t,e){return`rgba(${t.r}, ${t.g}, ${t.b}, ${e??sN})`}function u0(t,e){return`hsla(${t.h}, ${t.s}%, ${t.l}%, ${e??sN})`}function uN(t,e,n,r){let i=t,s=e;return i.r===void 0&&(i=Dh(t)),s.r===void 0&&(s=Dh(e)),{b:l2(i.b,s.b,n,r),g:l2(i.g,s.g,n,r),r:l2(i.r,s.r,n,r)}}function ZC(t,e,n){if(n===Rh)return TF();if(n===_y){const r=t.getFillColor()??t.getStrokeColor(),i=(e==null?void 0:e.getFillColor())??(e==null?void 0:e.getStrokeColor());if(r&&i&&e)return uN(r,i,t.getRadius(),e.getRadius());{const s=r??i;if(s)return Dh(s)}}else return n}function zF(t,e,n,r){const i=Hc(e)?e:e.value;return i===Rh?r?xa(t,{value:i}):n?Rh:_y:i===_y?_y:xa(t,{value:i})}function JM(t){return t!==void 0?{h:t.h.value,s:t.s.value,l:t.l.value}:void 0}function PF(t,e,n){const r={h:{enable:!1,value:t.h},s:{enable:!1,value:t.s},l:{enable:!1,value:t.l}};return e&&(c2(r.h,e.h,n),c2(r.s,e.s,n),c2(r.l,e.l,n)),r}function c2(t,e,n){t.enable=e.enable,t.enable?(t.velocity=vn(e.speed)/Ac*n,t.decay=gF-vn(e.decay),t.status=ki.increasing,t.loops=v0e,t.maxLoops=vn(e.count),t.time=x0e,t.delayTime=vn(e.delay)*hs,e.sync||(t.velocity*=Ar(),t.value*=Ar()),t.initialValue=t.value,t.offset=lr(e.offset)):t.velocity=y0e}function u2(t,e,n,r){if(!t||!t.enable||(t.maxLoops??0)>0&&(t.loops??0)>(t.maxLoops??0)||(t.time||(t.time=0),(t.delayTime??0)>0&&t.time<(t.delayTime??0)&&(t.time+=r.value),(t.delayTime??0)>0&&t.time<(t.delayTime??0)))return;const d=t.offset?ho(t.offset):0,f=(t.velocity??0)*r.factor+d*3.6,h=t.decay??1,m=Wa(e),y=Lx(e);!n||t.status===ki.increasing?(t.value+=f,t.value>m&&(t.loops||(t.loops=0),t.loops++,n?t.status=ki.decreasing:t.value-=m)):(t.value-=f,t.value<0&&(t.loops||(t.loops=0),t.loops++,t.status=ki.increasing)),t.velocity&&h!==1&&(t.velocity*=h),t.value=Uo(t.value,y,m)}function AF(t,e){if(!t)return;const{h:n,s:r,l:i}=t,s={h:{min:0,max:360},s:{min:0,max:100},l:{min:0,max:100}};n&&u2(n,s.h,!1,e),r&&u2(r,s.s,!0,e),i&&u2(i,s.l,!0,e)}function Nm(t,e,n){t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(n.x,n.y),t.closePath()}function G0e(t,e,n){t.fillStyle=n??"rgba(0,0,0,0)",t.fillRect(ds.x,ds.y,e.width,e.height)}function W0e(t,e,n,r){n&&(t.globalAlpha=r,t.drawImage(n,ds.x,ds.y,e.width,e.height),t.globalAlpha=1)}function d2(t,e){t.clearRect(ds.x,ds.y,e.width,e.height)}function q0e(t){const{container:e,context:n,particle:r,delta:i,colorStyles:s,backgroundMask:o,composite:a,radius:l,opacity:u,shadow:d,transform:f}=t,h=r.getPosition(),m=r.rotation+(r.pathRotation?r.velocity.angle:f0e),y={sin:Math.sin(m),cos:Math.cos(m)},g=!!m,w={a:y.cos*(f.a??Ob.a),b:g?y.sin*(f.b??YC):f.b??Ob.b,c:g?-y.sin*(f.c??YC):f.c??Ob.c,d:y.cos*(f.d??Ob.d)};n.setTransform(w.a,w.b,w.c,w.d,h.x,h.y),o&&(n.globalCompositeOperation=a);const v=r.shadowColor;d.enable&&v&&(n.shadowBlur=d.blur,n.shadowColor=Dl(v),n.shadowOffsetX=d.offset.x,n.shadowOffsetY=d.offset.y),s.fill&&(n.fillStyle=s.fill);const S=r.strokeWidth??yF;n.lineWidth=S,s.stroke&&(n.strokeStyle=s.stroke);const C={container:e,context:n,particle:r,radius:l,opacity:u,delta:i,transformData:w,strokeWidth:S};Y0e(C),X0e(C),K0e(C),n.globalCompositeOperation="source-over",n.resetTransform()}function K0e(t){const{container:e,context:n,particle:r,radius:i,opacity:s,delta:o,transformData:a}=t;if(!r.effect)return;const l=e.effectDrawers.get(r.effect);l&&l.draw({context:n,particle:r,radius:i,opacity:s,delta:o,pixelRatio:e.retina.pixelRatio,transformData:{...a}})}function Y0e(t){const{container:e,context:n,particle:r,radius:i,opacity:s,delta:o,strokeWidth:a,transformData:l}=t;if(!r.shape)return;const u=e.shapeDrawers.get(r.shape);u&&(n.beginPath(),u.draw({context:n,particle:r,radius:i,opacity:s,delta:o,pixelRatio:e.retina.pixelRatio,transformData:{...l}}),r.shapeClose&&n.closePath(),a>yF&&n.stroke(),r.shapeFill&&n.fill())}function X0e(t){const{container:e,context:n,particle:r,radius:i,opacity:s,delta:o,transformData:a}=t;if(!r.shape)return;const l=e.shapeDrawers.get(r.shape);l!=null&&l.afterDraw&&l.afterDraw({context:n,particle:r,radius:i,opacity:s,delta:o,pixelRatio:e.retina.pixelRatio,transformData:{...a}})}function Q0e(t,e,n){e.draw&&e.draw(t,n)}function Z0e(t,e,n,r){e.drawParticle&&e.drawParticle(t,n,r)}function J0e(t,e,n){return{h:t.h,s:t.s,l:t.l+(e===QC.darken?-1:h0e)*n}}function ege(t,e,n){const r=e[n];r!==void 0&&(t[n]=(t[n]??Gme)*r)}function eB(t,e,n=!1){if(!e)return;const r=t;if(!r)return;const i=r.style;if(!i)return;const s=new Set;for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.add(i[o]);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&s.add(e[o]);for(const o of s){const a=e.getPropertyValue(o);a?i.setProperty(o,a,n?"important":""):i.removeProperty(o)}}class tge{constructor(e,n){this.container=e,this._applyPostDrawUpdaters=s=>{var o;for(const a of this._postDrawUpdaters)(o=a.afterDraw)==null||o.call(a,s)},this._applyPreDrawUpdaters=(s,o,a,l,u,d)=>{var f;for(const h of this._preDrawUpdaters){if(h.getColorStyles){const{fill:m,stroke:y}=h.getColorStyles(o,s,a,l);m&&(u.fill=m),y&&(u.stroke=y)}if(h.getTransformValues){const m=h.getTransformValues(o);for(const y in m)ege(d,m,y)}(f=h.beforeDraw)==null||f.call(h,o)}},this._applyResizePlugins=()=>{var s;for(const o of this._resizePlugins)(s=o.resize)==null||s.call(o)},this._getPluginParticleColors=s=>{let o,a;for(const l of this._colorPlugins)if(!o&&l.particleFillColor&&(o=c0(this._engine,l.particleFillColor(s))),!a&&l.particleStrokeColor&&(a=c0(this._engine,l.particleStrokeColor(s))),o&&a)break;return[o,a]},this._initCover=async()=>{const s=this.container.actualOptions,o=s.backgroundMask.cover,a=o.color;if(a){const l=xa(this._engine,a);if(l){const u={...l,a:o.opacity};this._coverColorStyle=Dl(u,u.a)}}else await new Promise((l,u)=>{if(!o.image)return;const d=document.createElement("img");d.addEventListener("load",()=>{this._coverImage={image:d,opacity:o.opacity},l()}),d.addEventListener("error",f=>{u(f.error)}),d.src=o.image})},this._initStyle=()=>{const s=this.element,o=this.container.actualOptions;if(s){this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle();for(const a in o.style){if(!a||!o.style||!Object.prototype.hasOwnProperty.call(o.style,a))continue;const l=o.style[a];l&&s.style.setProperty(a,l,"important")}}},this._initTrail=async()=>{const s=this.container.actualOptions,o=s.particles.move.trail,a=o.fill;if(!o.enable)return;const l=pF/o.length;if(a.color){const u=xa(this._engine,a.color);if(!u)return;this._trailFill={color:{...u},opacity:l}}else await new Promise((u,d)=>{if(!a.image)return;const f=document.createElement("img");f.addEventListener("load",()=>{this._trailFill={image:f,opacity:l},u()}),f.addEventListener("error",h=>{d(h.error)}),f.src=a.image})},this._paintBase=s=>{this.draw(o=>G0e(o,this.size,s))},this._paintImage=(s,o)=>{this.draw(a=>W0e(a,this.size,s,o))},this._repairStyle=()=>{const s=this.element;s&&(this._safeMutationObserver(o=>o.disconnect()),this._initStyle(),this.initBackground(),this._safeMutationObserver(o=>{!s||!(s instanceof Node)||o.observe(s,{attributes:!0})}))},this._resetOriginalStyle=()=>{const s=this.element,o=this._originalStyle;!s||!o||eB(s,o,!0)},this._safeMutationObserver=s=>{this._mutationObserver&&s(this._mutationObserver)},this._setFullScreenStyle=()=>{const s=this.element;s&&eB(s,$0e(this.container.actualOptions.fullScreen.zIndex),!0)},this._engine=n,this._standardSize={height:0,width:0};const r=e.retina.pixelRatio,i=this._standardSize;this.size={height:i.height*r,width:i.width*r},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}clear(){const e=this.container.actualOptions,n=e.particles.move.trail,r=this._trailFill;e.backgroundMask.enable?this.paint():n.enable&&n.length>qme&&r?r.color?this._paintBase(Dl(r.color,r.opacity)):r.image&&this._paintImage(r.image,r.opacity):e.clear&&this.draw(i=>{d2(i,this.size)})}destroy(){if(this.stop(),this._generated){const e=this.element;e==null||e.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(e){const n=this._context;if(n)return e(n)}drawAsync(e){const n=this._context;if(n)return e(n)}drawParticle(e,n){if(e.spawning||e.destroyed)return;const r=e.getRadius();if(r<=Wme)return;const i=e.getFillColor(),s=e.getStrokeColor()??i;let[o,a]=this._getPluginParticleColors(e);o||(o=i),a||(a=s),!(!o&&!a)&&this.draw(l=>{var k;const u=this.container,d=u.actualOptions,f=e.options.zIndex,h=Kme-e.zIndexFactor,m=h**f.opacityRate,y=e.bubble.opacity??((k=e.opacity)==null?void 0:k.value)??sN,g=e.strokeOpacity??y,w=y*m,v=g*m,S={},C={fill:o?u0(o,w):void 0};C.stroke=a?u0(a,v):C.fill,this._applyPreDrawUpdaters(l,e,r,w,C,S),q0e({container:u,context:l,particle:e,delta:n,colorStyles:C,backgroundMask:d.backgroundMask.enable,composite:d.backgroundMask.composite,radius:r*h**f.sizeRate,opacity:w,shadow:e.options.shadow,transform:S}),this._applyPostDrawUpdaters(e)})}drawParticlePlugin(e,n,r){this.draw(i=>Z0e(i,e,n,r))}drawPlugin(e,n){this.draw(r=>Q0e(r,e,n))}async init(){this._safeMutationObserver(e=>e.disconnect()),this._mutationObserver=P0e(e=>{for(const n of e)n.type==="attributes"&&n.attributeName==="style"&&this._repairStyle()}),this.resize(),this._initStyle(),await this._initCover();try{await this._initTrail()}catch(e){gd().error(e)}this.initBackground(),this._safeMutationObserver(e=>{!this.element||!(this.element instanceof Node)||e.observe(this.element,{attributes:!0})}),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const e=this.container.actualOptions,n=e.background,r=this.element;if(!r)return;const i=r.style;if(i){if(n.color){const s=xa(this._engine,n.color);i.backgroundColor=s?Dl(s,n.opacity):""}else i.backgroundColor="";i.backgroundImage=n.image||"",i.backgroundPosition=n.position||"",i.backgroundRepeat=n.repeat||"",i.backgroundSize=n.size||""}}initPlugins(){this._resizePlugins=[];for(const e of this.container.plugins.values())e.resize&&this._resizePlugins.push(e),(e.particleFillColor??e.particleStrokeColor)&&this._colorPlugins.push(e)}initUpdaters(){this._preDrawUpdaters=[],this._postDrawUpdaters=[];for(const e of this.container.particles.updaters)e.afterDraw&&this._postDrawUpdaters.push(e),(e.getColorStyles??e.getTransformValues??e.beforeDraw)&&this._preDrawUpdaters.push(e)}loadCanvas(e){this._generated&&this.element&&this.element.remove(),this._generated=e.dataset&&Ku in e.dataset?e.dataset[Ku]==="true":this._generated,this.element=e,this.element.ariaHidden="true",this._originalStyle=L0e(this.element.style);const n=this._standardSize;n.height=e.offsetHeight,n.width=e.offsetWidth;const r=this.container.retina.pixelRatio,i=this.size;e.height=i.height=n.height*r,e.width=i.width=n.width*r,this._context=this.element.getContext("2d"),this._safeMutationObserver(s=>s.disconnect()),this.container.retina.init(),this.initBackground(),this._safeMutationObserver(s=>{!this.element||!(this.element instanceof Node)||s.observe(this.element,{attributes:!0})})}paint(){const e=this.container.actualOptions;this.draw(n=>{e.backgroundMask.enable&&e.backgroundMask.cover?(d2(n,this.size),this._coverImage?this._paintImage(this._coverImage.image,this._coverImage.opacity):this._coverColorStyle?this._paintBase(this._coverColorStyle):this._paintBase()):this._paintBase()})}resize(){if(!this.element)return!1;const e=this.container,n=e.canvas._standardSize,r={width:this.element.offsetWidth,height:this.element.offsetHeight},i=e.retina.pixelRatio,s={width:r.width*i,height:r.height*i};if(r.height===n.height&&r.width===n.width&&s.height===this.element.height&&s.width===this.element.width)return!1;const o={...n};n.height=r.height,n.width=r.width;const a=this.size;return this.element.width=a.width=s.width,this.element.height=a.height=s.height,this.container.started&&e.particles.setResizeFactor({width:n.width/o.width,height:n.height/o.height}),!0}stop(){this._safeMutationObserver(e=>e.disconnect()),this._mutationObserver=void 0,this.draw(e=>d2(e,this.size))}async windowResize(){if(!this.element||!this.resize())return;const e=this.container,n=e.updateActualOptions();e.particles.setDensity(),this._applyResizePlugins(),n&&await e.refresh()}}var rh;(function(t){t.canvas="canvas",t.parent="parent",t.window="window"})(rh||(rh={}));function zo(t,e,n,r,i){if(r){let s={passive:!0};vF(i)?s.capture=i:i!==void 0&&(s=i),t.addEventListener(e,n,s)}else{const s=i;t.removeEventListener(e,n,s)}}class nge{constructor(e){this.container=e,this._doMouseTouchClick=n=>{const r=this.container,i=r.actualOptions;if(this._canPush){const s=r.interactivity.mouse,o=s.position;if(!o)return;s.clickPosition={...o},s.clickTime=new Date().getTime();const a=i.interactivity.events.onClick;Go(a.mode,l=>this.container.handleClickMode(l))}n.type==="touchend"&&setTimeout(()=>this._mouseTouchFinish(),d0e)},this._handleThemeChange=n=>{const r=n,i=this.container,s=i.options,o=s.defaultThemes,a=r.matches?o.dark:o.light,l=s.themes.find(u=>u.name===a);l!=null&&l.default.auto&&i.loadTheme(a)},this._handleVisibilityChange=()=>{const n=this.container,r=n.actualOptions;this._mouseTouchFinish(),r.pauseOnBlur&&(document!=null&&document.hidden?(n.pageHidden=!0,n.pause()):(n.pageHidden=!1,n.animationStatus?n.play(!0):n.draw(!0)))},this._handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);const n=async()=>{const r=this.container.canvas;await(r==null?void 0:r.windowResize())};this._resizeTimeout=setTimeout(()=>void n(),this.container.actualOptions.interactivity.events.resize.delay*hs)},this._manageInteractivityListeners=(n,r)=>{const i=this._handlers,s=this.container,o=s.actualOptions,a=s.interactivity.element;if(!a)return;const l=a,u=s.canvas.element;u&&(u.style.pointerEvents=l===u?"initial":"none"),(o.interactivity.events.onHover.enable||o.interactivity.events.onClick.enable)&&(zo(a,pd,i.mouseMove,r),zo(a,Bme,i.touchStart,r),zo(a,Rme,i.touchMove,r),o.interactivity.events.onClick.enable?(zo(a,BM,i.touchEndClick,r),zo(a,Ame,i.mouseUp,r),zo(a,Pme,i.mouseDown,r)):zo(a,BM,i.touchEnd,r),zo(a,n,i.mouseLeave,r),zo(a,Ome,i.touchCancel,r))},this._manageListeners=n=>{const r=this._handlers,i=this.container,s=i.actualOptions,o=s.interactivity.detectsOn,a=i.canvas.element;let l=VC;o===rh.window?(i.interactivity.element=window,l=Mme):o===rh.parent&&a?i.interactivity.element=a.parentElement??a.parentNode:i.interactivity.element=a,this._manageMediaMatch(n),this._manageResize(n),this._manageInteractivityListeners(l,n),document&&zo(document,Lme,r.visibilityChange,n,!1)},this._manageMediaMatch=n=>{const r=this._handlers,i=kF("(prefers-color-scheme: dark)");if(i){if(i.addEventListener!==void 0){zo(i,"change",r.themeChange,n);return}i.addListener!==void 0&&(n?i.addListener(r.oldThemeChange):i.removeListener(r.oldThemeChange))}},this._manageResize=n=>{const r=this._handlers,i=this.container;if(!i.actualOptions.interactivity.events.resize)return;if(typeof ResizeObserver>"u"){zo(window,Dme,r.resize,n);return}const o=i.canvas.element;this._resizeObserver&&!n?(o&&this._resizeObserver.unobserve(o),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&n&&o&&(this._resizeObserver=new ResizeObserver(a=>{a.find(u=>u.target===o)&&this._handleWindowResize()}),this._resizeObserver.observe(o))},this._mouseDown=()=>{const{interactivity:n}=this.container;if(!n)return;const{mouse:r}=n;r.clicking=!0,r.downPosition=r.position},this._mouseTouchClick=n=>{const r=this.container,i=r.actualOptions,{mouse:s}=r.interactivity;s.inside=!0;let o=!1;const a=s.position;if(!(!a||!i.interactivity.events.onClick.enable)){for(const l of r.plugins.values())if(l.clickPositionValid&&(o=l.clickPositionValid(a),o))break;o||this._doMouseTouchClick(n),s.clicking=!1}},this._mouseTouchFinish=()=>{const n=this.container.interactivity;if(!n)return;const r=n.mouse;delete r.position,delete r.clickPosition,delete r.downPosition,n.status=VC,r.inside=!1,r.clicking=!1},this._mouseTouchMove=n=>{const r=this.container,i=r.actualOptions,s=r.interactivity,o=r.canvas.element;if(!(s!=null&&s.element))return;s.mouse.inside=!0;let a;if(n.type.startsWith("pointer")){this._canPush=!0;const u=n;if(s.element===window){if(o){const d=o.getBoundingClientRect();a={x:u.clientX-d.left,y:u.clientY-d.top}}}else if(i.interactivity.detectsOn===rh.parent){const d=u.target,f=u.currentTarget;if(d&&f&&o){const h=d.getBoundingClientRect(),m=f.getBoundingClientRect(),y=o.getBoundingClientRect();a={x:u.offsetX+ps*h.left-(m.left+y.left),y:u.offsetY+ps*h.top-(m.top+y.top)}}else a={x:u.offsetX??u.clientX,y:u.offsetY??u.clientY}}else u.target===o&&(a={x:u.offsetX??u.clientX,y:u.offsetY??u.clientY})}else if(this._canPush=n.type!=="touchmove",o){const u=n,d=u.touches[u.touches.length-bF],f=o.getBoundingClientRect();a={x:d.clientX-(f.left??Ev),y:d.clientY-(f.top??Ev)}}const l=r.retina.pixelRatio;a&&(a.x*=l,a.y*=l),s.mouse.position=a,s.status=pd},this._touchEnd=n=>{const r=n,i=Array.from(r.changedTouches);for(const s of i)this._touches.delete(s.identifier);this._mouseTouchFinish()},this._touchEndClick=n=>{const r=n,i=Array.from(r.changedTouches);for(const s of i)this._touches.delete(s.identifier);this._mouseTouchClick(n)},this._touchStart=n=>{const r=n,i=Array.from(r.changedTouches);for(const s of i)this._touches.set(s.identifier,performance.now());this._mouseTouchMove(n)},this._canPush=!0,this._touches=new Map,this._handlers={mouseDown:()=>this._mouseDown(),mouseLeave:()=>this._mouseTouchFinish(),mouseMove:n=>this._mouseTouchMove(n),mouseUp:n=>this._mouseTouchClick(n),touchStart:n=>this._touchStart(n),touchMove:n=>this._mouseTouchMove(n),touchEnd:n=>this._touchEnd(n),touchCancel:n=>this._touchEnd(n),touchEndClick:n=>this._touchEndClick(n),visibilityChange:()=>this._handleVisibilityChange(),themeChange:n=>this._handleThemeChange(n),oldThemeChange:n=>this._handleThemeChange(n),resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}}var Es;(function(t){t.configAdded="configAdded",t.containerInit="containerInit",t.particlesSetup="particlesSetup",t.containerStarted="containerStarted",t.containerStopped="containerStopped",t.containerDestroyed="containerDestroyed",t.containerPaused="containerPaused",t.containerPlay="containerPlay",t.containerBuilt="containerBuilt",t.particleAdded="particleAdded",t.particleDestroyed="particleDestroyed",t.particleRemoved="particleRemoved"})(Es||(Es={}));class gs{constructor(){this.value=""}static create(e,n){const r=new gs;return r.load(e),n!==void 0&&(Hc(n)||ll(n)?r.load({value:n}):r.load(n)),r}load(e){Yt(e)||Yt(e.value)||(this.value=e.value)}}class rge{constructor(){this.color=new gs,this.color.value="",this.image="",this.position="",this.repeat="",this.size="",this.opacity=1}load(e){Yt(e)||(e.color!==void 0&&(this.color=gs.create(this.color,e.color)),e.image!==void 0&&(this.image=e.image),e.position!==void 0&&(this.position=e.position),e.repeat!==void 0&&(this.repeat=e.repeat),e.size!==void 0&&(this.size=e.size),e.opacity!==void 0&&(this.opacity=e.opacity))}}class ige{constructor(){this.opacity=1}load(e){Yt(e)||(e.color!==void 0&&(this.color=gs.create(this.color,e.color)),e.image!==void 0&&(this.image=e.image),e.opacity!==void 0&&(this.opacity=e.opacity))}}class sge{constructor(){this.composite="destination-out",this.cover=new ige,this.enable=!1}load(e){if(!Yt(e)){if(e.composite!==void 0&&(this.composite=e.composite),e.cover!==void 0){const n=e.cover,r=Hc(e.cover)?{color:e.cover}:e.cover;this.cover.load(n.color!==void 0||n.image!==void 0?n:{color:r})}e.enable!==void 0&&(this.enable=e.enable)}}}class oge{constructor(){this.enable=!0,this.zIndex=0}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.zIndex!==void 0&&(this.zIndex=e.zIndex))}}class age{constructor(){this.enable=!1,this.mode=[]}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.mode!==void 0&&(this.mode=e.mode))}}var Lh;(function(t){t.circle="circle",t.rectangle="rectangle"})(Lh||(Lh={}));class tB{constructor(){this.selectors=[],this.enable=!1,this.mode=[],this.type=Lh.circle}load(e){Yt(e)||(e.selectors!==void 0&&(this.selectors=e.selectors),e.enable!==void 0&&(this.enable=e.enable),e.mode!==void 0&&(this.mode=e.mode),e.type!==void 0&&(this.type=e.type))}}class lge{constructor(){this.enable=!1,this.force=2,this.smooth=10}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.force!==void 0&&(this.force=e.force),e.smooth!==void 0&&(this.smooth=e.smooth))}}class cge{constructor(){this.enable=!1,this.mode=[],this.parallax=new lge}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.mode!==void 0&&(this.mode=e.mode),this.parallax.load(e.parallax))}}class uge{constructor(){this.delay=.5,this.enable=!0}load(e){Yt(e)||(e.delay!==void 0&&(this.delay=e.delay),e.enable!==void 0&&(this.enable=e.enable))}}class dge{constructor(){this.onClick=new age,this.onDiv=new tB,this.onHover=new cge,this.resize=new uge}load(e){if(Yt(e))return;this.onClick.load(e.onClick);const n=e.onDiv;n!==void 0&&(this.onDiv=Go(n,r=>{const i=new tB;return i.load(r),i})),this.onHover.load(e.onHover),this.resize.load(e.resize)}}class fge{constructor(e,n){this._engine=e,this._container=n}load(e){if(Yt(e)||!this._container)return;const n=this._engine.interactors.get(this._container);if(n)for(const r of n)r.loadModeOptions&&r.loadModeOptions(this,e)}}class MF{constructor(e,n){this.detectsOn=rh.window,this.events=new dge,this.modes=new fge(e,n)}load(e){if(Yt(e))return;const n=e.detectsOn;n!==void 0&&(this.detectsOn=n),this.events.load(e.events),this.modes.load(e.modes)}}class hge{load(e){Yt(e)||(e.position&&(this.position={x:e.position.x??YM,y:e.position.y??YM,mode:e.position.mode??Oh.percent}),e.options&&(this.options=Ys({},e.options)))}}var Qu;(function(t){t.screen="screen",t.canvas="canvas"})(Qu||(Qu={}));class pge{constructor(){this.maxWidth=1/0,this.options={},this.mode=Qu.canvas}load(e){Yt(e)||(Yt(e.maxWidth)||(this.maxWidth=e.maxWidth),Yt(e.mode)||(e.mode===Qu.screen?this.mode=Qu.screen:this.mode=Qu.canvas),Yt(e.options)||(this.options=Ys({},e.options)))}}var Ic;(function(t){t.any="any",t.dark="dark",t.light="light"})(Ic||(Ic={}));class mge{constructor(){this.auto=!1,this.mode=Ic.any,this.value=!1}load(e){Yt(e)||(e.auto!==void 0&&(this.auto=e.auto),e.mode!==void 0&&(this.mode=e.mode),e.value!==void 0&&(this.value=e.value))}}class gge{constructor(){this.name="",this.default=new mge}load(e){Yt(e)||(e.name!==void 0&&(this.name=e.name),this.default.load(e.default),e.options!==void 0&&(this.options=Ys({},e.options)))}}class dN{constructor(){this.count=0,this.enable=!1,this.speed=1,this.decay=0,this.delay=0,this.sync=!1}load(e){Yt(e)||(e.count!==void 0&&(this.count=lr(e.count)),e.enable!==void 0&&(this.enable=e.enable),e.speed!==void 0&&(this.speed=lr(e.speed)),e.decay!==void 0&&(this.decay=lr(e.decay)),e.delay!==void 0&&(this.delay=lr(e.delay)),e.sync!==void 0&&(this.sync=e.sync))}}class fN extends dN{constructor(){super(),this.mode=Xu.auto,this.startValue=nh.random}load(e){super.load(e),!Yt(e)&&(e.mode!==void 0&&(this.mode=e.mode),e.startValue!==void 0&&(this.startValue=e.startValue))}}class f2 extends dN{constructor(){super(),this.offset=0,this.sync=!0}load(e){super.load(e),!Yt(e)&&e.offset!==void 0&&(this.offset=lr(e.offset))}}class bge{constructor(){this.h=new f2,this.s=new f2,this.l=new f2}load(e){Yt(e)||(this.h.load(e.h),this.s.load(e.s),this.l.load(e.l))}}class d0 extends gs{constructor(){super(),this.animation=new bge}static create(e,n){const r=new d0;return r.load(e),n!==void 0&&(Hc(n)||ll(n)?r.load({value:n}):r.load(n)),r}load(e){if(super.load(e),Yt(e))return;const n=e.animation;n!==void 0&&(n.enable!==void 0?this.animation.h.load(n):this.animation.load(e.animation))}}var ih;(function(t){t.absorb="absorb",t.bounce="bounce",t.destroy="destroy"})(ih||(ih={}));class yge{constructor(){this.speed=2}load(e){Yt(e)||e.speed!==void 0&&(this.speed=e.speed)}}class vge{constructor(){this.enable=!0,this.retries=0}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.retries!==void 0&&(this.retries=e.retries))}}class Ed{constructor(){this.value=0}load(e){Yt(e)||Yt(e.value)||(this.value=lr(e.value))}}class xge extends Ed{constructor(){super(),this.animation=new dN}load(e){if(super.load(e),Yt(e))return;const n=e.animation;n!==void 0&&this.animation.load(n)}}class BF extends xge{constructor(){super(),this.animation=new fN}load(e){super.load(e)}}class nB extends Ed{constructor(){super(),this.value=1}}class RF{constructor(){this.horizontal=new nB,this.vertical=new nB}load(e){Yt(e)||(this.horizontal.load(e.horizontal),this.vertical.load(e.vertical))}}class wge{constructor(){this.absorb=new yge,this.bounce=new RF,this.enable=!1,this.maxSpeed=50,this.mode=ih.bounce,this.overlap=new vge}load(e){Yt(e)||(this.absorb.load(e.absorb),this.bounce.load(e.bounce),e.enable!==void 0&&(this.enable=e.enable),e.maxSpeed!==void 0&&(this.maxSpeed=lr(e.maxSpeed)),e.mode!==void 0&&(this.mode=e.mode),this.overlap.load(e.overlap))}}class kge{constructor(){this.close=!0,this.fill=!0,this.options={},this.type=[]}load(e){if(Yt(e))return;const n=e.options;if(n!==void 0)for(const r in n){const i=n[r];i&&(this.options[r]=Ys(this.options[r]??{},i))}e.close!==void 0&&(this.close=e.close),e.fill!==void 0&&(this.fill=e.fill),e.type!==void 0&&(this.type=e.type)}}class Sge{constructor(){this.offset=0,this.value=90}load(e){Yt(e)||(e.offset!==void 0&&(this.offset=lr(e.offset)),e.value!==void 0&&(this.value=lr(e.value)))}}class Cge{constructor(){this.distance=200,this.enable=!1,this.rotate={x:3e3,y:3e3}}load(e){if(!Yt(e)&&(e.distance!==void 0&&(this.distance=lr(e.distance)),e.enable!==void 0&&(this.enable=e.enable),e.rotate)){const n=e.rotate.x;n!==void 0&&(this.rotate.x=n);const r=e.rotate.y;r!==void 0&&(this.rotate.y=r)}}}class _ge{constructor(){this.x=50,this.y=50,this.mode=Oh.percent,this.radius=0}load(e){Yt(e)||(e.x!==void 0&&(this.x=e.x),e.y!==void 0&&(this.y=e.y),e.mode!==void 0&&(this.mode=e.mode),e.radius!==void 0&&(this.radius=e.radius))}}class Ege{constructor(){this.acceleration=9.81,this.enable=!1,this.inverse=!1,this.maxSpeed=50}load(e){Yt(e)||(e.acceleration!==void 0&&(this.acceleration=lr(e.acceleration)),e.enable!==void 0&&(this.enable=e.enable),e.inverse!==void 0&&(this.inverse=e.inverse),e.maxSpeed!==void 0&&(this.maxSpeed=lr(e.maxSpeed)))}}class Nge{constructor(){this.clamp=!0,this.delay=new Ed,this.enable=!1,this.options={}}load(e){Yt(e)||(e.clamp!==void 0&&(this.clamp=e.clamp),this.delay.load(e.delay),e.enable!==void 0&&(this.enable=e.enable),this.generator=e.generator,e.options&&(this.options=Ys(this.options,e.options)))}}class Ige{load(e){Yt(e)||(e.color!==void 0&&(this.color=gs.create(this.color,e.color)),e.image!==void 0&&(this.image=e.image))}}class jge{constructor(){this.enable=!1,this.length=10,this.fill=new Ige}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.fill!==void 0&&this.fill.load(e.fill),e.length!==void 0&&(this.length=e.length))}}var _i;(function(t){t.bounce="bounce",t.none="none",t.out="out",t.destroy="destroy",t.split="split"})(_i||(_i={}));class Tge{constructor(){this.default=_i.out}load(e){Yt(e)||(e.default!==void 0&&(this.default=e.default),this.bottom=e.bottom??e.default,this.left=e.left??e.default,this.right=e.right??e.default,this.top=e.top??e.default)}}class zge{constructor(){this.acceleration=0,this.enable=!1}load(e){Yt(e)||(e.acceleration!==void 0&&(this.acceleration=lr(e.acceleration)),e.enable!==void 0&&(this.enable=e.enable),e.position&&(this.position=Ys({},e.position)))}}class Pge{constructor(){this.angle=new Sge,this.attract=new Cge,this.center=new _ge,this.decay=0,this.distance={},this.direction=Yi.none,this.drift=0,this.enable=!1,this.gravity=new Ege,this.path=new Nge,this.outModes=new Tge,this.random=!1,this.size=!1,this.speed=2,this.spin=new zge,this.straight=!1,this.trail=new jge,this.vibrate=!1,this.warp=!1}load(e){if(Yt(e))return;this.angle.load(Gc(e.angle)?{value:e.angle}:e.angle),this.attract.load(e.attract),this.center.load(e.center),e.decay!==void 0&&(this.decay=lr(e.decay)),e.direction!==void 0&&(this.direction=e.direction),e.distance!==void 0&&(this.distance=Gc(e.distance)?{horizontal:e.distance,vertical:e.distance}:{...e.distance}),e.drift!==void 0&&(this.drift=lr(e.drift)),e.enable!==void 0&&(this.enable=e.enable),this.gravity.load(e.gravity);const n=e.outModes;n!==void 0&&(Vf(n)?this.outModes.load(n):this.outModes.load({default:n})),this.path.load(e.path),e.random!==void 0&&(this.random=e.random),e.size!==void 0&&(this.size=e.size),e.speed!==void 0&&(this.speed=lr(e.speed)),this.spin.load(e.spin),e.straight!==void 0&&(this.straight=e.straight),this.trail.load(e.trail),e.vibrate!==void 0&&(this.vibrate=e.vibrate),e.warp!==void 0&&(this.warp=e.warp)}}class Age extends fN{constructor(){super(),this.destroy=md.none,this.speed=2}load(e){super.load(e),!Yt(e)&&e.destroy!==void 0&&(this.destroy=e.destroy)}}class Mge extends BF{constructor(){super(),this.animation=new Age,this.value=1}load(e){if(Yt(e))return;super.load(e);const n=e.animation;n!==void 0&&this.animation.load(n)}}class Bge{constructor(){this.enable=!1,this.width=1920,this.height=1080}load(e){if(Yt(e))return;e.enable!==void 0&&(this.enable=e.enable);const n=e.width;n!==void 0&&(this.width=n);const r=e.height;r!==void 0&&(this.height=r)}}var f0;(function(t){t.delete="delete",t.wait="wait"})(f0||(f0={}));class Rge{constructor(){this.mode=f0.delete,this.value=0}load(e){Yt(e)||(e.mode!==void 0&&(this.mode=e.mode),e.value!==void 0&&(this.value=e.value))}}class Oge{constructor(){this.density=new Bge,this.limit=new Rge,this.value=0}load(e){Yt(e)||(this.density.load(e.density),this.limit.load(e.limit),e.value!==void 0&&(this.value=e.value))}}class Dge{constructor(){this.blur=0,this.color=new gs,this.enable=!1,this.offset={x:0,y:0},this.color.value="#000"}load(e){Yt(e)||(e.blur!==void 0&&(this.blur=e.blur),this.color=gs.create(this.color,e.color),e.enable!==void 0&&(this.enable=e.enable),e.offset!==void 0&&(e.offset.x!==void 0&&(this.offset.x=e.offset.x),e.offset.y!==void 0&&(this.offset.y=e.offset.y)))}}class Lge{constructor(){this.close=!0,this.fill=!0,this.options={},this.type="circle"}load(e){if(Yt(e))return;const n=e.options;if(n!==void 0)for(const r in n){const i=n[r];i&&(this.options[r]=Ys(this.options[r]??{},i))}e.close!==void 0&&(this.close=e.close),e.fill!==void 0&&(this.fill=e.fill),e.type!==void 0&&(this.type=e.type)}}class Fge extends fN{constructor(){super(),this.destroy=md.none,this.speed=5}load(e){super.load(e),!Yt(e)&&e.destroy!==void 0&&(this.destroy=e.destroy)}}class $ge extends BF{constructor(){super(),this.animation=new Fge,this.value=3}load(e){if(super.load(e),Yt(e))return;const n=e.animation;n!==void 0&&this.animation.load(n)}}class rB{constructor(){this.width=0}load(e){Yt(e)||(e.color!==void 0&&(this.color=d0.create(this.color,e.color)),e.width!==void 0&&(this.width=lr(e.width)),e.opacity!==void 0&&(this.opacity=lr(e.opacity)))}}class Uge extends Ed{constructor(){super(),this.opacityRate=1,this.sizeRate=1,this.velocityRate=1}load(e){super.load(e),!Yt(e)&&(e.opacityRate!==void 0&&(this.opacityRate=e.opacityRate),e.sizeRate!==void 0&&(this.sizeRate=e.sizeRate),e.velocityRate!==void 0&&(this.velocityRate=e.velocityRate))}}class Vge{constructor(e,n){this._engine=e,this._container=n,this.bounce=new RF,this.collisions=new wge,this.color=new d0,this.color.value="#fff",this.effect=new kge,this.groups={},this.move=new Pge,this.number=new Oge,this.opacity=new Mge,this.reduceDuplicates=!1,this.shadow=new Dge,this.shape=new Lge,this.size=new $ge,this.stroke=new rB,this.zIndex=new Uge}load(e){if(Yt(e))return;if(e.groups!==void 0)for(const r of Object.keys(e.groups)){if(!Object.hasOwn(e.groups,r))continue;const i=e.groups[r];i!==void 0&&(this.groups[r]=Ys(this.groups[r]??{},i))}e.reduceDuplicates!==void 0&&(this.reduceDuplicates=e.reduceDuplicates),this.bounce.load(e.bounce),this.color.load(d0.create(this.color,e.color)),this.effect.load(e.effect),this.move.load(e.move),this.number.load(e.number),this.opacity.load(e.opacity),this.shape.load(e.shape),this.size.load(e.size),this.shadow.load(e.shadow),this.zIndex.load(e.zIndex),this.collisions.load(e.collisions),e.interactivity!==void 0&&(this.interactivity=Ys({},e.interactivity));const n=e.stroke;if(n&&(this.stroke=Go(n,r=>{const i=new rB;return i.load(r),i})),this._container){const r=this._engine.updaters.get(this._container);if(r)for(const s of r)s.loadOptions&&s.loadOptions(this,e);const i=this._engine.interactors.get(this._container);if(i)for(const s of i)s.loadParticlesOptions&&s.loadParticlesOptions(this,e)}}}function OF(t,...e){for(const n of e)t.load(n)}function DF(t,e,...n){const r=new Vge(t,e);return OF(r,...n),r}class Hge{constructor(e,n){this._findDefaultTheme=r=>this.themes.find(i=>i.default.value&&i.default.mode===r)??this.themes.find(i=>i.default.value&&i.default.mode===Ic.any),this._importPreset=r=>{this.load(this._engine.getPreset(r))},this._engine=e,this._container=n,this.autoPlay=!0,this.background=new rge,this.backgroundMask=new sge,this.clear=!0,this.defaultThemes={},this.delay=0,this.fullScreen=new oge,this.detectRetina=!0,this.duration=0,this.fpsLimit=120,this.interactivity=new MF(e,n),this.manualParticles=[],this.particles=DF(this._engine,this._container),this.pauseOnBlur=!0,this.pauseOnOutsideViewport=!0,this.responsive=[],this.smooth=!1,this.style={},this.themes=[],this.zLayers=100}load(e){var o,a;if(Yt(e))return;e.preset!==void 0&&Go(e.preset,l=>this._importPreset(l)),e.autoPlay!==void 0&&(this.autoPlay=e.autoPlay),e.clear!==void 0&&(this.clear=e.clear),e.key!==void 0&&(this.key=e.key),e.name!==void 0&&(this.name=e.name),e.delay!==void 0&&(this.delay=lr(e.delay));const n=e.detectRetina;n!==void 0&&(this.detectRetina=n),e.duration!==void 0&&(this.duration=lr(e.duration));const r=e.fpsLimit;r!==void 0&&(this.fpsLimit=r),e.pauseOnBlur!==void 0&&(this.pauseOnBlur=e.pauseOnBlur),e.pauseOnOutsideViewport!==void 0&&(this.pauseOnOutsideViewport=e.pauseOnOutsideViewport),e.zLayers!==void 0&&(this.zLayers=e.zLayers),this.background.load(e.background);const i=e.fullScreen;vF(i)?this.fullScreen.enable=i:this.fullScreen.load(i),this.backgroundMask.load(e.backgroundMask),this.interactivity.load(e.interactivity),e.manualParticles&&(this.manualParticles=e.manualParticles.map(l
1044=>{const u=new hge;return u.load(l),u})),this.particles.load(e.particles),this.style=Ys(this.style,e.style),this._engine.loadOptions(this,e),e.smooth!==void 0&&(this.smooth=e.smooth);const s=this._engine.interactors.get(this._container);if(s)for(const l of s)l.loadOptions&&l.loadOptions(this,e);if(e.responsive!==void 0)for(const l of e.responsive){const u=new pge;u.load(l),this.responsive.push(u)}if(this.responsive.sort((l,u)=>l.maxWidth-u.maxWidth),e.themes!==void 0)for(const l of e.themes){const u=this.themes.find(d=>d.name===l.name);if(u)u.load(l);else{const d=new gge;d.load(l),this.themes.push(d)}}this.defaultThemes.dark=(o=this._findDefaultTheme(Ic.dark))==null?void 0:o.name,this.defaultThemes.light=(a=this._findDefaultTheme(Ic.light))==null?void 0:a.name}setResponsive(e,n,r){this.load(r);const i=this.responsive.find(s=>s.mode===Qu.screen&&screen?s.maxWidth>screen.availWidth:s.maxWidth*n>e);return this.load(i==null?void 0:i.options),i==null?void 0:i.maxWidth}setTheme(e){if(e){const n=this.themes.find(r=>r.name===e);n&&this.load(n.options)}else{const n=kF("(prefers-color-scheme: dark)"),r=n==null?void 0:n.matches,i=this._findDefaultTheme(r?Ic.dark:Ic.light);i&&this.load(i.options)}}}var Fh;(function(t){t.external="external",t.particles="particles"})(Fh||(Fh={}));class Gge{constructor(e,n){this.container=n,this._engine=e,this._interactors=[],this._externalInteractors=[],this._particleInteractors=[]}externalInteract(e){for(const n of this._externalInteractors)n.isEnabled()&&n.interact(e)}handleClickMode(e){var n;for(const r of this._externalInteractors)(n=r.handleClickMode)==null||n.call(r,e)}
vendor: 30,484 bytes, line 1044
1044async init(){this._interactors=await this._engine.getInteractors(this.container,!0),this._externalInteractors=[],this._particleInteractors=[];for(const e of this._interactors){switch(e.type){case Fh.external:this._externalInteractors.push(e);break;case Fh.particles:this._particleInteractors.push(e);break}e.init()}}particlesInteract(e,n){for(const r of this._externalInteractors)r.clear(e,n);for(const r of this._particleInteractors)r.isEnabled(e)&&r.interact(e,n)}reset(e){for(const n of this._externalInteractors)n.isEnabled()&&n.reset(e);for(const n of this._particleInteractors)n.isEnabled(e)&&n.reset(e)}}var wa;(function(t){t.normal="normal",t.inside="inside",t.outside="outside"})(wa||(wa={}));function Wge(t,e,n,r){const i=e.options[t];if(i)return Ys({close:e.close,fill:e.fill},ma(i,n,r))}function qge(t,e,n,r){const i=e.options[t];if(i)return Ys({close:e.close,fill:e.fill},ma(i,n,r))}function iB(t){if(!mi(t.outMode,t.checkModes))return;const e=t.radius*ps;t.coord>t.maxCoord-e?t.setCb(-t.radius):t.coord<e&&t.setCb(t.radius)}class Kge{constructor(e,n){this.container=n,this._calcPosition=(r,i,s,o=OM)=>{for(const y of r.plugins.values()){const g=y.particlePosition!==void 0?y.particlePosition(i,this):void 0;if(g)return oo.create(g.x,g.y,s)}const a=r.canvas.size,l=E0e({size:a,position:i}),u=oo.create(l.x,l.y,s),d=this.getRadius(),f=this.options.move.outModes,h=y=>{iB({outMode:y,checkModes:[_i.bounce],coord:u.x,maxCoord:r.canvas.size.width,setCb:g=>u.x+=g,radius:d})},m=y=>{iB({outMode:y,checkModes:[_i.bounce],coord:u.y,maxCoord:r.canvas.size.height,setCb:g=>u.y+=g,radius:d})};return h(f.left??f.default),h(f.right??f.default),m(f.top??f.default),m(f.bottom??f.default),this._checkOverlap(u,o)?this._calcPosition(r,void 0,s,o+r0e):u},this._calculateVelocity=()=>{const r=_0e(this.direction),i=r.copy(),s=this.options.move;if(s.direction===Yi.inside||s.direction===Yi.outside)return i;const o=Lc(vn(s.angle.value)),a=Lc(vn(s.angle.offset)),l={left:a-o*Pi,right:a+o*Pi};return s.straight||(i.angle+=ho(lr(l.left,l.right))),s.random&&typeof s.speed=="number"&&(i.length*=Ar()),i},this._checkOverlap=(r,i=OM)=>{const s=this.options.collisions,o=this.getRadius();if(!s.enable)return!1;const a=s.overlap;if(a.enable)return!1;const l=a.retries;if(l>=i0e&&i>l)throw new Error(`${$o} particle is overlapping and can't be placed`);return!!this.container.particles.find(u=>vo(r,u.position)<o+u.getRadius())},this._getRollColor=r=>{if(!r||!this.roll||!this.backColor&&!this.roll.alter)return r;const i=this.roll.horizontal&&this.roll.vertical?ps*GM:GM,s=this.roll.horizontal?Math.PI*Pi:Nv;return Math.floor(((this.roll.angle??Nv)+s)/(Math.PI/i))%ps?this.backColor?this.backColor:this.roll.alter?J0e(r,this.roll.alter.type,this.roll.alter.value):r:r},this._initPosition=r=>{const i=this.container,s=vn(this.options.zIndex.value);this.position=this._calcPosition(i,r,Uo(s,s0e,i.zLayers)),this.initialPosition=this.position.copy();const o=i.canvas.size;switch(this.moveCenter={...NF(this.options.move.center,o),radius:this.options.move.center.radius??o0e,mode:this.options.move.center.mode??Oh.percent},this.direction=C0e(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case Yi.inside:this.outType=wa.inside;break;case Yi.outside:this.outType=wa.outside;break}this.offset=Hi.origin},this._engine=e}destroy(e){var s,o,a;if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;const n=this.container,r=this.pathGenerator,i=n.shapeDrawers.get(this.shape);(s=i==null?void 0:i.particleDestroy)==null||s.call(i,this);for(const l of n.plugins.values())(o=l.particleDestroyed)==null||o.call(l,this,e);for(const l of n.particles.updaters)(a=l.particleDestroyed)==null||a.call(l,this,e);r==null||r.reset(this),this._engine.dispatchEvent(Es.particleDestroyed,{container:this.container,data:{particle:this}})}draw(e){const n=this.container,r=n.canvas;for(const i of n.plugins.values())r.drawParticlePlugin(i,this,e);r.drawParticle(this,e)}getFillColor(){return this._getRollColor(this.bubble.color??JM(this.color))}getMass(){return this.getRadius()**Nl*Math.PI*Pi}getPosition(){return{x:this.position.x+this.offset.x,y:this.position.y+this.offset.y,z:this.position.z}}getRadius(){return this.bubble.radius??this.size.value}getStrokeColor(){return this._getRollColor(this.bubble.color??JM(this.strokeColor))}init(e,n,r,i){var j,T,M,V,H,P;const s=this.container,o=this._engine;this.id=e,this.group=i,this.effectClose=!0,this.effectFill=!0,this.shapeClose=!0,this.shapeFill=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=wa.normal,this.ignoresResizeRatio=!0;const a=s.retina.pixelRatio,l=s.actualOptions,u=DF(this._engine,s,l.particles),{reduceDuplicates:d}=u,f=u.effect.type,h=u.shape.type;this.effect=ma(f,this.id,d),this.shape=ma(h,this.id,d);const m=u.effect,y=u.shape;if(r){if((j=r.effect)!=null&&j.type){const F=r.effect.type,I=ma(F,this.id,d);I&&(this.effect=I,m.load(r.effect))}if((T=r.shape)!=null&&T.type){const F=r.shape.type,I=ma(F,this.id,d);I&&(this.shape=I,y.load(r.shape))}}if(this.effect===Rh){const F=[...this.container.effectDrawers.keys()];this.effect=F[Math.floor(Math.random()*F.length)]}if(this.shape===Rh){const F=[...this.container.shapeDrawers.keys()];this.shape=F[Math.floor(Math.random()*F.length)]}this.effectData=Wge(this.effect,m,this.id,d),this.shapeData=qge(this.shape,y,this.id,d),u.load(r);const g=this.effectData;g&&u.load(g.particles);const w=this.shapeData;w&&u.load(w.particles);const v=new MF(o,s);v.load(s.actualOptions.interactivity),v.load(u.interactivity),this.interactivity=v,this.effectFill=(g==null?void 0:g.fill)??u.effect.fill,this.effectClose=(g==null?void 0:g.close)??u.effect.close,this.shapeFill=(w==null?void 0:w.fill)??u.shape.fill,this.shapeClose=(w==null?void 0:w.close)??u.shape.close,this.options=u;const S=this.options.move.path;this.pathDelay=vn(S.delay.value)*hs,S.generator&&(this.pathGenerator=this._engine.getPathGenerator(S.generator),this.pathGenerator&&s.addPath(S.generator,this.pathGenerator)&&this.pathGenerator.init(s)),s.retina.initParticle(this),this.size=EF(this.options.size,a),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(n),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=gF-vn(this.options.move.decay);const C=s.particles;C.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/s.zLayers,this.sides=24;let k=s.effectDrawers.get(this.effect);k||(k=this._engine.getEffectDrawer(this.effect),k&&s.effectDrawers.set(this.effect,k)),k!=null&&k.loadEffect&&k.loadEffect(this);let N=s.shapeDrawers.get(this.shape);N||(N=this._engine.getShapeDrawer(this.shape),N&&s.shapeDrawers.set(this.shape,N)),N!=null&&N.loadShape&&N.loadShape(this);const _=N==null?void 0:N.getSidesCount;_&&(this.sides=_(this)),this.spawning=!1,this.shadowColor=xa(this._engine,this.options.shadow.color);for(const F of C.updaters)F.init(this);for(const F of C.movers)(M=F.init)==null||M.call(F,this);(V=k==null?void 0:k.particleInit)==null||V.call(k,s,this),(H=N==null?void 0:N.particleInit)==null||H.call(N,s,this);for(const F of s.plugins.values())(P=F.particleCreated)==null||P.call(F,this)}isInsideCanvas(){const e=this.getRadius(),n=this.container.canvas.size,r=this.position;return r.x>=-e&&r.y>=-e&&r.y<=n.height+e&&r.x<=n.width+e}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){var e;for(const n of this.container.particles.updaters)(e=n.reset)==null||e.call(n,this)}}class Yge{constructor(e,n){this.position=e,this.particle=n}}var sh;(function(t){t.circle="circle",t.rectangle="rectangle"})(sh||(sh={}));class LF{constructor(e,n,r){this.position={x:e,y:n},this.type=r}}class ms extends LF{constructor(e,n,r){super(e,n,sh.circle),this.radius=r}contains(e){return vo(e,this.position)<=this.radius}intersects(e){const n=this.position,r=e.position,i={x:Math.abs(r.x-n.x),y:Math.abs(r.y-n.y)},s=this.radius;if(e instanceof ms||e.type===sh.circle){const o=e,a=s+o.radius,l=Math.sqrt(i.x**Nl+i.y**Nl);return a>l}else if(e instanceof Ca||e.type===sh.rectangle){const o=e,{width:a,height:l}=o.size;return Math.pow(i.x-a,Nl)+Math.pow(i.y-l,Nl)<=s**Nl||i.x<=s+a&&i.y<=s+l||i.x<=a||i.y<=l}return!1}}class Ca extends LF{constructor(e,n,r,i){super(e,n,sh.rectangle),this.size={height:i,width:r}}contains(e){const n=this.size.width,r=this.size.height,i=this.position;return e.x>=i.x&&e.x<=i.x+n&&e.y>=i.y&&e.y<=i.y+r}intersects(e){if(e instanceof ms)return e.intersects(this);const n=this.size.width,r=this.size.height,i=this.position,s=e.position,o=e instanceof Ca?e.size:{width:0,height:0},a=o.width,l=o.height;return s.x<i.x+n&&s.x+a>i.x&&s.y<i.y+r&&s.y+l>i.y}}class jv{constructor(e,n){this.rectangle=e,this.capacity=n,this._subdivide=()=>{const{x:r,y:i}=this.rectangle.position,{width:s,height:o}=this.rectangle.size,{capacity:a}=this;for(let l=0;l<Ume;l++){const u=l%ps;this._subs.push(new jv(new Ca(r+s*Pi*u,i+o*Pi*(Math.round(l*Pi)-u),s*Pi,o*Pi),a))}this._divided=!0},this._points=[],this._divided=!1,this._subs=[]}insert(e){return this.rectangle.contains(e.position)?this._points.length<this.capacity?(this._points.push(e),!0):(this._divided||this._subdivide(),this._subs.some(n=>n.insert(e))):!1}query(e,n){const r=[];if(!e.intersects(this.rectangle))return[];for(const i of this._points)!e.contains(i.position)&&vo(e.position,i.position)>i.particle.getRadius()&&(!n||n(i.particle))||r.push(i.particle);if(this._divided)for(const i of this._subs)r.push(...i.query(e,n));return r}queryCircle(e,n,r){return this.query(new ms(e.x,e.y,n),r)}queryRectangle(e,n,r){return this.query(new Ca(e.x,e.y,n.width,n.height),r)}}const sB=t=>{const{height:e,width:n}=t;return new Ca(WM*n,WM*e,qM*n,qM*e)};class Xge{constructor(e,n){this._addToPool=(...i)=>{this._pool.push(...i)},this._applyDensity=(i,s,o)=>{var m;const a=i.number;if(!((m=i.number.density)!=null&&m.enable)){o===void 0?this._limit=a.limit.value:a.limit&&this._groupLimits.set(o,a.limit.value);return}const l=this._initDensityFactor(a.density),u=a.value,d=a.limit.value>KM?a.limit.value:u,f=Math.min(u,d)*l+s,h=Math.min(this.count,this.filter(y=>y.group===o).length);o===void 0?this._limit=a.limit.value*l:this._groupLimits.set(o,a.limit.value*l),h<f?this.push(Math.abs(f-h),void 0,i,o):h>f&&this.removeQuantity(h-f,o)},this._initDensityFactor=i=>{const s=this._container;if(!s.canvas.element||!i.enable)return u0e;const o=s.canvas.element,a=s.retina.pixelRatio;return o.width*o.height/(i.height*i.width*a**Nl)},this._pushParticle=(i,s,o,a)=>{try{let l=this._pool.pop();l||(l=new Kge(this._engine,this._container)),l.init(this._nextId,i,s,o);let u=!0;return a&&(u=a(l)),u?(this._array.push(l),this._zArray.push(l),this._nextId++,this._engine.dispatchEvent(Es.particleAdded,{container:this._container,data:{particle:l}}),l):void 0}catch(l){gd().warning(`${$o} adding particle: ${l}`)}},this._removeParticle=(i,s,o)=>{const a=this._array[i];if(!a||a.group!==s)return!1;const l=this._zArray.indexOf(a);return this._array.splice(i,Iv),this._zArray.splice(l,Iv),a.destroy(o),this._engine.dispatchEvent(Es.particleRemoved,{container:this._container,data:{particle:a}}),this._addToPool(a),!0},this._engine=e,this._container=n,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._lastZIndex=0,this._interactionManager=new Gge(e,n),this._pluginsInitialized=!1;const r=n.canvas.size;this.quadTree=new jv(sB(r),DM),this.movers=[],this.updaters=[]}get count(){return this._array.length}addManualParticles(){const e=this._container;e.actualOptions.manualParticles.forEach(r=>this.addParticle(r.position?NF(r.position,e.canvas.size):void 0,r.options))}addParticle(e,n,r,i){const s=this._container.actualOptions.particles.number.limit.mode,o=r===void 0?this._limit:this._groupLimits.get(r)??this._limit,a=this.count;if(o>KM)switch(s){case f0.delete:{const l=a+a0e-o;l>l0e&&this.removeQuantity(l);break}case f0.wait:if(a>=o)return;break}return this._pushParticle(e,n,r,i)}clear(){this._array=[],this._zArray=[],this._pluginsInitialized=!1}destroy(){this._array=[],this._zArray=[],this.movers=[],this.updaters=[]}draw(e){const n=this._container,r=n.canvas;r.clear(),this.update(e);for(const i of n.plugins.values())r.drawPlugin(i,e);for(const i of this._zArray)i.draw(e)}filter(e){return this._array.filter(e)}find(e){return this._array.find(e)}get(e){return this._array[e]}handleClickMode(e){this._interactionManager.handleClickMode(e)}async init(){var i,s;const e=this._container,n=e.actualOptions;this._lastZIndex=0,this._needsSort=!1,await this.initPlugins();let r=!1;for(const o of e.plugins.values())if(r=((i=o.particlesInitialization)==null?void 0:i.call(o))??r,r)break;if(this.addManualParticles(),!r){const o=n.particles,a=o.groups;for(const l in a){const u=a[l];for(let d=this.count,f=0;f<((s=u.number)==null?void 0:s.value)&&d<o.number.value;d++,f++)this.addParticle(void 0,u,l)}for(let l=this.count;l<o.number.value;l++)this.addParticle()}}async initPlugins(){if(this._pluginsInitialized)return;const e=this._container;this.movers=await this._engine.getMovers(e,!0),this.updaters=await this._engine.getUpdaters(e,!0),await this._interactionManager.init();for(const n of e.pathGenerators.values())n.init(e)}push(e,n,r,i){for(let s=0;s<e;s++)this.addParticle(n==null?void 0:n.position,r,i)}async redraw(){this.clear(),await this.init(),this.draw({value:0,factor:0})}remove(e,n,r){this.removeAt(this._array.indexOf(e),void 0,n,r)}removeAt(e,n=$me,r,i){if(e<KC||e>this.count)return;let s=0;for(let o=e;s<n&&o<this.count;o++)this._removeParticle(o,r,i)&&(o--,s++)}removeQuantity(e,n){this.removeAt(KC,e,n)}setDensity(){const e=this._container.actualOptions,n=e.particles.groups;for(const r in n)this._applyDensity(n[r],c0e,r);this._applyDensity(e.particles,e.manualParticles.length)}setLastZIndex(e){this._lastZIndex=e,this._needsSort=this._needsSort||this._lastZIndex<e}setResizeFactor(e){this._resizeFactor=e}update(e){var s,o;const n=this._container,r=new Set;this.quadTree=new jv(sB(n.canvas.size),DM);for(const a of n.pathGenerators.values())a.update();for(const a of n.plugins.values())(s=a.update)==null||s.call(a,e);const i=this._resizeFactor;for(const a of this._array){i&&!a.ignoresResizeRatio&&(a.position.x*=i.width,a.position.y*=i.height,a.initialPosition.x*=i.width,a.initialPosition.y*=i.height),a.ignoresResizeRatio=!1,this._interactionManager.reset(a);for(const l of this._container.plugins.values()){if(a.destroyed)break;(o=l.particleUpdate)==null||o.call(l,a,e)}for(const l of this.movers)l.isEnabled(a)&&l.move(a,e);if(a.destroyed){r.add(a);continue}this.quadTree.insert(new Yge(a.getPosition(),a))}if(r.size){const a=l=>!r.has(l);this._array=this.filter(a),this._zArray=this._zArray.filter(a);for(const l of r)this._engine.dispatchEvent(Es.particleRemoved,{container:this._container,data:{particle:l}});this._addToPool(...r)}this._interactionManager.externalInteract(e);for(const a of this._array){for(const l of this.updaters)l.update(a,e);!a.destroyed&&!a.spawning&&this._interactionManager.particlesInteract(a,e)}if(delete this._resizeFactor,this._needsSort){const a=this._zArray;a.sort((l,u)=>u.position.z-l.position.z||l.id-u.id),this._lastZIndex=a[a.length-bF].position.z,this._needsSort=!1}}}class Qge{constructor(e){this.container=e,this.pixelRatio=LM,this.reduceFactor=FM}init(){const e=this.container,n=e.actualOptions;this.pixelRatio=!n.detectRetina||bd()?LM:window.devicePixelRatio,this.reduceFactor=FM;const r=this.pixelRatio,i=e.canvas;if(i.element){const a=i.element;i.size.width=a.offsetWidth*r,i.size.height=a.offsetHeight*r}const s=n.particles,o=s.move;this.maxSpeed=vn(o.gravity.maxSpeed)*r,this.sizeAnimationSpeed=vn(s.size.animation.speed)*r}initParticle(e){const n=e.options,r=this.pixelRatio,i=n.move,s=i.distance,o=e.retina;o.moveDrift=vn(i.drift)*r,o.moveSpeed=vn(i.speed)*r,o.sizeAnimationSpeed=vn(n.size.animation.speed)*r;const a=o.maxDistance;a.horizontal=s.horizontal!==void 0?s.horizontal*r:void 0,a.vertical=s.vertical!==void 0?s.vertical*r:void 0,o.maxSpeed=vn(i.gravity.maxSpeed)*r}}function si(t){return t&&!t.destroyed}function Zge(t,e=i2,n=!1){return{value:t,factor:n?i2/e:i2*t/hs}}function bf(t,e,...n){const r=new Hge(t,e);return OF(r,...n),r}class Jge{constructor(e,n,r){this._intersectionManager=i=>{if(!(!si(this)||!this.actualOptions.pauseOnOutsideViewport))for(const s of i)s.target===this.interactivity.element&&(s.isIntersecting?this.play():this.pause())},this._nextFrame=i=>{try{if(!this._smooth&&this._lastFrameTime!==void 0&&i<this._lastFrameTime+hs/this.fpsLimit){this.draw(!1);return}this._lastFrameTime??(this._lastFrameTime=i);const s=Zge(i-this._lastFrameTime,this.fpsLimit,this._smooth);if(this.addLifeTime(s.value),this._lastFrameTime=i,s.value>hs){this.draw(!1);return}if(this.particles.draw(s),!this.alive()){this.destroy();return}this.animationStatus&&this.draw(!1)}catch(s){gd().error(`${$o} in animation loop`,s)}},this._engine=e,this.id=Symbol(n),this.fpsLimit=120,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._clickHandlers=new Map,this._sourceOptions=r,this._initialSourceOptions=r,this.retina=new Qge(this),this.canvas=new tge(this,this._engine),this.particles=new Xge(this._engine,this),this.pathGenerators=new Map,this.interactivity={mouse:{clicking:!1,inside:!1}},this.plugins=new Map,this.effectDrawers=new Map,this.shapeDrawers=new Map,this._options=bf(this._engine,this),this.actualOptions=bf(this._engine,this),this._eventListeners=new nge(this),this._intersectionObserver=z0e(i=>this._intersectionManager(i)),this._engine.dispatchEvent(Es.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&si(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addClickHandler(e){if(!si(this))return;const n=this.interactivity.element;if(!n)return;const r=(f,h,m)=>{if(!si(this))return;const y=this.retina.pixelRatio,g={x:h.x*y,y:h.y*y},w=this.particles.quadTree.queryCircle(g,m*y);e(f,w)},i=f=>{if(!si(this))return;const h=f,m={x:h.offsetX||h.clientX,y:h.offsetY||h.clientY};r(f,m,Yme)},s=()=>{si(this)&&(u=!0,d=!1)},o=()=>{si(this)&&(d=!0)},a=f=>{if(si(this)){if(u&&!d){const h=f;let m=h.touches[h.touches.length-HM];if(!m&&(m=h.changedTouches[h.changedTouches.length-HM],!m))return;const y=this.canvas.element,g=y?y.getBoundingClientRect():void 0,w={x:m.clientX-(g?g.left:Ev),y:m.clientY-(g?g.top:Ev)};r(f,w,Math.max(m.radiusX,m.radiusY))}u=!1,d=!1}},l=()=>{si(this)&&(u=!1,d=!1)};let u=!1,d=!1;this._clickHandlers.set("click",i),this._clickHandlers.set("touchstart",s),this._clickHandlers.set("touchmove",o),this._clickHandlers.set("touchend",a),this._clickHandlers.set("touchcancel",l);for(const[f,h]of this._clickHandlers)n.addEventListener(f,h)}addLifeTime(e){this._lifeTime+=e}addPath(e,n,r=!1){return!si(this)||!r&&this.pathGenerators.has(e)?!1:(this.pathGenerators.set(e,n),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}clearClickHandlers(){var e;if(si(this)){for(const[n,r]of this._clickHandlers)(e=this.interactivity.element)==null||e.removeEventListener(n,r);this._clickHandlers.clear()}}destroy(e=!0){var n,r;if(si(this)){this.stop(),this.clearClickHandlers(),this.particles.destroy(),this.canvas.destroy();for(const i of this.effectDrawers.values())(n=i.destroy)==null||n.call(i,this);for(const i of this.shapeDrawers.values())(r=i.destroy)==null||r.call(i,this);for(const i of this.effectDrawers.keys())this.effectDrawers.delete(i);for(const i of this.shapeDrawers.keys())this.shapeDrawers.delete(i);if(this._engine.clearPlugins(this),this.destroyed=!0,e){const i=this._engine.items,s=i.findIndex(o=>o===this);s>=Xme&&i.splice(s,mF)}this._engine.dispatchEvent(Es.containerDestroyed,{container:this})}}draw(e){if(!si(this))return;let n=e;const r=i=>{n&&(this._lastFrameTime=void 0,n=!1),this._nextFrame(i)};this._drawAnimationFrame=k0e(i=>r(i))}async export(e,n={}){for(const r of this.plugins.values()){if(!r.export)continue;const i=await r.export(e,n);if(i.supported)return i.blob}gd().error(`${$o} - Export plugin with type ${e} not found`)}handleClickMode(e){var n;if(si(this)){this.particles.handleClickMode(e);for(const r of this.plugins.values())(n=r.handleClickMode)==null||n.call(r,e)}}async init(){var u,d,f,h;if(!si(this))return;const e=this._engine.getSupportedEffects();for(const m of e){const y=this._engine.getEffectDrawer(m);y&&this.effectDrawers.set(m,y)}const n=this._engine.getSupportedShapes();for(const m of n){const y=this._engine.getShapeDrawer(m);y&&this.shapeDrawers.set(m,y)}await this.particles.initPlugins(),this._options=bf(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=bf(this._engine,this,this._options);const r=await this._engine.getAvailablePlugins(this);for(const[m,y]of r)this.plugins.set(m,y);this.retina.init(),await this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();const{zLayers:i,duration:s,delay:o,fpsLimit:a,smooth:l}=this.actualOptions;this.zLayers=i,this._duration=vn(s)*hs,this._delay=vn(o)*hs,this._lifeTime=0,this.fpsLimit=a>Zme?a:Qme,this._smooth=l;for(const m of this.effectDrawers.values())await((u=m.init)==null?void 0:u.call(m,this));for(const m of this.shapeDrawers.values())await((d=m.init)==null?void 0:d.call(m,this));for(const m of this.plugins.values())await((f=m.init)==null?void 0:f.call(m));this._engine.dispatchEvent(Es.containerInit,{container:this}),await this.particles.init(),this.particles.setDensity();for(const m of this.plugins.values())(h=m.particlesSetup)==null||h.call(m);this._engine.dispatchEvent(Es.particlesSetup,{container:this})}async loadTheme(e){si(this)&&(this._currentTheme=e,await this.refresh())}pause(){var e;if(si(this)&&(this._drawAnimationFrame!==void 0&&(S0e(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const n of this.plugins.values())(e=n.pause)==null||e.call(n);this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(Es.containerPaused,{container:this})}}play(e){if(!si(this))return;const n=this._paused||e;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),n)for(const r of this.plugins.values())r.play&&r.play();this._engine.dispatchEvent(Es.containerPlay,{container:this}),this.draw(n??!1)}async refresh(){if(si(this))return this.stop(),this.start()}async reset(e){if(si(this))return this._initialSourceOptions=e,this._sourceOptions=e,this._options=bf(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=bf(this._engine,this,this._options),this.refresh()}async start(){!si(this)||this.started||(await this.init(),this.started=!0,await new Promise(e=>{const n=async()=>{var r;this._eventListeners.addListeners(),this.interactivity.element instanceof HTMLElement&&this._intersectionObserver&&this._intersectionObserver.observe(this.interactivity.element);for(const i of this.plugins.values())await((r=i.start)==null?void 0:r.call(i));this._engine.dispatchEvent(Es.containerStarted,{container:this}),this.play(),e()};this._delayTimeout=setTimeout(()=>void n(),this._delay)}))}stop(){var e;if(!(!si(this)||!this.started)){this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop(),this.interactivity.element instanceof HTMLElement&&this._intersectionObserver&&this._intersectionObserver.unobserve(this.interactivity.element);for(const n of this.plugins.values())(e=n.stop)==null||e.call(n);for(const n of this.plugins.keys())this.plugins.delete(n);this._sourceOptions=this._options,this._engine.dispatchEvent(Es.containerStopped,{container:this})}}updateActualOptions(){this.actualOptions.responsive=[];const e=this.actualOptions.setResponsive(this.canvas.size.width,this.retina.pixelRatio,this._options);return this.actualOptions.setTheme(this._currentTheme),this._responsiveMaxWidth===e?!1:(this._responsiveMaxWidth=e,!0)}}class ebe{constructor(){this._listeners=new Map}addEventListener(e,n){this.removeEventListener(e,n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r)),r.push(n)}dispatchEvent(e,n){const r=this._listeners.get(e);r==null||r.forEach(i=>i(n))}hasEventListener(e){return!!this._listeners.get(e)}removeAllEventListeners(e){e?this._listeners.delete(e):this._listeners=new Map}removeEventListener(e,n){const r=this._listeners.get(e);if(!r)return;const i=r.length,s=r.indexOf(n);s<KC||(i===Iv?this._listeners.delete(e):r.splice(s,Iv))}}async function h2(t,e,n,r=!1){let i=e.get(t);return(!i||r)&&(i=await Promise.all([...n.values()].map(s=>s(t))),e.set(t,i)),i}async function tbe(t){const e=ma(t.url,t.index);if(!e)return t.fallback;const n=await fetch(e);return n.ok?await n.json():(gd().error(`${$o} ${n.status} while retrieving config file`),t.fallback)}const nbe=t=>{let e;if(t instanceof HTMLCanvasElement||t.tagName.toLowerCase()===s2)e=t,e.dataset[Ku]||(e.dataset[Ku]=RM);else{const r=t.getElementsByTagName(s2);r.length?(e=r[Jme],e.dataset[Ku]=RM):(e=document.createElement(s2),e.dataset[Ku]=hF,t.appendChild(e))}const n="100%";return e.style.width||(e.style.width=n),e.style.height||(e.style.height=n),e},rbe=(t,e)=>{let n=e??document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.dataset[Ku]=hF,document.body.append(n),n)};class ibe{constructor(){this._configs=new Map,this._domArray=[],this._eventDispatcher=new ebe,this._initialized=!1,this.plugins=[],this.colorManagers=new Map,this.easingFunctions=new Map,this._initializers={interactors:new Map,movers:new Map,updaters:new Map},this.interactors=new Map,this.movers=new Map,this.updaters=new Map,this.presets=new Map,this.effectDrawers=new Map,this.shapeDrawers=new Map,this.pathGenerators=new Map}get configs(){const e={};for(const[n,r]of this._configs)e[n]=r;return e}get items(){return this._domArray}get version(){return"3.8.1"}async addColorManager(e,n=!0){this.colorManagers.set(e.key,e),await this.refresh(n)}addConfig(e){const n=e.key??e.name??"default";this._configs.set(n,e),this._eventDispatcher.dispatchEvent(Es.configAdded,{data:{name:n,config:e}})}async addEasing(e,n,r=!0){this.getEasing(e)||(this.easingFunctions.set(e,n),await this.refresh(r))}async addEffect(e,n,r=!0){Go(e,i=>{this.getEffectDrawer(i)||this.effectDrawers.set(i,n)}),await this.refresh(r)}addEventListener(e,n){this._eventDispatcher.addEventListener(e,n)}async addInteractor(e,n,r=!0){this._initializers.interactors.set(e,n),await this.refresh(r)}async addMover(e,n,r=!0){this._initializers.movers.set(e,n),await this.refresh(r)}async addParticleUpdater(e,n,r=!0){this._initializers.updaters.set(e,n),await this.refresh(r)}async addPathGenerator(e,n,r=!0){this.getPathGenerator(e)||this.pathGenerators.set(e,n),await this.refresh(r)}async addPlugin(e,n=!0){this.getPlugin(e.id)||this.plugins.push(e),await this.refresh(n)}async addPreset(e,n,r=!1,i=!0){(r||!this.getPreset(e))&&this.presets.set(e,n),await this.refresh(i)}async addShape(e,n=!0){for(const r of e.validTypes)this.getShapeDrawer(r)||this.shapeDrawers.set(r,e);await this.refresh(n)}checkVersion(e){if(this.version!==e)throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${e}`)}clearPlugins(e){this.updaters.delete(e),this.movers.delete(e),this.interactors.delete(e)}dispatchEvent(e,n){this._eventDispatcher.dispatchEvent(e,n)}dom(){return this.items}domItem(e){return this.item(e)}async getAvailablePlugins(e){const n=new Map;for(const r of this.plugins)r.needsPlugin(e.actualOptions)&&n.set(r.id,await r.getPlugin(e));return n}getEasing(e){return this.easingFunctions.get(e)??(n=>n)}getEffectDrawer(e){return this.effectDrawers.get(e)}async getInteractors(e,n=!1){return h2(e,this.interactors,this._initializers.interactors,n)}async getMovers(e,n=!1){return h2(e,this.movers,this._initializers.movers,n)}getPathGenerator(e){return this.pathGenerators.get(e)}getPlugin(e){return this.plugins.find(n=>n.id===e)}getPreset(e){return this.presets.get(e)}getShapeDrawer(e){return this.shapeDrawers.get(e)}getSupportedEffects(){return this.effectDrawers.keys()}getSupportedShapes(){return this.shapeDrawers.keys()}async getUpdaters(e,n=!1){return h2(e,this.updaters,this._initializers.updaters,n)}init(){this._initialized||(this._initialized=!0)}item(e){const{items:n}=this,r=n[e];if(!r||r.destroyed){n.splice(e,mF);return}return r}async load(e){var h;const n=e.id??((h=e.element)==null?void 0:h.id)??`tsparticles${Math.floor(Ar()*e0e)}`,{index:r,url:i}=e,s=i?await tbe({fallback:e.options,url:i,index:r}):e.options,o=ma(s,r),{items:a}=this,l=a.findIndex(m=>m.id.description===n),u=new Jge(this,n,o);if(l>=t0e){const m=this.item(l),y=m?n0e:Nv;m&&!m.destroyed&&m.destroy(!1),a.splice(l,y,u)}else a.push(u);const d=rbe(n,e.element),f=nbe(d);return u.canvas.loadCanvas(f),await u.start(),u}loadOptions(e,n){this.plugins.forEach(r=>{var i;return(i=r.loadOptions)==null?void 0:i.call(r,e,n)})}loadParticlesOptions(e,n,...r){const i=this.updaters.get(e);i&&i.forEach(s=>{var o;return(o=s.loadOptions)==null?void 0:o.call(s,n,...r)})}async refresh(e=!0){e&&await Promise.all(this.items.map(n=>n.refresh()))}removeEventListener(e,n){this._eventDispatcher.removeEventListener(e,n)}setOnClickHandler(e){const{items:n}=this;if(!n.length)throw new Error(`${$o} can only set click handlers after calling tsParticles.load()`);n.forEach(r=>r.addClickHandler(e))}}function sbe(){const t=new ibe;return t.init(),t}class cl{constructor(e){this.type=Fh.external,this.container=e}}class hN{constructor(e){this.type=Fh.particles,this.container=e}}var ha;(function(t){t.clockwise="clockwise",t.counterClockwise="counter-clockwise",t.random="random"})(ha||(ha={}));var oB;(function(t){t.linear="linear",t.radial="radial",t.random="random"})(oB||(oB={}));var nd;(function(t){t.easeInBack="ease-in-back",t.easeInCirc="ease-in-circ",t.easeInCubic="ease-in-cubic",t.easeInLinear="ease-in-linear",t.easeInQuad="ease-in-quad",t.easeInQuart="ease-in-quart",t.easeInQuint="ease-in-quint",t.easeInExpo="ease-in-expo",t.easeInSine="ease-in-sine",t.easeOutBack="ease-
1044out-back",t.easeOutCirc="ease-out-circ",t.easeOutCubic="ease-out-cubic",t.easeOutLinear="ease-out-linear",t.easeOutQuad="ease-out-quad",t.easeOutQuart="ease-out-quart",t.easeOutQuint="ease-out-quint",t.easeOutExpo="ease-out-expo",t.easeOutSine="ease-out-sine",t.easeInOutBack="ease-in-out-back",t.easeInOutCirc="ease-in-out-circ",t.easeInOutCubic="ease-in-out-cubic",t.easeInOutLinear="ease-in-out-linear",t.easeInOutQuad="ease-in-out-quad",t.easeInOutQuart="ease-in-out-quart",t.easeInOutQuint="ease-in-out-quint",t.easeInOutExpo="ease-in-out-expo",t.easeInOutSine="ease-in-out-sine"})(nd||(nd={}));const pN=sbe();bd()||(window.tsParticles=pN);const obe=t=>{const e=t.id??"tsparticles";return x.useEffect(()=>{let n;return pN.load({id:e,url:t.url,options:t.options}).then(r=>{var i;n=r,(i=t.particlesLoaded)==null||i.call(t,r)}),()=>{n==null||n.destroy()}},[e,t,t.url,t.options]),c.jsx("div",{id:e,className:t.className})};async function abe(t){await t(pN)}const JC=.5,lbe=2,Mc=0,$h=1,aB=60,lB=0,cbe=.01,ube=Math.PI*lbe;function dbe(t){const e=t.initialPosition,{dx:n,dy:r}=Ts(e,t.position),i=Math.abs(n),s=Math.abs(r),{maxDistance:o}=t.retina,a=o.horizontal,l=o.vertical;if(!a&&!l)return;const u=(a&&i>=a)??!1,d=(l&&s>=l)??!1;if((u||d)&&!t.misplaced)t.misplaced=!!a&&i>a||!!l&&s>l,a&&(t.velocity.x=t.velocity.y*JC-t.velocity.x),l&&(t.velocity.y=t.velocity.x*JC-t.velocity.y);else if((!a||i<a)&&(!l||s<l)&&t.misplaced)t.misplaced=!1;else if(t.misplaced){const f=t.position,h=t.velocity;a&&(f.x<e.x&&h.x<Mc||f.x>e.x&&h.x>Mc)&&(h.x*=-Ar()),l&&(f.y<e.y&&h.y<Mc||f.y>e.y&&h.y>Mc)&&(h.y*=-Ar())}}function fbe(t,e,n,r,i,s){pbe(t,s);const o=t.gravity,a=o!=null&&o.enable&&o.inverse?-1:$h;i&&n&&(t.velocity.x+=i*s.factor/(aB*n)),o!=null&&o.enable&&n&&(t.velocity.y+=a*(o.acceleration*s.factor)/(aB*n));const l=t.moveDecay;t.velocity.multTo(l);const u=t.velocity.mult(n);o!=null&&o.enable&&r>Mc&&(!o.inverse&&u.y>=Mc&&u.y>=r||o.inverse&&u.y<=Mc&&u.y<=-r)&&(u.y=a*r,n&&(t.velocity.y=u.y/n));const d=t.options.zIndex,f=($h-t.zIndexFactor)**d.velocityRate;u.multTo(f);const{position:h}=t;h.addTo(u),e.vibrate&&(h.x+=Math.sin(h.x*Math.cos(h.y)),h.y+=Math.cos(h.y*Math.sin(h.x)))}function hbe(t,e){const n=t.container;if(!t.spin)return;const r=t.spin.direction===ha.clockwise,i={x:r?Math.cos:Math.sin,y:r?Math.sin:Math.cos};t.position.x=t.spin.center.x+t.spin.radius*i.x(t.spin.angle),t.position.y=t.spin.center.y+t.spin.radius*i.y(t.spin.angle),t.spin.radius+=t.spin.acceleration;const s=Math.max(n.canvas.size.width,n.canvas.size.height),o=s*JC;t.spin.radius>o?(t.spin.radius=o,t.spin.acceleration*=-1):t.spin.radius<lB&&(t.spin.radius=lB,t.spin.acceleration*=-1),t.spin.angle+=e*cbe*($h-t.spin.radius/s)}function pbe(t,e){var o;const n=t.options,r=n.move.path;if(!r.enable)return;if(t.lastPathTime<=t.pathDelay){t.lastPathTime+=e.value;return}const s=(o=t.pathGenerator)==null?void 0:o.generate(t,e);s&&t.velocity.addTo(s),r.clamp&&(t.velocity.x=Uo(t.velocity.x,-1,$h),t.velocity.y=Uo(t.velocity.y,-1,$h)),t.lastPathTime-=t.pathDelay}function mbe(t){return t.slow.inRange?t.slow.factor:$h}function gbe(t){const e=t.container,n=t.options,r=n.move.spin;if(!r.enable)return;const i=r.position??{x:50,y:50},s=.01,o={x:i.x*s*e.canvas.size.width,y:i.y*s*e.canvas.size.height},a=t.getPosition(),l=vo(a,o),u=vn(r.acceleration);t.retina.spinAcceleration=u*e.retina.pixelRatio,t.spin={center:o,direction:t.velocity.x>=Mc?ha.clockwise:ha.counterClockwise,angle:Ar()*ube,radius:l,acceleration:t.retina.spinAcceleration}}const bbe=2,ybe=1,vbe=1;class xbe{init(e){const n=e.options,r=n.move.gravity;e.gravity={enable:r.enable,acceleration:vn(r.acceleration),inverse:r.inverse},gbe(e)}isEnabled(e){return!e.destroyed&&e.options.move.enable}move(e,n){var g,w;const r=e.options,i=r.move;if(!i.enable)return;const s=e.container,o=s.retina.pixelRatio;(g=e.retina).moveSpeed??(g.moveSpeed=vn(i.speed)*o),(w=e.retina).moveDrift??(w.moveDrift=vn(e.options.move.drift)*o);const a=mbe(e),l=e.retina.moveSpeed*s.retina.reduceFactor,u=e.retina.moveDrift,d=Wa(r.size.value)*o,f=i.size?e.getRadius()/d:ybe,h=n.factor||vbe,m=l*f*a*h/bbe,y=e.retina.maxSpeed??s.retina.maxSpeed;i.spin.enable?hbe(e,m):fbe(e,i,m,y,u,n),dbe(e)}}async function wbe(t,e=!0){t.checkVersion("3.8.1"),await t.addMover("base",()=>Promise.resolve(new xbe),e)}const kbe=2,Sbe=Math.PI*kbe,Cbe=0,cB={x:0,y:0};function _be(t){const{context:e,particle:n,radius:r}=t;n.circleRange||(n.circleRange={min:Cbe,max:Sbe});const i=n.circleRange;e.arc(cB.x,cB.y,r,i.min,i.max,!1)}const Ebe=12,Nbe=360,uB=0;class Ibe{constructor(){this.validTypes=["circle"]}draw(e){_be(e)}getSidesCount(){return Ebe}particleInit(e,n){const r=n.shapeData,i=(r==null?void 0:r.angle)??{max:Nbe,min:uB};n.circleRange=Vf(i)?{min:Lc(i.min),max:Lc(i.max)}:{min:uB,max:Lc(i)}}}async function jbe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new Ibe,e)}class Tbe{constructor(e,n){this._container=e,this._engine=n}
vendor: 65,010 bytes, line 1044
1044init(e){const n=c0(this._engine,e.options.color,e.id,e.options.reduceDuplicates);n&&(e.color=PF(n,e.options.color.animation,this._container.retina.reduceFactor))}isEnabled(e){const{h:n,s:r,l:i}=e.options.color.animation,{color:s}=e;return!e.destroyed&&!e.spawning&&((s==null?void 0:s.h.value)!==void 0&&n.enable||(s==null?void 0:s.s.value)!==void 0&&r.enable||(s==null?void 0:s.l.value)!==void 0&&i.enable)}update(e,n){AF(e.color,n)}}async function zbe(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("color",n=>Promise.resolve(new Tbe(n,t)),e)}var Ru;(function(t){t[t.r=1]="r",t[t.g=2]="g",t[t.b=3]="b",t[t.a=4]="a"})(Ru||(Ru={}));const Pbe=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,Abe=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i,Db=16,Mbe=1,Bbe=255;class Rbe{constructor(){this.key="hex",this.stringPrefix="#"}handleColor(e){return this._parseString(e.value)}handleRangeColor(e){return this._parseString(e.value)}parseString(e){return this._parseString(e)}_parseString(e){if(typeof e!="string"||!(e!=null&&e.startsWith(this.stringPrefix)))return;const n=e.replace(Pbe,(i,s,o,a,l)=>s+s+o+o+a+a+(l!==void 0?l+l:"")),r=Abe.exec(n);return r?{a:r[Ru.a]!==void 0?parseInt(r[Ru.a],Db)/Bbe:Mbe,b:parseInt(r[Ru.b],Db),g:parseInt(r[Ru.g],Db),r:parseInt(r[Ru.r],Db)}:void 0}}async function Obe(t,e=!0){t.checkVersion("3.8.1"),await t.addColorManager(new Rbe,e)}var Hf;(function(t){t[t.h=1]="h",t[t.s=2]="s",t[t.l=3]="l",t[t.a=5]="a"})(Hf||(Hf={}));class Dbe{constructor(){this.key="hsl",this.stringPrefix="hsl"}handleColor(e){const n=e.value,r=n.hsl??e.value;if(r.h!==void 0&&r.s!==void 0&&r.l!==void 0)return Dh(r)}handleRangeColor(e){const n=e.value,r=n.hsl??e.value;if(r.h!==void 0&&r.l!==void 0)return Dh({h:vn(r.h),l:vn(r.l),s:vn(r.s)})}parseString(e){if(!e.startsWith("hsl"))return;const n=/hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i,r=n.exec(e),i=4,s=1,o=10;return r?H0e({a:r.length>i?wF(r[Hf.a]):s,h:parseInt(r[Hf.h],o),l:parseInt(r[Hf.l],o),s:parseInt(r[Hf.s],o)}):void 0}}async function Lbe(t,e=!0){t.checkVersion("3.8.1"),await t.addColorManager(new Dbe,e)}class Fbe{constructor(e){this.container=e}init(e){const n=e.options.opacity,r=1;e.opacity=EF(n,r);const i=n.animation;i.enable&&(e.opacity.velocity=vn(i.speed)/Ac*this.container.retina.reduceFactor,i.sync||(e.opacity.velocity*=Ar()))}isEnabled(e){return!e.destroyed&&!e.spawning&&!!e.opacity&&e.opacity.enable&&((e.opacity.maxLoops??0)<=0||(e.opacity.maxLoops??0)>0&&(e.opacity.loops??0)<(e.opacity.maxLoops??0))}reset(e){e.opacity&&(e.opacity.time=0,e.opacity.loops=0)}update(e,n){!this.isEnabled(e)||!e.opacity||cN(e,e.opacity,!0,e.options.opacity.animation.destroy,n)}}async function $be(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("opacity",n=>Promise.resolve(new Fbe(n)),e)}const Tv=0,oh=0;function Ube(t){if(t.outMode!==_i.bounce&&t.outMode!==_i.split||t.direction!==Zn.left&&t.direction!==Zn.right)return;t.bounds.right<oh&&t.direction===Zn.left?t.particle.position.x=t.size+t.offset.x:t.bounds.left>t.canvasSize.width&&t.direction===Zn.right&&(t.particle.position.x=t.canvasSize.width-t.size-t.offset.x);const e=t.particle.velocity.x;let n=!1;if(t.direction===Zn.right&&t.bounds.right>=t.canvasSize.width&&e>Tv||t.direction===Zn.left&&t.bounds.left<=oh&&e<Tv){const i=vn(t.particle.options.bounce.horizontal.value);t.particle.velocity.x*=-i,n=!0}if(!n)return;const r=t.offset.x+t.size;t.bounds.right>=t.canvasSize.width&&t.direction===Zn.right?t.particle.position.x=t.canvasSize.width-r:t.bounds.left<=oh&&t.direction===Zn.left&&(t.particle.position.x=r),t.outMode===_i.split&&t.particle.destroy()}function Vbe(t){if(t.outMode!==_i.bounce&&t.outMode!==_i.split||t.direction!==Zn.bottom&&t.direction!==Zn.top)return;t.bounds.bottom<oh&&t.direction===Zn.top?t.particle.position.y=t.size+t.offset.y:t.bounds.top>t.canvasSize.height&&t.direction===Zn.bottom&&(t.particle.position.y=t.canvasSize.height-t.size-t.offset.y);const e=t.particle.velocity.y;let n=!1;if(t.direction===Zn.bottom&&t.bounds.bottom>=t.canvasSize.height&&e>Tv||t.direction===Zn.top&&t.bounds.top<=oh&&e<Tv){const i=vn(t.particle.options.bounce.vertical.value);t.particle.velocity.y*=-i,n=!0}if(!n)return;const r=t.offset.y+t.size;t.bounds.bottom>=t.canvasSize.height&&t.direction===Zn.bottom?t.particle.position.y=t.canvasSize.height-r:t.bounds.top<=oh&&t.direction===Zn.top&&(t.particle.position.y=r),t.outMode===_i.split&&t.particle.destroy()}class Hbe{constructor(e){this.container=e,this.modes=[_i.bounce,_i.split]}update(e,n,r,i){if(!this.modes.includes(i))return;const s=this.container;let o=!1;for(const h of s.plugins.values())if(h.particleBounce!==void 0&&(o=h.particleBounce(e,r,n)),o)break;if(o)return;const a=e.getPosition(),l=e.offset,u=e.getRadius(),d=K0(a,u),f=s.canvas.size;Ube({particle:e,outMode:i,direction:n,bounds:d,canvasSize:f,offset:l,size:u}),Vbe({particle:e,outMode:i,direction:n,bounds:d,canvasSize:f,offset:l,size:u})}}const Lb=0;class Gbe{constructor(e){this.container=e,this.modes=[_i.destroy]}update(e,n,r,i){if(!this.modes.includes(i))return;const s=this.container;switch(e.outType){case wa.normal:case wa.outside:if(oN(e.position,s.canvas.size,Hi.origin,e.getRadius(),n))return;break;case wa.inside:{const{dx:o,dy:a}=Ts(e.position,e.moveCenter),{x:l,y:u}=e.velocity;if(l<Lb&&o>e.moveCenter.radius||u<Lb&&a>e.moveCenter.radius||l>=Lb&&o<-e.moveCenter.radius||u>=Lb&&a<-e.moveCenter.radius)return;break}}s.particles.remove(e,e.group,!0)}}const Fb=0;class Wbe{constructor(e){this.container=e,this.modes=[_i.none]}update(e,n,r,i){if(!this.modes.includes(i)||((e.options.move.distance.horizontal&&(n===Zn.left||n===Zn.right))??(e.options.move.distance.vertical&&(n===Zn.top||n===Zn.bottom))))return;const s=e.options.move.gravity,o=this.container,a=o.canvas.size,l=e.getRadius();if(s.enable){const u=e.position;(!s.inverse&&u.y>a.height+l&&n===Zn.bottom||s.inverse&&u.y<-l&&n===Zn.top)&&o.particles.remove(e)}else{if(e.velocity.y>Fb&&e.position.y<=a.height+l||e.velocity.y<Fb&&e.position.y>=-l||e.velocity.x>Fb&&e.position.x<=a.width+l||e.velocity.x<Fb&&e.position.x>=-l)return;oN(e.position,o.canvas.size,Hi.origin,l,n)||o.particles.remove(e)}}}const $b=0,Ub=0;class qbe{constructor(e){this.container=e,this.modes=[_i.out]}update(e,n,r,i){if(!this.modes.includes(i))return;const s=this.container;switch(e.outType){case wa.inside:{const{x:o,y:a}=e.velocity,l=Hi.origin;l.length=e.moveCenter.radius,l.angle=e.velocity.angle+Math.PI,l.addTo(Hi.create(e.moveCenter));const{dx:u,dy:d}=Ts(e.position,l);if(o<=$b&&u>=Ub||a<=$b&&d>=Ub||o>=$b&&u<=Ub||a>=$b&&d<=Ub)return;e.position.x=Math.floor(ho({min:0,max:s.canvas.size.width})),e.position.y=Math.floor(ho({min:0,max:s.canvas.size.height}));const{dx:f,dy:h}=Ts(e.position,e.moveCenter);e.direction=Math.atan2(-h,-f),e.velocity.angle=e.direction;break}default:{if(oN(e.position,s.canvas.size,Hi.origin,e.getRadius(),n))return;switch(e.outType){case wa.outside:{e.position.x=Math.floor(ho({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.x,e.position.y=Math.floor(ho({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.y;const{dx:o,dy:a}=Ts(e.position,e.moveCenter);e.moveCenter.radius&&(e.direction=Math.atan2(a,o),e.velocity.angle=e.direction);break}case wa.normal:{const o=e.options.move.warp,a=s.canvas.size,l={bottom:a.height+e.getRadius()+e.offset.y,left:-e.getRadius()-e.offset.x,right:a.width+e.getRadius()+e.offset.x,top:-e.getRadius()-e.offset.y},u=e.getRadius(),d=K0(e.position,u);n===Zn.right&&d.left>a.width+e.offset.x?(e.position.x=l.left,e.initialPosition.x=e.position.x,o||(e.position.y=Ar()*a.height,e.initialPosition.y=e.position.y)):n===Zn.left&&d.right<-e.offset.x&&(e.position.x=l.right,e.initialPosition.x=e.position.x,o||(e.position.y=Ar()*a.height,e.initialPosition.y=e.position.y)),n===Zn.bottom&&d.top>a.height+e.offset.y?(o||(e.position.x=Ar()*a.width,e.initialPosition.x=e.position.x),e.position.y=l.top,e.initialPosition.y=e.position.y):n===Zn.top&&d.bottom<-e.offset.y&&(o||(e.position.x=Ar()*a.width,e.initialPosition.x=e.position.x),e.position.y=l.bottom,e.initialPosition.y=e.position.y);break}}break}}}}const Kbe=(t,e)=>t.default===e||t.bottom===e||t.left===e||t.right===e||t.top===e;class Ybe{constructor(e){this._addUpdaterIfMissing=(n,r,i)=>{const s=n.options.move.outModes;!this.updaters.has(r)&&Kbe(s,r)&&this.updaters.set(r,i(this.container))},this._updateOutMode=(n,r,i,s)=>{for(const o of this.updaters.values())o.update(n,s,r,i)},this.container=e,this.updaters=new Map}init(e){this._addUpdaterIfMissing(e,_i.bounce,n=>new Hbe(n)),this._addUpdaterIfMissing(e,_i.out,n=>new qbe(n)),this._addUpdaterIfMissing(e,_i.destroy,n=>new Gbe(n)),this._addUpdaterIfMissing(e,_i.none,n=>new Wbe(n))}isEnabled(e){return!e.destroyed&&!e.spawning}update(e,n){const r=e.options.move.outModes;this._updateOutMode(e,n,r.bottom??r.default,Zn.bottom),this._updateOutMode(e,n,r.left??r.default,Zn.left),this._updateOutMode(e,n,r.right??r.default,Zn.right),this._updateOutMode(e,n,r.top??r.default,Zn.top)}}async function Xbe(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("outModes",n=>Promise.resolve(new Ybe(n)),e)}var Gf;(function(t){t[t.r=1]="r",t[t.g=2]="g",t[t.b=3]="b",t[t.a=5]="a"})(Gf||(Gf={}));class Qbe{constructor(){this.key="rgb",this.stringPrefix="rgb"}handleColor(e){const n=e.value,r=n.rgb??e.value;if(r.r!==void 0)return r}handleRangeColor(e){const n=e.value,r=n.rgb??e.value;if(r.r!==void 0)return{r:vn(r.r),g:vn(r.g),b:vn(r.b)}}parseString(e){if(!e.startsWith(this.stringPrefix))return;const n=/rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i,r=n.exec(e),i=10;return r?{a:r.length>4?wF(r[Gf.a]):1,b:parseInt(r[Gf.b],i),g:parseInt(r[Gf.g],i),r:parseInt(r[Gf.r],i)}:void 0}}async function Zbe(t,e=!0){t.checkVersion("3.8.1"),await t.addColorManager(new Qbe,e)}const xu=0;class Jbe{init(e){const n=e.container,r=e.options.size,i=r.animation;i.enable&&(e.size.velocity=(e.retina.sizeAnimationSpeed??n.retina.sizeAnimationSpeed)/Ac*n.retina.reduceFactor,i.sync||(e.size.velocity*=Ar()))}isEnabled(e){return!e.destroyed&&!e.spawning&&e.size.enable&&((e.size.maxLoops??xu)<=xu||(e.size.maxLoops??xu)>xu&&(e.size.loops??xu)<(e.size.maxLoops??xu))}reset(e){e.size.loops=xu}update(e,n){this.isEnabled(e)&&cN(e,e.size,!0,e.options.size.animation.destroy,n)}}async function eye(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("size",()=>Promise.resolve(new Jbe),e)}async function tye(t,e=!0){t.checkVersion("3.8.1"),await Obe(t,!1),await Lbe(t,!1),await Zbe(t,!1),await wbe(t,!1),await jbe(t,!1),await zbe(t,!1),await $be(t,!1),await Xbe(t,!1),await eye(t,!1),await t.refresh(e)}async function nye(t,e=!0){t.checkVersion("3.8.1"),await t.addEasing(nd.easeInQuad,n=>n**2,!1),await t.addEasing(nd.easeOutQuad,n=>1-(1-n)**2,!1),await t.addEasing(nd.easeInOutQuad,n=>n<.5?2*n**2:1-(-2*n+2)**2/2,!1),await t.refresh(e)}function rye(t,e){const{context:n,opacity:r}=t,i=.5,s=n.globalAlpha;if(!e)return;const o=e.width,a=o*i;n.globalAlpha=r,n.drawImage(e,-a,-a,o,o),n.globalAlpha=s}const p2='"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"',dB=0;class iye{constructor(){this.validTypes=["emoji"],this._emojiShapeDict=new Map}destroy(){for(const[e,n]of this._emojiShapeDict)n instanceof ImageBitmap&&(n==null||n.close()),this._emojiShapeDict.delete(e)}draw(e){const n=e.particle.emojiDataKey;if(!n)return;const r=this._emojiShapeDict.get(n);r&&rye(e,r)}async init(e){const n=e.actualOptions,{validTypes:r}=this;if(!r.find(o=>mi(o,n.particles.shape.type)))return;const i=[ZM(p2)],s=r.map(o=>n.particles.shape.options[o]).find(o=>!!o);s&&Go(s,o=>{o.font&&i.push(ZM(o.font))}),await Promise.all(i)}particleDestroy(e){e.emojiDataKey=void 0}particleInit(e,n){const i=n.shapeData;if(!(i!=null&&i.value))return;const s=ma(i.value,n.randomIndexData);if(!s)return;const o=typeof s=="string"?{font:i.font??p2,padding:i.padding??dB,value:s}:{font:p2,padding:dB,...i,...s},a=o.font,l=o.value,u=`${l}_${a}`;if(this._emojiShapeDict.has(u)){n.emojiDataKey=u;return}const d=o.padding*2,f=Wa(n.size.value),h=f+d,m=h*2;let y;if(typeof OffscreenCanvas<"u"){const g=new OffscreenCanvas(m,m),w=g.getContext("2d");if(!w)return;w.font=`400 ${f*2}px ${a}`,w.textBaseline="middle",w.textAlign="center",w.fillText(l,h,h),y=g.transferToImageBitmap()}else{const g=document.createElement("canvas");g.width=m,g.height=m;const w=g.getContext("2d");if(!w)return;w.font=`400 ${f*2}px ${a}`,w.textBaseline="middle",w.textAlign="center",w.fillText(l,h,h),y=g}this._emojiShapeDict.set(u,y),n.emojiDataKey=u}}async function sye(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new iye,e)}const oye=1,aye=1,FF=0;function $F(t,e,n,r,i,s){const o=e.actualOptions.interactivity.modes.attract;if(!o)return;const a=e.particles.quadTree.query(i,s);for(const l of a){const{dx:u,dy:d,distance:f}=Ts(l.position,n),h=o.speed*o.factor,m=Uo(t.getEasing(o.easing)(aye-f/r)*h,oye,o.maxSpeed),y=Hi.create(f?u/f*m:h,f?d/f*m:h);l.position.subFrom(y)}}function lye(t,e,n){e.attract||(e.attract={particles:[]});const{attract:r}=e;if(r.finish||(r.count||(r.count=0),r.count++,r.count===e.particles.count&&(r.finish=!0)),r.clicking){const i=e.interactivity.mouse.clickPosition,s=e.retina.attractModeDistance;if(!s||s<FF||!i)return;$F(t,e,i,s,new ms(i.x,i.y,s),o=>n(o))}else r.clicking===!1&&(r.particles=[])}function cye(t,e,n){const r=e.interactivity.mouse.position,i=e.retina.attractModeDistance;!i||i<FF||!r||$F(t,e,r,i,new ms(r.x,r.y,i),s=>n(s))}class uye{constructor(){this.distance=200,this.duration=.4,this.easing=nd.easeOutQuad,this.factor=1,this.maxSpeed=50,this.speed=1}load(e){Yt(e)||(e.distance!==void 0&&(this.distance=e.distance),e.duration!==void 0&&(this.duration=e.duration),e.easing!==void 0&&(this.easing=e.easing),e.factor!==void 0&&(this.factor=e.factor),e.maxSpeed!==void 0&&(this.maxSpeed=e.maxSpeed),e.speed!==void 0&&(this.speed=e.speed))}}const Hp="attract";let dye=class extends cl{constructor(e,n){super(n),this._engine=e,n.attract||(n.attract={particles:[]}),this.handleClickMode=r=>{const i=this.container.actualOptions,s=i.interactivity.modes.attract;if(!(!s||r!==Hp)){n.attract||(n.attract={particles:[]}),n.attract.clicking=!0,n.attract.count=0;for(const o of n.attract.particles)this.isEnabled(o)&&o.velocity.setTo(o.initialVelocity);n.attract.particles=[],n.attract.finish=!1,setTimeout(()=>{n.destroyed||(n.attract||(n.attract={particles:[]}),n.attract.clicking=!1)},s.duration*hs)}}}clear(){}init(){const e=this.container,n=e.actualOptions.interactivity.modes.attract;n&&(e.retina.attractModeDistance=n.distance*e.retina.pixelRatio)}interact(){const e=this.container,n=e.actualOptions,r=e.interactivity.status===pd,i=n.interactivity.events,{enable:s,mode:o}=i.onHover,{enable:a,mode:l}=i.onClick;r&&s&&mi(Hp,o)?cye(this._engine,this.container,u=>this.isEnabled(u)):a&&mi(Hp,l)&&lye(this._engine,this.container,u=>this.isEnabled(u))}isEnabled(e){const n=this.container,r=n.actualOptions,i=n.interactivity.mouse,s=((e==null?void 0:e.interactivity)??r.interactivity).events;if((!i.position||!s.onHover.enable)&&(!i.clickPosition||!s.onClick.enable))return!1;const o=s.onHover.mode,a=s.onClick.mode;return mi(Hp,o)||mi(Hp,a)}loadModeOptions(e,...n){e.attract||(e.attract=new uye);for(const r of n)e.attract.load(r==null?void 0:r.attract)}reset(){}};async function fye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalAttract",n=>Promise.resolve(new dye(t,n)),e)}const hye=2,Ny=.5,pye=Math.PI*Ny,fB=2,UF=10,mye=0;function VF(t,e,n,r,i){const s=t.particles.quadTree.query(r,i);for(const o of s)r instanceof ms?CF(XC(o),{position:e,mass:n**hye*pye,velocity:Hi.origin,factor:Hi.origin}):r instanceof Ca&&R0e(o,K0(e,n))}function gye(t,e,n,r){const i=document.querySelectorAll(e);i.length&&i.forEach(s=>{const o=s,a=t.retina.pixelRatio,l={x:(o.offsetLeft+o.offsetWidth*Ny)*a,y:(o.offsetTop+o.offsetHeight*Ny)*a},u=o.offsetWidth*Ny*a,d=UF*a,f=n.type===Lh.circle?new ms(l.x,l.y,u+d):new Ca(o.offsetLeft*a-d,o.offsetTop*a-d,o.offsetWidth*a+d*fB,o.offsetHeight*a+d*fB);r(l,u,f)})}function bye(t,e,n,r){lN(n,e,(i,s)=>gye(t,i,s,(o,a,l)=>VF(t,o,a,l,r)))}function yye(t,e){const n=t.retina.pixelRatio,r=UF*n,i=t.interactivity.mouse.position,s=t.retina.bounceModeDistance;!s||s<mye||!i||VF(t,i,s,new ms(i.x,i.y,s+r),e)}class vye{constructor(){this.distance=200}load(e){Yt(e)||e.distance!==void 0&&(this.distance=e.distance)}}const Vb="bounce";class xye extends cl{constructor(e){super(e)}clear(){}init(){const e=this.container,n=e.actualOptions.interactivity.modes.bounce;n&&(e.retina.bounceModeDistance=n.distance*e.retina.pixelRatio)}interact(){const e=this.container,n=e.actualOptions,r=n.interactivity.events,i=e.interactivity.status===pd,s=r.onHover.enable,o=r.onHover.mode,a=r.onDiv;i&&s&&mi(Vb,o)?yye(this.container,l=>this.isEnabled(l)):bye(this.container,a,Vb,l=>this.isEnabled(l))}isEnabled(e){const n=this.container,r=n.actualOptions,i=n.interactivity.mouse,s=((e==null?void 0:e.interactivity)??r.interactivity).events,o=s.onDiv;return!!i.position&&s.onHover.enable&&mi(Vb,s.onHover.mode)||aN(Vb,o)}loadModeOptions(e,...n){e.bounce||(e.bounce=new vye);for(const r of n)e.bounce.load(r==null?void 0:r.bounce)}reset(){}}async function wye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalBounce",n=>Promise.resolve(new xye(n)),e)}class HF{constructor(){this.distance=200,this.duration=.4,this.mix=!1}load(e){if(!Yt(e)){if(e.distance!==void 0&&(this.distance=e.distance),e.duration!==void 0&&(this.duration=e.duration),e.mix!==void 0&&(this.mix=e.mix),e.opacity!==void 0&&(this.opacity=e.opacity),e.color!==void 0){const n=ll(this.color)?void 0:this.color;this.color=Go(e.color,r=>gs.create(n,r))}e.size!==void 0&&(this.size=e.size)}}}class kye extends HF{constructor(){super(),this.selectors=[]}load(e){super.load(e),!Yt(e)&&e.selectors!==void 0&&(this.selectors=e.selectors)}}class Sye extends HF{load(e){super.load(e),!Yt(e)&&(this.divs=Go(e.divs,n=>{const r=new kye;return r.load(n),r}))}}var La;(function(t){t.color="color",t.opacity="opacity",t.size="size"})(La||(La={}));function hB(t,e,n,r){if(e>=n){const i=t+(e-n)*r;return Uo(i,t,e)}else if(e<n){const i=t-(n-e)*r;return Uo(i,e,t)}}const wu="bubble",m2=0,Cye=0,_ye=2,pB=1,mB=1,Eye=0,Nye=0,g2=.5,b2=1;class Iye extends cl{constructor(e,n){super(e),this._clickBubble=()=>{var d;const r=this.container,i=r.actualOptions,s=r.interactivity.mouse.clickPosition,o=i.interactivity.modes.bubble;if(!o||!s)return;r.bubble||(r.bubble={});const a=r.retina.bubbleModeDistance;if(!a||a<m2)return;const l=r.particles.quadTree.queryCircle(s,a,f=>this.isEnabled(f)),{bubble:u}=r;for(const f of l){if(!u.clicking)continue;f.bubble.inRange=!u.durationEnd;const h=f.getPosition(),m=vo(h,s),y=(new Date().getTime()-(r.interactivity.mouse.clickTime??Cye))/hs;y>o.duration&&(u.durationEnd=!0),y>o.duration*_ye&&(u.clicking=!1,u.durationEnd=!1);const g={bubbleObj:{optValue:r.retina.bubbleModeSize,value:f.bubble.radius},particlesObj:{optValue:Wa(f.options.size.value)*r.retina.pixelRatio,value:f.size.value},type:La.size};this._process(f,m,y,g);const w={bubbleObj:{optValue:o.opacity,value:f.bubble.opacity},particlesObj:{optValue:Wa(f.options.opacity.value),value:((d=f.opacity)==null?void 0:d.value)??pB},type:La.opacity};this._process(f,m,y,w),!u.durationEnd&&m<=a?this._hoverBubbleColor(f,m):delete f.bubble.color}},this._hoverBubble=()=>{const r=this.container,i=r.interactivity.mouse.position,s=r.retina.bubbleModeDistance;if(!s||s<m2||!i)return;const o=r.particles.quadTree.queryCircle(i,s,a=>this.isEnabled(a));for(const a of o){a.bubble.inRange=!0;const l=a.getPosition(),u=vo(l,i),d=mB-u/s;u<=s?d>=Nye&&r.interactivity.status===pd&&(this._hoverBubbleSize(a,d),this._hoverBubbleOpacity(a,d),this._hoverBubbleColor(a,d)):this.reset(a),r.interactivity.status===VC&&this.reset(a)}},this._hoverBubbleColor=(r,i,s)=>{const o=this.container.actualOptions,a=s??o.interactivity.modes.bubble;if(a){if(!r.bubble.finalColor){const l=a.color;if(!l)return;const u=ma(l);r.bubble.finalColor=c0(this._engine,u)}if(r.bubble.finalColor)if(a.mix){r.bubble.color=void 0;const l=r.getFillColor();r.bubble.color=l?jF(uN(l,r.bubble.finalColor,mB-i,i)):r.bubble.finalColor}else r.bubble.color=r.bubble.finalColor}},this._hoverBubbleOpacity=(r,i,s)=>{var h,m;const o=this.container,a=o.actualOptions,l=(s==null?void 0:s.opacity)??((h=a.interactivity.modes.bubble)==null?void 0:h.opacity);if(!l)return;const u=r.options.opacity.value,d=((m=r.opacity)==null?void 0:m.value)??pB,f=hB(d,l,Wa(u),i);f!==void 0&&(r.bubble.opacity=f)},this._hoverBubbleSize=(r,i,s)=>{const o=this.container,a=s!=null&&s.size?s.size*o.retina.pixelRatio:o.retina.bubbleModeSize;if(a===void 0)return;const l=Wa(r.options.size.value)*o.retina.pixelRatio,u=r.size.value,d=hB(u,a,l,i);d!==void 0&&(r.bubble.radius=d)},this._process=(r,i,s,o)=>{const a=this.container,l=o.bubbleObj.optValue,u=a.actualOptions,d=u.interactivity.modes.bubble;if(!d||l===void 0)return;const f=d.duration,h=a.retina.bubbleModeDistance,m=o.particlesObj.optValue,y=o.bubbleObj.value,g=o.particlesObj.value??Eye,w=o.type;if(!(!h||h<m2||l===m))if(a.bubble||(a.bubble={}),a.bubble.durationEnd)y&&(w===La.size&&delete r.bubble.radius,w===La.opacity&&delete r.bubble.opacity);else if(i<=h){if((y??g)!==l){const S=g-s*(g-l)/f;w===La.size&&(r.bubble.radius=S),w===La.opacity&&(r.bubble.opacity=S)}}else w===La.size&&delete r.bubble.radius,w===La.opacity&&delete r.bubble.opacity},this._singleSelectorHover=(r,i,s)=>{const o=this.container,a=document.querySelectorAll(i),l=o.actualOptions.interactivity.modes.bubble;!l||!a.length||a.forEach(u=>{const d=u,f=o.retina.pixelRatio,h={x:(d.offsetLeft+d.offsetWidth*g2)*f,y:(d.offsetTop+d.offsetHeight*g2)*f},m=d.offsetWidth*g2*f,y=s.type===Lh.circle?new ms(h.x,h.y,m):new Ca(d.offsetLeft*f,d.offsetTop*f,d.offsetWidth*f,d.offsetHeight*f),g=o.particles.quadTree.query(y,w=>this.isEnabled(w));for(const w of g){if(!y.contains(w.getPosition()))continue;w.bubble.inRange=!0;const v=l.divs,S=SF(v,d);(!w.bubble.div||w.bubble.div!==d)&&(this.clear(w,r,!0),w.bubble.div=d),this._hoverBubbleSize(w,b2,S),this._hoverBubbleOpacity(w,b2,S),this._hoverBubbleColor(w,b2,S)}})},this._engine=n,e.bubble||(e.bubble={}),this.handleClickMode=r=>{r===wu&&(e.bubble||(e.bubble={}),e.bubble.clicking=!0)}}clear(e,n,r){e.bubble.inRange&&!r||(delete e.bubble.div,delete e.bubble.opacity,delete e.bubble.radius,delete e.bubble.color)}init(){const e=this.container,n=e.actualOptions.interactivity.modes.bubble;n&&(e.retina.bubbleModeDistance=n.distance*e.retina.pixelRatio,n.size!==void 0&&(e.retina.bubbleModeSize=n.size*e.retina.pixelRatio))}interact(e){const n=this.container.actualOptions,r=n.interactivity.events,i=r.onHover,s=r.onClick,o=i.enable,a=i.mode,l=s.enable,u=s.mode,d=r.onDiv;o&&mi(wu,a)?this._hoverBubble():l&&mi(wu,u)?this._clickBubble():lN(wu,d,(f,h)=>this._singleSelectorHover(e,f,h))}isEnabled(e){const n=this.container,r=n.actualOptions,i=n.interactivity.mouse,s=((e==null?void 0:e.interactivity)??r.interactivity).events,{onClick:o,onDiv:a,onHover:l}=s,u=aN(wu,a);return u||l.enable&&i.position||o.enable&&i.clickPosition?mi(wu,l.mode)||mi(wu,o.mode)||u:!1}loadModeOptions(e,...n){e.bubble||(e.bubble=new Sye);for(const r of n)e.bubble.load(r==null?void 0:r.bubble)}reset(e){e.bubble.inRange=!1}}async function jye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalBubble",n=>Promise.resolve(new Iye(n,t)),e)}class Tye{constructor(){this.opacity=.5}load(e){Yt(e)||e.opacity!==void 0&&(this.opacity=e.opacity)}}class zye{constructor(){this.distance=80,this.links=new Tye,this.radius=60}load(e){Yt(e)||(e.distance!==void 0&&(this.distance=e.distance),this.links.load(e.links),e.radius!==void 0&&(this.radius=e.radius))}}const gB=0,bB=1,Pye=0;function Aye(t,e,n,r){const i=Math.floor(n.getRadius()/e.getRadius()),s=e.getFillColor(),o=n.getFillColor();if(!s||!o)return;const a=e.getPosition(),l=n.getPosition(),u=uN(s,o,e.getRadius(),n.getRadius()),d=t.createLinearGradient(a.x,a.y,l.x,l.y);return d.addColorStop(gB,u0(s,r)),d.addColorStop(Uo(i,gB,bB),Dl(u,r)),d.addColorStop(bB,u0(o,r)),d}function Mye(t,e,n,r,i){Nm(t,r,i),t.lineWidth=e,t.strokeStyle=n,t.stroke()}function Bye(t,e,n,r){const i=t.actualOptions,s=i.interactivity.modes.connect;if(s)return Aye(e,n,r,s.links.opacity)}function Rye(t,e,n){t.canvas.draw(r=>{const i=Bye(t,r,e,n);if(!i)return;const s=e.getPosition(),o=n.getPosition();Mye(r,e.retina.linksWidth??Pye,i,s,o)})}const Oye="connect",yB=0;class Dye extends cl{constructor(e){super(e)}clear(){}init(){const e=this.container,n=e.actualOptions.interactivity.modes.connect;n&&(e.retina.connectModeDistance=n.distance*e.retina.pixelRatio,e.retina.connectModeRadius=n.radius*e.retina.pixelRatio)}interact(){const e=this.container;if(e.actualOptions.interactivity.events.onHover.enable&&e.interactivity.status==="pointermove"){const r=e.interactivity.mouse.position,{connectModeDistance:i,connectModeRadius:s}=e.retina;if(!i||i<yB||!s||s<yB||!r)return;const o=Math.abs(s),a=e.particles.quadTree.queryCircle(r,o,l=>this.isEnabled(l));a.forEach((l,u)=>{const d=l.getPosition(),f=1;for(const h of a.slice(u+f)){const m=h.getPosition(),y=Math.abs(i),g=Math.abs(d.x-m.x),w=Math.abs(d.y-m.y);g<y&&w<y&&Rye(e,l,h)}})}}isEnabled(e){const n=this.container,r=n.interactivity.mouse,i=((e==null?void 0:e.interactivity)??n.actualOptions.interactivity).events;return i.onHover.enable&&r.position?mi(Oye,i.onHover.mode):!1}loadModeOptions(e,...n){e.connect||(e.connect=new zye);for(const r of n)e.connect.load(r==null?void 0:r.connect)}reset(){}}async function Lye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalConnect",n=>Promise.resolve(new Dye(n)),e)}class Fye{constructor(){this.blink=!1,this.consent=!1,this.opacity=1}load(e){Yt(e)||(e.blink!==void 0&&(this.blink=e.blink),e.color!==void 0&&(this.color=gs.create(this.color,e.color)),e.consent!==void 0&&(this.consent=e.consent),e.opacity!==void 0&&(this.opacity=e.opacity))}}class $ye{constructor(){this.distance=100,this.links=new Fye}load(e){Yt(e)||(e.distance!==void 0&&(this.distance=e.distance),this.links.load(e.links))}}const Uye=0;function Vye(t,e,n,r,i,s){Nm(t,n,r),t.strokeStyle=Dl(i,s),t.lineWidth=e,t.stroke()}function Hye(t,e,n,r,i){t.canvas.draw(s=>{const o=e.getPosition();Vye(s,e.retina.linksWidth??Uye,o,i,n,r)})}const Gye="grab",Wye=0,qye=0;class Kye extends cl{constructor(e,n){super(e),this._engine=n}clear(){}init(){const e=this.container,n=e.actualOptions.interactivity.modes.grab;n&&(e.retina.grabModeDistance=n.distance*e.retina.pixelRatio)}interact(){var a;const e=this.container,n=e.actualOptions,r=n.interactivity;if(!r.modes.grab||!r.events.onHover.enable||e.interactivity.status!==pd)return;const i=e.interactivity.mouse.position;if(!i)return;const s=e.retina.grabModeDistance;if(!s||s<Wye)return;const o=e.particles.quadTree.queryCircle(i,s,l=>this.isEnabled(l));for(const l of o){const u=l.getPosition(),d=vo(u,i);if(d>s)continue;const f=r.modes.grab.links,h=f.opacity,m=h-d*h/s;if(m<=qye)continue;const y=f.color??((a=l.options.links)==null?void 0:a.color);if(!e.particles.grabLineColor&&y){const w=r.modes.grab.links;e.particles.grabLineColor=zF(this._engine,y,w.blink,w.consent)}const g=ZC(l,void 0,e.particles.grabLineColor);g&&Hye(e,l,g,m,i)}}isEnabled(e){const n=this.container,r=n.interactivity.mouse,i=((e==null?void 0:e.interactivity)??n.actualOptions.interactivity).events;return i.onHover.enable&&!!r.position&&mi(Gye,i.onHover.mode)}loadModeOptions(e,...n){e.grab||(e.grab=new $ye);for(const r of n)e.grab.load(r==null?void 0:r.grab)}reset(){}}async function Yye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalGrab",n=>Promise.resolve(new Kye(n,t)),e)}const Xye="pause";class Qye extends cl{constructor(e){super(e),this.handleClickMode=n=>{if(n!==Xye)return;const r=this.container;r.animationStatus?r.pause():r.play()}}clear(){}init(){}interact(){}isEnabled(){return!0}reset(){}}async function Zye(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalPause",n=>Promise.resolve(new Qye(n)),e)}class Jye{constructor(){this.default=!0,this.groups=[],this.quantity=4}load(e){if(Yt(e))return;e.default!==void 0&&(this.default=e.default),e.groups!==void 0&&(this.groups=e.groups.map(r=>r)),this.groups.length||(this.default=!0);const n=e.quantity;n!==void 0&&(this.quantity=lr(n))}}const eve="push",tve=0;class nve extends cl{constructor(e){super(e),this.handleClickMode=n=>{if(n!==eve)return;const r=this.container,i=r.actualOptions,s=i.interactivity.modes.push;if(!s)return;const o=vn(s.quantity);if(o<=tve)return;const a=Fx([void 0,...s.groups]),l=a!==void 0?r.actualOptions.particles.groups[a]:void 0;r.particles.push(o,r.interactivity.mouse,l,a)}}clear(){}init(){}interact(){}isEnabled(){return!0}loadModeOptions(e,...n){e.push||(e.push=new Jye);for(const r of n)e.push.load(r==null?void 0:r.push)}reset(){}}async function rve(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalPush",n=>Promise.resolve(new nve(n)),e)}class ive{constructor(){this.quantity=2}load(e){if(Yt(e))return;const n=e.quantity;n!==void 0&&(this.quantity=lr(n))}}const sve="remove";class ove extends cl{constructor(e){super(e),this.handleClickMode=n=>{const r=this.container,i=r.actualOptions;if(!i.interactivity.modes.remove||n!==sve)return;const s=vn(i.interactivity.modes.remove.quantity);r.particles.removeQuantity(s)}}clear(){}init(){}interact(){}isEnabled(){return!0}loadModeOptions(e,...n){e.remove||(e.remove=new ive);for(const r of n)e.remove.load(r==null?void 0:r.remove)}reset(){}}async function ave(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalRemove",n=>Promise.resolve(new ove(n)),e)}class GF{constructor(){this.distance=200,this.duration=.4,this.factor=100,this.speed=1,this.maxSpeed=50,this.easing=nd.easeOutQuad}load(e){Yt(e)||(e.distance!==void 0&&(this.distance=e.distance),e.duration!==void 0&&(this.duration=e.duration),e.easing!==void 0&&(this.easing=e.easing),e.factor!==void 0&&(this.factor=e.factor),e.speed!==void 0&&(this.speed=e.speed),e.maxSpeed!==void 0&&(this.maxSpeed=e.maxSpeed))}}class lve extends GF{constructor(){super(),this.selectors=[]}load(e){super.load(e),!Yt(e)&&e.selectors!==void 0&&(this.selectors=e.selectors)}}class cve extends GF{load(e){super.load(e),!Yt(e)&&(this.divs=Go(e.divs,n=>{const r=new lve;return r.load(n),r}))}}const ku="repulse",uve=0,dve=6,fve=3,hve=2,pve=0,mve=0,gve=1,y2=.5;class bve extends cl{constructor(e,n){super(n),this._clickRepulse=()=>{const r=this.container,i=r.actualOptions.interactivity.modes.repulse;if(!i)return;const s=r.repulse??{particles:[]};if(s.finish||(s.count||(s.count=0),s.count++,s.count===r.particles.count&&(s.finish=!0)),s.clicking){const o=r.retina.repulseModeDistance;if(!o||o<uve)return;const a=Math.pow(o/dve,fve),l=r.interactivity.mouse.clickPosition;if(l===void 0)return;const u=new ms(l.x,l.y,a),d=r.particles.quadTree.query(u,f=>this.isEnabled(f));for(const f of d){const{dx:h,dy:m,distance:y}=Ts(l,f.position),g=y**hve,w=i.speed,v=-a*w/g;if(g<=a){s.particles.push(f);const S=Hi.create(h,m);S.length=v,f.velocity.setTo(S)}}}else if(s.clicking===!1){for(const o of s.particles)o.velocity.setTo(o.initialVelocity);s.particles=[]}},this._hoverRepulse=()=>{const r=this.container,i=r.interactivity.mouse.position,s=r.retina.repulseModeDistance;!s||s<pve||!i||this._processRepulse(i,s,new ms(i.x,i.y,s))},this._processRepulse=(r,i,s,o)=>{const a=this.container,l=a.particles.quadTree.query(s,w=>this.isEnabled(w)),u=a.actualOptions.interactivity.modes.repulse;if(!u)return;const{easing:d,speed:f,factor:h,maxSpeed:m}=u,y=this._engine.getEasing(d),g=((o==null?void 0:o.speed)??f)*h;for(const w of l){const{dx:v,dy:S,distance:C}=Ts(w.position,r),k=Uo(y(gve-C/i)*g,mve,m),N=Hi.create(C?v/C*k:g,C?S/C*k:g);w.position.addTo(N)}},this._singleSelectorRepulse=(r,i)=>{const s=this.container,o=s.actualOptions.interactivity.modes.repulse;if(!o)return;const a=document.querySelectorAll(r);a.length&&a.forEach(l=>{const u=l,d=s.retina.pixelRatio,f={x:(u.offsetLeft+u.offsetWidth*y2)*d,y:(u.offsetTop+u.offsetHeight*y2)*d},h=u.offsetWidth*y2*d,m=i.type===Lh.circle?new ms(f.x,f.y,h):new Ca(u.offsetLeft*d,u.offsetTop*d,u.offsetWidth*d,u.offsetHeight*d),y=o.divs,g=SF(y,u);this._processRepulse(f,h,m,g)})},this._engine=e,n.repulse||(n.repulse={particles:[]}),this.handleClickMode=r=>{const i=this.container.actualOptions,s=i.interactivity.modes.repulse;if(!s||r!==ku)return;n.repulse||(n.repulse={particles:[]});const o=n.repulse;o.clicking=!0,o.count=0;for(const a of n.repulse.particles)this.isEnabled(a)&&a.velocity.setTo(a.initialVelocity);o.particles=[],o.finish=!1,setTimeout(()=>{n.destroyed||(o.clicking=!1)},s.duration*hs)}}clear(){}init(){const e=this.container,n=e.actualOptions.interactivity.modes.repulse;n&&(e.retina.repulseModeDistance=n.distance*e.retina.pixelRatio)}interact(){const e=this.container,n=e.actualOptions,r=e.interactivity.status===pd,i=n.interactivity.events,s=i.onHover,o=s.enable,a=s.mode,l=i.onClick,u=l.enable,d=l.mode,f=i.onDiv;r&&o&&mi(ku,a)?this._hoverRepulse():u&&mi(ku,d)?this._clickRepulse():lN(ku,f,(h,m)=>this._singleSelectorRepulse(h,m))}isEnabled(e){const n=this.container,r=n.actualOptions,i=n.interactivity.mouse,s=((e==null?void 0:e.interactivity)??r.interactivity).events,o=s.onDiv,a=s.onHover,l=s.onClick,u=aN(ku,o);if(!(u||a.enable&&i.position||l.enable&&i.clickPosition))return!1;const d=a.mode,f=l.mode;return mi(ku,d)||mi(ku,f)||u}loadModeOptions(e,...n){e.repulse||(e.repulse=new cve);for(const r of n)e.repulse.load(r==null?void 0:r.repulse)}reset(){}}async function yve(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalRepulse",n=>Promise.resolve(new bve(t,n)),e)}class vve{constructor(){this.factor=3,this.radius=200}load(e){Yt(e)||(e.factor!==void 0&&(this.factor=e.factor),e.radius!==void 0&&(this.radius=e.radius))}}const xve="slow",wve=0;class kve extends cl{constructor(e){super(e)}clear(e,n,r){e.slow.inRange&&!r||(e.slow.factor=1)}init(){const e=this.container,n=e.actualOptions.interactivity.modes.slow;n&&(e.retina.slowModeRadius=n.radius*e.retina.pixelRatio)}interact(){}isEnabled(e){const n=this.container,r=n.interactivity.mouse,i=((e==null?void 0:e.interactivity)??n.actualOptions.interactivity).events;return i.onHover.enable&&!!r.position&&mi(xve,i.onHover.mode)}loadModeOptions(e,...n){e.slow||(e.slow=new vve);for(const r of n)e.slow.load(r==null?void 0:r.slow)}reset(e){e.slow.inRange=!1;const n=this.container,r=n.actualOptions,i=n.interactivity.mouse.position,s=n.retina.slowModeRadius,o=r.interactivity.modes.slow;if(!o||!s||s<wve||!i)return;const a=e.getPosition(),l=vo(i,a),u=l/s,d=o.factor,{slow:f}=e;l>s||(f.inRange=!0,f.factor=u/d)}}async function Sve(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("externalSlow",n=>Promise.resolve(new kve(n)),e)}const Cve=0,_ve=1,Eve=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;function Nve(t,e,n){const{svgData:r}=t;if(!r)return"";const i=u0(e,n);if(r.includes("fill"))return r.replace(Eve,()=>i);const s=r.indexOf(">");return`${r.substring(Cve,s)} fill="${i}"${r.substring(s)}`}async function $x(t){return new Promise(e=>{t.loading=!0;const n=new Image;t.element=n,n.addEventListener("load",()=>{t.loading=!1,e()}),n.addEventListener("error",()=>{t.element=void 0,t.error=!0,t.loading=!1,gd().error(`${$o} loading image: ${t.source}`),e()}),n.src=t.source})}async function Ive(t){if(t.type!=="svg"){await $x(t);return}t.loading=!0;const e=await fetch(t.source);e.ok?t.svgData=await e.text():(gd().error(`${$o} Image not found`),t.error=!0),t.loading=!1}function jve(t,e,n,r){var o;const i=Nve(t,n,((o=r.opacity)==null?void 0:o.value)??_ve),s={color:n,gif:e.gif,data:{...t,svgData:i},loaded:!1,ratio:e.width/e.height,replaceColor:e.replaceColor,source:e.src};return new Promise(a=>{const l=new Blob([i],{type:"image/svg+xml"}),u=URL||window.URL||window.webkitURL||window,d=u.createObjectURL(l),f=new Image;f.addEventListener("load",()=>{s.loaded=!0,s.element=f,a(s),u.revokeObjectURL(d)});const h=async()=>{u.revokeObjectURL(d);const m={...t,error:!1,loading:!0};await $x(m),s.loaded=!0,s.element=m.element,a(s)};f.addEventListener("error",()=>void h()),f.src=d})}const v2=[0,4,2,1],vB=[8,8,4,2];class Tve{constructor(e){this.pos=0,this.data=new Uint8ClampedArray(e)}getString(e){const n=this.data.slice(this.pos,this.pos+e);return this.pos+=n.length,n.reduce((r,i)=>r+String.fromCharCode(i),"")}nextByte(){return this.data[this.pos++]}nextTwoBytes(){return this.pos+=2,this.data[this.pos-2]+(this.data[this.pos-1]<<8)}readSubBlocks(){let e="",n=0;const r=0,i=0;do{n=this.data[this.pos++];for(let s=n;--s>=r;e+=String.fromCharCode(this.data[this.pos++]));}while(n!==i);return e}readSubBlocksBin(){let e=this.data[this.pos],n=0;const r=0,i=1;for(let o=0;e!==r;o+=e+i,e=this.data[this.pos+o])n+=e;const s=new Uint8Array(n);e=this.data[this.pos++];for(let o=0;e!==r;e=this.data[this.pos++])for(let a=e;--a>=r;s[o++]=this.data[this.pos++]);return s}skipSubBlocks(){for(const e=1,n=0;this.data[this.pos]!==n;this.pos+=this.data[this.pos]+e);this.pos++}}var sa;(function(t){t[t.Replace=0]="Replace",t[t.Combine=1]="Combine",t[t.RestoreBackground=2]="RestoreBackground",t[t.RestorePrevious=3]="RestorePrevious",t[t.UndefinedA=4]="UndefinedA",t[t.UndefinedB=5]="UndefinedB",t[t.UndefinedC=6]="UndefinedC",t[t.UndefinedD=7]="UndefinedD"})(sa||(sa={}));var Pl;(function(t){t[t.Extension=33]="Extension",t[t.ApplicationExtension=255]="ApplicationExtension",t[t.GraphicsControlExtension=249]="GraphicsControlExtension",t[t.PlainTextExtension=1]="PlainTextExtension",t[t.CommentExtension=254]="CommentExtension",t[t.Image=44]="Image",t[t.EndOfFile=59]="EndOfFile"})(Pl||(Pl={}));const Fs={x:0,y:0},zve=0,xB=.5,Pve=0,wB=0,e_=0;function WF(t,e){const n=[];for(let r=0;r<e;r++)n.push({r:t.data[t.pos],g:t.data[t.pos+1],b:t.data[t.pos+2]}),t.pos+=3;return n}function Ave(t,e,n,r){switch(t.nextByte()){case Pl.GraphicsControlExtension:{const i=e.frames[n(!1)];t.pos++;const s=t.nextByte();i.GCreserved=(s&224)>>>5,i.disposalMethod=(s&28)>>>2,i.userInputDelayFlag=(s&2)===2;const o=(s&1)===1;i.delayTime=t.nextTwoBytes()*10;const a=t.nextByte();o&&r(a),t.pos++;break}case Pl.ApplicationExtension:{t.pos++;const i={identifier:t.getString(8),authenticationCode:t.getString(3),data:t.readSubBlocksBin()};e.applicationExtensions.push(i);break}case Pl.CommentExtension:{e.comments.push([n(!1),t.readSubBlocks()]);break}case Pl.PlainTextExtension:{if(e.globalColorTable.length===0)throw new EvalError("plain text extension without global color table");t.pos++,e.frames[n(!1)].plainTextData={left:t.nextTwoBytes(),top:t.nextTwoBytes(),width:t.nextTwoBytes(),height:t.nextTwoBytes(),charSize:{width:t.nextTwoBytes(),height:t.nextTwoBytes()},foregroundColor:t.nextByte(),backgroundColor:t.nextByte(),text:t.readSubBlocks()};break}default:t.skipSubBlocks();break}}async function Mve(t,e,n,r,i,s){const o=e.frames[r(!0)];o.left=t.nextTwoBytes(),o.top=t.nextTwoBytes(),o.width=t.nextTwoBytes(),o.height=t.nextTwoBytes();const a=t.nextByte(),l=(a&128)===128,u=(a&64)===64;o.sortFlag=(a&32)===32,o.reserved=(a&24)>>>3;const d=1<<(a&7)+1;l&&(o.localColorTable=WF(t,d));const f=v=>{const{r:S,g:C,b:k}=(l?o.localColorTable:e.globalColorTable)[v];return v!==i(null)?{r:S,g:C,b:k,a:255}:{r:S,g:C,b:k,a:n?~~((S+C+k)/3):0}},h=(()=>{try{return new ImageData(o.width,o.height,{colorSpace:"srgb"})}catch(v){if(v instanceof DOMException&&v.name==="IndexSizeError")return null;throw v}})();if(h==null)throw new EvalError("GIF frame size is to large");const m=t.nextByte(),y=t.readSubBlocksBin(),g=1<<m,w=(v,S)=>{const C=v>>>3,k=v&7;return(y[C]+(y[C+1]<<8)+(y[C+2]<<16)&(1<<S)-1<<k)>>>k};if(u){for(let v=0,S=m+1,C=0,k=[[0]],N=0;N<4;N++)if(v2[N]<o.height){let _=0,j=0,T=!1;for(;!T;){const M=v;if(v=w(C,S),C+=S+1,v===g){S=m+1,k.length=g+2;for(let V=0;V<k.length;V++)k[V]=V<g?[V]:[]}else{v>=k.length?k.push(k[M].concat(k[M][0])):M!==g&&k.push(k[M].concat(k[v][0]));for(const V of k[v]){const{r:H,g:P,b:F,a:I}=f(V);h.data.set([H,P,F,I],v2[N]*o.width+vB[N]*j+_%(o.width*4)),_+=4}k.length===1<<S&&S<12&&S++}_===o.width*4*(j+1)&&(j++,v2[N]+vB[N]*j>=o.height&&(T=!0))}}o.image=h,o.bitmap=await createImageBitmap(h)}else{let v=0,S=m+1,C=0,k=-4,N=!1;const _=[[0]];for(;!N;){const j=v;if(v=w(C,S),C+=S,v===g){S=m+1,_.length=g+2;for(let T=0;T<_.length;T++)_[T]=T<g?[T]:[]}else{if(v===g+1){N=!0;break}v>=_.length?_.push(_[j].concat(_[j][0])):j!==g&&_.push(_[j].concat(_[v][0]));for(const T of _[v]){const{r:M,g:V,b:H,a:P}=f(T);h.data.set([M,V,H,P],k+=4)}_.length>=1<<S&&S<12&&S++}}o.image=h,o.bitmap=await createImageBitmap(h)}}async function Bve(t,e,n,r,i,s){switch(t.nextByte()){case Pl.EndOfFile:return!0;case Pl.Image:await Mve(t,e,n,r,i);break;case Pl.Extension:Ave(t,e,r,i);break;default:throw new EvalError("undefined block found")}return!1}function Rve(t){for(const e of t.applicationExtensions)if(e.identifier+e.authenticationCode==="NETSCAPE2.0")return e.data[1]+(e.data[2]<<8);return NaN}async function Ove(t,e,n){n||(n=!1);const r=await fetch(t);if(!r.ok&&r.status===404)throw new EvalError("file not found");const i=await r.arrayBuffer(),s={width:0,height:0,totalTime:0,colorRes:0,pixelAspectRatio:0,frames:[],sortFlag:!1,globalColorTable:[],backgroundImage:new ImageData(1,1,{colorSpace:"srgb"}),comments:[],applicationExtensions:[]},o=new Tve(new Uint8ClampedArray(i));if(o.getString(6)!=="GIF89a")throw new Error("not a supported GIF file");s.width=o.nextTwoBytes(),s.height=o.nextTwoBytes();const a=o.nextByte(),l=(a&128)===128;s.colorRes=(a&112)>>>4,s.sortFlag=(a&8)===8;const u=1<<(a&7)+1,d=o.nextByte();s.pixelAspectRatio=o.nextByte(),s.pixelAspectRatio!==0&&(s.pixelAspectRatio=(s.pixelAspectRatio+15)/64),l&&(s.globalColorTable=WF(o,u));const f=(()=>{try{return new ImageData(s.width,s.height,{colorSpace:"srgb"})}catch(k){if(k instanceof DOMException&&k.name==="IndexSizeError")return null;throw k}})();if(f==null)throw new Error("GIF frame size is to large");const{r:h,g:m,b:y}=s.globalColorTable[d];f.data.set(l?[h,m,y,255]:[0,0,0,0]);for(let k=4;k<f.data.length;k*=2)f.data.copyWithin(k,0,k);s.backgroundImage=f;let g=-1,w=!0,v=-1;const S=k=>(k&&(w=!0),g),C=k=>(k!=null&&(v=k),v);try{do w&&(s.frames.push({left:0,top:0,width:0,height:0,disposalMethod:sa.Replace,image:new ImageData(1,1,{colorSpace:"srgb"}),plainTextData:null,userInputDelayFlag:!1,delayTime:0,sortFlag:!1,localColorTable:[],reserved:0,GCreserved:0}),g++,v=-1,w=!1);while(!await Bve(o,s,n,S,C,e));s.frames.length--;for(const k of s.frames){if(k.userInputDelayFlag&&k.delayTime===0){s.totalTime=1/0;break}s.totalTime+=k.delayTime}return s}catch(k){throw k instanceof EvalError?new Error(`error while parsing frame ${g} "${k.message}"`):k}}function Dve(t){const{context:e,radius:n,particle:r,delta:i}=t,s=r.image;if(!(s!=null&&s.gifData)||!s.gif)return;const o=new OffscreenCanvas(s.gifData.width,s.gifData.height),a=o.getContext("2d");if(!a)throw new Error("could not create offscreen canvas context");a.imageSmoothingQuality="low",a.imageSmoothingEnabled=!1,a.clearRect(Fs.x,Fs.y,o.width,o.height),r.gifLoopCount===void 0&&(r.gifLoopCount=s.gifLoopCount??e_);let l=r.gifFrame??zve;const u={x:-s.gifData.width*xB,y:-s.gifData.height*xB},d=s.gifData.frames[l];if(r.gifTime===void 0&&(r.gifTime=Pve),!!d.bitmap){switch(e.scale(n/s.gifData.width,n/s.gifData.height),d.disposalMethod){case sa.UndefinedA:case sa.UndefinedB:case sa.UndefinedC:case sa.UndefinedD:case sa.Replace:a.drawImage(d.bitmap,d.left,d.top),e.drawImage(o,u.x,u.y),a.clearRect(Fs.x,Fs.y,o.width,o.height);break;case sa.Combine:a.drawImage(d.bitmap,d.left,d.top),e.drawImage(o,u.x,u.y);break;case sa.RestoreBackground:a.drawImage(d.bitmap,d.left,d.top),e.drawImage(o,u.x,u.y),a.clearRect(Fs.x,Fs.y,o.width,o.height),s.gifData.globalColorTable.length?a.putImageData(s.gifData.backgroundImage,u.x,u.y):a.putImageData(s.gifData.frames[wB].image,u.x+d.left,u.y+d.top);break;case sa.RestorePrevious:{const f=a.getImageData(Fs.x,Fs.y,o.width,o.height);a.drawImage(d.bitmap,d.left,d.top),e.drawImage(o,u.x,u.y),a.clearRect(Fs.x,Fs.y,o.width,o.height),a.putImageData(f,Fs.x,Fs.y)}break}if(r.gifTime+=i.value,r.gifTime>d.delayTime){if(r.gifTime-=d.delayTime,++l>=s.gifData.frames.length){if(--r.gifLoopCount<=e_)return;l=wB,a.clearRect(Fs.x,Fs.y,o.width,o.height)}r.gifFrame=l}e.scale(s.gifData.width/n,s.gifData.height/n)}}async function Lve(t){if(t.type!=="gif"){await $x(t);return}t.loading=!0;try{t.gifData=await Ove(t.source),t.gifLoopCount=Rve(t.gifData)??e_,t.gifLoopCount||(t.gifLoopCount=1/0)}catch{t.error=!0}t.loading=!1}const Fve=2,$ve=1,Uve=12,Vve=1;class Hve{constructor(e){this.validTypes=["image","images"],this.loadImageShape=async n=>{if(!this._engine.loadImage)throw new Error(`${$o} image shape not initialized`);await this._engine.loadImage({gif:n.gif,name:n.name,replaceColor:n.replaceColor??!1,src:n.src})},this._engine=e}addImage(e){this._engine.images||(this._engine.images=[]),this._engine.images.push(e)}draw(e){const{context:n,radius:r,particle:i,opacity:s}=e,o=i.image,a=o==null?void 0:o.element;if(o){if(n.globalAlpha=s,o.gif&&o.gifData)Dve(e);else if(a){const l=o.ratio,u={x:-r,y:-r},d=r*Fve;n.drawImage(a,u.x,u.y,d,d/l)}n.globalAlpha=$ve}}getSidesCount(){return Uve}async init(e){const n=e.actualOptions;if(!(!n.preload||!this._engine.loadImage))for(const r of n.preload)await this._engine.loadImage(r)}loadShape(e){if(e.shape!=="image"&&e.shape!=="images")return;this._engine.images||(this._engine.images=[]);const n=e.shapeData;if(!n)return;this._engine.images.find(i=>i.name===n.name||i.source===n.src)||this.loadImageShape(n).then(()=>{this.loadShape(e)})}particleInit(e,n){if(n.shape!=="image"&&n.shape!=="images")return;this._engine.images||(this._engine.images=[]);const r=this._engine.images,i=n.shapeData;if(!i)return;const s=n.getFillColor(),o=r.find(l=>l.name===i.name||l.source===i.src);if(!o)return;const a=i.replaceColor??o.replaceColor;if(o.loading){setTimeout(()=>{this.particleInit(e,n)});return}(async()=>{let l;o.svgData&&s?l=await jve(o,i,s,n):l={color:s,data:o,element:o.element,gif:o.gif,gifData:o.gifData,gifLoopCount:o.gifLoopCount,loaded:!0,ratio:i.width&&i.height?i.width/i.height:o.ratio??Vve,replaceColor:a,source:i.src},l.ratio||(l.ratio=1);const u=i.fill??n.shapeFill,d=i.close??n.shapeClose,f={image:l,fill:u,close:d};n.image=f.image,n.shapeFill=f.fill,n.shapeClose=f.close})()}}class Gve{constructor(){this.src="",this.gif=!1}load(e){Yt(e)||(e.gif!==void 0&&(this.gif=e.gif),e.height!==void 0&&(this.height=e.height),e.name!==void 0&&(this.name=e.name),e.replaceColor!==void 0&&(this.replaceColor=e.replaceColor),e.src!==void 0&&(this.src=e.src),e.width!==void 0&&(this.width=e.width))}}class Wve{constructor(e){this.id="imagePreloader",this._engine=e}async getPlugin(){return await Promise.resolve(),{}}loadOptions(e,n){if(!(n!=null&&n.preload))return;e.preload||(e.preload=[]);const r=e.preload;for(const i of n.preload){const s=r.find(o=>o.name===i.name||o.src===i.src);if(s)s.load(i);else{const o=new Gve;o.load(i),r.push(o)}}}needsPlugin(){return!0}}const qve=3;function Kve(t){t.loadImage||(t.loadImage=async e=>{if(!e.name&&!e.src)throw new Error(`${$o} no image source provided`);if(t.images||(t.images=[]),!t.images.find(n=>n.name===e.name||n.source===e.src))try{const n={gif:e.gif??!1,name:e.name??e.src,source:e.src,type:e.src.substring(e.src.length-qve),error:!1,loading:!0,replaceColor:e.replaceColor,ratio:e.width&&e.height?e.width/e.height:void 0};t.images.push(n);let r;e.gif?r=Lve:r=e.replaceColor?Ive:$x,await r(n)}catch{throw new Error(`${$o} ${e.name??e.src} not found`)}})}async function Yve(t,e=!0){t.checkVersion("3.8.1"),Kve(t);const n=new Wve(t);await t.addPlugin(n,e),await t.addShape(new Hve(t),e)}class Xve extends Ed{constructor(){super(),this.sync=!1}load(e){Yt(e)||(super.load(e),e.sync!==void 0&&(this.sync=e.sync))}}class Qve extends Ed{constructor(){super(),this.sync=!1}load(e){Yt(e)||(super.load(e),e.sync!==void 0&&(this.sync=e.sync))}}class Zve{constructor(){this.count=0,this.delay=new Xve,this.duration=new Qve}load(e){Yt(e)||(e.count!==void 0&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}const yf=0,Jve=-1,kB=0,SB=0;function exe(t,e,n){if(!t.life)return;const r=t.life;let i=!1;if(t.spawning)if(r.delayTime+=e.value,r.delayTime>=t.life.delay)i=!0,t.spawning=!1,r.delayTime=yf,r.time=yf;else return;if(r.duration===Jve||t.spawning||(i?r.time=yf:r.time+=e.value,r.time<r.duration))return;if(r.time=yf,t.life.count>kB&&t.life.count--,t.life.count===kB){t.destroy();return}const s=lr(SB,n.width),o=lr(SB,n.width);t.position.x=ho(s),t.position.y=ho(o),t.spawning=!0,r.delayTime=yf,r.time=yf,t.reset();const a=t.options.life;a&&(r.delay=vn(a.delay.value)*hs,r.duration=vn(a.duration.value)*hs)}const Su=0,CB=1,_B=-1;class txe{constructor(e){this.container=e}init(e){const n=this.container,r=e.options,i=r.life;i&&(e.life={delay:n.retina.reduceFactor?vn(i.delay.value)*(i.delay.sync?CB:Ar())/n.retina.reduceFactor*hs:Su,delayTime:Su,duration:n.retina.reduceFactor?vn(i.duration.value)*(i.duration.sync?CB:Ar())/n.retina.reduceFactor*hs:Su,time:Su,count:i.count},e.life.duration<=Su&&(e.life.duration=_B),e.life.count<=Su&&(e.life.count=_B),e.life&&(e.spawning=e.life.delay>Su))}isEnabled(e){return!e.destroyed}loadOptions(e,...n){e.life||(e.life=new Zve);for(const r of n)e.life.load(r==null?void 0:r.life)}update(e,n){!this.isEnabled(e)||!e.life||exe(e,n,this.container.canvas.size)}}async function nxe(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("life",async n=>Promise.resolve(new txe(n)),e)}function rxe(t){const{context:e,particle:n,radius:r}=t,i=n.shapeData,s=0;e.moveTo(-r,s),e.lineTo(r,s),e.lineCap=(i==null?void 0:i.cap)??"butt"}const ixe=1;class sxe{constructor(){this.validTypes=["line"]}draw(e){rxe(e)}getSidesCount(){return ixe}}async function oxe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new sxe,e)}const EB=.5;class axe{init(){}isEnabled(e){return!bd()&&!e.destroyed&&e.container.actualOptions.interactivity.events.onHover.parallax.enable}move(e){const n=e.container,r=n.actualOptions,i=r.interactivity.events.onHover.parallax;if(bd()||!i.enable)return;const s=i.force,o=n.interactivity.mouse.position;if(!o)return;const a=n.canvas.size,l={x:a.width*EB,y:a.height*EB},u=i.smooth,d=e.getRadius()/s,f={x:(o.x-l.x)*d,y:(o.y-l.y)*d},{offset:h}=e;h.x+=(f.x-h.x)/u,h.y+=(f.y-h.y)/u}}async function lxe(t,e=!0){t.checkVersion("3.8.1"),await t.addMover("parallax",()=>Promise.resolve(new axe),e)}const NB=1e3,cxe=1;class uxe extends hN{constructor(e){super(e)}clear(){}init(){}interact(e){const n=this.container;e.attractDistance===void 0&&(e.attractDistance=vn(e.options.move.attract.distance)*n.retina.pixelRatio);const r=e.attractDistance,i=e.getPosition(),s=n.particles.quadTree.queryCircle(i,r);for(const o of s){if(e===o||!o.options.move.attract.enable||o.destroyed||o.spawning)continue;const a=o.getPosition(),{dx:l,dy:u}=Ts(i,a),d=e.options.move.attract.rotate,f=l/(d.x*NB),h=u/(d.y*NB),m=o.size.value/e.size.value,y=cxe/m;e.velocity.x-=f*m,e.velocity.y-=h*m,o.velocity.x+=f*y,o.velocity.y+=h*y}}isEnabled(e){return e.options.move.attract.enable}reset(){}}async function dxe(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("particlesAttract",n=>Promise.resolve(new uxe(n)),e)}const fxe=.5,hxe=10,pxe=0;function IB(t,e,n,r,i,s){const o=Uo(t.options.collisions.absorb.speed*i.factor/hxe,pxe,r);t.size.value+=o*fxe,n.size.value-=o,r<=s&&(n.size.value=0,n.destroy())}function mxe(t,e,n,r){const i=t.getRadius(),s=e.getRadius();i===void 0&&s!==void 0?t.destroy():i!==void 0&&s===void 0?e.destroy():i!==void 0&&s!==void 0&&(i>=s?IB(t,i,e,s,n,r):IB(e,s,t,i,n,r))}const jB=t=>{t.collisionMaxSpeed===void 0&&(t.collisionMaxSpeed=vn(t.options.collisions.maxSpeed)),t.velocity.length>t.collisionMaxSpeed&&(t.velocity.length=t.collisionMaxSpeed)};function qF(t,e){CF(XC(t),XC(e)),jB(t),jB(e)}function gxe(t,e){!t.unbreakable&&!e.unbreakable&&qF(t,e),t.getRadius()===void 0&&e.getRadius()!==void 0?t.destroy():t.getRadius()!==void 0&&e.getRadius()===void 0?e.destroy():t.getRadius()!==void 0&&e.getRadius()!==void 0&&(t.getRadius()>=e.getRadius()?e:t).destroy()}function bxe(t,e,n,r){switch(t.options.collisions.mode){case ih.absorb:{mxe(t,e,n,r);break}case ih.bounce:{qF(t,e);break}case ih.destroy:{gxe(t,e);break}}}const yxe=2;class vxe extends hN{constructor(e){super(e)}clear(){}init(){}interact(e,n){if(e.destroyed||e.spawning)return;const r=this.container,i=e.getPosition(),s=e.getRadius(),o=r.particles.quadTree.queryCircle(i,s*yxe);for(const a of o){if(e===a||!a.options.collisions.enable||e.options.collisions.mode!==a.options.collisions.mode||a.destroyed||a.spawning)continue;const l=a.getPosition(),u=a.getRadius();if(Math.abs(Math.round(i.z)-Math.round(l.z))>s+u)continue;const d=vo(i,l),f=s+u;d>f||bxe(e,a,n,r.retina.pixelRatio)}}isEnabled(e){return e.options.collisions.enable}reset(){}}async function xxe(t,e=!0){t.checkVersion("3.8.1"),await t.addInteractor("particlesCollisions",n=>Promise.resolve(new vxe(n)),e)}const x2=2;class wxe extends ms{constructor(e,n,r,i){super(e,n,r),this.canvasSize=i,this.canvasSize={...i}}contains(e){const{width:n,height:r}=this.canvasSize,{x:i,y:s}=e;return super.contains(e)||super.contains({x:i-n,y:s})||super.contains({x:i-n,y:s-r})||super.contains({x:i,y:s-r})}intersects(e){if(super.intersects(e))return!0;const n=e,r=e,i={x:e.position.x-this.canvasSize.width,y:e.position.y-this.canvasSize.height};if(r.radius!==void 0){const s=new ms(i.x,i.y,r.radius*x2);return super.intersects(s)}else if(n.size!==void 0){const s=new Ca(i.x,i.y,n.size.width*x2,n.size.height*x2);return super.intersects(s)}return!1}}class kxe{constructor(){this.blur=5,this.color=new gs,this.color.value="#000",this.enable=!1}load(e){Yt(e)||(e.blur!==void 0&&(this.blur=e.blur),this.color=gs.create(this.color,e.color),e.enable!==void 0&&(this.enable=e.enable))}}class Sxe{constructor(){this.enable=!1,this.frequency=1}load(e){Yt(e)||(e.color!==void 0&&(this.color=gs.create(this.color,e.color)),e.enable!==void 0&&(this.enable=e.enable),e.frequency!==void 0&&(this.frequency=e.frequency),e.opacity!==void 0&&(this.opacity=e.opacity))}}class Cxe{constructor(){this.blink=!1,this.color=new gs,this.color.value="#fff",this.consent=!1,this.distance=100,this.enable=!1,this.frequency=1,this.opacity=1,this.shadow=new kxe,this.triangles=new Sxe,this.width=1,this.warp=!1}load(e){Yt(e)||(e.id!==void 0&&(this.id=e.id),e.blink!==void 0&&(this.blink=e.blink),this.color=gs.create(this.color,e.color),e.consent!==void 0&&(this.consent=e.consent),e.distance!==void 0&&(this.distance=e.distance),e.enable!==void 0&&(this.enable=e.enable),e.frequency!==void 0&&(this.frequency=e.frequency),e.opacity!==void 0&&(this.opacity=e.opacity),this.shadow.load(e.shadow),this.triangles.load(e.triangles),e.width!==void 0&&(this.width=e.width),e.warp!==void 0&&(this.warp=e.warp))}}const TB=2,_xe=1,Hb={x:0,y:0},Exe=0;function Nxe(t,e,n,r,i){const{dx:s,dy:o,distance:a}=Ts(t,e);if(!i||a<=n)return a;const l={x:Math.abs(s),y:Math.abs(o)},u={x:Math.min(l.x,r.width-l.x),y:Math.min(l.y,r.height-l.y)};return Math.sqrt(u.x**TB+u.y**TB)}class Ixe extends hN{constructor(e,n){super(e),this._setColor=r=>{if(!r.options.links)return;const i=this._linkContainer,s=r.options.links;let o=s.id===void 0?i.particles.linksColor:i.particles.linksColors.get(s.id);if(o)return;const a=s.color;o=zF(this._engine,a,s.blink,s.consent),s.id===void 0?i.particles.linksColor=o:i.particles.linksColors.set(s.id,o)},this._linkContainer=e,this._engine=n}clear(){}init(){this._linkContainer.particles.linksColor=void 0,this._linkContainer.particles.linksColors=new Map}interact(e){if(!e.options.links)return;e.links=[];const n=e.getPosition(),r=this.container,i=r.canvas.size;if(n.x<Hb.x||n.y<Hb.y||n.x>i.width||n.y>i.height)return;const s=e.options.links,o=s.opacity,a=e.retina.linksDistance??Exe,l=s.warp;let u;l?u=new wxe(n.x,n.y,a,i):u=new ms(n.x,n.y,a);const d=r.particles.quadTree.query(u);for(const f of d){const h=f.options.links;if(e===f||!(h!=null&&h.enable)||s.id!==h.id||f.spawning||f.destroyed||!f.links||e.links.some(w=>w.destination===f)||f.links.some(w=>w.destination===e))continue;const m=f.getPosition();if(m.x<Hb.x||m.y<Hb.y||m.x>i.width||m.y>i.height)continue;const y=Nxe(n,m,a,i,l&&h.warp);if(y>a)continue;const g=(_xe-y/a)*o;this._setColor(e),e.links.push({destination:f,opacity:g})}}isEnabled(e){var n;return!!((n=e.options.links)!=null&&n.enable)}loadParticlesOptions(e,...n){e.links||(e.links=new Cxe);for(const r of n)e.links.load(r==null?void 0:r.links)}reset(){}}async function jxe(t,e=!0){await t.addInteractor("particlesLinks",async n=>Promise.resolve(new Ixe(n,t)),e)}function Txe(t,e,n,r){t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(n.x,n.y),t.lineTo(r.x,r.y),t.closePath()}function zxe(t){let e=!1;const{begin:n,end:r,engine:i,maxDistance:s,context:o,canvasSize:a,width:l,backgroundMask:u,colorLine:d,opacity:f,links:h}=t;if(vo(n,r)<=s)Nm(o,n,r),e=!0;else if(h.warp){let y,g;const w={x:r.x-a.width,y:r.y},v=Ts(n,w);if(v.distance<=s){const S=n.y-v.dy/v.dx*n.x;y={x:0,y:S},g={x:a.width,y:S}}else{const S={x:r.x,y:r.y-a.height},C=Ts(n,S);if(C.distance<=s){const N=-(n.y-C.dy/C.dx*n.x)/(C.dy/C.dx);y={x:N,y:0},g={x:N,y:a.height}}else{const k={x:r.x-a.width,y:r.y-a.height},N=Ts(n,k);if(N.distance<=s){const _=n.y-N.dy/N.dx*n.x;y={x:-_/(N.dy/N.dx),y:_},g={x:y.x+a.width,y:y.y+a.height}}}}y&&g&&(Nm(o,n,y),Nm(o,r,g),e=!0)}if(!e)return;o.lineWidth=l,u.enable&&(o.globalCompositeOperation=u.composite),o.strokeStyle=Dl(d,f);const{shadow:m}=h;if(m.enable){const y=xa(i,m.color);y&&(o.shadowBlur=m.blur,o.shadowColor=Dl(y))}o.stroke()}function Pxe(t){const{context:e,pos1:n,pos2:r,pos3:i,backgroundMask:s,colorTriangle:o,opacityTriangle:a}=t;Txe(e,n,r,i),s.enable&&(e.globalCompositeOperation=s.composite),e.fillStyle=Dl(o,a),e.fill()}function Axe(t){return t.sort((e,n)=>e-n),t.join("_")}function zB(t,e){const n=Axe(t.map(i=>i.id));let r=e.get(n);return r===void 0&&(r=Ar(),e.set(n,r)),r}const PB=0,w2=0,AB=0,Mxe=.5,Bxe=1;class Rxe{constructor(e,n){this._drawLinkLine=(r,i)=>{const s=r.options.links;if(!(s!=null&&s.enable))return;const o=this._container,a=o.actualOptions,l=i.destination,u=r.getPosition(),d=l.getPosition();let f=i.opacity;o.canvas.draw(h=>{var S;let m;const y=(S=r.options.twinkle)==null?void 0:S.lines;if(y!=null&&y.enable){const C=y.frequency,k=xa(this._engine,y.color);Ar()<C&&k&&(m=k,f=vn(y.opacity))}if(!m){const C=s.id!==void 0?o.particles.linksColors.get(s.id):o.particles.linksColor;m=ZC(r,l,C)}if(!m)return;const g=r.retina.linksWidth??w2,w=r.retina.linksDistance??AB,{backgroundMask:v}=a;zxe({context:h,width:g,begin:u,end:d,engine:this._engine,maxDistance:w,canvasSize:o.canvas.size,links:s,backgroundMask:v,colorLine:m,opacity:f})})},this._drawLinkTriangle=(r,i,s)=>{const o=r.options.links;if(!(o!=null&&o.enable))return;const a=o.triangles;if(!a.enable)return;const l=this._container,u=l.actualOptions,d=i.destination,f=s.destination,h=a.opacity??(i.opacity+s.opacity)*Mxe;h<=PB||l.canvas.draw(m=>{const y=r.getPosition(),g=d.getPosition(),w=f.getPosition(),v=r.retina.linksDistance??AB;if(vo(y,g)>v||vo(w,g)>v||vo(w,y)>v)return;let S=xa(this._engine,a.color);if(!S){const C=o.id!==void 0?l.particles.linksColors.get(o.id):l.particles.linksColor;S=ZC(r,d,C)}S&&Pxe({context:m,pos1:y,pos2:g,pos3:w,backgroundMask:u.backgroundMask,colorTriangle:S,opacityTriangle:h})})},this._drawTriangles=(r,i,s,o)=>{var u,d,f;const a=s.destination;if(!((u=r.links)!=null&&u.triangles.enable&&((d=a.options.links)!=null&&d.triangles.enable)))return;const l=(f=a.links)==null?void 0:f.filter(h=>{const m=this._getLinkFrequency(a,h.destination);return a.options.links&&m<=a.options.links.frequency&&o.findIndex(g=>g.destination===h.destination)>=0});if(l!=null&&l.length)for(const h of l){const m=h.destination;this._getTriangleFrequency(i,a,m)>r.links.triangles.frequency||this._drawLinkTriangle(i,s,h)}},this._getLinkFrequency=(r,i)=>zB([r,i],this._freqs.links),this._getTriangleFrequency=(r,i,s)=>zB([r,i,s],this._freqs.triangles),this._container=e,this._engine=n,this._freqs={links:new Map,triangles:new Map}}drawParticle(e,n){const{links:r,options:i}=n;if(!(r!=null&&r.length))return;const s=r.filter(o=>i.links&&(i.links.frequency>=Bxe||this._getLinkFrequency(n,o.destination)<=i.links.frequency));for(const o of s)this._drawTriangles(i,n,o,s),o.opacity>PB&&(n.retina.linksWidth??w2)>w2&&this._drawLinkLine(n,o)}async init(){this._freqs.links=new Map,this._freqs.triangles=new Map,await Promise.resolve()}particleCreated(e){if(e.links=[],!e.options.links)return;const n=this._container.retina.pixelRatio,{retina:r}=e,{distance:i,width:s}=e.options.links;r.linksDistance=i*n,r.linksWidth=s*n}particleDestroyed(e){e.links=[]}}class Oxe{constructor(e){this.id="links",this._engine=e}getPlugin(e){return Promise.resolve(new Rxe(e,this._engine))}loadOptions(){}needsPlugin(){return!0}}async function Dxe(t,e=!0){const n=new Oxe(t);await t.addPlugin(n,e)}async function Lxe(t,e=!0){t.checkVersion("3.8.1"),await jxe(t,e),await Dxe(t,e)}const Fxe=180,Gb={x:0,y:0},$xe=2;function Uxe(t,e,n){const{context:r}=t,i=n.count.numerator*n.count.denominator,s=n.count.numerator/n.count.denominator,o=Fxe*(s-$xe)/s,a=Math.PI-Lc(o);if(r){r.beginPath(),r.translate(e.x,e.y),r.moveTo(Gb.x,Gb.y);for(let l=0;l<i;l++)r.lineTo(n.length,Gb.y),r.translate(n.length,Gb.y),r.rotate(a)}}const Vxe=5;class KF{draw(e){const{particle:n,radius:r}=e,i=this.getCenter(n,r),s=this.getSidesData(n,r);Uxe(e,i,s)}getSidesCount(e){const n=e.shapeData;return Math.round(vn((n==null?void 0:n.sides)??Vxe))}}const MB=3.5,BB=2.66,Hxe=3;class Gxe extends KF{constructor(){super(...arguments),this.validTypes=["polygon"]}getCenter(e,n){return{x:-n/(e.sides/MB),y:-n/(BB/MB)}}getSidesData(e,n){const r=e.sides;return{count:{denominator:1,numerator:r},length:n*BB/(r/Hxe)}}}const Wxe=1.66,qxe=3,Kxe=2;class Yxe extends KF{constructor(){super(...arguments),this.validTypes=["triangle"]}getCenter(e,n){return{x:-n,y:n/Wxe}}getSidesCount(){return qxe}getSidesData(e,n){const r=n*Kxe;return{count:{denominator:2,numerator:3},length:r}}}async function Xxe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new Gxe,e)}async function Qxe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new Yxe,e)}async function Zxe(t,e=!0){t.checkVersion("3.8.1"),await Xxe(t,e),await Qxe(t,e)}class Jxe{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(e){Yt(e)||(e.enable!==void 0&&(this.enable=e.enable),e.speed!==void 0&&(this.speed=lr(e.speed)),e.decay!==void 0&&(this.decay=lr(e.decay)),e.sync!==void 0&&(this.sync=e.sync))}}class ewe extends Ed{constructor(){super(),this.animation=new Jxe,this.direction=ha.clockwise,this.path=!1,this.value=0}load(e){Yt(e)||(super.load(e),e.direction!==void 0&&(this.direction=e.direction),this.animation.load(e.animation),e.path!==void 0&&(this.path=e.path))}}const YF=2,twe=Math.PI*YF,nwe=1,rwe=360;class iwe{constructor(e){this.container=e}init(e){const n=e.options.rotate;if(!n)return;e.rotate={enable:n.animation.enable,value:Lc(vn(n.value)),min:0,max:twe},e.pathRotation=n.path;let r=n.direction;switch(r===ha.random&&(r=Math.floor(Ar()*YF)>0?ha.counterClockwise:ha.clockwise),r){case ha.counterClockwise:case"counterClockwise":e.rotate.status=ki.decreasing;break;case ha.clockwise:e.rotate.status=ki.increasing;break}const i=n.animation;i.enable&&(e.rotate.decay=nwe-vn(i.decay),e.rotate.velocity=vn(i.speed)/rwe*this.container.retina.reduceFactor,i.sync||(e.rotate.velocity*=Ar())),e.rotation=e.rotate.value}isEnabled(e){const n=e.options.rotate;return n?!e.destroyed&&!e.spawning&&(!!n.value||n.animation.enable||n.path):!1}loadOptions(e,...n){e.rotate||(e.rotate=new ewe);for(const r of n)e.rotate.load(r==null?void 0:r.rotate)}update(e,n){this.isEnabled(e)&&(e.isRotating=!!e.rotate,e.rotate&&(cN(e,e.rotate,!1,md.none,n),e.rotation=e.rotate.value))}}async function swe(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("rotate",n=>Promise.resolve(new iwe(n)),e)}const owe=2,awe=Math.sqrt(owe),lwe=2;function cwe(t){const{context:e,radius:n}=t,r=n/awe,i=r*lwe;e.rect(-r,-r,i,i)}const uwe=4;class dwe{constructor(){this.validTypes=["edge","square"]}draw(e){cwe(e)}getSidesCount(){return uwe}}async function fwe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new dwe,e)}const hwe=2,vf={x:0,y:0};function pwe(t){const{context:e,particle:n,radius:r}=t,i=n.sides,s=n.starInset??hwe;e.moveTo(vf.x,vf.y-r);for(let o=0;o<i;o++)e.rotate(Math.PI/i),e.lineTo(vf.x,vf.y-r*s),e.rotate(Math.PI/i),e.lineTo(vf.x,vf.y-r)}const mwe=2,gwe=5;class bwe{constructor(){this.validTypes=["star"]}draw(e){pwe(e)}getSidesCount(e){const n=e.shapeData;return Math.round(vn((n==null?void 0:n.sides)??gwe))}particleInit(e,n){const r=n.shapeData;n.starInset=vn((r==null?void 0:r.inset)??mwe)}}async function ywe(t,e=!0){t.checkVersion("3.8.1"),await t.addShape(new bwe,e)}const vwe=1;class xwe{constructor(e,n){this._container=e,this._engine=n}
1044init(e){var o;const n=this._container,r=e.options,i=ma(r.stroke,e.id,r.reduceDuplicates);e.strokeWidth=vn(i.width)*n.retina.pixelRatio,e.strokeOpacity=vn(i.opacity??vwe),e.strokeAnimation=(o=i.color)==null?void 0:o.animation;const s=c0(this._engine,i.color)??e.getFillColor();s&&(e.strokeColor=PF(s,e.strokeAnimation,n.retina.reduceFactor))}isEnabled(e){const n=e.strokeAnimation,{strokeColor:r}=e;return!e.destroyed&&!e.spawning&&!!n&&((r==null?void 0:r.h.value)!==void 0&&r.h.enable||(r==null?void 0:r.s.value)!==void 0&&r.s.enable||(r==null?void 0:r.l.value)!==void 0&&r.l.enable)}update(e,n){this.isEnabled(e)&&AF(e.strokeColor,n)}}async function wwe(t,e=!0){t.checkVersion("3.8.1"),await t.addParticleUpdater("strokeColor",n=>Promise.resolve(new xwe(n,t)),e)}async function kwe(t,e=!0){t.checkVersion("3.8.1"),await lxe(t,!1),await fye(t,!1),await wye(t,!1),await jye(t,!1),await Lye(t,!1),await Yye(t,!1),await Zye(t,!1),await rve(t,!1),await ave(t,!1),await yve(t,!1),await Sve(t,!1),await dxe(t,!1),await xxe(t,!1),await Lxe(t,!1),await nye(t,!1),await sye(t,!1),await Yve(t,!1),await oxe(t,!1),await Zxe(t,!1),await fwe(t,!1),await ywe(t,!1),await nxe(t,!1),await swe(t,!1),await wwe(t,!1),await tye(t,e)}function Swe(t){const{id:e,className:n,background:r,minSize:i,maxSize:s,speed:o,particleColor:a,particleDensity:l}=t;x.useEffect(()=>{abe(async h=>{await kwe(h)})},[]);const u=cle(),d=async h=>{h&&u.start({opacity:1,transition:{duration:1}})},f=x.useId();return c.jsx(et.div,{animate:u,className:Cv("opacity-0",n),children:c.jsx(obe,{id:e||f,className:Cv("h-full w-full"),particlesLoaded:d,options:{background:{color:{value:r||"#0d47a1"}},fullScreen:{enable:!1,zIndex:1},fpsLimit:120,interactivity:{events:{onClick:{enable:!0,mode:"push"},onHover:{enable:!1,mode:"repulse"},resize:!0},modes:{push:{quantity:4},repulse:{distance:200,duration:.4}}},particles:{bounce:{horizontal:{value:1},vertical:{value:1}},collisions:{absorb:{speed:2},bounce:{horizontal:{value:1},vertical:{value:1}},enable:!1,maxSpeed:50,mode:"bounce",overlap:{enable:!0,retries:0}},color:{value:a||"#ffffff",animation:{h:{count:0,enable:!1,speed:1,decay:0,delay:0,sync:!0,offset:0},s:{count:0,enable:!1,speed:1,decay:0,delay:0,sync:!0,offset:0},l:{count:0,enable:!1,speed:1,decay:0,delay:0,sync:!0,offset:0}}},effect:{close:!0,fill:!0,options:{},type:{}},groups:{},move:{angle:{offset:0,value:90},attract:{distance:200,enable:!1,rotate:{x:3e3,y:3e3}},center:{x:50,y:50,mode:"percent",radius:0},decay:0,distance:{},direction:"none",drift:0,enable:!0,gravity:{acceleration:9.81,enable:!1,inverse:!1,maxSpeed:50},path:{clamp:!0,delay:{value:0},enable:!1,options:{}},outModes:{default:"out"},random:!1,size:!1,speed:{min:.1,max:1},spin:{acceleration:0,enable:!1},straight:!1,trail:{enable:!1,length:10,fill:{}},vibrate:!1,warp:!1},number:{density:{enable:!0,width:400,height:400},limit:{mode:"delete",value:0},value:l||120},opacity:{value:{min:.1,max:1},animation:{count:0,enable:!0,speed:o||4,decay:0,delay:0,sync:!1,mode:"auto",startValue:"random",destroy:"none"}},reduceDuplicates:!1,shadow:{blur:0,color:{value:"#000"},enable:!1,offset:{x:0,y:0}},shape:{close:!0,fill:!0,options:{},type:"circle"},size:{value:{min:i||1,max:s||3},animation:{count:0,enable:!1,speed:5,decay:0,delay:0,sync:!1,mode:"auto",startValue:"random",destroy:"none"}},stroke:{width:0},zIndex:{value:0,opacityRate:1,sizeRate:1,velocityRate:1},destroy:{bounds:{},mode:"none",split:{count:1,factor:{value:3},rate:{value:{min:4,max:9}},sizeOffset:!0}}
1044,roll:{darken:{enable:!1,value:0},enable:!1,enlighten:{enable:!1,value:0},mode:"vertical",speed:25},tilt:{value:0,animation:{enable:!1,speed:0,decay:0,sync:!1},direction:"clockwise",enable:!1},twinkle:{lines:{enable:!1,frequency:.05,opacity:1},particles:{enable:!1,frequency:.05,opacity:1}},wobble:{distance:5,enable:!1,speed:{angle:50,move:10}},life:{count:0,delay:{value:0,sync:!1},duration:{value:0,sync:!1}},rotate:{value:0,animation:{enable:!1,speed:0,decay:0,sync:!1},direction:"clockwise",path:!1},orbit:{animation:{count:0,enable:!1,speed:1,decay:0,delay:0,sync:!1},enable:!1,opacity:1,rotation:{value:45},width:1},links:{blink:!1,color:{value:"#fff"},consent:!1,distance:100,enable:!1,frequency:1,opacity:1,shadow:{blur:5,color:{value:"#000"},enable:!1},triangles:{enable:!1,frequency:1},width:1,warp:!1},repulse:{value:0,enabled:!1,distance:1,duration:1,factor:1,speed:1}},detectRetina:!0}})})}const Cwe=mr.memo(Swe),_we=({onClose:t})=>{const{isDarkMode:e}=Pn(),{caiSecondary:n}=oE(),[r,i]=x.useState(!1),{isMobile:s}=Hn(),{startDemo:o}=nN(),{setHasSeenTutorial:a}=il(),l=/iPad|iPhone|iPod/.test(navigator.userAgent),u=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),d=s&&l&&u,f=async()=>{a(!0),await o(),i(!0)},h=()=>{a(!0),t&&t()},m=()=>{t&&t()};return x.useEffect(()=>{const y=g=>{g.key==="Escape"&&h()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]),c.jsxs(et.div,{initial:{opacity:0}
1044,animate:{opacity:1},className:`fixed inset-0 ${e?"bg-black/30":"bg-white/30"} backdrop-blur-sm flex items-center justify-center overflow-hidden z-[70]`,children:[c.jsx("button",{onClick:h,className:`fixed top-4 right-4 z-[71] p-2 rounded-full transition-all duration-200 ${e?"text-zinc-400 hover:text-white hover:bg-red-600":"text-zinc-600 hover:text-white hover:bg-red-600"}`,"aria-label":"Close welcome screen (ESC)",title:"Close welcome screen (ESC)",children:c.jsx(nr,{size:20})}),c.jsxs("div",{className:"flex flex-col space-y-12 md:space-y-20 justify-center items-center text-center w-screen",children:[c.jsxs("div",{className:"relative w-screen h-60 md:h-96",children:[c.jsx("div",{className:"absolute inset-0 w-full h-full",children:c.jsx(Cwe,{background:"transparent",minSize:.4,maxSize:1,particleColor:n,particleDensity:s?150:100,className:"w-full h-full opacity-50",speed:.2})}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsx("div",{className:"text-cai-secondary",style:{fontFamily:"'Times New Roman', Times, serif"},children:s?c.jsxs("div",{className:"flex flex-col space-y-2 text-7xl",children:[c.jsx(r2,{text:"Welcome",triggerVanish:r,onVanishComplete:m,className:"drop-shadow-2xl",duration:.35}),c.jsx(r2,{text:"to Cai.",triggerVanish:r,className:"drop-shadow-2xl",duration:.35})]}):c.jsx("div",{className:"text-9xl",children:c.jsx(r2,{text:"Welcome to Cai.",triggerVanish:r,onVanishComplete:m,className:"drop-shadow-2xl",duration:.35})})})})]}),c.jsx("div",{className:"flex flex-col md:flex-row gap-4 md:gap-6 items-center justify-center",children:c.jsx("button",{className:`
1045 text-lg md:text-xl p-3 md:p-4 rounded-lg shadow-2xl 1046 hover:scale-105 transition-all duration-200 1047 bg-gradient-to-r from-caiGreen to-caiBlue 1048 bg-[length:200%_auto] animate-gradientMove 1049 min-w-[180px] md:min-w-[220px] min-h-[45px] md:min-h-[50px] z-20 1050 text-white font-semibold 1051 `,onClick:f,children:"Let's Get Started"})}),d&&c.jsx(et.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`px-6 py-3 rounded-xl backdrop-blur-sm border ${e?"bg-amber-900/20 border-amber-600/30 text-amber-200":"bg-amber-100/80 border-amber-300/50 text-amber-800"} shadow-lg max-w-sm mx-auto`,children:c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{className:"text-base",children:"ð"}),c.jsxs("p",{className:"leading-tight",children:[c.jsx("strong",{children:"iOS Tip:"})," Turn your ringer switch ON to hear audio playback!"]})]})})]})]})},Ewe=({step:t,currentIndex:e,totalSteps:n,onNext:r,onPrevious:i,onSkip:s,onEnd:o})=>{var m,y;const[a,l]=x.useState({x:0,y:0}),[u,d]=x.useState(!1),f=x.useRef(null),{isMobile:h}=Hn();return x.useEffect(()=>{if(t.targetSelector){const g=document.querySelector(t.targetSelector);if(g){const w=g.getBoundingClientRect(),v=h?window.innerWidth-32:400,S=300;let C=w.left+w.width/2-v/2,k=w.top;switch(t.position){case"bottom":k=w.bottom+10;break;case"top":k=w.top-S-10;break;case"left":C=w.left-v-10,k=w.top+w.height/2-S/2;break;case"right":C=w.right+10,k=w.top+w.height/2-S/2;break;default:k=w.bottom+10}return C=Math.max(10,Math.min(C,window.innerWidth-v-10)),k=Math.max(10,Math.min(k,window.innerHeight-S-10)),l({x:C,y:k}),d(!0),g.classList.add("demo-highlight"),()=>{g.classList.remove("demo-highlight")}}}else if(t.position==="center"){const g=h?window.innerWidth-32:400;l({x:window.innerWidth/2-g/2,y:window.innerHeight/2-150}),d(!0)}},[t.targetSelector,t.position,h]),x.useEffect(()=>{const g="demo-highlight-styles";let w=document.getElementById(g);return w||(w=document.createElement("style"),w.id=g,document.head.appendChild(w)),w.textContent=` 1052 .demo-highlight { 1053 position: relative !important; 1054 z-index: 59 !important; 1055 box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.5), 0 0 20px rgba(34, 197, 94, 0.3) !important; 1056 border-radius: 8px !important; 1057 } 1058 `,()=>{const v=document.getElementById(g);v&&v.remove()}},[]),u?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 bg-black/20 z-[60]"}),c.jsx(et.div,{ref:f,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:"fixed z-[61] bg-white dark:bg-zinc-800 rounded-xl shadow-2xl border border-zinc-200 dark:border-zinc-700",style:{left:a.x,top:a.y,width:h?"calc(100vw - 2rem)":"400px",maxWidth:h?"calc(100vw - 2rem)":"400px"},children:c.jsxs("div",{className:"p-6",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h3",{className:"font-semibold text-zinc-900 dark:text-zinc-100",children:t.title}),c.jsxs("span",{className:"text-xs text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-700 px-2 py-1 rounded",children:[e+1," of ",n]})]}),c.jsx("button",{onClick:o,className:"p-1 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded-lg transition-colors","aria-label":"Close demo",children:c.jsx(nr,{size:16,className:"text-zinc-500 dark:text-zinc-400"})})]}),c.jsx("div",{className:"text-zinc-700 dark:text-zinc-300 text-sm mb-6 whitespace-pre-line",children:t.content}),c.jsxs("div",{className:"mb-4",children:[c.jsxs("div",{className:"flex justify-between text-xs text-zinc-500 dark:text-zinc-400 mb-1",children:[c.jsx("span",{children:"Progress"}),c.jsxs("span",{children:[Math.round((e+1)/n*100),"%"]})]}),c.jsx("div",{className:"w-full bg-zinc-200 dark:bg-zinc-700 rounded-full h-1",children:c.jsx("div",{className:"bg-gradient-to-r from-caiGreen to-caiBlue h-1 rounded-full transition-all duration-300",style:{width:`${(e+1)/n*100}%`}})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[e>0&&c.jsxs("button",{onClick:i,className:"px-3 py-1.5 text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors flex items-center gap-1",children:[c.jsx(Sh,{size:14}),"Back"]}),c.jsxs("button",{onClick:s,className:"px-3 py-1.5 text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors flex items-center gap-1",children:[c.jsx(_D,{size:14}),"Skip Tour"]})]}),c.jsxs("div",{className:"flex gap-2",children:[((m=t.actions)==null?void 0:m.secondary)&&c.jsx("button",{onClick:t.actions.secondary.action,className:"px-3 py-1.5 text-sm border border-zinc-300 dark:border-zinc-600 rounded-lg hover:bg-zinc-50 dark:hover:bg-zinc-700 transition-colors",children:t.actions.secondary.text}),(y=t.actions)!=null&&y.primary?c.jsxs("button",{onClick:t.actions.primary.action,className:"px-3 py-1.5 text-sm bg-gradient-to-r from-caiGreen to-caiBlue text-white rounded-lg hover:from-caiGreen/90 hover:to-caiBlue/90 transition-all flex items-center gap-1",children:[t.actions.primary.text,t.actions.primary.text!=="Finish"&&c.jsx(pi,{size:14})]}):c.jsxs("button",{onClick:r,className:"px-3 py-1.5 text-sm bg-gradient-to-r from-caiGreen to-caiBlue text-white rounded-lg hover:from-caiGreen/90 hover:to-caiBlue/90 transition-all flex items-center gap-1",children:[e===n-1?"Finish":"Next",e!==n-1&&c.jsx(pi,{size:14})]})]})]})]})})]}):null},XF=()=>{const{isActive:t,currentStepIndex:e,totalSteps:n,getCurrentStep:r,nextStep:i,previousStep:s,endDemo:o}=nN(),a=r();return x.useEffect(()=>{a!=null&&a.beforeStep&&a.beforeStep()},[a]),x.useEffect(()=>()=>{a!=null&&a.afterStep&&a.afterStep()},[a]),!t||!a?null:c.jsx(Vn,{children:c.jsx(Ewe,{step:a,currentIndex:e,totalSteps:n,onNext:i,onPrevious:s,onSkip:o,onEnd:o})})},Nwe=({step:t,onComplete:e,onSkip:n,onEnd:r})=>{var v,S;const[i,s]=x.useState({x:0,y:0}
1058),[o,a]=x.useState(!1),[l,u]=x.useState(0),[d,f]=x.useState(null),h=x.useRef(null),m=x.useRef(null),{isMobile:y}=Hn(),g=x.useCallback(()=>({"Canvas Navigation":[{id:"basic",title:"Basic Controls",content:y?c.jsxs("ul",{className:"space-y-2 list-disc pl-5 text-sm",children:[c.jsx("li",{children:"Pinch to zoom in and out"}),c.jsx("li",{children:"Drag with one finger to pan"}),c.jsx("li",{children:"Tap to select items"}),c.jsx("li",{children:"Tap empty area to deselect"})]}):c.jsxs("ul",{className:"space-y-2 list-disc pl-5 text-sm",children:[c.jsx("li",{children:"Scroll wheel to zoom"}),c.jsx("li",{children:"Click and drag to pan"}),c.jsx("li",{children:"Click to select items"}),c.jsx("li",{children:"Press Space to play/pause"})]})},{id:"creation",title:"Creating Content",content:c.jsxs("ul",{className:"space-y-2 list-disc pl-5 text-sm",children:[c.jsxs("li",{children:["Double-",y?"tap":"click"," empty space to create a song"]}),c.jsxs("li",{children:["Double-",y?"tap":"click"," inside a song to add a track"]}),!y&&c.jsx("li",{children:"Use arrow keys to move selected items"})]})}]}),[y]);x.useEffect(()=>{var N,_;const k=g()[t.title];if(m.current){const j=m.current;j.style.visibility="hidden",j.style.position="absolute",j.style.top="-9999px",j.style.left="-9999px",j.style.display="block";const T=document.createElement("div");T.className="space-y-3 p-4";const M=document.createElement("div");M.className="flex items-center justify-between mb-3";const V=document.createElement("span");if(V.textContent=t.title,V.className="font-semibold text-zinc-900 dark:text-zinc-100",M.appendChild(V),T.appendChild(M),k&&k.length>1){const L=document.createElement("div");L.className="flex border-b border-zinc-200 dark:border-zinc-700 mb-3",k.forEach($=>{const q=document.createElement("button");q.className="px-3 py-2 text-sm font-medium",q.textContent=$.title,L.appendChild(q)}),T.appendChild(L)}const H=document.createElement("div");H.className="text-zinc-700 dark:text-zinc-300 text-sm mb-4";let P=80;k&&k.length>1&&(P=120),(t.title.includes("AI Chat Assistant")||t.title.includes("Transport Controls"))&&(P=140),H.style.minHeight=`${P}px`,H.innerHTML="<div>Sample content for measurement</div>",T.appendChild(H);const F=document.createElement("div");F.className="flex items-center justify-between";const I=document.createElement("button");I.textContent="Skip",I.className="px-3 py-1.5 text-sm";const R=document.createElement("button");R.textContent=((_=(N=t.actions)==null?void 0:N.primary)==null?void 0:_.text)||"Close",R.className="px-3 py-1.5 text-sm",F.appendChild(I),F.appendChild(R),T.appendChild(F),j.innerHTML="",j.appendChild(T);const U=j.getBoundingClientRect();j.style.display="none";const A=y?window.innerWidth-32:400,W=y?window.innerWidth-32:500,D=250,B=y?window.innerHeight-100:600;f({width:Math.min(Math.max(U.width+20,A),W),height:Math.min(Math.max(U.height+20,D),B)})}},[t.title,t.actions,y,g]),x.useEffect(()=>{if(t.targetSelector){const C=document.querySelector(t.targetSelector);if(C){const k=C.getBoundingClientRect();let N=k.left+k.width/2,_=k.top;if(d){const j=d.width,T=d.height;switch(t.position){case"bottom":_=k.bottom+10,N-=j/2;break;case"top":_=k.top-T-10,N-=j/2;break;case"left":N=k.left-j-10,_=k.top+k.height/2-T/2;break;case"right":N=k.right+10,_=k.top+k.height/2-T/2;break;default:_=k.bottom+10,N-=j/2}N=Math.max(10,Math.min(N,window.innerWidth-j-10)),_=Math.max(10,Math.min(_,window.innerHeight-T-10))}return s({x:N,y:_}),a(!0),C.classList.add("wizard-highlight"),()=>{C.classList.remove("wizard-highlight")}}}else{const C=(d==null?void 0:d.width)||(y?window.innerWidth-32:400),k=(d==null?void 0:d.height)||300;s({x:window.innerWidth/2-C/2,y:window.innerHeight/2-k/2}),a(!0)}},[t.targetSelector,t.position,d,y]),x.useEffect(()=>{const C="wizard-highlight-styles";let k=document.getElementById(C);return k||(k=document.createElement("style"),k.id=C,document.head.appendChild(k)),k.textContent=` 1059 .wizard-highlight { 1060 position: relative !important; 1061 z-index: 59 !important; 1062 box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 0 0 20px rgba(59, 130, 246, 0.3) !important; 1063 border-radius: 8px !important; 1064 } 1065 `,()=>{const N=document.getElementById(C);N&&N.remove()}},[]),x.useEffect(()=>{u(0)},[t.id]);const w=x.useCallback(C=>{const N=g()[t.title];return N&&N.length>1?c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"flex border-b border-zinc-200 dark:border-zinc-700",children:N.map((_,j)=>c.jsx("button",{onClick:()=>u(j),className:`px-3 py-2 text-sm font-medium transition-colors ${l===j?"text-cai-secondary border-b-2 border-cai-secondary":"text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300"}`,children:_.title},_.id))}),c.jsx(Vn,{mode:"wait",children:c.jsx(et.div,{initial:{opacity:0}
1065,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:N[l].content},l)})]}):N&&N.length===1?N[0].content:c.jsx("p",{children:C})},[g,t.title,l]);return o?c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:m,className:"fixed invisible pointer-events-none z-[-1]",style:{width:y?"calc(100vw - 2rem)":"32rem",maxWidth:y?"calc(100vw - 2rem)":"32rem"}}),c.jsx("div",{className:"fixed inset-0 bg-black/20 z-[60]"}),c.jsx(et.div,{ref:h,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:"fixed z-[61] bg-white dark:bg-zinc-800 rounded-xl shadow-2xl border border-zinc-200 dark:border-zinc-700",style:{left:i.x,top:i.y,width:(d==null?void 0:d.width)||(y?"calc(100vw - 2rem)":"400px"),height:(d==null?void 0:d.height)||"300px",maxWidth:y?"calc(100vw - 2rem)":"32rem"},children:c.jsxs("div",{className:"p-4 h-full flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[c.jsx("h3",{className:"font-semibold text-zinc-900 dark:text-zinc-100",children:t.title}),c.jsx("button",{onClick:r,className:"p-1 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded-lg transition-colors","aria-label":"Close tutorial",children:c.jsx(nr,{size:16,className:"text-zinc-500 dark:text-zinc-400"})})]}),c.jsx("div",{className:"text-zinc-700 dark:text-zinc-300 text-sm flex-grow overflow-auto",children:w(t.content)}),c.jsxs("div",{className:"flex items-center justify-between flex-shrink-0 mt-4",children:[c.jsx("div",{className:"flex gap-2 mt-4",children:t.allowSkip&&c.jsxs("button",{onClick:n,className:"px-3 py-1.5 text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors flex items-center gap-1",children:[c.jsx(_D,{size:14}),"Skip"]})}),c.jsxs("div",{className:"flex gap-2",children:[((v=t.actions)==null?void 0:v.secondary)&&c.jsx("button",{onClick:t.actions.secondary.action,className:"px-3 py-1.5 text-sm border border-zinc-300 dark:border-zinc-600 rounded-lg hover:bg-zinc-50 dark:hover:bg-zinc-700 transition-colors",children:t.actions.secondary.text}),(S=t.actions)!=null&&S.primary?c.jsxs("button",{onClick:t.actions.primary.action,className:"px-3 py-1.5 text-sm bg-gradient-to-r from-caiGreen to-caiBlue text-white rounded-lg hover:from-caiGreen/90 hover:to-caiBlue/90 transition-all flex items-center gap-1",children:[t.actions.primary.text,t.actions.primary.text!=="Close"&&c.jsx(pi,{size:14})]}):c.jsx("button",{onClick:e,className:"px-3 py-1.5 text-sm bg-gradient-to-r from-caiGreen to-caiBlue text-white rounded-lg hover:from-caiGreen/90 hover:to-caiBlue/90 transition-all flex items-center gap-1",children:"Close"})]})]})]})})]}):null},Iwe=()=>{const{currentStep:t,completeStep:e,skipStep:n,endWizard:r,getStepData:i}=GL();if(t===tn.WELCOME)return c.jsx(_we,{onClose:()=>e()});const s=t?i(t):null;return c.jsxs(c.Fragment,{children:[s&&c.jsx(Vn,{children:c.jsx(Nwe,{step:s,onComplete:()=>e(),onSkip:n,onEnd:r})}),c.jsx(XF,{})]})},jwe="_floatingControls_1p4re_14",Twe="_visible_1p4re_28",zwe="_floatingButton_1p4re_35",Pwe="_usageButton_1p4re_62",Awe="_warning_1p4re_69",Mwe="_critical_1p4re_78",Bwe="_inFlightButton_1p4re_87",Rwe="_cancelButton_1p4re_130",Owe="_generatingRandomQuery_1p4re_179",Dwe="_promptContainer_1p4re_463",Lwe="_promptContainerStatic_1p4re_464",Fwe="_chatMinimizedContainer_1p4re_548",$we="_chatMinimizedPrimary_1p4re_557",Uwe="_promptInputContainer_1p4re_561",Vwe="_promptInput_1p4re_561",Hwe="_expandablePromptInput_1p4re_604",Gwe="_defaultState_1p4re_657",fr={floatingControls:jwe,visible:Twe,floatingButton:zwe,usageButton:Pwe,warning:Awe,critical:Mwe,inFlightButton:Bwe,cancelButton:Rwe,generatingRandomQuery:Owe,promptContainer:Dwe,promptContainerStatic:Lwe,chatMinimizedContainer:Fwe,chatMinimizedPrimary:$we,promptInputContainer:Uwe,promptInput:Vwe,expandablePromptInput:Hwe,defaultState:Gwe},RB=["Give me","Can I get","I want","Let me get","I'm feeling in the mood for","Start me off with"],OB=["rock","pop","jazz","blues","country","hip-hop","electronic","classical","folk","metal","punk","reggae","soul"],DB=["a fire","an award-winning","an epic","a legendary","a crazy","a unique","a simple","an indescribable","an otherworldly"],LB=["that feels like a heartbreak","that I can workout out to","that I can dance to","that reminds me of my childhood","that sounds really happy","that sounds super fast and energetic","that evokes feelings of nostalgia","that transports me to a beach in Ibiza"],Wwe=()=>{const t=RB[Math.floor(Math.random()*RB.length)],e=OB[Math.floor(Math.random()*OB.length)],n=DB[Math.floor(Math.random()*DB.length)],r=LB[Math.floor(Math.random()*LB.length)],i=Math.floor(Math.random()*3)+1;let s,o;
1065if(i===1){const u=Object.keys(Sn).filter(f=>!f.toLowerCase().includes("drums")&&!f.toLowerCase().includes("effects")),d=xf(u[Math.floor(Math.random()*u.length)]);o=`${t} ${n} ${e} ${d}`}else if(i===2){const u=Object.keys(Sn).filter(g=>!g.toLowerCase().includes("drums")&&!g.toLowerCase().includes("effects")),d=u[Math.floor(Math.random()*u.length)],f=xf(d),h=u.filter(g=>g!==d),m=h[Math.floor(Math.random()*h.length)],y=xf(m);o=`${t} ${n} ${e} ${f} and ${y}`}else if(i===3){const u=Object.keys(Sn).filter(S=>!S.toLowerCase().includes("drums")&&!S.toLowerCase().includes("effects")),d=u[Math.floor(Math.random()*u.length)],f=xf(d),h=u.filter(S=>S!==d),m=h[Math.floor(Math.random()*h.length)],y=xf(m),g=h.filter(S=>S!==m),w=g[Math.floor(Math.random()*g.length)],v=xf(w);o=`${t} ${n} ${e} ${f}, ${y}, and ${v}`}s=`${o} ${r}`;const a=Math.random()<.9,l=Math.random()<.1;return a&&(s+=" with some drums"),l&&(s+=" and even add a sound effect"),s},xf=t=>t==null||typeof t!="string"?"instrument":t.toLowerCase().includes("synth")?"synth":t.toLowerCase().includes("strings")?"a string instrument ":t,ta=30,qwe=1,Kwe=3.5,k2=.5,Ywe=80,Cu=15,Xwe=.6,Qwe=.65,S2=.6,FB=.4,Zwe=1.5,zv=({minimized:t,isRecording:e=!0,animate:n=!1})=>{const r=x.useRef(null),i=x.useRef([]),{getCurrentAudioContext:s}=es(),o=x.useRef(null),a=x.useRef(null),l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),f=x.useRef(null),h=x.useRef(!1),m=x.useRef([]),y=x.useRef(0),g=x.useRef(!1),w=x.useRef(0),v=x.useCallback((N,_)=>{const j=N.match(/\d+/g);if(!j||j.length!==3)return N;const T=parseInt(j[0]),M=parseInt(j[1]),V=parseInt(j[2]),H=1+_*(Zwe-1),P=Math.min(255,Math.round(T*H)),F=Math.min(255,Math.round(M*H)),I=Math.min(255,Math.round(V*H));return`rgb(${P}, ${F}, ${I})`},[]),S=x.useCallback((N,_)=>{var A,W,D;const j=Si.caiPeach.DEFAULT,T=Si.caiBlue.DEFAULT,M=Si.caiGreen.DEFAULT,V=((A=j.match(/\d+/g))==null?void 0:A.map(Number))||[248,194,145],H=((W=T.match(/\d+/g))==null?void 0:W.map(Number))||[107,136,204],P=((D=M.match(/\d+/g))==null?void 0:D.map(Number))||[125,195,131],F=N/(_-1);let I,R,U;if(F<=.5){const B=F*2;I=Math.round(V[0]+(H[0]-V[0])*B),R=Math.round(V[1]+(H[1]-V[1])*B),U=Math.round(V[2]+(H[2]-V[2])*B)}else{const B=(F-.5)*2;I=Math.round(H[0]+(P[0]-H[0])*B),R=Math.round(H[1]+(P[1]-H[1])*B),U=Math.round(H[2]+(P[2]-H[2])*B)}return`rgb(${I}, ${R}, ${U})`},[]),C=x.useCallback(()=>{if(!h.current||!i.current.length)return;if(m.current.length===0&&(m.current=Array(ta).fill(Cu)),g.current){y.current+=.02,w.current=Math.min(1,w.current+.01);const j=50;for(let T=0;T<i.current.length;T++){const M=T/ta*Math.PI*2,V=y.current*.5,H=Math.sin(M+V),P=j,F=m.current[T]||j,I=F+(P-F)*S2;if(m.current[T]=I,i.current[T]){const R=S(T,ta),U=Math.abs(H)*.3,A=v(R,U);i.current[T].style.height=`${I}%`,i.current[T].style.backgroundColor=A,i.current[T].style.boxShadow=`0 0 4px ${A}`}}f.current=requestAnimationFrame(C);return}if(!a.current||!l.current)return;l.current&&a.current.getByteFrequencyData(l.current);const N=l.current,_=N.reduce((j,T)=>j+T,0)/N.length;if(_>qwe){const j=Math.floor(N.length*.1),T=Math.floor(N.length*.7),M=N.slice(j,T),V=M.length;for(let H=0;H<Math.min(ta,i.current.length);H++){const P=Math.floor(H/ta*V),F=Math.floor(V/ta),I=Math.min(P+F,V);let R=0,U=0;for(let Y=P;Y<I;Y++)R+=M[Y],U++;const A=R/U,W=ta/2,D=Math.abs(H-W)/W,B=D<k2?1:Math.pow(1-(D-k2)/(1-k2),2),L=1+Kwe*B;let $=A/255*(.4+.6*L);if(D<.7){const Y=_/255*(1-D)*Xwe;$+=Y}const q=Math.pow(Math.min($,1),Qwe),ie=Cu+q*(Ywe-Cu),ge=m.current[H]||Cu,re=ge+(ie-ge)*S2;if(m.current[H]=re,i.current[H]){const Y=S(H,ta),ne=v(Y,q);i.current[H].style.height=`${re}%`,i.current[H].style.backgroundColor=ne,i.current[H].style.boxShadow=`0 0 4px ${ne}`}}}else for(let j=0;j<i.current.length;j++){const T=m.current[j]||Cu,M=T+(Cu-T)*S2;if(m.current[j]=M,i.current[j]){const V=S(j,ta),H=v(V,0);i.current[j].style.height=`${M}%`,i.current[j].style.backgroundColor=H,i.current[j].style.boxShadow=`0 0 4px ${H}`}}f.current=requestAnimationFrame(C)},[v,S]);x.useEffect(()=>{if(!r.current)return;if(r.current.innerHTML="",i.current=Array(ta).fill(0).map((_,j)=>{var V;const T=document.createElement("div"),M=S(j,ta);return Object.assign(T.style,{backgroundColor:M,width:t?"1.5px":"2px",margin:"0 1px",height:`${Cu}%`,borderRadius:"1px",transition:"height 0.05s ease-out, background-color 0.05s ease-out",boxShadow:`0 0 4px ${M}`,willChange:"height, background-color"}),(V=r.current)==null||V.appendChild(T),T}),n){h.current=!0,g.current=!0,C();return}return e?((async()=>{try{const _=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=_;const j=s();o.current=j;const T=j.createAnalyser();a.current=T,T.fftSize=2048,T.smoothingTimeConstant=FB,T.minDecibels=-85,T.maxDecibels=-10;const M=T.frequencyBinCount;
1065l.current=new Uint8Array(M);const V=j.createMediaStreamSource(_);u.current=V,V.connect(T),h.current=!0,g.current=!1,C()}catch{}})(),()=>{h.current=!1,m.current=[],f.current&&(cancelAnimationFrame(f.current),f.current=null),u.current&&(u.current.disconnect(),u.current=null),o.current&&o.current.state!=="closed"&&(o.current=null),d.current&&(d.current.getTracks().forEach(_=>_.stop()),d.current=null)}):void 0},[s,e,t,C,S,n]),x.useEffect(()=>{h.current=!1,f.current&&(cancelAnimationFrame(f.current),f.current=null),u.current&&(u.current.disconnect(),u.current=null),d.current&&(d.current.getTracks().forEach(N=>N.stop()),d.current=null),m.current=[],y.current=0,w.current=0,n?(h.current=!0,g.current=!0,C()):e&&(async()=>{try{const _=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=_;const j=s();o.current=j;const T=j.createAnalyser();a.current=T,T.fftSize=2048,T.smoothingTimeConstant=FB,T.minDecibels=-85,T.maxDecibels=-10;const M=T.frequencyBinCount;l.current=new Uint8Array(M);const V=j.createMediaStreamSource(_);u.current=V,V.connect(T),h.current=!0,g.current=!1,C()}catch{}})()},[e,s,C,n]);const k=`recordBarContainer ${t?"minimized":""}`;return c.jsx("div",{ref:r,className:k,style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"transparent",borderRadius:t?"50%":"inherit",padding:"0 8px",gap:"1px",overflow:"hidden",flex:"1"}})};function Jwe(){const{showBanner:t}=ts(),{selectedSingleCaiObject:e,selectedCaiObjects:n}=Yn(),{selectCaiObject:r}=cr(),{addTextNode:i,addEmbeddingNode:s,addVisualMediaNode:o}=Gn(),{commitToStore:a}=Ln(),{caiChatState:l}=Yn(),{getBloobById:u,getNoteById:d,getSongById:f,songs:h,tracks:m,getBloobsInSongForRequest:y,getBloobByIdForRequest:g,getAudioFileDataRelevantToSongs:w}=mn(),{handleCaiAgentRequest:v}=U0(),{getRandomViewportCenteredCanvasPosition:S}=sl(),{getThreadForObject:C,appendMessage:k,addThread:N}=xd(),_=x.useMemo(()=>{if(!e)return"global";switch(e.type){case J.Song:return`song:${e.id}`;case J.Bloob:return`song:${u(e.id).songId}`;case J.Note:{const Q=d(e.id).bloobId;return`song:${u(Q).songId}`}case J.Track:{const Q=m[e.id];return Q?`song:${Q.songId}`:"global"}case J.TextNode:return`text_node:${e.id}`;case J.EmbeddingNode:return`embedding_node:${e.id}`;case J.VisualMediaNode:return`visual_node:${e.id}`;default:return"global"}},[e,u,d,m]),j=x.useMemo(()=>{if(_!=="global"||n.length===0)return _;const Q=n.filter(Ce=>Ce.type===J.Bloob).map(Ce=>Ce.id);if(Q.length!==n.length)return _;const de=u(Q[0]);return de&&Q.every(Ce=>{const Ae=u(Ce);return(Ae==null?void 0:Ae.songId)===de.songId})?`song:${de.songId}`:_},[_,n,u]),T=fD(j),M=at(Q=>Q.awaitingResponse),V=at(Q=>Object.keys(Q.inFlightAgentRequests??{}).length),H=at(Q=>Q.addInFlightRequest),P=at(Q=>Q.removeInFlightRequest),F=at(Q=>Q.cancelRequest),I=at(Q=>Q.cancelRequestForContext),R=at(Q=>Q.cancelRequestById),U=at(Q=>Q.getInFlightCount),A=at(Q=>Q.isContextAwaitingResponse),W=at(Q=>Q.setDisplayRequestProgression),[D,B]=x.useState(!1),[L,$]=x.useState(!1),q=x.useRef(null),Z=x.useRef([]),ie=x.useRef(t);ie.current=t;const[ge,re]=x.useState(!1),[Y,ne]=x.useState(null),[be,we]=x.useState(0),te=x.useRef(null),fe=x.useRef(null);x.useEffect(()=>{let Q=!1;return L?(async()=>{try{const Ne=await navigator.mediaDevices.getUserMedia({audio:!0});if(Q){Ne.getTracks().forEach(Ae=>Ae.stop());return}const Ce=new MediaRecorder(Ne);q.current=Ce,Z.current=[],Ce.ondataavailable=Ae=>{Ae.data.size>0&&Z.current.push(Ae.data)},Ce.onstop=()=>{const Ae=new Blob(Z.current,{type:"audio/webm"}),Ue=new FileReader;Ue.readAsArrayBuffer(Ae),Ue.onloadend=()=>{var je;const Se=Ue.result;if(!Se)return;const ve=new Uint8Array(Se);at.getState().getInFlightCount()>=3||(je=fe.current)==null||je.call(fe,ve).catch(Te=>{Te instanceof Rf?ie.current("Voice Request Cancelled"):Te instanceof qu?ie.current(Te.userMessage):ie.current("Error submitting voice request"),pr("Error submitting voice request:",Te)})},Ne.getTracks().forEach(Se=>Se.stop())},Ce.start()}catch{ie.current("There was an issue accessing the microphone")}})():q.current&&(q.current.stop(),q.current=null),()=>{Q=!0}},[L]),x.useEffect(()=>{const Q=Ne=>{var Ce,Ae,Ue;if(!(((Ce=document.activeElement)==null?void 0:Ce.tagName)==="INPUT"||((Ae=document.activeElement)==null?void 0:Ae.tagName)==="TEXTAREA"||((Ue=document.activeElement)==null?void 0:Ue.getAttribute("contenteditable"))==="true")&&Ne.code==="Space"&&!ge){re(!0);const Se=Date.now(),ve=setInterval(()=>{const je=Math.floor((Date.now()-Se)/1e3);we(je),je>=1&&!L&&($(!0),clearInterval(ve),ne(null))},100);ne(ve),Ne.preventDefault()}},de=Ne=>{Ne.code==="Space"&&(re(!1),Y&&(clearInterval(Y),ne(null)),L&&$(!1),we(0))};return window.addEventListener("keydown",Q),window.addEventListener("keyup",de),()=>{window.removeEventListener("keydown",Q),window.removeEventListener("keyup",de),Y&&clearInterval(Y)}},[ge,Y,L,be]);const O=x.useCallback(async(Q,de)=>{var ce;const Ne=typeof Q=="string",Ce=Ne?Q.trim():"";let Ae="global",Ue=0;if(e)switch(e.type){case J.Bloob:{Ae="song",Ue=u(e.id).songId;break}case J.Note:{const se=d(e.id).bloobId;Ae="song",Ue=u(se).songId;break}case J.Song:{Ae="song",Ue=e.id;break}case J.Track:{const se=m[e.id];se&&(Ae="song",Ue=se.songId);break}case J.TextNode:{Ae="text",Ue=e.id;break}case J.EmbeddingNode:{Ae="embedding",Ue=e.id;break}case J.VisualMediaNode:{Ae="visual",Ue=e.id;break}}if(T&&Ne&&!Ce.toLowerCase().includes("@cai")){const se=C(Ae,Ue),ye=await dd();let ke;se?ke=se.id:ke=N(Ae,Ue);const ze=Date.now(),qe={id:`${ze}-u-${ke}`,timestamp:ze,role:"user",body:Ce,authorId:ye==null?void 0:ye.id,authorDisplayName:(ye==null?void 0:ye.email)??((ce=ye==null?void 0:ye.user_metadata)==null?void 0:ce.firstName)??"User",inReplyToId:de==null?void 0:de.inReplyToId};k(ke,qe),B(!0);return}if(U()>=3){t("You have 3 agentic requests in progress. Please wait for one to finish.");return}const ve=`${Date.now()}-${Math.random().toString(36).slice(2)}`,je=new AbortController;te.current=je;const Te=Ne?Ce.slice(0,200)||void 0:"[Voice message]";H(ve,Ae,Ue,je,Te),W(!0);try{const se=(e==null?void 0:e.type)===J.Song||(e==null?void 0:e.type)===J.Bloob||(e==null?void 0:e.type)===J.Track;let ye=[],ke=null;const ze=(e==null?void 0:e.type)===J.Bloob?e.id:null;let qe=[],ot={},Ze;if(e===null)Ze=Jt.CHAT_NSC,ye=Object.values(h),ot=Object.values(h).reduce((Kt,rn)=>(Kt[rn.id]=y(rn.id),Kt),{});else if(e.type===J.Song)Ze=Jt.CHAT_SSC,ye=[h[e.id]],ot[e.id]=y(e.id),ke=e.id;else if(e.type===J.Track){const Kt=m[e.id];Kt?(Ze=Jt.CHAT_SSC,ye=[h[Kt.songId]],ot[Kt.songId]=y(Kt.songId),ke=Kt.songId):Ze=Jt.CHAT_NSC}else if(e.type===J.Bloob){Ze=Jt.CHAT_BSC;const Kt=g(e.id);ye=[f(Kt.songId)],qe=[Kt],ot[Kt.songId]=y(Kt.songId),ke=Kt.songId}const _t=ye.map(Kt=>Kt.id),tt=await w(_t);Ji.event({category:qs.USER_ACTIONS,action:Ze,label:bo.GENERAL_CHAT_ACTS}),l&&Ji.event({category:qs.USER_ACTIONS,action:l===zn.MINIMIZED?Jt.CHAT_MIN_SENT:l===zn.MAXIMIZED?Jt.CHAT_MAX_SENT:Jt.CHAT_DEF_SENT,label:bo.GENERAL_CHAT_ACTS});const gt={timestamp:new Date,message:Q,songsContext:ye,specifiedBloobsContext:qe,songIdToBloobsContext:ot,songsWereSelected:se,audioFileIdToAudioData:tt,inReplyToId:de==null?void 0:de.inReplyToId},dt=C(Ae,Ue),wt=await v(gt,!0,dt,ke,ze,Ne,S(),je),{routeActions:Dt}=wt||{routeActions:[]};Dt&&Dt.some(Kt=>Kt.startsWith("chat"))&&B(!0);return}catch(se){throw se instanceof Rf?t("Request Cancelled"):se instanceof qu?t(se.userMe
vendor: 5,339 bytes, line 1065
1065ssage):t("Error processing request"),se}finally{P(ve),setTimeout(()=>{U()===0&&W(!1)},500),te.current=null}},[H,P,U,e,w,l,C,k,N,T,v,S,h,m,y,g,f,u,d,t,W]);fe.current=O;const pe=x.useCallback(()=>{F()},[F]),he=x.useCallback(()=>{const Q={x:window.innerWidth/2,y:window.innerHeight/2},de=i(Q);r({type:J.TextNode,id:de}),a()},[i,r,a]),le=x.useCallback(()=>{const Q={x:window.innerWidth/2,y:window.innerHeight/2},de=s(Q);r({type:J.EmbeddingNode,id:de}),a()},[s,r,a]),oe=x.useCallback(()=>{const Q={x:window.innerWidth/2,y:window.innerHeight/2},de=o(Q);r({type:J.VisualMediaNode,id:de}),a()},[o,r,a]);return{awaitingResponse:M,inFlightCount:V,canSendAgenticRequest:V<3,isContextAwaitingResponse:A,openChatBox:D,setOpenChatBox:B,isRecording:L,setIsRecording:$,spacePressed:ge,spaceHoldDuration:be,handlePromptSubmit:O,cancelRequest:pe,cancelRequestForContext:I,cancelRequestById:R,handleCreateTextNode:he,handleCreateEmbeddingNode:le,handleCreateVisualMediaNode:oe}}function e1e(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const t1e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,n1e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,r1e={};function $B(t,e){return(r1e.jsx?n1e:t1e).test(t)}const i1e=/[ \t\n\f\r]/g;function s1e(t){return typeof t=="object"?t.type==="text"?UB(t.value):!1:UB(t)}function UB(t){return t.replace(i1e,"")===""}class Y0{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Y0.prototype.normal={};Y0.prototype.property={};Y0.prototype.space=void 0;function QF(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new Y0(n,r,e)}function t_(t){return t.toLowerCase()}class Zs{constructor(e,n){this.attribute=n,this.property=e}}Zs.prototype.attribute="";Zs.prototype.booleanish=!1;Zs.prototype.boolean=!1;Zs.prototype.commaOrSpaceSeparated=!1;Zs.prototype.commaSeparated=!1;Zs.prototype.defined=!1;Zs.prototype.mustUseProperty=!1;Zs.prototype.number=!1;Zs.prototype.overloadedBoolean=!1;Zs.prototype.property="";Zs.prototype.spaceSeparated=!1;Zs.prototype.space=void 0;let o1e=0;const Rn=Nd(),vi=Nd(),ZF=Nd(),Ft=Nd(),Ir=Nd(),ah=Nd(),io=Nd();function Nd(){return 2**++o1e}const n_=Object.freeze(Object.defineProperty({__proto__:null,boolean:Rn,booleanish:vi,commaOrSpaceSeparated:io,commaSeparated:ah,number:Ft,overloadedBoolean:ZF,spaceSeparated:Ir},Symbol.toStringTag,{value:"Module"})),C2=Object.keys(n_);class mN extends Zs{constructor(e,n,r,i){let s=-1;if(super(e,n),VB(this,"space",i),typeof r=="number")for(;++s<C2.length;){const o=C2[s];VB(this,C2[s],(r&n_[o])===n_[o])}}}mN.prototype.defined=!0;function VB(t,e,n){n&&(t[e]=n)}function np(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const s=new mN(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[t_(r)]=r,n[t_(s.attribute)]=r}return new Y0(e,n,t.space)}const JF=np({properties:{ariaActiveDescendant:null,ariaAtomic:vi,ariaAutoComplete:null,ariaBusy:vi,ariaChecked:vi,ariaColCount:Ft,ariaColIndex:Ft,ariaColSpan:Ft,ariaControls:Ir,ariaCurrent:null,ariaDescribedBy:Ir,ariaDetails:null,ariaDisabled:vi,ariaDropEffect:Ir,ariaErrorMessage:null,ariaExpanded:vi,ariaFlowTo:Ir,ariaGrabbed:vi,ariaHasPopup:null,ariaHidden:vi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ir,ariaLevel:Ft,ariaLive:null,ariaModal:vi,ariaMultiLine:vi,ariaMultiSelectable:vi,ariaOrientation:null,ariaOwns:Ir,ariaPlaceholder:null,ariaPosInSet:Ft,ariaPressed:vi,ariaReadOnly:vi,ariaRelevant:null,ariaRequired:vi,ariaRoleDescription:Ir,ariaRowCount:Ft,ariaRowIndex:Ft,ariaRowSpan:Ft,ariaSelected:vi,ariaSetSize:Ft,ariaSort:null,ariaValueMax:Ft,ariaValueMin:Ft,ariaValueNow:Ft,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function e9(t,e){return e in t?t[e]:e}function t9(t,e){return e9(t,e.toLowerCase())}const a1e=np({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ah,acceptCharset:Ir,accessKey:Ir,action:null,allow:null,allowFullScreen:Rn,allowPaymentRequest:Rn,allowUserMedia:Rn,alt:null,as:null,async:Rn,autoCapitalize:null,autoComplete:Ir,autoFocus:Rn,autoPlay:Rn,blocking:Ir,capture:null,charSet:null,checked:Rn,cite:null,className:Ir,cols:Ft,colSpan:null,content:null,contentEditable:vi,controls:Rn,controlsList:Ir,coords:Ft|ah,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Rn,defer:Rn,dir:null,dirName:null,disabled:Rn,download:ZF,draggable:vi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Rn,formTarget:null,headers:Ir,height:Ft,hidden:Rn,high:Ft,href:null,hrefLang:null,htmlFor:Ir,httpEquiv:Ir,id:null,imageSizes:null,imageSrcSet:null,inert:Rn,inputMode:null,integrity:null,is:null,isMap:Rn,itemId:null,itemProp:Ir,itemRef:Ir,itemScope:Rn,itemType:Ir,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Rn,low:Ft,manifest:null,max:null,maxLength:Ft,media:null,method:null,min:null,minLength:Ft,multiple:Rn,muted:Rn,name:null,nonce:null,noModule:Rn,noValidate:Rn,onAbort:null,onAfterPrint:null,onAuxCl
1065ick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Rn,optimum:Ft,pattern:null,ping:Ir,placeholder:null,playsInline:Rn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Rn,referrerPolicy:null,rel:Ir,required:Rn,reversed:Rn,rows:Ft,rowSpan:Ft,sandbox:Ir,scope:null,scoped:Rn,seamless:Rn,selected:Rn,shadowRootClonable:Rn,shadowRootDelegatesFocus:Rn,shadowRootMode:null,shape:null,size:Ft,sizes:null,slot:null,span:Ft,spellCheck:vi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ft,step:null,style:null,tabIndex:Ft,target:null,title:null,translate:null,type:null,typeMustMatch:Rn,useMap:null,value:vi,width:Ft,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ir,axis:null,background:null,bgColor:null,border:Ft,borderColor:null,bottomMargin:Ft,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Rn,declare:Rn,event:null,face:null,frame:null,frameBorder:null,hSpace:Ft,leftMargin:Ft,link:null,longDesc:null,lowSrc:null,marginHeight:Ft,marginWidth:Ft,noResize:Rn,noHref:Rn,noShade:Rn,noWrap:Rn,object:null,profile:null,prompt:null,rev:null,rightMargin:Ft,rules:null,scheme:null,scrolling:vi,standby:null,summary:null,text:null,topMargin:Ft,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ft,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Rn,disableRemotePlayback:Rn,prefix:null,property:null,results:Ft,security:null,unselectable:null},space:"html",transform:t9}),l1e=np({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav
1065-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:io,accentHeight:Ft,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ft,amplitude:Ft,arabicForm:null,ascent:Ft,attributeName:null,attributeType:null,azimuth:Ft,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ft,by:null,calcMode:null,capHeight:Ft,className:Ir,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ft,diffuseConstant:Ft,direction:null,display:null,dur:null,divisor:Ft,dominantBaseline:null,download:Rn,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ft,enableBackground:null,end:null,event:null,exponent:Ft,externalResourcesRequired:null,fill:null,fillOpacity:Ft,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ah,g2:ah,glyphName:ah,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ft,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ft,horizOriginX:Ft,horizOriginY:Ft,id:null,ideographic:Ft,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ft,k:Ft,k1:Ft,k2:Ft,k3:Ft,k4:Ft,kernelMatrix:io,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ft,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ft,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,on
vendor: 5,389 bytes, lines 1065-1066
1065Zoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ft,overlineThickness:Ft,paintOrder:null,panose1:null,path:null,pathLength:Ft,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ir,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ft,pointsAtY:Ft,pointsAtZ:Ft,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:io,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:io,rev:io,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:io,requiredFeatures:io,requiredFonts:io,requiredFormats:io,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ft,specularExponent:Ft,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ft,strikethroughThickness:Ft,string:null,stroke:null,strokeDashArray:io,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ft,strokeOpacity:Ft,strokeWidth:null,style:null,surfaceScale:Ft,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:io,tabIndex:Ft,tableValues:null,target:null,targetX:Ft,targetY:Ft,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:io,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ft,underlineThickness:Ft,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ft,values:null,vAlphabetic:Ft,vMathematical:Ft,vectorEffect:null,vHanging:Ft,vIdeographic:Ft,version:null,vertAdvY:Ft,vertOriginX:Ft,vertOriginY:Ft,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ft,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:e9}),n9=np({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),r9=np({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:t9}),i9=np({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),c1e={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},u1e=/[A-Z]/g,HB=/-[a-z]/g,d1e=/^data[-\w.:]+$/i;function f1e(t,e){const n=t_(e);let r=e,i=Zs;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&d1e.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(HB,p1e);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!HB.test(s)){let o=s.replace(u1e,h1e);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=mN}return new i(r,e)}function h1e(t){return"-"+t.toLowerCase()}function p1e(t){return t.charAt(1).toUpperCase()}const m1e=QF([JF,a1e,n9,r9,i9],"html"),gN=QF([JF,l1e,n9,r9,i9],"svg");function g1e(t){return t.join(" ").trim()}var wf={},_2,GB;function b1e(){if(GB)return _2;GB=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=` 1066`,u="/",d="*",f="",h="comment",m="declaration";_2=function(g,w){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];w=w||{};var v=1,S=1;function C(F){var I=F.match(e);I&&(v+=I.length);var R=F.lastIndexOf(l);S=~R?F.length-R:S+F.length}function k(){var F={line:v,column:S};return function(I){return I.position=new N(F),T(),I}}function N(F){this.start=F,this.end={line:v,column:S},this.source=w.source}N.prototype.content=g;function _(F){var I=new Error(w.source+":"+v+":"+S+": "+F);if(I.reason=F,I.filename=w.source,I.line=v,I.column=S,I.source=g,!w.silent)throw I}function j(F){var I=F.exec(g);if(I){var R=I[0];return C(R),g=g.slice(R.length),I}}function T(){j(n)}function M(F){var I;for(F=F||[];I=V();)I!==!1&&F.push(I);return F}function V(){var F=k();if(!(u!=g.charAt(0)||d!=g.charAt(1))){for(var I=2;f!=g.charAt(I)&&(d!=g.charAt(I)||u!=g.charAt(I+1));)++I;if(I+=2,f===g.charAt(I-1))return _("End of comment missing");var R=g.slice(2,I-2);return S+=2,C(R),g=g.slice(I),S+=2,F({type:h,comment:R})}}function H(){var F=k(),I=j(r);if(I){if(V(),!j(i))return _("property missing ':'");var R=j(s),U=F({type:m,property:y(I[0].replace(t,f)),value:R?y(R[0].replace(t,f)):f});return j(o),U}}function P(){var F=[];M(F);for(var I;I=H();)I!==!1&&(F.push(I),M(F));return F}return T(),P()};function y(g){return g?g.replace(a,f):f}return _2}var WB;function y1e(){if(WB)return wf;WB=1;var t=wf&&wf.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};
vendor: 3,697 bytes, line 1066
1066Object.defineProperty(wf,"__esModule",{value:!0}),wf.default=n;var e=t(b1e());function n(r,i){var s=null;if(!r||typeof r!="string")return s;var o=(0,e.default)(r),a=typeof i=="function";return o.forEach(function(l){if(l.type==="declaration"){var u=l.property,d=l.value;a?i(u,d,l):d&&(s=s||{},s[u]=d)}}),s}return wf}var Gp={},qB;function v1e(){if(qB)return Gp;qB=1,Object.defineProperty(Gp,"__esModule",{value:!0}),Gp.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||t.test(u)},o=function(u,d){return d.toUpperCase()},a=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(e,o))};return Gp.camelCase=l,Gp}var Wp,KB;function x1e(){if(KB)return Wp;KB=1;var t=Wp&&Wp.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(y1e()),n=v1e();function r(i,s){var o={};return!i||typeof i!="string"||(0,e.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Wp=r,Wp}var w1e=x1e();const k1e=Vo(w1e),s9=o9("end"),bN=o9("start");function o9(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function S1e(t){const e=bN(t),n=s9(t);if(e&&n)return{start:e,end:n}}function Im(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?YB(t.position):"start"in t||"end"in t?YB(t):"line"in t||"column"in t?r_(t):""}function r_(t){return XB(t&&t.line)+":"+XB(t&&t.column)}function YB(t){return r_(t&&t.start)+"-"+r_(t&&t.end)}function XB(t){return t&&typeof t=="number"?t:1}class bs extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=a?a.line:void 0,this.name=Im(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual,this.expected,this.note,this.url}}bs.prototype.file="";bs.prototype.name="";bs.prototype.reason="";bs.prototype.message="";bs.prototype.stack="";bs.prototype.column=void 0;bs.prototype.line=void 0;bs.prototype.ancestors=void 0;bs.prototype.cause=void 0;bs.prototype.fatal=void 0;bs.prototype.place=void 0;bs.prototype.ruleId=void 0;bs.prototype.source=void 0;const yN={}.hasOwnProperty,C1e=new Map,_1e=/[A-Z]/g,E1e=new Set(["table","tbody","thead","tfoot","tr"]),N1e=new Set(["td","th"]),a9="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function I1e(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=R1e(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");
vendor: 6,347 bytes, line 1066
1066if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=B1e(n,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?gN:m1e,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=l9(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function l9(t,e,n){if(e.type==="element")return j1e(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return T1e(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return P1e(t,e,n);if(e.type==="mdxjsEsm")return z1e(t,e);if(e.type==="root")return A1e(t,e,n);if(e.type==="text")return M1e(t,e)}function j1e(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=gN,t.schema=i),t.ancestors.push(e);const s=u9(t,e.tagName,!1),o=O1e(t,e);let a=xN(t,e);return E1e.has(e.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!s1e(l):!0})),c9(t,o,s,e),vN(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function T1e(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}h0(t,e.position)}function z1e(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);h0(t,e.position)}function P1e(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=gN,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:u9(t,e.name,!0),o=D1e(t,e),a=xN(t,e);return c9(t,o,s,e),vN(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function A1e(t,e,n){const r={};return vN(r,xN(t,e)),t.create(e,t.Fragment,r,n)}function M1e(t,e){return e.value}function c9(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function vN(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function B1e(t,e,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:e;return a?u(s,o,a):u(s,o)}}function R1e(t,e){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=bN(r);return e(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:t,lineNumber:l?l.line:void 0},void 0)}}function O1e(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&yN.call(e.properties,i)){const s=L1e(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&N1e.has(e.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function D1e(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,t.evaluater.evaluateExpression(a.argument))}else h0(t,e.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const a=r.value.data.estree.body[0];a.type,s=t.evaluater.evaluateExpression(a.expression)}else h0(t,e.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function xN(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:C1e;for(;++r<e.children.length;){const s=e.children[r];let o;if(t.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=l9(t,s,o);a!==void 0&&n.push(a)}return n}function L1e(t,e,n){const r=f1e(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?e1e(n):g1e(n)),r.property==="style"){let i=typeof n=="object"?n:F1e(t,String(n));return t.stylePropertyNameCase==="css"&&(i=$1e(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?c1e[r.property]||r.property:r.attribute,n]}}function F1e(t,e){try{return k1e(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new bs("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=a9+"#cannot-parse-style-attribute",i}}function u9(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let s=-1,o;for(;++s<i.length;){const a=$B(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=$B(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return yN.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(r);h0(t)}function h0(t,e){const n=new bs("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=a9+"#cannot-handle-mdx-estrees-without-createevaluater",n}function $1e(t){const e={};let n;for(n in t)yN.call(t,n)&&(e[U1e(n)]=t[n]);return e}function U1e(t){let e=t.replace(_1e,V1e);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function V1e(t){return"-"+t.toLowerCase()}const E2={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},H1e={};function G1e(t,e){const n=H1e,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return d9(t,r,i)}function d9(t,e,n){if(W1e(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return QB(t.children,e,n)}return Array.isArray(t)?QB(t,e,n):""}function QB(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=d9(t[i],e,n);return r.join("")}function W1e(t){return!!(t&&typeof t=="object")}const ZB=document.createElement("i");function wN(t){const e="&"+t+";";ZB.innerHTML=e;const n=ZB.textContent;
vendor: 13,052 bytes, line 1066
1066return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function nl(t,e,n,r){const i=t.length;let s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(e,0),t.splice(...o),s+=1e4,e+=1e4}function Mo(t,e){return t.length>0?(nl(t,t.length,0,e),t):e}const JB={}.hasOwnProperty;function q1e(t){const e={};let n=-1;for(;++n<t.length;)K1e(e,t[n]);return e}function K1e(t,e){let n;for(n in e){const i=(JB.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n];let o;if(s)for(o in s){JB.call(i,o)||(i[o]=[]);const a=s[o];Y1e(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Y1e(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);nl(t,0,0,r)}function f9(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function lh(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Va=Qc(/[A-Za-z]/),po=Qc(/[\dA-Za-z]/),X1e=Qc(/[#-'*+\--9=?A-Z^-~]/);function i_(t){return t!==null&&(t<32||t===127)}const s_=Qc(/\d/),Q1e=Qc(/[\dA-Fa-f]/),Z1e=Qc(/[!-/:-@[-`{-~]/);function Tn(t){return t!==null&&t<-2}function Ks(t){return t!==null&&(t<0||t===32)}function ur(t){return t===-2||t===-1||t===32}const J1e=Qc(new RegExp("\\p{P}|\\p{S}","u")),eke=Qc(/\s/);function Qc(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function rp(t){const e=[];let n=-1,r=0,i=0;for(;++n<t.length;){const s=t.charCodeAt(n);let o="";if(s===37&&po(t.charCodeAt(n+1))&&po(t.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=t.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(e.push(t.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return e.join("")+t.slice(r)}function Pr(t,e,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return ur(l)?(t.enter(n),a(l)):e(l)}function a(l){return ur(l)&&s++<i?(t.consume(l),a):(t.exit(n),e(l))}}const tke={tokenize:nke};function nke(t){const e=t.attempt(this.parser.constructs.contentInitial,r,i);let n;return e;function r(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Pr(t,e,"linePrefix")}function i(a){return t.enter("paragraph"),s(a)}function s(a){const l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return Tn(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}const rke={tokenize:ike},e4={tokenize:ske};function ike(t){const e=this,n=[];let r=0,i,s,o;return a;function a(C){if(r<n.length){const k=n[r];return e.containerState=k[1],t.attempt(k[0].continuation,l,u)(C)}return u(C)}function l(C){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&S();const k=e.events.length;let N=k,_;for(;N--;)if(e.events[N][0]==="exit"&&e.events[N][1].type==="chunkFlow"){_=e.events[N][1].end;break}v(r);let j=k;for(;j<e.events.length;)e.events[j][1].end={..._},j++;return nl(e.events,N+1,0,e.events.slice(k)),e.events.length=j,u(C)}return a(C)}function u(C){if(r===n.length){if(!i)return h(C);if(i.currentConstruct&&i.currentConstruct.concrete)return y(C);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(e4,d,f)(C)}function d(C){return i&&S(),v(r),h(C)}function f(C){return e.parser.lazy[e.now().line]=r!==n.length,o=e.now().offset,y(C)}function h(C){return e.containerState={},t.attempt(e4,m,y)(C)}function m(C){return r++,n.push([e.currentConstruct,e.containerState]),h(C)}function y(C){if(C===null){i&&S(),v(0),t.consume(C);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),g(C)}function g(C){if(C===null){w(t.exit("chunkFlow"),!0),v(0),t.consume(C);return}return Tn(C)?(t.consume(C),w(t.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(t.consume(C),g)}function w(C,k){const N=e.sliceStream(C);if(k&&N.push(null),C.previous=s,s&&(s.next=C),s=C,i.defineSkip(C.start),i.write(N),e.parser.lazy[C.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const j=e.events.length;let T=j,M,V;for(;T--;)if(e.events[T][0]==="exit"&&e.events[T][1].type==="chunkFlow"){if(M){V=e.events[T][1].end;break}M=!0}for(v(r),_=j;_<e.events.length;)e.events[_][1].end={...V},_++;nl(e.events,T+1,0,e.events.slice(j)),e.events.length=_}}function v(C){let k=n.length;for(;k-- >C;){const N=n[k];e.containerState=N[1],N[0].exit.call(e,t)}n.length=C}function S(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function ske(t,e,n){return Pr(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function t4(t){if(t===null||Ks(t)||eke(t))return 1;if(J1e(t))return 2}function kN(t,e,n){const r=[];let i=-1;for(;++i<t.length;){const s=t[i].resolveAll;s&&!r.includes(s)&&(e=s(e,n),r.push(s))}return e}const o_={name:"attention",resolveAll:oke,tokenize:ake};function oke(t,e){let n=-1,r,i,s,o,a,l,u,d;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;l=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const f={...t[r][1].end},h={...t[n][1].start};n4(f,-l),n4(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...t[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[r][1].end={...o.start},t[n][1].start={...a.end},u=[],t[r][1].end.offset-t[r][1].start.offset&&(u=Mo(u,[["enter",t[r][1],e],["exit",t[r][1],e]])),u=Mo(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=Mo(u,kN(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),u=Mo(u,[["exit",s,e],["enter",a,e],["exit",a,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(d=2,u=Mo(u,[["enter",t[n][1],e],["exit",t[n][1],e]])):d=0,nl(t,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function ake(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=t4(r);let s;return o;function o(l){return s=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===s)return t.consume(l),a;const u=t.exit("attentionSequence"),d=t4(l),f=!d||d===2&&i||n.includes(l),h=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(i||!h)),u._close=!!(s===42?h:h&&(d||!f)),e(l)}}function n4(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const lke={name:"autolink",tokenize:cke};function cke(t,e,n){let r=0;return i;function i(m){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(m){return Va(m)?(t.consume(m),o):m===64?n(m):u(m)}function o(m){return m===43||m===45||m===46||po(m)?(r=1,a(m)):u(m)}function a(m){return m===58?(t.consume(m),r=0,l):(m===43||m===45||m===46||po(m))&&r++<32?(t.consume(m),a):(r=0,u(m))}function l(m){return m===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):m===null||m===32||m===60||i_(m)?n(m):(t.consume(m),l)}function u(m){return m===64?(t.consume(m),d):X1e(m)?(t.consume(m),u):n(m)}function d(m){return po(m)?f(m):n(m)}function f(m){return m===46?(t.consume(m),r=0,d):m===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):h(m)}function h(m){if((m===45||po(m))&&r++<63){const y=m===45?h:f;return t.consume(m),y}return n(m)}}const Ux={partial:!0,tokenize:uke};function uke(t,e,n){return r;function r(s){return ur(s)?Pr(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||Tn(s)?e(s):n(s)}}const h9={continuation:{tokenize:fke},exit:hke,name:"blockQuote",tokenize:dke};function dke(t,e,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),s}return n(o)}function s(o){return ur(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function fke(t,e,n){const r=this;return i;function i(o){return ur(o)?Pr(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return t.attempt(h9,e,n)(o)}}function hke(t){t.exit("blockQuote")}const p9={name:"characterEscape",tokenize:pke};function pke(t,e,n){return r;function r(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return Z1e(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}const m9={name:"characterReference",tokenize:mke};function mke(t,e,n){const r=this;let i=0,s,o;return a;function a(f){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),l}function l(f){return f===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(f),t.exit("characterReferenceMarkerNumeric"),u):(t.enter("characterReferenceValue"),s=31,o=po,d(f))}function u(f){return f===88||f===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(f),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,o=Q1e,d):(t.enter("characterReferenceValue"),s=7,o=s_,d(f))}function d(f){if(f===59&&i){const h=t.exit("characterReferenceValue");return o===po&&!wN(r.sliceSerialize(h))?n(f):(t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(f)&&i++<s?(t.consume(f),d):n(f)}}const r4={partial:!0,tokenize:bke},i4={concrete:!0,name:"codeFenced",tokenize:gke};function gke(t,e,n){const r=this,i={partial:!0,tokenize:N};let s=0,o=0,a;return l;function l(_){return u(_)}function u(_){const j=r.events[r.events.length-1];return s=j&&j[1].type==="linePrefix"?j[2].sliceSerialize(j[1],!0).length:0,a=_,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(_)}function d(_){return _===a?(o++,t.consume(_),d):o<3?n(_):(t.exit("codeFencedFenceSequence"),ur(_)?Pr(t,f,"whitespace")(_):f(_))}function f(_){return _===null||Tn(_)?(t.exit("codeFencedFence"),r.interrupt?e(_):t.check(r4,g,k)(_)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),h(_))}function h(_){return _===null||Tn(_)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),f(_)):ur(_)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Pr(t,m,"whitespace")(_)):_===96&&_===a?n(_):(t.consume(_),h)}function m(_){return _===null||Tn(_)?f(_):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),y(_))}function y(_){return _===null||Tn(_)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),f(_)):_===96&&_===a?n(_):(t.consume(_),y)}function g(_){return t.attempt(i,k,w)(_)}function w(_){return t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),v}function v(_){return s>0&&ur(_)?Pr(t,S,"linePrefix",s+1)(_):S(_)}function S(_){return _===null||Tn(_)?t.check(r4,g,k)(_):(t.enter("codeFlowValue"),C(_))}function C(_){return _===null||Tn(_)?(t.exit("codeFlowValue"),S(_)):(t.consume(_),C)}function k(_){return t.exit("codeFenced"),e(_)}function N(_,j,T){let M=0;return V;function V(R){return _.enter("lineEnding"),_.consume(R),_.exit("lineEnding"),H}function H(R){return _.enter("codeFencedFence"),ur(R)?Pr(_,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):P(R)}function P(R){return R===a?(_.enter("codeFencedFenceSequence"),F(R)):T(R)}function F(R){return R===a?(M++,_.consume(R),F):M>=o?(_.exit("codeFencedFenceSequence"),ur(R)?Pr(_,I,"whitespace")(R):I(R)):T(R)}function I(R){return R===null||Tn(R)?(_.exit("codeFencedFence"),j(R)):T(R)}}}function bke(t,e,n){const r=this;return i;function i(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}const N2={name:"codeIndented",tokenize:vke},yke={partial:!0,tokenize:xke};function vke(t,e,n){const r=this;return i;
vendor: 5,070 bytes, line 1066
1066function i(u){return t.enter("codeIndented"),Pr(t,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Tn(u)?t.attempt(yke,o,l)(u):(t.enter("codeFlowValue"),a(u))}function a(u){return u===null||Tn(u)?(t.exit("codeFlowValue"),o(u)):(t.consume(u),a)}function l(u){return t.exit("codeIndented"),e(u)}}function xke(t,e,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Tn(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i):Pr(t,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):Tn(o)?i(o):n(o)}}const wke={name:"codeText",previous:Ske,resolve:kke,tokenize:Cke};function kke(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function Ske(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Cke(t,e,n){let r=0,i,s;return o;function o(f){return t.enter("codeText"),t.enter("codeTextSequence"),a(f)}function a(f){return f===96?(t.consume(f),r++,a):(t.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(t.enter("space"),t.consume(f),t.exit("space"),l):f===96?(s=t.enter("codeTextSequence"),i=0,d(f)):Tn(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),l):(t.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Tn(f)?(t.exit("codeTextData"),l(f)):(t.consume(f),u)}function d(f){return f===96?(t.consume(f),i++,d):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(f)):(s.type="codeTextData",u(f))}}class _ke{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&qp(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),qp(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),qp(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);qp(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);qp(this.left,n.reverse())}}}function qp(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function g9(t){const e={};let n=-1,r,i,s,o,a,l,u;const d=new _ke(t);for(;++n<d.length;){for(;n in e;)n=e[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,Eke(d,n)),n=e[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return nl(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Eke(t,e){const n=t.get(e)[1],r=t.get(e)[2];let i=e-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let d,f,h=-1,m=n,y=0,g=0;const w=[g];for(;m;){for(;t.get(++i)[1]!==m;);s.push(i),m._tokenizer||(d=r.sliceStream(m),m.next||d.push(null),f&&o.defineSki
vendor: 18,631 bytes, line 1066
1066p(m.start),m._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),m._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(g=h+1,w.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(o.events=[],m?(m._tokenizer=void 0,m.previous=void 0):w.pop(),h=w.length;h--;){const v=a.slice(w[h],w[h+1]),S=s.pop();l.push([S,S+v.length-1]),t.splice(S,2,v)}for(l.reverse(),h=-1;++h<l.length;)u[y+l[h][0]]=y+l[h][1],y+=l[h][1]-l[h][0]-1;return u}const Nke={resolve:jke,tokenize:Tke},Ike={partial:!0,tokenize:zke};function jke(t){return g9(t),t}function Tke(t,e){let n;return r;function r(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Tn(a)?t.check(Ike,o,s)(a):(t.consume(a),i)}function s(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function zke(t,e,n){const r=this;return i;function i(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Pr(t,s,"linePrefix")}function s(o){if(o===null||Tn(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(r.parser.constructs.flow,n,e)(o)}}function b9(t,e,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(v){return v===60?(t.enter(r),t.enter(i),t.enter(s),t.consume(v),t.exit(s),h):v===null||v===32||v===41||i_(v)?n(v):(t.enter(r),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),g(v))}function h(v){return v===62?(t.enter(s),t.consume(v),t.exit(s),t.exit(i),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===62?(t.exit("chunkString"),t.exit(a),h(v)):v===null||v===60||Tn(v)?n(v):(t.consume(v),v===92?y:m)}function y(v){return v===60||v===62||v===92?(t.consume(v),m):m(v)}function g(v){return!d&&(v===null||v===41||Ks(v))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(r),e(v)):d<u&&v===40?(t.consume(v),d++,g):v===41?(t.consume(v),d--,g):v===null||v===32||v===40||i_(v)?n(v):(t.consume(v),v===92?w:g)}function w(v){return v===40||v===41||v===92?(t.consume(v),g):g(v)}}function y9(t,e,n,r,i,s){const o=this;let a=0,l;return u;function u(m){return t.enter(r),t.enter(i),t.consume(m),t.exit(i),t.enter(s),d}function d(m){return a>999||m===null||m===91||m===93&&!l||m===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(m):m===93?(t.exit(s),t.enter(i),t.consume(m),t.exit(i),t.exit(r),e):Tn(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||Tn(m)||a++>999?(t.exit("chunkString"),d(m)):(t.consume(m),l||(l=!ur(m)),m===92?h:f)}function h(m){return m===91||m===92||m===93?(t.consume(m),a++,f):f(m)}}function v9(t,e,n,r,i,s){let o;return a;function a(h){return h===34||h===39||h===40?(t.enter(r),t.enter(i),t.consume(h),t.exit(i),o=h===40?41:h,l):n(h)}function l(h){return h===o?(t.enter(i),t.consume(h),t.exit(i),t.exit(r),e):(t.enter(s),u(h))}function u(h){return h===o?(t.exit(s),l(o)):h===null?n(h):Tn(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),Pr(t,u,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===o||h===null||Tn(h)?(t.exit("chunkString"),u(h)):(t.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(t.consume(h),d):d(h)}}function jm(t,e){let n;return r;function r(i){return Tn(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):ur(i)?Pr(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const Pke={name:"definition",tokenize:Mke},Ake={partial:!0,tokenize:Bke};function Mke(t,e,n){const r=this;let i;return s;function s(m){return t.enter("definition"),o(m)}function o(m){return y9.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function a(m){return i=lh(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),l):n(m)}function l(m){return Ks(m)?jm(t,u)(m):u(m)}function u(m){return b9(t,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return t.attempt(Ake,f,f)(m)}function f(m){return ur(m)?Pr(t,h,"whitespace")(m):h(m)}function h(m){return m===null||Tn(m)?(t.exit("definition"),r.parser.defined.push(i),e(m)):n(m)}}function Bke(t,e,n){return r;function r(a){return Ks(a)?jm(t,i)(a):n(a)}function i(a){return v9(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return ur(a)?Pr(t,o,"whitespace")(a):o(a)}function o(a){return a===null||Tn(a)?e(a):n(a)}}const Rke={name:"hardBreakEscape",tokenize:Oke};function Oke(t,e,n){return r;function r(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return Tn(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}const Dke={name:"headingAtx",resolve:Lke,tokenize:Fke};function Lke(t,e){let n=t.length-2,r=3,i,s;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},s={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},nl(t,r,n-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function Fke(t,e,n){let r=0;return i;function i(d){return t.enter("atxHeading"),s(d)}function s(d){return t.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(t.consume(d),o):d===null||Ks(d)?(t.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(t.enter("atxHeadingSequence"),l(d)):d===null||Tn(d)?(t.exit("atxHeading"),e(d)):ur(d)?Pr(t,a,"whitespace")(d):(t.enter("atxHeadingText"),u(d))}function l(d){return d===35?(t.consume(d),l):(t.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||Ks(d)?(t.exit("atxHeadingText"),a(d)):(t.consume(d),u)}}const $ke=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],s4=["pre","script","style","textarea"],Uke={concrete:!0,name:"htmlFlow",resolveTo:Gke,tokenize:Wke},Vke={partial:!0,tokenize:Kke},Hke={partial:!0,tokenize:qke};function Gke(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function Wke(t,e,n){const r=this;let i,s,o,a,l;return u;function u(q){return d(q)}function d(q){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(q),f}function f(q){return q===33?(t.consume(q),h):q===47?(t.consume(q),s=!0,g):q===63?(t.consume(q),i=3,r.interrupt?e:B):Va(q)?(t.consume(q),o=String.fromCharCode(q),w):n(q)}function h(q){return q===45?(t.consume(q),i=2,m):q===91?(t.consume(q),i=5,a=0,y):Va(q)?(t.consume(q),i=4,r.interrupt?e:B):n(q)}function m(q){return q===45?(t.consume(q),r.interrupt?e:B):n(q)}function y(q){const Z="CDATA[";return q===Z.charCodeAt(a++)?(t.consume(q),a===Z.length?r.interrupt?e:P:y):n(q)}function g(q){return Va(q)?(t.consume(q),o=String.fromCharCode(q),w):n(q)}function w(q){if(q===null||q===47||q===62||Ks(q)){const Z=q===47,ie=o.toLowerCase();return!Z&&!s&&s4.includes(ie)?(i=1,r.interrupt?e(q):P(q)):$ke.includes(o.toLowerCase())?(i=6,Z?(t.consume(q),v):r.interrupt?e(q):P(q)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(q):s?S(q):C(q))}return q===45||po(q)?(t.consume(q),o+=String.fromCharCode(q),w):n(q)}function v(q){return q===62?(t.consume(q),r.interrupt?e:P):n(q)}function S(q){return ur(q)?(t.consume(q),S):V(q)}function C(q){return q===47?(t.consume(q),V):q===58||q===95||Va(q)?(t.consume(q),k):ur(q)?(t.consume(q),C):V(q)}function k(q){return q===45||q===46||q===58||q===95||po(q)?(t.consume(q),k):N(q)}function N(q){return q===61?(t.consume(q),_):ur(q)?(t.consume(q),N):C(q)}function _(q){return q===null||q===60||q===61||q===62||q===96?n(q):q===34||q===39?(t.consume(q),l=q,j):ur(q)?(t.consume(q),_):T(q)}function j(q){return q===l?(t.consume(q),l=null,M):q===null||Tn(q)?n(q):(t.consume(q),j)}function T(q){return q===null||q===34||q===39||q===47||q===60||q===61||q===62||q===96||Ks(q)?N(q):(t.consume(q),T)}function M(q){return q===47||q===62||ur(q)?C(q):n(q)}function V(q){return q===62?(t.consume(q),H):n(q)}function H(q){return q===null||Tn(q)?P(q):ur(q)?(t.consume(q),H):n(q)}function P(q){return q===45&&i===2?(t.consume(q),U):q===60&&i===1?(t.consume(q),A):q===62&&i===4?(t.consume(q),L):q===63&&i===3?(t.consume(q),B):q===93&&i===5?(t.consume(q),D):Tn(q)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(Vke,$,F)(q)):q===null||Tn(q)?(t.exit("htmlFlowData"),F(q)):(t.consume(q),P)}function F(q){return t.check(Hke,I,$)(q)}function I(q){return t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),R}function R(q){return q===null||Tn(q)?F(q):(t.enter("htmlFlowData"),P(q))}function U(q){return q===45?(t.consume(q),B):P(q)}function A(q){return q===47?(t.consume(q),o="",W):P(q)}function W(q){if(q===62){const Z=o.toLowerCase();return s4.includes(Z)?(t.consume(q),L):P(q)}return Va(q)&&o.length<8?(t.consume(q),o+=String.fromCharCode(q),W):P(q)}function D(q){return q===93?(t.consume(q),B):P(q)}function B(q){return q===62?(t.consume(q),L):q===45&&i===2?(t.consume(q),B):P(q)}function L(q){return q===null||Tn(q)?(t.exit("htmlFlowData"),$(q)):(t.consume(q),L)}function $(q){return t.exit("htmlFlow"),e(q)}}function qke(t,e,n){const r=this;return i;function i(o){return Tn(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}function Kke(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Ux,e,n)}}const Yke={name:"htmlText",tokenize:Xke};function Xke(t,e,n){const r=this;let i,s,o;return a;function a(B){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(B),l}function l(B){return B===33?(t.consume(B),u):B===47?(t.consume(B),N):B===63?(t.consume(B),C):Va(B)?(t.consume(B),T):n(B)}function u(B){return B===45?(t.consume(B),d):B===91?(t.consume(B),s=0,y):Va(B)?(t.consume(B),S):n(B)}function d(B){return B===45?(t.consume(B),m):n(B)}function f(B){return B===null?n(B):B===45?(t.consume(B),h):Tn(B)?(o=f,A(B)):(t.consume(B),f)}function h(B){return B===45?(t.consume(B),m):f(B)}function m(B){return B===62?U(B):B===45?h(B):f(B)}function y(B){const L="CDATA[";return B===L.charCodeAt(s++)?(t.consume(B),s===L.length?g:y):n(B)}function g(B){return B===null?n(B):B===93?(t.consume(B),w):Tn(B)?(o=g,A(B)):(t.consume(B),g)}function w(B){return B===93?(t.consume(B),v):g(B)}function v(B){return B===62?U(B):B===93?(t.consume(B),v):g(B)}function S(B){return B===null||B===62?U(B):Tn(B)?(o=S,A(B)):(t.consume(B),S)}function C(B){return B===null?n(B):B===63?(t.consume(B),k):Tn(B)?(o=C,A(B)):(t.consume(B),C)}function k(B){return B===62?U(B):C(B)}function N(B){return Va(B)?(t.consume(B),_):n(B)}function _(B){return B===45||po(B)?(t.consume(B),_):j(B)}function j(B){return Tn(B)?(o=j,A(B)):ur(B)?(t.consume(B),j):U(B)}function T(B){return B===45||po(B)?(t.consume(B),T):B===47||B===62||Ks(B)?M(B):n(B)}function M(B){return B===47?(t.consume(B),U):B===58||B===95||Va(B)?(t.consume(B),V):Tn(B)?(o=M,A(B)):ur(B)?(t.consume(B),M):U(B)}function V(B){return B===45||B===46||B===58||B===95||po(B)?(t.consume(B),V):H(B)}function H(B){return B===61?(t.consume(B),P):Tn(B)?(o=H,A(B)):ur(B)?(t.consume(B),H):M(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(t.consume(B),i=B,F):Tn(B)?(o=P,A(B)):ur(B)?(t.consume(B),P):(t.consume(B),I)}function F(B){return B===i?(t.consume(B),i=void 0,R):B===null?n(B):Tn(B)?(o=F,A(B)):(t.consume(B),F)}function I(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||Ks(B)?M(B):(t.consume(B),I)}function R(B){return B===47||B===62||Ks(B)?M(B):n(B)}function U(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):n(B)}function A(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),W}function W(B){return ur(B)?Pr(t,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):D(B)}function D(B){return t.enter("htmlTextData"),o(B)}}const SN={name:"labelEnd",resolveAll:e2e,resolveTo:t2e,tokenize:n2e},Qke={tokenize:r2e},Zke={tokenize:i2e},Jke={tokenize:s2e};function e2e(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&nl(t,0,t.length,n),t}function t2e(t,e){let n=t.length,r=0,i,s,o,a;for(;n--;)if(i=t[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},u={type:"label",start:{...t[s][1].start},end:{...t[o][1].end}},d={type:"labelText",start:{...t[s+r+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",l,e],["enter",u,e]],a=Mo(a,t.slice(s+1,s+r+3)),a=Mo(a,[["enter",d,e]]),a=Mo(a,kN(e.parser.constructs.insideSpan.null,t.slice(s+r+4,o-3),e)),a=Mo(a,[["exit",d,e],t[o-2],t[o-1],["exit",u,e]]),a=Mo(a,t.slice(o+1)),a=Mo(a,[["exit",l,e]]),nl(t,s,t.length,a),t}function n2e(t,e,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(h){return s?s._inactive?f(h):(o=r.parser.defined.includes(lh(r.sliceSerialize({start:s.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelEnd"),l):n(h)}function l(h){return h===40?t.attempt(Qke,d,o?d:f)(h):h===91?t.attempt(Zke,d,o?u:f)(h):o?d(h):f(h)}function u(h){return t.attempt(Jke,d,f)(h)}function d(h){return e(h)}function f(h){return s._balanced=!0,n(h)}}function r2e(t,e,n){return r;function r(f){return t.enter("resource"),t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),i}function i(f){return Ks(f)?jm(t,s)(f):s(f)}function s(f){return f===41?d(f):b9(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return Ks(f)?jm(t,l)(f):d(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?v9(t,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Ks(f)?jm(t,d)(f):d(f)}function d(f){return f===41?(t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),t.exit("resource"),e):n(f)}}function i2e(t,e,n){const r=this;return i;function i(a){return y9.call(r,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(lh(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function s2e(t,e,n){return r;function r(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):n(s)}}const o2e={name:"labelStartImage",resolveAll:SN.resolveAll,tokenize:a2e};function a2e(t,e,n){const r=this;return i;function i(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),s}function s(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):e(a)}}const l2e={name:"labelStartLink",resolveAll:SN.resolveAll,tokenize:c2e};function c2e(t,e,n){const r=this;return i;function i(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):e(o)}}const I2={name:"lineEnding",tokenize:u2e};function u2e(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),Pr(t,e,"linePrefix")}}const Iy={name:"thematicBreak",tokenize:d2e};function d2e(t,e,n){let r=0,i;return s;function s(u){return t.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(t.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Tn(u))?(t.exit("thematicBreak"),e(u)):n(u)}function l(u){return u===i?(t.consume(u),r++,l):(t.exit("thematicBreakSequence"),ur(u)?Pr(t,a,"whitespace")(u):a(u))}}const $s={continuation:{tokenize:m2e},exit:b2e,name:"list",tokenize:p2e},f2e={partial:!0,tokenize:y2e},h2e={partial:!0,tokenize:g2e};function p2e(t,e,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:s_(m)){if(r.containerState.type||(r.containerState.type=y,t.enter(y,{_container:!0})),y==="listUnordered")return t.enter("listItemPrefix"),m===42||m===45?t.check(Iy,n,u)(m):u(m);if(!r.interrupt||m===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(m)}return n(m)}function l(m){return s_(m)&&++o<10?(t.consume(m),l):(!r.interrupt||o<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(t.exit("listItemValue"),u(m)):n(m)}function u(m){return t.enter("listItemMarker"),t.consume(m),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,t.check(Ux,r.interrupt?n:d,t.attempt(f2e,h,f))}
vendor: 5,407 bytes, line 1066
1066function d(m){return r.containerState.initialBlankLine=!0,s++,h(m)}function f(m){return ur(m)?(t.enter("listItemPrefixWhitespace"),t.consume(m),t.exit("listItemPrefixWhitespace"),h):n(m)}function h(m){return r.containerState.size=s+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(m)}}function m2e(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(Ux,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Pr(t,e,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!ur(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(h2e,e,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Pr(t,t.attempt($s,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function g2e(t,e,n){const r=this;return Pr(t,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(s):n(s)}}function b2e(t){t.exit(this.containerState.type)}function y2e(t,e,n){const r=this;return Pr(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!ur(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}const o4={name:"setextUnderline",resolveTo:v2e,tokenize:x2e};function v2e(t,e){let n=t.length,r,i,s;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!s&&t[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",s?(t.splice(i,0,["enter",o,e]),t.splice(s+1,0,["exit",t[r][1],e]),t[r][1].end={...t[s][1].end}):t[r][1]=o,t.push(["exit",o,e]),t}function x2e(t,e,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(t.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return t.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(t.consume(u),a):(t.exit("setextHeadingLineSequence"),ur(u)?Pr(t,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Tn(u)?(t.exit("setextHeadingLine"),e(u)):n(u)}}const w2e={tokenize:k2e};function k2e(t){const e=this,n=t.attempt(Ux,r,t.attempt(this.parser.constructs.flowInitial,i,Pr(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Nke,i)),"linePrefix")));return n;function r(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const S2e={resolveAll:w9()},C2e=x9("string"),_2e=x9("text");function x9(t){return{resolveAll:w9(t==="text"?E2e:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],s=n.attempt(i,o,a);return o;function o(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const m=f[h];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function w9(t){return e;function e(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return t?t(n,r):n}}function E2e(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const r=t[n-1][1],i=e.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(a=0),a){const u={type:n===t.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(t.splice(n,0,["enter",u,e],["exit",u,e]),n+=2)}n++}return t}const N2e={42:$s,43:$s,45:$s,48:$s,49:$s,50:$s,51:$s,52:$s,53:$s,54:$s,55:$s,56:$s,57:$s,62:h9},I2e={91:Pke},j2e={[-2]:N2,[-1]:N2,32:N2},T2e={35:Dke,42:Iy,45:[o4,Iy],60:Uke,61:o4,95:Iy,96:i4,126:i4},z2e={38:m9,92:p9},P2e={[-5]:I2,[-4]:I2,[-3]:I2,33:o2e,38:m9,42:o_,60:[lke,Yke],91:l2e,92:[Rke,p9],93:SN,95:o_,96:wke},A2e={null:[o_,S2e]},M2e={null:[42,95]},B2e={null:[]},R2e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:M2e,contentInitial:I2e,disable:B2e,document:N2e,flow:T2e,flowInitial:j2e,insideSpan:A2e,string:z2e,text:P2e},Symbol.toStringTag,{value:"Module"}));function O2e(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,c
vendor: 20,776 bytes, lines 1066-1072
1066olumn:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:j(N),check:j(_),consume:S,enter:C,exit:k,interrupt:j(_,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:y,parser:t,previous:null,sliceSerialize:h,sliceStream:m,write:f};let d=e.tokenize.call(u,l);return e.resolveAll&&s.push(e),u;function f(H){return o=Mo(o,H),w(),o[o.length-1]!==null?[]:(T(e,0),u.events=kN(s,u.events,u),u.events)}function h(H,P){return L2e(m(H),P)}function m(H){return D2e(o,H)}function y(){const{_bufferIndex:H,_index:P,line:F,column:I,offset:R}=r;return{_bufferIndex:H,_index:P,line:F,column:I,offset:R}}function g(H){i[H.line]=H.column,V()}function w(){let H;for(;r._index<o.length;){const P=o[r._index];if(typeof P=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<P.length;)v(P.charCodeAt(r._bufferIndex));else v(P)}}function v(H){d=d(H)}function S(H){Tn(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,V()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=H}function C(H,P){const F=P||{};return F.type=H,F.start=y(),u.events.push(["enter",F,u]),a.push(F),F}function k(H){const P=a.pop();return P.end=y(),u.events.push(["exit",P,u]),P}function N(H,P){T(H,P.from)}function _(H,P){P.restore()}function j(H,P){return F;function F(I,R,U){let A,W,D,B;return Array.isArray(I)?$(I):"tokenize"in I?$([I]):L(I);function L(ge){return re;function re(Y){const ne=Y!==null&&ge[Y],be=Y!==null&&ge.null,we=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(be)?be:be?[be]:[]];return $(we)(Y)}}function $(ge){return A=ge,W=0,ge.length===0?U:q(ge[W])}function q(ge){return re;function re(Y){return B=M(),D=ge,ge.partial||(u.currentConstruct=ge),ge.name&&u.parser.constructs.disable.null.includes(ge.name)?ie():ge.tokenize.call(P?Object.assign(Object.create(u),P):u,l,Z,ie)(Y)}}function Z(ge){return H(D,B),R}function ie(ge){return B.restore(),++W<A.length?q(A[W]):U}}}function T(H,P){H.resolveAll&&!s.includes(H)&&s.push(H),H.resolve&&nl(u.events,P,u.events.length-P,H.resolve(u.events.slice(P),u)),H.resolveTo&&(u.events=H.resolveTo(u.events,u))}function M(){const H=y(),P=u.previous,F=u.currentConstruct,I=u.events.length,R=Array.from(a);return{from:I,restore:U};function U(){r=H,u.previous=P,u.currentConstruct=F,u.events.length=I,a=R,V()}}function V(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function D2e(t,e){const n=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let o;if(n===i)o=[t[n].slice(r,s)];else{if(o=t.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(t[i].slice(0,s))}return o}function L2e(t,e){let n=-1;const r=[];let i;for(;++n<t.length;){const s=t[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=` 1067`;break}case-3:{o=`\r 1068`;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function F2e(t){const r={constructs:q1e([R2e,...(t||{}).extensions||[]]),content:i(tke),defined:[],document:i(rke),flow:i(w2e),lazy:{},string:i(C2e),text:i(_2e)};return r;function i(s){return o;function o(a){return O2e(r,s,a)}}}function $2e(t){for(;!g9(t););return t}const a4=/[\0\t\n\r]/g;function U2e(){let t=1,e="",n=!0,r;return i;function i(s,o,a){const l=[];let u,d,f,h,m;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,e="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(a4.lastIndex=f,u=a4.exec(s),h=u&&u.index!==void 0?u.index:s.length,m=s.charCodeAt(h),!u){e=s.slice(f);break}if(m===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(s.slice(f,h)),t+=h-f),m){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:r=!0,t=1}f=h+1}return a&&(r&&l.push(-5),e&&l.push(e),l.push(null)),l}}const V2e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function H2e(t){return t.replace(V2e,G2e)}function G2e(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return f9(n.slice(s?2:1),s?16:10)}return wN(n)||t}const k9={}.hasOwnProperty;function W2e(t,e,n){return typeof e!="string"&&(n=e,e=void 0),q2e(n)($2e(F2e(n).document().write(U2e()(t,e,!0))))}function q2e(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Q),autolinkProtocol:M,autolinkEmail:M,atxHeading:s(pe),blockQuote:s(be),characterEscape:M,characterReference:M,codeFenced:s(we),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(we,o),codeText:s(te,o),codeTextData:M,data:M,codeFlowValue:M,definition:s(fe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(O),hardBreakEscape:s(he),hardBreakTrailing:s(he),htmlFlow:s(le,o),htmlFlowData:M,htmlText:s(le,o),htmlTextData:M,image:s(oe),label:o,link:s(Q),listItem:s(Ne),listItemValue:h,listOrdered:s(de,f),listUnordered:s(de),paragraph:s(Ce),reference:q,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(pe),strong:s(Ae),thematicBreak:s(Se)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:ne,autolinkProtocol:Y,blockQuote:l(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:ge,characterReference:re,codeFenced:l(w),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:V,codeIndented:l(v),codeText:l(R),codeTextData:V,data:V,definition:l(),definitionDestinationString:k,definitionLabelString:S,definitionTitleString:C,emphasis:l(),hardBreakEscape:l(P),hardBreakTrailing:l(P),htmlFlow:l(F),htmlFlowData:V,htmlText:l(I),htmlTextData:V,image:l(A),label:D,labelText:W,lineEnding:H,link:l(U),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Z,resourceDestinationString:B,resourceTitleString:L,resource:$,setextHeading:l(T),setextHeadingLineSequence:j,setextHeadingText:_,strong:l(),thematicBreak:l()}};S9(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(ve){let je={type:"root",children:[]};const Te={stack:[je],tokenStack:[],config:e,enter:a,exit:u,buffer:o,resume:d,data:n},ce=[];let se=-1;for(;++se<ve.length;)if(ve[se][1].type==="listOrdered"||ve[se][1].type==="listUnordered")if(ve[se][0]==="enter")ce.push(se);else{const ye=ce.pop();se=i(ve,ye,se)}for(se=-1;++se<ve.length;){const ye=e[ve[se][0]];k9.call(ye,ve[se][1].type)&&ye[ve[se][1].type].call(Object.assign({sliceSerialize:ve[se][2].sliceSerialize},Te),ve[se][1])}if(Te.tokenStack.length>0){const ye=Te.tokenStack[Te.tokenStack.length-1];(ye[1]||l4).call(Te,void 0,ye[0])}for(je.position={start:bc(ve.length>0?ve[0][1].start:{line:1,column:1,offset:0}),end:bc(ve.length>0?ve[ve.length-2][1].end:{line:1,column:1,offset:0})},se=-1;++se<e.transforms.length;)je=e.transforms[se](je)||je;return je}function i(ve,je,Te){let ce=je-1,se=-1,ye=!1,ke,ze,qe,ot;for(;++ce<=Te;){const Ze=ve[ce];switch(Ze[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ze[0]==="enter"?se++:se--,ot=void 0;break}case"lineEndingBlank":{Ze[0]==="enter"&&(ke&&!ot&&!se&&!qe&&(qe=ce),ot=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ot=void 0}if(!se&&Ze[0]==="enter"&&Ze[1].type==="listItemPrefix"||se===-1&&Ze[0]==="exit"&&(Ze[1].type==="listUnordered"||Ze[1].type==="listOrdered")){if(ke){let _t=ce;for(ze=void 0;_t--;){const tt=ve[_t];if(tt[1].type==="lineEnding"||tt[1].type==="lineEndingBlank"){if(tt[0]==="exit")continue;ze&&(ve[ze][1].type="lineEndingBlank",ye=!0),tt[1].type="lineEnding",ze=_t}else if(!(tt[1].type==="linePrefix"||tt[1].type==="blockQuotePrefix"||tt[1].type==="blockQuotePrefixWhitespace"||tt[1].type==="blockQuoteMarker"||tt[1].type==="listItemIndent"))break}qe&&(!ze||qe<ze)&&(ke._spread=!0),ke.end=Object.assign({},ze?ve[ze][1].start:Ze[1].end),ve.splice(ze||ce,0,["exit",ke,Ze[2]]),ce++,Te++}if(Ze[1].type==="listItemPrefix"){const _t={type:"listItem",_spread:!1,start:Object.assign({},Ze[1].start),end:void 0};ke=_t,ve.splice(ce,0,["enter",_t,Ze[2]]),ce++,Te++,qe=void 0,ot=!0}}}return ve[je][1]._spread=ye,Te}function s(ve,je){return Te;function Te(ce){a.call(this,ve(ce),ce),je&&je.call(this,ce)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(ve,je,Te){this.stack[this.stack.length-1].children.push(ve),this.stack.push(ve),this.tokenStack.push([je,Te||void 0]),ve.position={start:bc(je.start),end:void 0}}function l(ve){return je;function je(Te){ve&&ve.call(this,Te),u.call(this,Te)}}function u(ve,je){const Te=this.stack.pop(),ce=this.tokenStack.pop();if(ce)ce[0].type!==ve.type&&(je?je.call(this,ve,ce[0]):(ce[1]||l4).call(this,ve,ce[0]));else throw new Error("Cannot close `"+ve.type+"` ("+Im({start:ve.start,end:ve.end})+"): itâs not open");Te.position.end=bc(ve.end)}function d(){return G1e(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(ve){if(this.data.expectingFirstListItemValue){const je=this.stack[this.stack.length-2];je.start=Number.parseInt(this.sliceSerialize(ve),10),this.data.expectingFirstListItemValue=void 0}}function m(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.lang=ve}function y(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.meta=ve}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.value=ve.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.value=ve.replace(/(\r?\n|\r)$/g,"")}function S(ve){const je=this.resume(),Te=this.stack[this.stack.length-1];Te.label=je,Te.identifier=lh(this.sliceSerialize(ve)).toLowerCase()}function C(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.title=ve}function k(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.url=ve}function N(ve){const je=this.stack[this.stack.length-1];if(!je.depth){const Te=this.sliceSerialize(ve).length;je.depth=Te}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function j(ve){const je=this.stack[this.stack.length-1];je.depth=this.sliceSerialize(ve).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function M(ve){const Te=this.stack[this.stack.length-1].children;let ce=Te[Te.length-1];(!ce||ce.type!=="text")&&(ce=Ue(),ce.position={start:bc(ve.start),end:void 0},Te.push(ce)),this.stack.push(ce)}function V(ve){const je=this.stack.pop();je.value+=this.sliceSerialize(ve),je.position.end=bc(ve.end)}function H(ve){const je=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Te=je.children[je.children.length-1];Te.position.end=bc(ve.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(je.type)&&(M.call(this,ve),V.call(this,ve))}function P(){this.data.atHardBreak=!0}function F(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.value=ve}function I(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.value=ve}function R(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.value=ve}function U(){const ve=this.stack[this.stack.length-1];if(this.data.inReference){const je=this.data.referenceType||"shortcut";ve.type+="Reference",ve.referenceType=je,delete ve.url,delete ve.title}else delete ve.identifier,delete ve.label;this.data.referenceType=void 0}function A(){const ve=this.stack[this.stack.length-1];if(this.data.inReference){const je=this.data.referenceType||"shortcut";ve.type+="Reference",ve.referenceType=je,delete ve.url,delete ve.title}else delete ve.identifier,delete ve.label;this.data.referenceType=void 0}function W(ve){const je=this.sliceSerialize(ve),Te=this.stack[this.stack.length-2];Te.label=H2e(je),Te.identifier=lh(je).toLowerCase()}function D(){const ve=this.stack[this.stack.length-1],je=this.resume(),Te=this.stack[this.stack.length-1];if(this.data.inReference=!0,Te.type==="link"){const ce=ve.children;Te.children=ce}else Te.alt=je}function B(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.url=ve}function L(){const ve=this.resume(),je=this.stack[this.stack.length-1];je.title=ve}function $(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function Z(ve){const je=this.resume(),Te=this.stack[this.stack.length-1];Te.label=je,Te.identifier=lh(this.sliceSerialize(ve)).toLowerCase(),this.data.referenceType="full"}function ie(ve){this.data.characterReferenceType=ve.type}function ge(ve){const je=this.sliceSerialize(ve),Te=this.data.characterReferenceType;let ce;Te?(ce=f9(je,Te==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ce=wN(je);const se=this.stack[this.stack.length-1];se.value+=ce}function re(ve){const je=this.stack.pop();je.position.end=bc(ve.end)}function Y(ve){V.call(this,ve);const je=this.stack[this.stack.length-1];je.url=this.sliceSerialize(ve)}function ne(ve){V.call(this,ve);const je=this.stack[this.stack.length-1];je.url="mailto:"+this.sliceSerialize(ve)}function be(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function te(){return{type:"inlineCode",value:""}}function fe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function O(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function he(){return{type:"break"}}function le(){return{type:"html",value:""}}function oe(){return{type:"image",title:null,url:"",alt:null}}function Q(){return{type:"link",title:null,url:"",children:[]}}function de(ve){return{type:"list",ordered:ve.type==="listOrdered",start:null,spread:ve._spread,children:[]}}function Ne(ve){return{type:"listItem",spread:ve._spread,checked:null,children:[]}}function Ce(){return{type:"paragraph",children:[]}}function Ae(){return{type:"strong",children:[]}}function Ue(){return{type:"text",value:""}}function Se(){return{type:"thematicBreak"}}}function bc(t){return{line:t.line,column:t.column,offset:t.offset}}function S9(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?S9(t,r):K2e(t,r)}}function K2e(t,e){let n;for(n in e)if(k9.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function l4(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Im({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Im({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Im({start:e.start,end:e.end})+") is still open")}function Y2e(t){const e=this;e.parser=n;function n(r){return W2e(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function X2e(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function Q2e(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:` 1069`}]}function Z2e(t,e){const n=e.value?e.value+` 1070`:"",r={};e.lang&&(r.className=["language-"+e.lang]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(i.data={meta:e.meta}),t.patch(e,i),i=t.applyData(e,i),i={type:"element",tagName:"pre",properties:{},children:[i]},t.patch(e,i),i}function J2e(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function eSe(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function tSe(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),i=rp(r.toLowerCase()),s=t.footnoteOrder.indexOf(r);let o,a=t.footnoteCounts.get(r);a===void 0?(a=0,t.footnoteOrder.push(r),o=t.footnoteOrder.length):o=s+1,a+=1,t.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};t.patch(e,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,u),t.applyData(e,u)}function nSe(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function rSe(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function C9(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function iSe(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return C9(t,e);const i={src:rp(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,s),t.applyData(e,s)}function sSe(t,e){const n={src:rp(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function oSe(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function aSe(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return C9(t,e);const i={href:rp(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function lSe(t,e){const n={href:rp(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function cSe(t,e,n){const r=t.all(e),i=n?uSe(n):_9(e),s={},o=[];if(typeof e.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const d=r[a];(i||a!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:` 1071`}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:` 1072`});const u={type:"element",tagName:"li",properties:s,children:o};return t.patch(e,u),t.applyData(e,u)}function uSe(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=_9(n[r])}return e}function _9(t){const e=t.spread;return e??t.children.length>1}function dSe(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,s),t.applyData(e,s)}function fSe(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function hSe(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function pSe(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function mSe(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=bN(e.children[1]),l=s9(e.children[e.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{}
vendor: 6,233 bytes, lines 1072-1073
1072,children:t.wrap(i,!0)};return t.patch(e,s),t.applyData(e,s)}function gSe(t,e,n){const r=n?n.children:void 0,s=(r?r.indexOf(e):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:e.children.length;let l=-1;const u=[];for(;++l<a;){const f=e.children[l],h={},m=o?o[l]:void 0;m&&(h.align=m);let y={type:"element",tagName:s,properties:h,children:[]};f&&(y.children=t.all(f),t.patch(f,y),y=t.applyData(f,y)),u.push(y)}const d={type:"element",tagName:"tr",properties:{},children:t.wrap(u,!0)};return t.patch(e,d),t.applyData(e,d)}function bSe(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const c4=9,u4=32;function ySe(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const s=[];for(;r;)s.push(d4(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return s.push(d4(e.slice(i),i>0,!1)),s.join("")}function d4(t,e,n){let r=0,i=t.length;if(e){let s=t.codePointAt(r);for(;s===c4||s===u4;)r++,s=t.codePointAt(r)}if(n){let s=t.codePointAt(i-1);for(;s===c4||s===u4;)i--,s=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function vSe(t,e){const n={type:"text",value:ySe(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function xSe(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const wSe={blockquote:X2e,break:Q2e,code:Z2e,delete:J2e,emphasis:eSe,footnoteReference:tSe,heading:nSe,html:rSe,imageReference:iSe,image:sSe,inlineCode:oSe,linkReference:aSe,link:lSe,listItem:cSe,list:dSe,paragraph:fSe,root:hSe,strong:pSe,table:mSe,tableCell:bSe,tableRow:gSe,text:vSe,thematicBreak:xSe,toml:Wb,yaml:Wb,definition:Wb,footnoteDefinition:Wb};function Wb(){}const E9=-1,Vx=0,Tm=1,Pv=2,CN=3,_N=4,EN=5,NN=6,N9=7,I9=8,f4=typeof self=="object"?self:globalThis,kSe=(t,e)=>{const n=(i,s)=>(t.set(s,i),i),r=i=>{if(t.has(i))return t.get(i);const[s,o]=e[i];switch(s){case Vx:case E9:return n(o,i);case Tm:{const a=n([],i);for(const l of o)a.push(r(l));return a}case Pv:{const a=n({},i);for(const[l,u]of o)a[r(l)]=r(u);return a}case CN:return n(new Date(o),i);case _N:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case EN:{const a=n(new Map,i);for(const[l,u]of o)a.set(r(l),r(u));return a}case NN:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case N9:{const{name:a,message:l}=o;return n(new f4[a](l),i)}case I9:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new f4[s](o),i)};return r},h4=t=>kSe(new Map,t)(0),kf="",{toString:SSe}={},{keys:CSe}=Object,Kp=t=>{const e=typeof t;if(e!=="object"||!t)return[Vx,e];const n=SSe.call(t).slice(8,-1);switch(n){case"Array":return[Tm,kf];case"Object":return[Pv,kf];case"Date":return[CN,kf];case"RegExp":return[_N,kf];case"Map":return[EN,kf];case"Set":return[NN,kf];case"DataView":return[Tm,n]}return n.includes("Array")?[Tm,n]:n.includes("Error")?[N9,n]:[Pv,n]},qb=([t,e])=>t===Vx&&(e==="function"||e==="symbol"),_Se=(t,e,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Kp(o);switch(a){case Vx:{let d=o;switch(l){case"bigint":a=I9,d=o.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([E9],o)}return i([a,d],o)}case Tm:{if(l){let h=o;return l==="DataView"?h=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(o)),i([l,[...h]],o)}const d=[],f=i([a,d],o);for(const h of o)d.push(s(h));return f}case Pv:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(e&&"toJSON"in o)return s(o.toJSON());const d=[],f=i([a,d],o);for(const h of CSe(o))(t||!qb(Kp(o[h])))&&d.push([s(h),s(o[h])]);return f}case CN:return i([a,o.toISOString()],o);case _N:{const{source:d,flags:f}=o;return i([a,{source:d,flags:f}],o)}case EN:{const d=[],f=i([a,d],o);for(const[h,m]of o)(t||!(qb(Kp(h))||qb(Kp(m))))&&d.push([s(h),s(m)]);return f}case NN:{const d=[],f=i([a,d],o);for(const h of o)(t||!qb(Kp(h)))&&d.push(s(h));return f}}const{message:u}=o;return i([a,{name:l,message:u}],o)};return s},p4=(t,{json:e,lossy:n}={})=>{const r=[];return _Se(!(e||n),!!e,new Map,r)(t),r},Av=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?h4(p4(t,e)):structuredClone(t):(t,e)=>h4(p4(t,e));function ESe(t,e){const n=[{type:"text",value:"â©"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function NSe(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function ISe(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||ESe,r=t.options.footnoteBackLabel||NSe,i=t.options.footnoteLabel||"Footnotes",s=t.options.footnoteLabelTagName||"h2",o=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<t.footnoteOrder.length;){const u=t.footnoteById.get(t.footnoteOrder[l]);if(!u)continue;const d=t.all(u),f=String(u.identifier).toUpperCase(),h=rp(f.toLowerCase());let m=0;const y=[],g=t.footnoteCounts.get(f);for(;g!==void 0&&++m<=g;){y.length>0&&y.push({type:"text",value:" "});let S=typeof n=="string"?n:n(l,m);typeof S=="string"&&(S={type:"text",value:S}),y.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+h+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,m),className:["data-footnote-backref"]},children:Array.isArray(S)?S:[S]})}const w=d[d.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const S=w.children[w.children.length-1];S&&S.type==="text"?S.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...y)}else d.push(...y);const v={type:"element",tagName:"li",properties:{id:e+"fn-"+h},children:t.wrap(d,!0)};t.patch(u,v),a.push(v)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Av(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` 1073`},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)}
vendor: 5,575 bytes, lines 1073-1078
1073,{type:"text",value:` 1074`}]}}const j9=function(t){if(t==null)return PSe;if(typeof t=="function")return Hx(t);if(typeof t=="object")return Array.isArray(t)?jSe(t):TSe(t);if(typeof t=="string")return zSe(t);throw new Error("Expected function, string, or object as test")};function jSe(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=j9(t[n]);return Hx(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function TSe(t){const e=t;return Hx(n);function n(r){const i=r;let s;for(s in t)if(i[s]!==e[s])return!1;return!0}}function zSe(t){return Hx(e);function e(n){return n&&n.type===t}}function Hx(t){return e;function e(n,r,i){return!!(ASe(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function PSe(){return!0}function ASe(t){return t!==null&&typeof t=="object"&&"type"in t}const T9=[],MSe=!0,m4=!1,BSe="skip";function RSe(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const s=j9(i),o=r?-1:1;a(t,void 0,[])();function a(l,u,d){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const m=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return h;function h(){let m=T9,y,g,w;if((!e||s(l,u,d[d.length-1]||void 0))&&(m=OSe(n(l,d)),m[0]===m4))return m;if("children"in l&&l.children){const v=l;if(v.children&&m[0]!==BSe)for(g=(r?v.children.length:-1)+o,w=d.concat(v);g>-1&&g<v.children.length;){const S=v.children[g];if(y=a(S,g,w)(),y[0]===m4)return y;g=typeof y[1]=="number"?y[1]:g+o}}return m}}}function OSe(t){return Array.isArray(t)?t:typeof t=="number"?[MSe,t]:t==null?T9:[t]}function z9(t,e,n,r){let i,s,o;typeof e=="function"?(s=void 0,o=e,i=n):(s=e,o=n,i=r),RSe(t,s,a,i);function a(l,u){const d=u[u.length-1],f=d?d.children.indexOf(l):void 0;return o(l,f,d)}}const a_={}.hasOwnProperty,DSe={};function LSe(t,e){const n=e||DSe,r=new Map,i=new Map,s=new Map,o={...wSe,...n.handlers},a={all:u,applyData:$Se,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:FSe,wrap:VSe};return z9(t,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,h=String(d.identifier).toUpperCase();f.has(h)||f.set(h,d)}}),a;function l(d,f){const h=d.type,m=a.handlers[h];if(a_.call(a.handlers,h)&&m)return m(a,d,f);if(a.options.passThrough&&a.options.passThrough.includes(h)){if("children"in d){const{children:g,...w}=d,v=Av(w);return v.children=a.all(d),v}return Av(d)}return(a.options.unknownHandler||USe)(a,d,f)}function u(d){const f=[];if("children"in d){const h=d.children;let m=-1;for(;++m<h.length;){const y=a.one(h[m],d);if(y){if(m&&h[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=g4(y.value)),!Array.isArray(y)&&y.type==="element")){const g=y.children[0];g&&g.type==="text"&&(g.value=g4(g.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function FSe(t,e){t.position&&(e.position=S1e(t))}function $Se(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,s=t.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,Av(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function USe(t,e){const n=e.data||{},r="value"in e&&!(a_.call(n,"hProperties")||a_.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function VSe(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:` 1075`});++r<t.length;)r&&n.push({type:"text",value:` 1076`}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:` 1077`}),n}function g4(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function b4(t,e){const n=LSe(t,e),r=n.one(t,void 0),i=ISe(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:` 1078`},i),s}function HSe(t,e){return t&&"run"in t?async function(n,r){const i=b4(n,{file:r,...e});await t.run(i,r)}:function(n,r){return b4(n,{file:r,...t||e})}}function y4(t){if(t)throw t}var j2,v4;function GSe(){if(v4)return j2;v4=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):e.call(u)==="[object Array]"},s=function(u){if(!u||e.call(u)!=="[object Object]")return!1;var d=t.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&t.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!f)return!1;var h;for(h in u);return typeof h>"u"||t.call(u,h)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},a=function(u,d){if(d==="__proto__")if(t.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return j2=function l(){var u,d,f,h,m,y,g=arguments[0],w=1,v=arguments.length,S=!1;for(typeof g=="boolean"&&(S=g,g=arguments[1]||{},w=2),(g==null||typeof g!="object"&&typeof g!="function")&&(g={});w<v;++w)if(u=arguments[w],u!=null)for(d in u)f=a(g,d),h=a(u,d),g!==h&&(S&&h&&(s(h)||(m=i(h)))?(m?(m=!1,y=f&&i(f)?f:[]):y=f&&s(f)?f:{},o(g,{name:d,newValue:l(S,y,h)})):typeof h<"u"&&o(g,{name:d,newValue:h}));return g},j2}var WSe=GSe();const T2=Vo(WSe);function l_(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);
vendor: 17,092 bytes, line 1078
1078return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function qSe(){const t=[],e={run:n,use:r};return e;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...u){const d=t[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,d?KSe(d,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function KSe(t,e){let n;return r;function r(...o){const a=t.length>o.length;let l;a&&o.push(i);try{l=t.apply(this,o)}catch(u){const d=u;if(a&&n)throw d;return i(d)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,e(o,...a))}function s(o){i(null,o)}}const Fa={basename:YSe,dirname:XSe,extname:QSe,join:ZSe,sep:"/"};function YSe(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');X0(t);let n=0,r=-1,i=t.length,s;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let o=-1,a=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(t.codePointAt(i)===e.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=t.length),t.slice(n,r)}function XSe(t){if(X0(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function QSe(t){X0(t);let e=t.length,n=-1,r=0,i=-1,s=0,o;for(;e--;){const a=t.codePointAt(e);if(a===47){if(o){r=e+1;break}continue}n<0&&(o=!0,n=e+1),a===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function ZSe(...t){let e=-1,n;for(;++e<t.length;)X0(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":JSe(n)}function JSe(t){X0(t);const e=t.codePointAt(0)===47;let n=eCe(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function eCe(t,e){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=t.length;){if(o<t.length)a=t.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,o):n=t.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function X0(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const tCe={cwd:nCe};function nCe(){return"/"}function c_(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function rCe(t){if(typeof t=="string")t=new URL(t);else if(!c_(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return iCe(t)}function iCe(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const z2=["history","path","basename","stem","extname","dirname"];class P9{constructor(e){let n;e?c_(e)?n={path:e}:typeof e=="string"||sCe(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":tCe.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<z2.length;){const s=z2[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)z2.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Fa.basename(this.path):void 0}set basename(e){A2(e,"basename"),P2(e,"basename"),this.path=Fa.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Fa.dirname(this.path):void 0}set dirname(e){x4(this.basename,"dirname"),this.path=Fa.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Fa.extname(this.path):void 0}set extname(e){if(P2(e,"extname"),x4(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Fa.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){c_(e)&&(e=rCe(e)),A2(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Fa.basename(this.path,this.extname):void 0}set stem(e){A2(e,"stem"),P2(e,"stem"),this.path=Fa.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){const i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){const i=new bs(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function P2(t,e){if(t&&t.includes(Fa.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Fa.sep+"`")}function A2(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function x4(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function sCe(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const oCe=function(t){const r=this.constructor.prototype,i=r[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},aCe={}.hasOwnProperty;class IN extends oCe{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qSe()}copy(){const e=new IN;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(T2(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(R2("data",this.frozen),this.namespace[e]=n,this):aCe.call(this.namespace,e)&&this.namespace[e]||void 0:e?(R2("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Kb(e),r=this.parser||this.Parser;return M2("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),M2("process",this.parser||this.Parser),B2("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Kb(e),l=r.parse(a);r.run(l,a,function(d,f,h){if(d||!f||!h)return u(d);const m=f,y=r.stringify(m,h);uCe(y)?h.value=y:h.result=y,u(d,h)});function u(d,f){d||!f?o(d):s?s(f):n(void 0,f)}}}processSync(e){let n=!1,r;return this.freeze(),M2("processSync",this.parser||this.Parser),B2("processSync",this.compiler||this.Compiler),this.process(e,i),k4("processSync","process",n),r;function i(s,o){n=!0,y4(s),r=o}}run(e,n,r){w4(e),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=Kb(n);i.run(e,l,u);function u(d,f,h){const m=f||e;d?a(d):o?o(m):r(void 0,m,h)}}}runSync(e,n){let r=!1,i;return this.run(e,n,s),k4("runSync","run",r),i;function s(o,a){y4(o),i=a,r=!0}}stringify(e,n){this.freeze();const r=Kb(n),i=this.compiler||this.Compiler;return B2("stringify",i),w4(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(R2("use",this.frozen),e!=null)if(typeof e=="function")l(e,n);else if(typeof e=="object")Array.isArray(e)?a(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;l(d,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=T2(!0,i.settings,u.settings))}function a(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,d){let f=-1,h=-1;for(;++f<r.length;)if(r[f][0]===u){h=f;break}if(h===-1)r.push([u,...d]);else if(d.length>0){let[m,...y]=d;const g=r[h][1];l_(g)&&l_(m)&&(m=T2(!0,g,m)),r[h]=[u,m,...y]}}}}const lCe=new IN().freeze();function M2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function B2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function R2(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function w4(t){if(!l_(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function k4(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Kb(t){return cCe(t)?t:new P9(t)}function cCe(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function uCe(t){return typeof t=="string"||dCe(t)}function dCe(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const fCe="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",S4=[],C4={allowDangerousHtml:!0},hCe=/^(https?|ircs?|mailto|xmpp)$/i,pCe=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function A9(t){const e=mCe(t),n=gCe(t);return bCe(e.runSync(e.parse(n),n),t)}function mCe(t){const e=t.rehypePlugins||S4,n=t.remarkPlugins||S4,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...C4}:C4;return lCe().use(Y2e).use(n).use(HSe,r).use(e)}function gCe(t){const e=t.children||"",n=new P9;return typeof e=="string"&&(n.value=e),n}function bCe(t,e){const n=e.allowedElements,r=e.allowElement,i=e.components,s=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,l=e.urlTransform||yCe;for(const d of pCe)Object.hasOwn(e,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+fCe+d.id,void 0);return z9(t,u),I1e(t,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return o?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let m;for(m in E2)if(Object.hasOwn(E2,m)&&Object.hasOwn(d.properties,m)){const y=d.properties[m],g=E2[m];(g===null||g.includes(d.tagName))&&(d.properties[m]=l(String(y||""),m,d))}}if(d.type==="element"){let m=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!m&&r&&typeof f=="number"&&(m=!r(d,f,h)),m&&h&&typeof f=="number")return a&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function yCe(t){const e=t.indexOf(":"),n=t.indexOf("?"),r=t.indexOf("#"),i=t.indexOf("/");return e===-1||i!==-1&&e>i||n!==-1&&e>n||r!==-1&&e>r||hCe.test(t.slice(0,e))?t:""}const _4=["You can describe the mood you want - try 'make something happy' or 'create a dark ambient track'","Ask Cai to 'add some reverb' or 'make it more energetic' to modify existing music","Use specific genres like 'make a jazz fusion piece' or 'create a lo-fi hip hop beat'","Try asking for specific instruments: 'add a piano melody' or 'include some synth sounds'","You can request specific tempos: 'make it 120 BPM' or 'slow it down to 80 BPM'","Ask Cai to 'make it longer' or 'add a bridge section' to expand your music","You can ask for specific scales: 'use a minor key' or 'make it in C major'","Try asking Cai to 'create a melody that fits this chord progression'","You can say 'make it sound like [artist name]' for style inspiration","Try 'make it more danceable' or 'create something relaxing' for mood-based requests","You can ask Cai to 'harmonize this melody' or 'add some counterpoint'","Try clicking on the clover icon for an inspiration prompt","You can ask Cai to 'copy this section over twice' or 'delete the pianos and guitars'","Double click anywhere on the canvas to add a new song, media, or note","Press 't' to switch between different chat box views","Chat how you want! Click space to record or send via text","Double click in a song to add a new empty bloob","Press cmd/ctrl + z to undo changes","Press cmd/ctrl + c to copy items that you have selected","You can click on a bloob and press 'R' to record your own midi with your voice or plug in.","You can drag and drop any midi or audio file onto the canvas","Double click on a bloob or press 'd' while selected to edit a bloobs notes","Made a hit? Share it with your friends by pressing cmd/ctrl + e"],E4=["The oldest known musical instrument is a 40,000-year-old flute made from vulture bone","Mozart wrote his first symphony at age 8","The longest recorded song is 'Longplayer' which has been playing since 1999 and will continue until 2999","The piano has 88 keys, but the harpsichord can have up to 5 octaves","The word 'music' comes from the Greek word 'mousike', meaning 'art of the Muses'","Beethoven was completely deaf when he composed his 9th Symphony","The human brain can recognize a song in just 100-400 milliseconds","The world's most expensive violin, the 'Lady Blunt' Stradivarius, sold for $15.9 million","The shortest song ever recorded is 'You Suffer' by Napalm Death, lasting just 1.316 seconds","The first recorded use of the word 'jazz' in music was in 1915","The human voice can produce over 300 different sounds","The oldest surviving complete musical composition is the 'Seikilos Epitaph' from ancient Greece","The world's largest piano is 18 feet long and weighs 1.4 tons","The fastest rapper in the world can speak 11.8 syllables per second","The human ear can distinguish between 400,000 different sounds","The first music video was made in 1894, long before MTV","The longest concert ever performed lasted 639 years and is still ongoing","The human brain processes music in the same areas that process language","The world's most expensive guitar is worth $2.7 million","The first Grammy Awards were held in 1959"],O2=[{question:"What is the most common time signature in popular music?",options:["3/4","4/4","6/8","2/4"],correctAnswer:1,explanation:"4/4 (common time) is the most widely used time signature in popular music, rock, pop, and many other genres."},{question:"Which instrument has the widest range of notes?",options:["Piano","Violin","Organ","Harp"],correctAnswer:2,explanation:"The pipe organ has the widest range of any instrument, spanning from sub-bass to ultra-high frequencies."},{question:"What does 'BPM' stand for in music?",options:["Beats Per Minute","Bass Per Measure","Beat Pattern Mode","Bass Pitch Modulation"],correctAnswer:0,explanation:"BPM stands for Beats Per Minute, which measures the tempo or speed of a piece of music."},{question:"Which musical period came first?",options:["Classical","Baroque","Romantic","Renaissance"],correctAnswer:3,explanation:"The Renaissance peri
1078od (1400-1600) came before Baroque (1600-1750), Classical (1750-1820), and Romantic (1820-1900)."},{question:"What is the term for a group of three notes played in the time of two?",options:["Triplet","Trill","Tremolo","Triad"],correctAnswer:0,explanation:"A triplet is a group of three notes played in the time normally occupied by two notes of the same value."},{question:"Which of these is NOT a type of musical scale?",options:["Major","Minor","Pentatonic","Quadratic"],correctAnswer:3,explanation:"Quadratic is not a musical scale. Major, minor, and pentatonic are all common musical scales."},{question:"What is the highest female singing voice?",options:["Alto","Soprano","Mezzo-soprano","Contralto"],correctAnswer:1,explanation:"Soprano is the highest female singing voice, followed by mezzo-soprano, alto, and contralto."},{question:"Which composer wrote 'The Four Seasons'?",options:["Bach","Vivaldi","Handel","Mozart"],correctAnswer:1,explanation:"Antonio Vivaldi composed 'The Four Seasons' (Le quattro stagioni) in 1723."},{question:"What is a 'crescendo' in music?",options:["Getting louder","Getting softer","Getting faster","Getting slower"],correctAnswer:0,explanation:"A crescendo is a gradual increase in volume, making the music get louder over time."},{question:"Which instrument family does the saxophone belong to?",options:["Brass","Woodwind","String","Percussion"],correctAnswer:1,explanation:"The saxophone belongs to the woodwind family, despite being made of brass, because it uses a reed to produce sound."}],vCe=t=>{const[e,n]=x.useState("tips"),[r,i]=x.useState(0),[s,o]=x.useState(0),[a,l]=x.useState(0),[u,d]=x.useState(null),[f,h]=x.useState(!1),m=x.useRef(null),y=()=>Math.floor(Math.random()*_4.length),g=()=>Math.floor(Math.random()*E4.length),w=()=>Math.floor(Math.random()*O2.length);x.useEffect(()=>{if(t)return i(y()),o(g()),l(w()),d(null),h(!1),m.current=setInterval(()=>{e==="tips"?i(y()):e==="facts"&&o(g())},5e3),()=>{m.current&&clearInterval(m.current)};m.current&&clearInterval(m.current)},[t,e]);const v=k=>{d(k),h(!0),setTimeout(()=>{l(w()),d(null),h(!1)},3e3)},S=()=>{switch(e){case"tips":return _4[r];case"facts":return E4[s];case"quiz":return O2[a];default:return""}},C=()=>e==="quiz"?O2[a]:null;return{activeTab:e,setActiveTab:n,currentContent:S(),currentQuiz:C(),selectedAnswer:u,showExplanation:f,handleQuizAnswer:v,isActive:t}},M9=({isActive:t,onTabChange:e})=>{const{activeTab:n,setActiveTab:r,currentContent:i,currentQuiz:s,selectedAnswer:o,showExplanation:a,handleQuizAnswer:l}=vCe(t),u=h=>{r(h),e==null||e(h)},d=[{type:"tips",label:"Tips",icon:c.jsx(bD,{className:"h-4 w-4"})},{type:"facts",label:"Facts",icon:c.jsx(Mn,{className:"h-4 w-4"})},{type:"quiz",label:"Quiz",icon:c.jsx(dx,{className:"h-4 w-4"})}],f=()=>n==="quiz"&&s?c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-sm font-medium text-zinc-900 dark:text-zinc-100",children:s.question}),c.jsx("div",{className:"space-y-2",children:s.options.map((h,m)=>c.jsxs("button",{onClick:()=>l(m),disabled:o!==null,className:`w-full text-left p-2 rounded-md text-sm transition-all duration-200 ${o===m?m===s.correctAnswer?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border border-green-300 dark:border-green-700":"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 border border-red-300 dark:border-red-700":o!==null&&m===s.correctAnswer?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border border-green-300 dark:border-green-700":"bg-zinc-100 dark:bg-zinc-800/50 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-200 dark:hover:bg-zinc-700/50 border border-transparent"}`,children:[String.fromCharCode(65+m),". ",h]},m))}),a&&c.jsxs("div",{className:"mt-3 p-2 bg-blue-50 dark:bg-blue-900/20 rounded-md border border-blue-200 dark:border-blue-800",children:[c.jsx("div",{className:"text-xs font-medium text-blue-800 dark:text-blue-200 mb-1",children:"Explanation:"}),c.jsx("div",{className:"text-xs text-blue-700 dark:text-blue-300",children:s.explanation})]})]}):c.jsx("div",{className:"text-sm italic text-zinc-900 dark:text-zinc-100",children:typeof i=="string"?i:""});return c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsx("div",{className:"flex space-x-1 mb-3",children:d.map(h=>c.jsxs("button",{onClick:()=>u(h.type),className:`flex items-center space-x-1 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-200 ${n===h.type?"bg-white/80 dark:bg-white/20 text-zinc-900 dark:text-zinc-100 shadow-sm":"text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:bg-white/40 dark:hover:bg-white/10"}`,children:[h.icon,c.jsx("span",{children:h.label})]}
1078,h.type))}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:f()})]})},B9=()=>c.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none"},children:[c.jsx("line",{x1:"6",y1:"14",x2:"6",y2:"10",strokeWidth:"1.5",style:{pointerEvents:"none"}}),c.jsx("line",{x1:"9",y1:"17",x2:"9",y2:"7",strokeWidth:"1.5",style:{pointerEvents:"none"}}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"6",strokeWidth:"1.5",style:{pointerEvents:"none"}}),c.jsx("line",{x1:"15",y1:"17",x2:"15",y2:"7",strokeWidth:"1.5",style:{pointerEvents:"none"}}),c.jsx("line",{x1:"18",y1:"14",x2:"18",y2:"10",strokeWidth:"1.5",style:{pointerEvents:"none"}})]}),xCe=(t,e)=>{const[n,r]=x.useState(()=>Math.min(99,(Date.now()-t)/1e3/e*99));return x.useEffect(()=>{const i=setInterval(()=>{const s=(Date.now()-t)/1e3;if(s>=e){r(99);return}const o=Math.min(99,s/e*99);r(o)},100);return()=>clearInterval(i)},[t,e]),n},wCe="6rem",kCe="1.25rem";function SCe(t,e,n){if(t==="global"&&e===0)return"Global";if(t==="song"){const r=n.getSongById(e);return(r==null?void 0:r.label)!=null?`Song: ${r.label}`:`Song ${e}`}if(t==="text"){const r=n.getTextNodeName(e);return r?`Text: ${r}`:`Text ${e}`}if(t==="embedding"){const r=n.getEmbeddingNodeName(e);return r?`Embedding: ${r}`:`Embedding ${e}`}if(t==="visual"){const r=n.getVisualMediaNodeName(e);return r?`Visual: ${r}`:`Visual ${e}`}return`${t} ${e}`}const Mv=({item:t,onCancel:e})=>{const{requestId:n,objectType:r,objectId:i,userMessagePreview:s,startedAt:o,progressDurationSec:a}=t,[l,u]=x.useState(!1),d=xCe(o,a),{getSongById:f,getTextNodeName:h,getEmbeddingNodeName:m,getVisualMediaNodeName:y}=mn(),g=x.useMemo(()=>SCe(r,i,{getSongById:f,getTextNodeName:h,getEmbeddingNodeName:m,getVisualMediaNodeName:y}),[r,i,f,h,m,y]),w=s??"â¦",v=w.length>0;return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-1.5",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-xs text-zinc-600 dark:text-zinc-400 truncate",title:g,children:g}),c.jsx("div",{className:`text-xs text-zinc-700 dark:text-zinc-300 overflow-hidden transition-[max-height] duration-200 ease-out ${l&&v?"overflow-y-auto":""}`,style:{maxHeight:l&&v?wCe:kCe},title:w,children:c.jsx("span",{className:`whitespace-pre-wrap break-words block ${l&&v?"":"line-clamp-1"}`,children:w})})]}),c.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&c.jsx("button",{type:"button",onClick:()=>e(n),className:"p-0.5 rounded text-zinc-500 dark:text-zinc-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-100/80 dark:hover:bg-red-900/30","aria-label":"Cancel this request",title:"Cancel this request",children:c.jsx(nr,{size:14})}),v&&c.jsx("button",{type:"button",onClick:()=>u(S=>!S),className:"shrink-0 p-0.5 rounded text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 hover:bg-zinc-200/50 dark:hover:bg-zinc-600/50","aria-expanded":l,"aria-label":l?"Collapse full request":"View full request",title:l?"Collapse":"View full request",children:l?c.jsx(j0,{size:14}):c.jsx(Vi,{size:14})})]})]}),c.jsx(fF,{progress:d,variant:"gradient",showPercentage:!1,className:"h-2"})]})};function R9(){const[t,e]=x.useState(null);return x.useEffect(()=>{let n=!1;return dd().then(r=>{!n&&(r!=null&&r.id)&&e(r.id)}).catch(()=>{n||e(null)}),()=>{n=!0}},[]),t}function O9(t){return t.split(/(@cai)/gi).map((n,r)=>/^@cai$/i.test(n)?c.jsx("span",{className:"font-bold text-blue-600 dark:text-blue-400",children:n},r):c.jsx(mr.Fragment,{children:n},r))}const N4=t=>{const e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`},CCe=t=>{const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=(r.getTime()-i.getTime())/(24*60*60*1e3);if(s===0)return"Today";if(s===1)return"Yesterday";const o=e.getFullYear()!==n.getFullYear();return e.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",...o?{year:"numeric"}:{}})},_Ce=({usage:t,onSubscriptionModalOpen:e})=>
1078{if(!t)return c.jsx("button",{type:"button",className:"p-2 rounded-md transition-all duration-200 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0","aria-label":"Loading Takes",title:"Loading Takes",onClick:e,children:c.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-zinc-600 dark:border-zinc-400"})});const n=t.takes_quota-t.takes_used,r=(t.takes_quota-n)/t.takes_quota*100;let i="p-2 rounded-md transition-all duration-200 text-xs font-semibold hover:scale-110 focus:outline-none focus:ring-0 focus:border-0";r>=90?i+=" text-red-500 hover:text-red-700 dark:hover:text-red-300":r>=75?i+=" text-yellow-500 hover:text-yellow-700 dark:hover:text-yellow-300":i+=" text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100";const s=n>999?"999+":n,o=n>999?{fontSize:"9px"}:{};return c.jsx("button",{type:"button",className:i,"aria-label":`${n} Takes remaining`,title:`${n} Takes remaining`,onClick:e,children:c.jsx("span",{style:o,children:s})})},ECe=({chatTitle:t,awaitingResponse:e,canSendAgenticRequest:n=!0,inFlightCount:r=0,inFlightRequests:i=[],userMessage:s,onUserMessageChange:o,onKeyPress:a,onSubmit:l,onCancelRequest:u,onCancelRequestById:d,onMinimize:f,isRecording:h,setIsRecording:m,handleRandomQueryGeneration:y,replyTo:g,onReplyToMessage:w,onClearReply:v})=>{var q;const{currentThread:S}=xd(),C=S,{selectedSingleCaiObject:k,selectedCaiObjects:N}=Yn(),{getBloobById:_}=mn(),j=(()=>{if(!k)return"";switch(k.type){case J.Song:return`song:${k.id}`;case J.Bloob:{const Z=_(k.id);return Z?`song:${Z.songId}`:""}case J.TextNode:return`text_node:${k.id}`;case J.EmbeddingNode:return`embedding_node:${k.id}`;case J.VisualMediaNode:return`visual_node:${k.id}`;default:return""}})()||(()=>{if(N.length===0)return"";const Z=N.filter(re=>re.type===J.Bloob).map(re=>re.id);if(Z.length!==N.length)return"";const ie=_(Z[0]);return ie&&Z.every(re=>{const Y=_(re);return(Y==null?void 0:Y.songId)===ie.songId})?`song:${ie.songId}`:""})(),T=Vr(j||"global"),M=R9(),V=x.useRef(null),H=Ix(),P=x.useRef(null),F=x.useRef(e),[I,R]=x.useState(!1),{setCaiChatState:U}=cr(),[A,W]=x.useState("tips"),D=((q=C==null?void 0:C.content)==null?void 0:q.messages)??[];x.useEffect(()=>{P.current&&(P.current.scrollTop=P.current.scrollHeight)},[]),x.useEffect(()=>{P.current&&(F.current&&!e?P.current.scrollTo({top:P.current.scrollHeight,behavior:"smooth"}):P.current.scrollTop=P.current.scrollHeight)},[e,C]),x.useEffect(()=>{F.current&&!e&&o({target:{value:""}}),F.current=e},[e,o]),x.useEffect(()=>{if(V.current){V.current.style.height="auto";const Z=V.current.scrollHeight,ie=120;V.current.style.height=Math.min(Z,ie)+"px"}},[s]);const B=Z=>{if(Z.key==="Enter"&&!Z.shiftKey){Z.preventDefault(),Z.stopPropagation(),s.trim()&&n&&l(s);return}a(Z)},L=Z=>{Z&&(Z.preventDefault(),Z.stopPropagation()),s.trim()&&n&&l(s)},$=()=>{m(!h)};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"border-b border-zinc-200 dark:border-zinc-800 relative overflow-hidden w-full",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-100/75 to-zinc-175/75 dark:from-zinc-800/75 dark:to-zinc-900/75"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-200/30 via-zinc-150/30 to-zinc-300/30 dark:from-zinc-800/30 dark:via-zinc-750/30 dark:to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsx("div",{className:"relative z-10 p-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex items-center gap-2 max-w-[65%]",children:c.jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/20 dark:bg-white/10 backdrop-blur-sm border border-white/20 dark:border-white/10 w-full",children:c.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-200 truncate font-medium overflow-ellipsis block w-full",title:t,"aria-label":`Chat title: ${t}`,children:t})})}),c.jsxs("div",{className:"flex items-center gap-0.5 max-w-[35%]",children:[c.jsx("button",{onClick:()=>{U(zn.MINIMIZED)},className:"p-2 rounded-md transition-all duration-200 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0","aria-label":"Voice mode",title:"Voice mode",children:c.jsx(B9,{})}),c.jsx("button",{onClick:f,className:"p-2 rounded-md transition-all duration-200 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0","aria-label":"Minimize chat",title:"Minimize chat",children:c.jsx(SD,{size:16})})]})]})})]}),c.jsx("div",{ref:P,className:"flex-1 overflow-y-auto px-4 py-2 space-y-4 select-text",children:D.map((Z,ie)=>{var O;if(!Z.body||Z.body.trim().length===0)return null;const re=D[ie-1],Y=ie===0||!re||N4(re.timestamp)!==N4(Z.timestamp),ne=Z.authorDisplayName??(Z.role==="cai"?"Cai":"User"),be=new Date(Z.timestamp).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),we=Z.role==="user"&&(Z.authorId==null||M!=null&&Z.authorId===M),te=Z.inReplyToId?(((O=C==null?void 0:C.content)==null?void 0:O.messages)??[]).find(pe=>pe.id===Z.inReplyToId):null,fe=pe=>pe.length>50?pe.slice(0,50).trim()+"â¦":pe;return c.jsxs(mr.Fragment,{children:[Y&&c.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[c.jsx("div",{className:"h-px flex-1 bg-zinc-200 dark:bg-zinc-700"}),c.jsx("span",{className:"text-[11px] uppercase tracking-wide text-zinc-500 dark:text-zinc-400",children:CCe(Z.timestamp)}),c.jsx("div",{className:"h-px flex-1 bg-zinc-200 dark:bg-zinc-700"})]}),c.jsx("div",{className:"space-y-1 group",children:c.jsxs("div",{className:`flex flex-col ${we?"items-end":"items-start"}`,children:[c.jsxs("div",{className:`flex items-center gap-1 w-full max-w-full px-1 ${we?"justify-end":""}`,children:[T&&we&&c.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 transition-opacity","aria-label":"Reply",t
1078itle:"Reply",onClick:()=>w(Z.id,fe(Z.body)),children:c.jsx(Xf,{size:12})}),c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400 py-1",children:we?be:`${ne} · ${be}`}),T&&!we&&c.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 transition-opacity","aria-label":"Reply",title:"Reply",onClick:()=>w(Z.id,fe(Z.body)),children:c.jsx(Xf,{size:12})})]}),te&&c.jsxs("div",{className:`text-xs text-zinc-500 dark:text-zinc-400 mb-0.5 px-2 py-1 rounded border-l-2 border-zinc-300 dark:border-zinc-600 max-w-full ${we?"mr-0 ml-auto":""}`,style:{maxWidth:"100%"},children:["Replying to ",te.authorDisplayName??(te.role==="cai"?"Cai":"User"),": ",fe(te.body)]}),c.jsx("div",{className:`rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 mb-1 select-text max-w-full ${we?"bg-caiBlue-100 dark:bg-caiBlue-500":"bg-zinc-200 dark:bg-zinc-800"}`,children:Z.role==="cai"?c.jsx(A9,{children:Z.body}):O9(Z.body)})]})})]},Z.id)})}),c.jsx("div",{className:`px-4 border-none overflow-hidden transition-all duration-[1000ms] ease-in-out ${r>0?"py-3 opacity-100 max-h-96":"py-0 opacity-0 max-h-0"}`,children:c.jsx("div",{className:`bg-gradient-to-r from-caiGreen-100 to-caiBlue-100 dark:from-caiGreen-700/20 dark:to-caiBlue-700/20 rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 mb-1 w-full overflow-y-auto transition-all duration-500 ease-in-out ${A==="quiz"?"h-60":"h-[100px]"}`,children:c.jsx(M9,{isActive:r>0,onTabChange:W})})}),r>0&&c.jsx("div",{className:"px-4 pt-2 pb-4 border-t border-zinc-200/50 dark:border-zinc-700/50",children:c.jsxs("div",{className:"bg-gradient-to-r from-caiGreen-100 to-caiBlue-100 dark:from-caiGreen-700/20 dark:to-caiBlue-700/20 rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100",children:[c.jsxs("button",{type:"button",onClick:()=>R(Z=>!Z),className:"w-full flex items-center justify-between gap-2 rounded-lg py-2 text-left transition-colors","aria-expanded":I,"aria-label":I?"Hide progress bars":"Show progress bars",children:[c.jsxs("span",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-300",children:[r," request",r!==1?"s":""," processing"]}),I?c.jsx(j0,{size:18,className:"text-zinc-500 dark:text-zinc-400 shrink-0"}):c.jsx(Vi,{size:18,className:"text-zinc-500 dark:text-zinc-400 shrink-0"})]}),c.jsx("div",{className:"grid max-h-[500px] transition-[grid-template-rows] duration-300 ease-in-out",style:{gridTemplateRows:I&&i.length>0?"1fr":"0fr"},children:c.jsx("div",{className:"min-h-0 overflow-y-auto",children:c.jsx("div",{className:"mt-2 space-y-4 pr-0.5",children:i.map(Z=>c.jsx(Mv,{item:Z,onCancel:d},Z.requestId))})})})]})}),c.jsxs("div",{className:"border-t border-zinc-200 dark:border-zinc-800 sticky bottom-0 overflow-hidden",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-100/75 to-zinc-175/75 dark:from-zinc-800/75 dark:to-zinc-900/75"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-200/30 via-zinc-150/30 to-zinc-300/30 dark:from-zinc-800/30 dark:via-zinc-750/30 dark:to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsxs("div",{className:"relative z-10 p-4",children:[g&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1.5 rounded-lg bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700",children:[c.jsx(Xf,{size:14,className:"text-zinc-500 dark:text-zinc-400 shrink-0"}),c.jsxs("span",{className:"text-xs text-zinc-600 dark:text-zinc-300 truncate flex-1 min-w-0",children:["Replying to: ",g.snippet]}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400","aria-label":"Cancel reply",onClick:v,children:c.jsx(nr,{size:14})})]}),c.jsx("div",{style:{minHeight:"80px"},className:"mb-2",children:h?c.jsx("div",{style:{height:"80px",display:"flex",alignItems:"center"},children:c.jsx(zv,{minimized:!1,isRecording:h})}):c.jsxs("div",{className:"relative",children:[!T&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic mb-1",children:"View only â you cannot send messages"}
1078),c.jsx("textarea",{id:"cai-chat-expanded-input",ref:V,value:s,onChange:o,onKeyPress:B,className:"w-full rounded-lg border border-zinc-300/40 dark:border-zinc-700/40 bg-white/80 dark:bg-zinc-800/80 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 focus:outline-none focus:ring-1 focus:ring-caiGreen-300 disabled:opacity-50 resize-none overflow-hidden backdrop-blur-sm relative z-10",placeholder:"Ask me anything...",disabled:h||!T,style:{minHeight:"80px"}}),c.jsx("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-b from-white/20 to-transparent dark:from-white/5 pointer-events-none"})]})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_Ce,{usage:H,onSubscriptionModalOpen:$0}),c.jsx("button",{type:"button",disabled:!n||!T,className:`p-2 rounded-md transition-all duration-200 focus:outline-none focus:ring-0 focus:border-0 ${!n||!T?"text-zinc-400 dark:text-zinc-600 cursor-not-allowed":"text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110"}`,"aria-label":"Need inspiration?",title:"Need inspiration?",onClick:y,children:c.jsx(fx,{size:16})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:`p-2 rounded-md transition-all duration-200 focus:outline-none focus:ring-0 focus:border-0 ${h?"bg-red-500 text-white hover:bg-red-600 hover:scale-110 animate-pulse":!n||!T?"text-zinc-400 dark:text-zinc-600 cursor-not-allowed":"text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110"}`,"aria-label":h?"Stop recording":"Start recording",title:h?"Stop recording":"Start recording",onClick:$,disabled:!n||!T,children:c.jsx(Rc,{size:16})}),c.jsx("button",{type:"button",className:`rounded-md p-2 transition-all duration-200 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0 1079 ${s.trim()&&n?"bg-caiGreen-500 hover:bg-caiGreen-600 text-white":e?"bg-red-500 hover:bg-red-600 text-white":"bg-transparent text-zinc-400 dark:text-zinc-600 hover:bg-caiGreen-100 dark:hover:bg-caiGreen-700"} 1080 `,disabled:h||!T||!(s.trim()&&n)&&!e,"aria-label":s.trim()&&n?"Send message":e?"Cancel request":"Send message",title:s.trim()&&n?"Send message":e?"Cancel request":"Send message",onClick:s.trim()&&n?L:e?u:void 0,children:s.trim()&&n?c.jsx(Nh,{size:16}):e?c.jsx(nr,{size:16}):c.jsx(Nh,{size:16})})]})]})]})]})]})},I4=t=>{const e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`},NCe=t=>{const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=(r.getTime()-i.getTime())/(24*60*60*1e3);if(s===0)return"Today";if(s===1)return"Yesterday";const o=e.getFullYear()!==n.getFullYear();return e.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",...o?{year:"numeric"}:{}})},ICe=({usage:t,onSubscriptionModalOpen:e})=>{if(!t)return c.jsx("button",{type:"button",className:"p-2 rounded-md transition-all duration-200 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0","aria-label":"Loading Takes",title:"Loading Takes",onClick:e,children:c.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-zinc-600 dark:border-zinc-400"})});const n=t.takes_quota-t.takes_used,r=(t.takes_quota-n)/t.takes_quota*100;let i="p-2 rounded-md transition-all duration-200 text-xs font-semibold hover:scale-110 focus:outline-none focus:ring-0 focus:border-0";r>=90?i+=" text-red-500 hover:text-red-700 dark:hover:text-red-300":r>=75?i+=" text-yellow-500 hover:text-yellow-700 dark:hover:text-yellow-300":i+=" text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100";const s=n>999?"999+":n,o=n>999?{fontSize:"9px"}:{};return c.jsx("button",{type:"button",className:i,"aria-label":`${n} Takes remaining`,title:`${n} Takes remaining`,onClick:e,children:c.jsx("span",{style:o,children:s})})},jCe=({chatTitle:t,awaitingResponse:e,canSendAgenticRequest:n=!0,inFlightCount:r=0,inFlightRequests:i=[],userMessage:s,onUserMessageChange:o,onKeyPress:a,onSubmit:l,onCancelRequest:u,onCancelRequestById:d,onMinimize:f,isRecording:h,setIsRecording:m,handleRandomQueryGeneration:y,replyTo:g,onReplyToMessage:w,onClearReply:v})=>{var L;const{currentThread:S}=xd(),C=S,{selectedSingleCaiObject:k}=Yn(),{getBloobById:N}=mn(),_=(()=>
1080{if(!k)return"";switch(k.type){case J.Song:return`song:${k.id}`;case J.Bloob:{const $=N(k.id);return $?`song:${$.songId}`:""}case J.TextNode:return`text_node:${k.id}`;case J.EmbeddingNode:return`embedding_node:${k.id}`;case J.VisualMediaNode:return`visual_node:${k.id}`;default:return""}})(),j=Vr(_||"global"),T=R9(),M=x.useRef(null),V=Ix(),H=x.useRef(null),P=((L=C==null?void 0:C.content)==null?void 0:L.messages)??[],[F,I]=x.useState("tips"),[R,U]=x.useState(!1),A=x.useRef(e);x.useEffect(()=>{H.current&&(H.current.scrollTop=H.current.scrollHeight)},[]),x.useEffect(()=>{H.current&&(A.current&&!e?H.current.scrollTo({top:H.current.scrollHeight,behavior:"smooth"}):H.current.scrollTop=H.current.scrollHeight)},[e,C]),x.useEffect(()=>{A.current&&!e&&o({target:{value:""}}),A.current=e},[e,o]),x.useEffect(()=>{if(M.current){M.current.style.height="auto";const $=M.current.scrollHeight,q=120;M.current.style.height=Math.min($,q)+"px"}},[s]);const W=$=>{if($.key==="Enter"&&!$.shiftKey){$.preventDefault(),$.stopPropagation(),s.trim()&&n&&l(s);return}a($)},D=$=>{$&&($.preventDefault(),$.stopPropagation()),s.trim()&&n&&l(s)},B=()=>{m(!h)};return c.jsxs("div",{className:"fixed inset-[.1rem] z-50 flex flex-col rounded-[10px] shadow-2xl border border-zinc-300/40 dark:border-zinc-800/40 overflow-hidden",onClick:$=>$.stopPropagation(),children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-100/85 to-zinc-175/85 dark:from-zinc-800/85 dark:to-zinc-950/85 backdrop-blur-lg rounded-[10px]"}),c.jsxs("div",{className:"relative z-10 flex flex-col h-full",children:[c.jsxs("div",{className:"border-b border-zinc-200/50 dark:border-zinc-800/50 relative overflow-hidden w-full rounded-t-[10px]",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-200/40 via-zinc-150/40 to-zinc-300/40 dark:from-zinc-800/40 dark:via-zinc-750/40 dark:to-zinc-700/40 rounded-t-[10px]"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10 rounded-t-[10px]"}),c.jsx("div",{className:"absolute inset-0 backdrop-blur-sm rounded-t-[10px]"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsx("div",{className:"relative z-10 p-4 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between rounded-lg",children:[c.jsx("div",{className:"flex items-center gap-2 max-w-[70%]",children:c.jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/30 dark:bg-white/10 backdrop-blur-sm border border-white/30 dark:border-white/10 w-full",children:c.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-200 truncate font-medium overflow-ellipsis block w-full",title:t,"aria-label":`Chat title: ${t}`,children:t})})}),c.jsx("div",{className:"flex items-center gap-2 max-w-[30%]",children:c.jsx("button",{onClick:f,className:"p-2 rounded-md transition-all duration-200 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0","aria-label":"Close chat",title:"Close chat",children:c.jsx(SD,{size:16})})})]})})]}),c.jsx("div",{ref:H,className:"flex-1 overflow-y-auto px-4 py-2 space-y-4 select-text",children:P.map(($,q)=>{var te;if(!$.body||$.body.trim().length===0)return null;const ie=P[q-1],ge=q===0||!ie||I4(ie.timestamp)!==I4($.timestamp),re=$.authorDisplayName??($.role==="cai"?"Cai":"User"),Y=new Date($.timestamp).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ne=$.role==="user"&&($.authorId==null||T!=null&&$.authorId===T),be=$.inReplyToId?(((te=C==null?void 0:C.content)==null?void 0:te.messages)??[]).find(fe=>fe.id===$.inReplyToId):null,we=fe=>fe.length>50?fe.slice(0,50).trim()+"â¦":fe;return c.jsxs(mr.Fragment,{children:[ge&&c.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[c.jsx("div",{className:"h-px flex-1 bg-zinc-200 dark:bg-zinc-700"}),c.jsx("span",{className:"text-[11px] uppercase tracking-wide text-zinc-500 dark:text-zinc-400",children:NCe($.timestamp)}),c.jsx("div",{className:"h-px flex-1 bg-zinc-200 dark:bg-zinc-700"})]}),c.jsx("div",{className:"space-y-1 group",children:c.jsxs("div",{className:`flex flex-col ${ne?"items-end":"items-start"}`,children:[c.jsxs("div",{className:`flex items-center gap-1 w-full max-w-full px-1 ${ne?"justify-end":""}`,children:[j&&ne&&c.jsx("button",{type:"button",className:"opacity-70 hover:opacity-100 p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 transition-opacity touch-manipulation","aria-label":"Reply",t
1080itle:"Reply",onClick:()=>w($.id,we($.body)),children:c.jsx(Xf,{size:12})}),c.jsx("span",{className:"text-xs text-zinc-500 dark:text-zinc-400 py-1",children:ne?Y:`${re} · ${Y}`}),j&&!ne&&c.jsx("button",{type:"button",className:"opacity-70 hover:opacity-100 p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 transition-opacity touch-manipulation","aria-label":"Reply",title:"Reply",onClick:()=>w($.id,we($.body)),children:c.jsx(Xf,{size:12})})]}),be&&c.jsxs("div",{className:`text-xs text-zinc-500 dark:text-zinc-400 mb-0.5 px-2 py-1 rounded border-l-2 border-zinc-300 dark:border-zinc-600 max-w-full ${ne?"mr-0 ml-auto":""}`,style:{maxWidth:"100%"},children:["Replying to ",be.authorDisplayName??(be.role==="cai"?"Cai":"User"),": ",we(be.body)]}),c.jsx("div",{className:`rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 mb-1 select-text max-w-full ${ne?"bg-caiBlue-100 dark:bg-caiBlue-500":"bg-zinc-200 dark:bg-zinc-800"}`,children:$.role==="cai"?c.jsx(A9,{children:$.body}):O9($.body)})]})})]},$.id)})}),c.jsx("div",{className:`px-4 border-none overflow-hidden transition-all duration-[1000ms] ease-in-out ${r>0?"py-3 opacity-100 max-h-96":"py-0 opacity-0 max-h-0"}`,children:c.jsx("div",{className:`bg-gradient-to-r from-caiGreen-100 to-caiBlue-100 dark:from-caiGreen-700/20 dark:to-caiBlue-700/20 rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 mb-1 w-full overflow-y-auto transition-all duration-500 ease-in-out ${F==="quiz"?"h-60":"h-24"}`,children:c.jsx(M9,{isActive:r>0,onTabChange:I})})}),r>0&&c.jsx("div",{className:"px-4 pt-2 pb-4 border-t border-zinc-200/50 dark:border-zinc-700/50",children:c.jsxs("div",{className:"bg-gradient-to-r from-caiGreen-100 to-caiBlue-100 dark:from-caiGreen-700/20 dark:to-caiBlue-700/20 rounded-lg px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100",children:[c.jsxs("button",{type:"button",onClick:()=>U($=>!$),className:"w-full flex items-center justify-between gap-2 rounded-lg py-2 text-left transition-colors touch-manipulation","aria-expanded":R,"aria-label":R?"Hide progress bars":"Show progress bars",children:[c.jsxs("span",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-300",children:[r," request",r!==1?"s":""," processing"]}),R?c.jsx(j0,{size:18,className:"text-zinc-500 dark:text-zinc-400 shrink-0"}):c.jsx(Vi,{size:18,className:"text-zinc-500 dark:text-zinc-400 shrink-0"})]}),c.jsx("div",{className:"grid max-h-[400px] transition-[grid-template-rows] duration-300 ease-in-out",style:{gridTemplateRows:R&&i.length>0?"1fr":"0fr"},children:c.jsx("div",{className:"min-h-0 overflow-y-auto",children:c.jsx("div",{className:"mt-2 space-y-4 pr-0.5",children:i.map($=>c.jsx(Mv,{item:$,onCancel:d},$.requestId))})})})]})}),c.jsxs("div",{className:"border-t border-zinc-200/50 dark:border-zinc-800/50 sticky bottom-0 overflow-hidden rounded-b-[10px]",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-200/40 via-zinc-150/40 to-zinc-300/40 dark:from-zinc-800/40 dark:via-zinc-750/40 dark:to-zinc-700/40 rounded-b-[10px]"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/40 to-transparent dark:from-white/10 rounded-b-[10px]"}),c.jsx("div",{className:"absolute inset-0 backdrop-blur-sm rounded-b-[10px]"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-300/80 to-transparent dark:via-zinc-600/80"}),c.jsxs("div",{className:"relative z-10 p-4",children:[g&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1.5 rounded-lg bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700",children:[c.jsx(Xf,{size:14,className:"text-zinc-500 dark:text-zinc-400 shrink-0"}),c.jsxs("span",{className:"text-xs text-zinc-600 dark:text-zinc-300 truncate flex-1 min-w-0",children:["Replying to: ",g.snippet]}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-500 dark:text-zinc-400 touch-manipulation","aria-label":"Cancel reply",onClick:v,children:c.jsx(nr,{size:14})})]}),c.jsx("div",{style:{minHeight:"80px"},className:"mb-2",children:h?c.jsx("div",{style:{height:"80px",display:"flex",alignItems:"center"},children:c.jsx(zv,{minimized:!1,isRecording:h})}):c.jsxs("div",{className:"relative",children:[!j&&c.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 italic mb-1",children:"View only â you cannot send messages"}
1080),c.jsx("textarea",{id:"cai-chat-expanded-mobile-input",ref:M,value:s,onChange:o,onKeyPress:W,className:"w-full rounded-lg border border-zinc-300/50 dark:border-zinc-700/50 bg-white/70 dark:bg-zinc-800/70 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 focus:outline-none focus:ring-1 focus:ring-caiGreen-300 disabled:opacity-50 resize-none overflow-hidden backdrop-blur-sm relative z-10",placeholder:"Ask me anything...",disabled:h||!j,style:{minHeight:"80px"}}),c.jsx("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-b from-white/20 to-transparent dark:from-white/5 pointer-events-none"})]})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ICe,{usage:V,onSubscriptionModalOpen:$0}),y&&c.jsx("button",{type:"button",disabled:!n||!j,className:`p-2 rounded-md transition-all duration-200 focus:outline-none focus:ring-0 focus:border-0 ${!n||!j?"text-zinc-400 dark:text-zinc-600 cursor-not-allowed":"text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110"}`,"aria-label":"Need inspiration?",title:"Need inspiration?",onClick:y,children:c.jsx(fx,{size:16})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:`p-2 rounded-md transition-all duration-200 focus:outline-none focus:ring-0 focus:border-0 ${h?"bg-red-500 text-white hover:bg-red-600 hover:scale-110 animate-pulse":!n||!j?"text-zinc-400 dark:text-zinc-600 cursor-not-allowed":"text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 hover:scale-110"}`,"aria-label":h?"Stop recording":"Start recording",title:h?"Stop recording":"Start recording",onClick:B,disabled:!n||!j,children:c.jsx(Rc,{size:16})}),c.jsx("button",{type:"button",className:`rounded-md p-2 transition-all duration-200 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0 1081 ${s.trim()&&n?"bg-caiGreen-500 hover:bg-caiGreen-600 text-white":e?"bg-red-500 hover:bg-red-600 text-white animate-pulse":"bg-transparent text-zinc-400 dark:text-zinc-600 hover:bg-caiGreen-100 dark:hover:bg-caiGreen-700"} 1082 `,disabled:h||!j||!(s.trim()&&n)&&!e,"aria-label":s.trim()&&n?"Send message":e?"Cancel request":"Send message",title:s.trim()&&n?"Send message":e?"Cancel request":"Send message",onClick:s.trim()&&n?D:e?u:void 0,children:s.trim()&&n?c.jsx(Nh,{size:16}):e?c.jsx(nr,{size:16}):c.jsx(Nh,{size:16})})]})]})]})]})]})]})},zm="bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 dark:from-zinc-800/50 dark:to-zinc-900/25 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40",TCe=({usage:t,onSubscriptionModalOpen:e})=>{if(!t)return c.jsx("button",{className:`${fr.usageButton} ${fr.floatingButton} ${zm}`,"aria-label":"Loading Takes",title:"Loading Takes",onClick:e,children:c.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2"})});const n=t.takes_quota-t.takes_used,r=(t.takes_quota-n)/t.takes_quota*100;let i=fr.usageButton;r>=90?i=`${fr.usageButton} ${fr.critical}`:r>=75&&(i=`${fr.usageButton} ${fr.warning}`);const s=n>999?"999+":n,o=n>999?{fontSize:"9px"}:{};return c.jsx("button",{className:`${i} ${fr.floatingButton} ${zm}`,"aria-label":`${n} Takes remaining`,title:`${n} Takes remaining`,onClick:e,children:c.jsx("span",{style:o,children:s})})},j4=50,zCe=40,PCe=5e3,ACe=5e3,T4=2e3,z4=30,MCe=3,BCe="16px",RCe=["Double click anywhere to create a new bloob and song...","Right click on a bloob to edit its properties...","Click within a song's borders to create a new bloob...","Click and drag a bloob to move it around...","Click on a bloob and press m to mute it...","Click on a bloob and press backspace/delete to delete it..."],OCe=["Let's make something magical...","Ask me a question...","Create a bass line...","Make a drum pattern...","Create a melody..."];function DCe({onResize:t}){const[e,n]=x.useState(350),[r,i]=x.useState(!1),s=x.useRef(null),[o,a]=x.useState(""),[l,u]=x.useState(!0),[d,f]=x.useState(""),[h,m]=x.useState(null),[y,g]=x.useState(!1),[w,v]=x.useState(!1),[S,C]=x.useState(!1),[k,N]=x.useState({top:0,left:0,width:0}),[_,j]=x.useState(!1),[T,M]=x.useState(!1),V=x.useRef(null),H=x.useRef(null),P=x.useRef(null),F=x.useRef(!1),I=x.useRef(null),R=x.useRef(!1),U=x.useRef(!0),A=x.useRef(Date.now()),{
1082caiChatInputRef:W}=di(),D=x.useRef(null),B=x.useRef(null),{showBanner:L}=ts(),{awaitingResponse:$,inFlightCount:q,canSendAgenticRequest:Z,isContextAwaitingResponse:ie,cancelRequestForContext:ge,cancelRequestById:re,openChatBox:Y,setOpenChatBox:ne,isRecording:be,setIsRecording:we,handlePromptSubmit:te,handleCreateTextNode:fe,handleCreateEmbeddingNode:O,handleCreateVisualMediaNode:pe}=Jwe(),{caiChatState:he,selectedSingleCaiObject:le,selectedCaiObjects:oe,chatPositionSide:Q}=Yn(),{setCaiChatState:de}=cr(),{isMobile:Ne}=Hn(),{getBloobById:Ce,getNoteById:Ae,getSongById:Ue,tracks:Se,getTextNodeName:ve,getEmbeddingNodeName:je,getVisualMediaNodeName:Te}=mn(),ce=x.useMemo(()=>{if(!le)return{objectType:"global",objectId:0};switch(le.type){case J.Bloob:{const Ye=Ce(le.id);return{objectType:"song",objectId:(Ye==null?void 0:Ye.songId)??0}}case J.Note:{const Ye=Ae(le.id),bt=Ye?Ce(Ye.bloobId):null;return{objectType:"song",objectId:(bt==null?void 0:bt.songId)??0}}case J.Song:return{objectType:"song",objectId:le.id};case J.Track:{const Ye=Se[le.id];return{objectType:"song",objectId:(Ye==null?void 0:Ye.songId)??0}}case J.TextNode:return{objectType:"text",objectId:le.id};case J.EmbeddingNode:return{objectType:"embedding",objectId:le.id};case J.VisualMediaNode:return{objectType:"visual",objectId:le.id};default:return{objectType:"global",objectId:0}}},[le,Ce,Ae,Se]),se=ie(ce.objectType,ce.objectId),ye=x.useCallback(()=>{ge(ce.objectType,ce.objectId)},[ge,ce.objectType,ce.objectId]),ke=x.useCallback(Ye=>{re(Ye)},[re]),ze=x.useMemo(()=>{if(!le)return"";switch(le.type){case J.Song:return`song:${le.id}`;case J.Bloob:{const Ye=Ce(le.id);return Ye?`song:${Ye.songId}`:""}case J.Track:{const Ye=Se[le.id];return Ye?`song:${Ye.songId}`:""}case J.TextNode:return`text_node:${le.id}`;case J.EmbeddingNode:return`embedding_node:${le.id}`;case J.VisualMediaNode:return`visual_node:${le.id}`;default:return""}},[le,Ce,Se]),qe=Vr(ze||"global"),ot=x.useCallback(Ye=>{Ye.preventDefault(),Ye.stopPropagation(),i(!0),document.body.style.cursor="col-resize";const bt=Ye.clientX,Ie=e,it=Ut=>{Ut.preventDefault();const Et=Ut.clientX-bt,yn=Q==="right"?-Et:Et;let nn=Ie+yn;nn=Math.max(295,Math.min(500,nn)),n(nn),t&&t(nn)},ct=()=>{i(!1),document.body.style.cursor="",window.removeEventListener("mousemove",it),window.removeEventListener("mouseup",ct)};window.addEventListener("mousemove",it),window.addEventListener("mouseup",ct)},[e,t,Q]),Ze=Ix(),_t=at(Ye=>Object.entries(Ye.inFlightAgentRequests??{}).map(([bt,Ie])=>({requestId:bt,objectType:Ie.objectType,objectId:Ie.objectId,userMessagePreview:Ie.userMessagePreview,startedAt:Ie.startedAt,progressDurationSec:Ie.progressDurationSec}))),tt=x.useMemo(()=>{if(!le){const Ye=oe.filter(bt=>bt.type===J.Bloob).map(bt=>bt.id);if(Ye.length===oe.length&&Ye.length){const bt=Ce(Ye[0]);if(!bt)return"General Chat History";if(Ye.every(it=>{const ct=Ce(it);return(ct==null?void 0:ct.songId)===bt.songId})){const it=Ue(bt.songId);return it!=null&&it.label?`${it.label} History`:"General Chat History"}}}if(!le)return"General Chat History";switch(le.type){case J.Bloob:{const Ye=Ce(le.id);if(!Ye)return"General Chat History";const bt=Ue(Ye.songId);return bt!=null&&bt.label?`${bt.label} History`:"General Chat History"}case J.Note:{const Ye=Ae(le.id);if(!Ye)return"General Chat History";const bt=Ce(Ye.bloobId);if(!bt)return"General Chat History";const Ie=Ue(bt.songId);return Ie!=null&&Ie.label?`${Ie.label} History`:"General Chat History"}case J.Song:{const Ye=Ue(le.id);return Ye!=null&&Ye.label?`${Ye.label} History`:"General Chat History"}case J.Track:{const Ye=Se[le.id];if(!Ye)return"General Chat History";const bt=Ue(Ye.songId);return bt!=null&&bt.label?`${bt.label} History`:"General Chat History"}case J.TextNode:{const Ye=ve(le.id);return Ye?`${Ye} History`:"Text History"}case J.EmbeddingNode:{const Ye=je(le.id);return Ye?`${Ye} History`:"Embedding History"}case J.VisualMediaNode:{const Ye=Te(le.id);return Ye?`${Ye} History`:"Visual History"}default:return"General Chat History"}},[le,oe,Ce,Ae,Ue,Se,ve,je,Te]),gt=x.useRef(!0);x.useEffect(()=>{if(!$&&!be){const Ye=setTimeout(()=>{d===""&&!R.current&&u(!0)},1e3);return()=>clearTimeout(Ye)}},[$,be,d]);const dt=()=>{we(!be),Dt()},wt=()=>{switch(he){case zn.DEFAULT:return{width:Ne?"calc(100% - 2rem)":`${z4*20}px`,maxWidth:Ne?"500px":`${z4*20}px`,height:`${MCe*20}px`,borderRadius:"9999px",bottom:Ne?"1rem":"1.5rem",left:"50%",top:"auto",right:"auto",x:"-50%",y:"0%",position:"fixed",zIndex:47};case zn.MINIMIZED:return{width:q>0?"64px":"30px",height:"30px",bottom:"0rem",left:"0rem",top:"auto",right:"auto",x:"0%",y:"0%",position:"absolute",zIndex:40};case zn.MAXIMIZED:return Ne?{width:"95%",height:"85%",borderRadius:"10px",bottom:"1rem",left:"50%",top:"auto",right:"auto",x:"-50%",y:"0%",position:"fixed",zIndex:49}:{width:`${e}px`,height:"100vh",borderRadius:"0px",top:"0",left:Q==="left"?"0":"auto",right:Q==="right"?"0":"auto",bottom:"auto",x:"0%",y:"0%",position:"fixed",zIndex:49};default:return{}}},Dt=x.useCallback(()=>{D.current&&(clearTimeout(D.current),D.current=null),v(!0),D.current=setTimeout(()=>{!S&&U.current&&v(!1)},T4)},[S]);x.useEffect(()=>{g(!0)},[]),x.useEffect(()=>{const Ye=()=>{if(P.current){const it=P.current.getBoundingClientRect(),ct=P.current.getBoundingClientRect().width;if(it.width>0&&it.height>0){const Ut=Ne?it.top-45:it.top-36;N({top:Ut,left:it.left,width:ct})}}},bt=setTimeout(Ye,100),Ie=new MutationObserver(Ye);return P.current&&Ie.observe(P.current,{attributes:!0,attributeFilter:["style"]}),window.addEventListener("resize",Ye),()=>{clearTimeout(bt),window.removeEventListener("resize",Ye),Ie.disconnect()}},[Ne,he,se]),x.useEffect(()=>()=>{U.current=!1,I.current&&cancelAnimationFrame(I.current),D.current&&(clearTimeout(D.current),D.current=null)},[]),x.useEffect(()=>
1082{Y&&(de(zn.MAXIMIZED),setTimeout(()=>{ne(!1)},300))},[Y,de,ne]);const Kt=x.useCallback(()=>{F.current&&cancelAnimationFrame(I.current),F.current=!0;let Ye=0,bt=0,Ie=!1,it=!1,ct=0,Ut=null;const Et=Ne?OCe:RCe;if(he===zn.MINIMIZED)return()=>{F.current=!1};const yn=nn=>{if(!F.current)return;ct===0&&(ct=nn);const rr=nn-ct;if(!it&&rr>=(Ie?zCe:j4)){const xn=Et[Ye];if(!Ie&&bt<xn.length)a(xn.slice(0,bt+1)),bt++;else if(Ie&&bt>0)a(xn.slice(0,bt-1)),bt--;else if(bt===xn.length){Ie=!0,it=!0,Ut&&clearTimeout(Ut),Ut=setTimeout(()=>{F.current&&(it=!1,I.current=requestAnimationFrame(yn))},PCe);return}else if(bt===0){Ie=!1,it=!0,Ut&&clearTimeout(Ut),Ut=setTimeout(()=>{F.current&&(it=!1,Ye=(Ye+1)%Et.length,I.current=requestAnimationFrame(yn))},ACe);return}ct=nn}I.current=requestAnimationFrame(yn)};return I.current=requestAnimationFrame(yn),()=>{Ut&&clearTimeout(Ut),I.current&&cancelAnimationFrame(I.current),F.current=!1}},[he,Ne]),rn=x.useCallback(Ye=>new Promise(bt=>{F.current&&cancelAnimationFrame(I.current),F.current=!0;let Ie=0,it=0;const ct=Ut=>{if(!F.current)return;if(it===0&&(it=Ut),Ut-it>=j4)if(Ie<Ye.length)f(Ye.slice(0,Ie+1)),Ie++,it=Ut;else{F.current=!1,bt();return}I.current=requestAnimationFrame(ct)};I.current=requestAnimationFrame(ct)}),[]),pn=x.useCallback(async()=>{if(!_){j(!0),F.current&&cancelAnimationFrame(I.current);try{const Ye=Wwe();await rn(Ye),te(Ye).catch(bt=>{bt instanceof qu?L(bt.userMessage):bt instanceof Rf?L("Request Cancelled"):L("Error sending inspiration query"),pr("Error sending inspiration query:",bt)}),j(!1),f(""),Kt()}catch(Ye){j(!1),Ye instanceof qu?L(Ye.userMessage):Ye instanceof Rf?L("Request Cancelled"):L("Error sending inspiration query"),Kt()}}},[_,rn,te,L,Kt]);x.useEffect(()=>{let Ye;return l&&!$&&!F.current&&!R.current&&(Ye=Kt()),()=>{Ye&&Ye(),I.current&&(cancelAnimationFrame(I.current),F.current=!1)}},[Kt,l,$]),x.useEffect(()=>{be&&(f(""),Dt())},[be,Dt]),x.useEffect(()=>(S?(D.current&&(clearTimeout(D.current),D.current=null),v(!0)):!S&&U.current&&(D.current||(D.current=setTimeout(()=>{U.current&&v(!1),D.current=null},T4))),()=>{D.current&&(clearTimeout(D.current),D.current=null)}),[S]);const cn=Ye=>{Ye.target.value===" "&&d===""?f(""):(f(Ye.target.value),A.current=Date.now(),Dt(),Ye.target.value!==""&&u(!1))},kt=()=>{R.current=!0,gt.current=!1,A.current=Date.now(),Dt(),I.current&&(cancelAnimationFrame(I.current),F.current=!1),u(!1)},rt=()=>{R.current=!1,gt.current=!0,d===""&&(u(!0),F.current||Kt())},Tt=Ye=>{if(A.current=Date.now(),Dt(),(Ye.metaKey||Ye.ctrlKey)&&Ye.key==="Enter"){f(d+` 1083`);return}Ye.key==="Enter"&&!Ye.shiftKey&&(Ye.preventDefault(),Ye.stopPropagation(),be?dt():Mt(Ye))},Mt=async Ye=>{Ye&&(Ye.preventDefault(),Ye.stopPropagation());const bt=d.trim();if(!(!Z||!bt||!qe))try{f(""),m(null),u(!1),I.current&&(cancelAnimationFrame(I.current),F.current=!1),await te(bt,{inReplyToId:h==null?void 0:h.id})}catch(Ie){Ie instanceof qu?L(Ie.userMessage):Ie instanceof Rf?L("Request Cancelled"):L("Error submitting message")}},Rt=x.useCallback(async Ye=>{const bt=typeof Ye=="string"?Ye.trim():"";if(!(typeof Ye=="string"&&(!Z||!bt||!qe))&&!(typeof Ye!="string"&&(!Z||!qe))){f(""),m(null),u(!1),I.current&&(cancelAnimationFrame(I.current),F.current=!1);try{await te(Ye,{inReplyToId:h==null?void 0:h.id})}catch(Ie){Ie instanceof qu?L(Ie.userMessage):Ie instanceof Rf?L("Request Cancelled"):L("Error submitting message")}}},[Z,qe,te,h==null?void 0:h.id,L]),Ct=()=>{v(!1),C(!1),D.current&&(clearTimeout(D.current),D.current=null),de(zn.MINIMIZED)},Gt=()=>{v(!1),C(!1),D.current&&(clearTimeout(D.current),D.current=null),de(zn.MAXIMIZED)},Lt=x.useCallback(()=>{he===zn.DEFAULT&&(A.current=Date.now(),Dt())},[he,Dt]),$t=()=>{Dt()};x.useEffect(()=>{const Ye=bt=>{const Ie=document.querySelector(`.${fr.promptContainer}`)||document.querySelector(`.${fr.promptContainerStatic}`),it=B.current&&B.current.contains(bt.target);he===zn.DEFAULT&&Ie&&!Ie.contains(bt.target)&&!it&&v(!1)};return document.addEventListener("click",Ye),()=>{document.removeEventListener("click",Ye)}},[he,de]),x.useEffect(()=>{if(!T||q===0)return;const Ye=bt=>{var it,ct;const Ie=bt.target;(it=V.current)!=null&&it.contains(Ie)||(ct=H.current)!=null&&ct.contains(Ie)||M(!1)};return document.addEventListener("mousedown",Ye),()=>document.removeEventListener("mousedown",Ye)},[T,q]),x.useEffect(()=>{q===0&&M(!1)},[q]);const Qt=x.useMemo(()=>
1083{if(le)switch(le.type){case J.Song:{if(Ue(le.id).bloobIds.size===0)return"Fill this song with...";break}case J.Bloob:{const Ye=Ce(le.id);if(Gh(Ye))return"Fill this bloob with...";break}}return"Ask me anything..."},[Ce,Ue,le]);return c.jsx(c.Fragment,{children:c.jsx(Vn,{children:y&&c.jsxs(c.Fragment,{children:[he===zn.DEFAULT&&c.jsx("div",{ref:B,className:`${fr.floatingControls} ${fr.defaultState} ${w||S?fr.visible:""} z-47`,style:{top:`${k.top}px`,left:Ne?`${k.left}px`:`${k.left}px`,width:`${k.width}px`},onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),onTouchStart:()=>C(!0),onTouchEnd:()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{C(!1),D.current=null},500)},children:c.jsxs("div",{className:"flex justify-between items-center w-full",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(TCe,{usage:Ze,onSubscriptionModalOpen:$0}),q>0&&c.jsxs("div",{className:"relative",children:[c.jsx("button",{ref:V,type:"button",onClick:()=>M(Ye=>!Ye),className:`${fr.usageButton} ${fr.floatingButton} ${fr.inFlightButton}`,"aria-label":`${q} request${q!==1?"s":""} in progress`,title:`${q} request${q!==1?"s":""} in progress`,"aria-expanded":T,children:c.jsx("span",{children:q})}),T&&c.jsxs("div",{ref:H,className:"absolute left-0 bottom-full mb-2 z-[100] min-w-[280px] max-w-[90vw] rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-xl pt-2 px-3 pb-4",style:{boxShadow:"0 10px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05)"},children:[c.jsx("p",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2 px-0.5",children:"Requests in progress"}),c.jsx("div",{className:"space-y-4",children:_t.map(Ye=>c.jsx(Mv,{item:Ye,onCancel:re},Ye.requestId))})]})]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{className:`${fr.floatingButton} ${_?fr.generatingRandomQuery:zm}`,onClick:pn,"aria-label":"Need inspiration?",title:"Need inspiration?",children:c.jsx(fx,{size:16})}),!Ne&&c.jsx("button",{className:`${fr.floatingButton} ${zm}`,onClick:Ct,"aria-label":"Voice Mode",title:"Voice Mode",children:c.jsx(B9,{})}),c.jsx("button",{className:`${fr.floatingButton} ${zm}`,onClick:Gt,"aria-label":"Expand chat",title:"Expand chat",children:c.jsx(vD,{size:16})})]})]})}),c.jsx(et.div,{ref:P,className:`${he!==zn.MINIMIZED?se&&he!==zn.DEFAULT?fr.promptContainer:fr.promptContainerStatic:""} ${!Ne&&he===zn.MAXIMIZED?Q==="left"?"pl-0 pt-0 pb-0":"pr-0 pt-0 pb-0":""}`,initial:wt(),animate:wt(),exit:wt(),transition:{duration:.2,ease:"easeInOut"},onClick:Ye=>Ye.stopPropagation(),onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),onMouseMove:Lt,onTouchStart:$t,children:he===zn.MAXIMIZED?Ne?c.jsx(jCe,{chatTitle:tt,awaitingResponse:se,canSendAgenticRequest:Z,inFlightCount:q,inFlightRequests:_t,userMessage:d,onUserMessageChange:cn,onKeyPress:Tt,onSubmit:Rt,onCancelRequest:ye,onCancelRequestById:ke,onMinimize:()=>{de(zn.DEFAULT)},onCreateTextNode:fe,onCreateEmbeddingNode:O,onCreateVisualMediaNode:pe,isRecording:be,setIsRecording:we,handleRandomQueryGeneration:pn,replyTo:h,onReplyToMessage:(Ye,bt)=>m({id:Ye,snippet:bt}),onClearReply:()=>m(null)}):c.jsxs("div",{ref:s,className:"flex flex-col h-full min-h-0 w-full relative",style:{transition:r?"none":"width 0.1s ease-out"},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-100/85 to-zinc-200/85 dark:from-zinc-800/85 dark:to-zinc-950/85 backdrop-blur-lg border-r border-zinc-300/40 dark:border-zinc-800/40"}),c.jsxs("div",{className:"relative z-10 flex flex-col h-full",children:[c.jsx("div",{style:{position:"absolute",top:0,[Q==="left"?"right":"left"]:"-15px",width:"15px",height:"100%",cursor:"col-resize",zIndex:47,pointerEvents:"auto"},onMouseDown:ot,onMouseEnter:()=>{document.body.style.cursor="col-resize"},onMouseLeave:()=>{r||(document.body.style.cursor="")},"aria-label":"Resize sidebar",role:"separator"}),c.jsx(ECe,{chatTitle:tt,awaitingResponse:se,canSendAgenticRequest:Z,inFlightCount:q,inFlightRequests:_t,userMessage:d,onUserMessageChange:cn,onKeyPress:Tt,onSubmit:Rt,onCancelRequest:ye,onCancelRequestById:ke,onMinimize:()=>{de(zn.DEFAULT)},isRecording:be,setIsRecording:we,handleRandomQueryGeneration:pn,replyTo:h,onReplyToMessage:(Ye,bt)=>m({id:Ye,snippet:bt}),onClearReply:()=>m(null)})]})]}):c.jsxs(c.Fragment,{children:[he===zn.DEFAULT&&c.jsx("div",{className:`${fr.promptInputContainer} relative`,children:be?c.jsxs(c.Fragment,{children:[c.jsx(zv,{minimized:!1}),c.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none z-10",children:c.jsx("button",{type:"button",onClick:dt,className:`group pointer-events-auto relative z-20 rounded-full transition-all duration-200 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 border-0 [box-shadow:none] flex items-center justify-center p-2 bg-red-500 ${Z?"":"opacity-60"}`,style:{WebkitTapHighlightColor:"transparent"},"aria-label":"Stop recording",disabled:!Z,children:c.jsx(Rc,{size:16,className:"text-white transition-colors duration-200"})})})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",id:"cai-chat-input",n
1083ame:"cai-chat-input",autoComplete:"off","data-form-type":"other",ref:W,value:se||_?d:l?o:d,onChange:cn,onFocus:kt,onBlur:rt,onKeyDown:Tt,className:`${fr.promptInput} ${d.length>30?fr.expandablePromptInput:""}`,placeholder:Qt,style:{fontSize:BCe,paddingRight:"44px",textIndent:"22px"},disabled:!qe,"aria-label":"Cai Chat"}),c.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none z-10",children:c.jsx("button",{type:"button",onClick:d.trim()&&Z?Mt:se?ye:dt,disabled:!Z&&!se,className:`group pointer-events-auto relative z-20 rounded-full transition-all duration-200 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 border-0 flex items-center justify-center p-2 1084 ${d.trim()&&Z?"bg-gradient-to-r from-caiGreen to-caiBlue":se?fr.cancelButton:Z?be?"bg-red-500 text-white animate-pulse":"bg-zinc-500/20 [box-shadow:none]":"bg-zinc-400 dark:bg-zinc-600 cursor-not-allowed"}`,style:{WebkitTapHighlightColor:"transparent"},"aria-label":d.trim()&&Z?"Send":se?"Cancel request":Z?be?"Stop recording":"Start recording":"Max requests in flight",children:d.trim()&&Z?c.jsx(cte,{size:16,className:"text-zinc-700 dark:text-zinc-200 group-hover:text-zinc-800 dark:group-hover:text-zinc-300 transition-colors duration-200"}):se?c.jsx(nr,{size:16,className:"text-white transition-colors duration-200"}):c.jsx(Rc,{size:16,className:"text-zinc-700 dark:text-zinc-200 group-hover:text-zinc-800 dark:group-hover:text-zinc-300 transition-colors duration-200"})})})]})}),he===zn.MINIMIZED&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex h-full w-full",style:{display:"flex",alignItems:"stretch",justifyContent:"flex-start",gap:"0px"},children:[c.jsx(et.button,{initial:{opacity:0}
1084,animate:{opacity:1},exit:{opacity:0},transition:{duration:.3,ease:"easeInOut"},className:`light:hover:bg-zinc-900 dark:hover:bg-zinc-800 ${fr.chatMinimizedContainer} ${q>0?fr.chatMinimizedPrimary:""}`,onClick:()=>de(zn.DEFAULT),style:{display:"flex",alignItems:"center",justifyContent:"center"},children:be?c.jsx(Rc,{size:16,strokeWidth:2,className:"feather feather-arrow-up-right"}):$?c.jsx(Nh,{size:16}):c.jsx(ate,{size:16})}),q>0&&c.jsxs("div",{className:"relative h-full w-full",children:[c.jsx("button",{ref:V,type:"button",onClick:()=>M(Ye=>!Ye),className:`${fr.chatMinimizedContainer} ${fr.inFlightButton}`,style:{display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":`${q} request${q!==1?"s":""} in progress`,title:`${q} request${q!==1?"s":""} in progress`,"aria-expanded":T,children:c.jsx("span",{className:"text-xs font-semibold",children:q})}),T&&c.jsxs("div",{ref:H,className:"absolute left-0 bottom-full mb-2 z-[100] min-w-[260px] max-w-[90vw] rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-xl pt-2 px-3 pb-4",style:{boxShadow:"0 10px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05)"},children:[c.jsx("p",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Requests in progress"}),c.jsx("div",{className:"space-y-4",children:_t.map(Ye=>c.jsx(Mv,{item:Ye,onCancel:re},Ye.requestId))})]})]})]}),c.jsx(Vn,{children:be&&c.jsx(et.div,{initial:{opacity:0}
1084,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2,ease:"easeInOut"},style:{position:"fixed",bottom:"1.5rem",left:"50%",transform:"translate(-50%, 0)",zIndex:50,width:"200px",height:"60px",transformOrigin:"center center"},children:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx(zv,{minimized:!1,isRecording:!0})})})})]})]})})]})})})}const LCe=()=>{const{initAudio:t,isAudioInitialized:e}=es(),{initialize:n}=Lo(),r=lx(),i=x.useRef("idle"),s=x.useRef(!1),o=x.useRef(null),a=x.useRef(null),l=x.useCallback(()=>{if(!s.current)return;const h=["mousedown","keydown","click","touchend"],m=o.current;m&&h.forEach(y=>{document.removeEventListener(y,m)}),s.current=!1},[]),u=x.useCallback(async h=>{if(!(i.current==="attempting"||i.current==="completed")){i.current="attempting";try{await t(),n(),i.current="completed";const m=a.current;m&&m()}catch{i.current="idle"}}},[t,n]),d=x.useCallback(async h=>{await u(`user-${h.type}`)},[u]),f=x.useCallback(()=>{if(s.current)return;const h=["mousedown","keydown","click","touchend"],m=o.current;m&&h.forEach(y=>{document.addEventListener(y,m,{once:!0,passive:!0})}),s.current=!0},[]);x.useEffect(()=>{a.current=l},[l]),x.useEffect(()=>{o.current=d},[d]),x.useEffect(()=>{if(r){if(e){i.current="completed",l();return}return i.current==="idle"&&f(),()=>{l()}}},[r,e,f,l]),x.useEffect(()=>()=>{l(),i.current="idle"},[l])};function FCe(){Sy().then(t=>at.getState().setSharedByMe(t)).catch(()=>{})}function $Ce(t){return`${(Yh.caiServerFastAPI||"https://localhost:8000").replace(/^https:/,"wss:").replace(/^http:/,"ws:")}/api/v0/user-data/sync?token=${encodeURIComponent(t)}`}function UCe(t){try{const e=t.split(".");if(e.length<2)return null;let n=e[1].replace(/-/g,"+").replace(/_/g,"/");const r=n.length%4;r&&(n+="=".repeat(4-r));const i=JSON.parse(atob(n)),s=i.user_metadata||{},o=i["cognito:username"]||s.cognito_user_id||i.sub;return typeof o=="string"?o:null}catch{return null}}function P4(t){const e=["global"];return Object.keys(t.songs||{}).forEach(n=>e.push(`song:${n}`)),Object.keys(t.textNodes||{}).forEach(n=>e.push(`text_node:${n}`)),Object.keys(t.embeddingNodes||{}).forEach(n=>e.push(`embedding_node:${n}`)),Object.keys(t.visualMediaNodes||{}).forEach(n=>e.push(`visual_node:${n}`)),e}function VCe(){const t=x.useRef(null),e=x.useRef(0),n=x.useRef(null),r=3e4,i=at(u=>u.songs),s=at(u=>u.textNodes),o=at(u=>u.embeddingNodes),a=at(u=>u.visualMediaNodes),l=x.useCallback(async()=>{const u=Ga.getInstance();if(u)try{const f=(await tr.get("/api/v0/user-data/timestamps")).data;u.updateCloudTimestamps({settings_timestamp:f.settings_timestamp??0,chat_history_timestamp:f.chat_history_timestamp??0,canvas_object_timestamps:f.canvas_object_timestamps,thread_object_timestamps:f.thread_object_timestamps}),u.pruneRevokedDomains();const h=u.getStaleDomainChannels();if(h.length>0){const m=await tr.post("/api/v0/user-data/catch_up",{domains:h}),{state:y,domain_timestamps:g,roles_by_domain:w,policies_by_domain:v}=m.data;y&&Object.keys(y).length>0&&u.applyMergedStateToStore(y,{mergePartial:!0}),g&&typeof g=="object"&&u.updateLocalTimestampsFromCatchUp(g),w&&Object.keys(w).length>0&&at.getState().setDomainRolesByChannel(w),v&&Object.keys(v).length>0&&at.getState().setDomainPoliciesByChannel(v)}await u.replayOfflineOpsAfterCatchUp()}catch{}},[]);x.useEffect(()=>{let u=!1;const d=async()=>{var m,y;const{data:{session:f}}=await xr.auth.getSession();if(u||!(f!=null&&f.access_token))return;if(n.current=UCe(f.access_token)??((m=f.user)==null?void 0:m.id)??null,n.current){const g=(()=>{try{const v=f.access_token.split(".");if(v.length<2)return null;let S=v[1].replace(/-/g,"+").replace(/_/g,"/");const C=S.length%4;return C&&(S+="=".repeat(4-C)),JSON.parse(atob(S))}catch{return null}})(),w=(g==null?void 0:g.name)||(g==null?void 0:g.given_name)||(g==null?void 0:g.preferred_username)||((g==null?void 0:g.user_metadata)||{}).name||((g==null?void 0:g.user_metadata)||{}).given_name||((y=f.user)==null?void 0:y.email)||null;at.getState().setCurrentUserIdentity(n.current,w??null)}const h=$Ce(f.access_token);cz(g=>{var v,S,C;const w=Ga.getInstance();if(w){if(g.type==="error"&&ar("[Sync WS] server error",{message:g.message,channel:g.channel}),g.type==="subscribed")g.roles_by_domain&&Object.keys(g.roles_by_domain).length>
10840&&at.getState().setDomainRolesByChannel(g.roles_by_domain),g.policies_by_domain&&Object.keys(g.policies_by_domain).length>0&&at.getState().setDomainPoliciesByChannel(g.policies_by_domain);else if(g.type==="presence"){if(!g.channel||!g.user_id)return;const k=g.data??{};at.getState().updateCollaboratorPresence(g.channel,g.user_id,{name:g.name??null,email:g.email??null,bloobId:typeof k.bloobId=="number"?k.bloobId:k.bloobId??null})}if(g.type==="remote_op")g.kind==="canvas"&&Array.isArray(g.operations)?w.applyRemoteCanvasOperations(g.operations):g.kind==="chat"&&Array.isArray(g.operations)&&w.applyRemoteChatOperations(g.operations),g.domain_timestamp!=null&&g.channel&&w.updateLocalDomainTimestamp(g.channel,g.domain_timestamp);else if(g.type==="access_revoked"&&g.target_user_id===n.current){w.removeDomainFromStore(g.channel),FJ([g.channel]);const k=g.channel.split(":");if(k.length===2){const N=k[0],_=parseInt(k[1],10);if(!Number.isNaN(_)){const j=at.getState().sharedWithMe;Array.isArray(j)&&at.getState().setSharedWithMe(j.filter(T=>!(T.object_type===N&&T.object_id===_)))}}}else if(g.type==="role_updated"&&g.target_user_id===n.current)at.getState().setDomainRolesByChannel({[g.channel]:g.role});else if(g.type==="policy_updated"&&g.target_user_id===n.current)at.getState().setDomainPoliciesByChannel({[g.channel]:{allow_copy:g.allow_copy,allow_export:g.allow_export}});else if(g.type==="member_joined"){const k=at.getState().domainRoleByChannel[g.channel];if(ar("[Sync WS] member_joined received",{channel:g.channel,user_id:g.user_id,role:g.role,currentUserRoleForChannel:k??"(none)",isOwner:(k==null?void 0:k.toLowerCase())==="owner"}),(k==null?void 0:k.toLowerCase())==="owner"){const N=g.channel.split(":");if(N.length===2){const _=N[0],j=parseInt(N[1],10);if(!Number.isNaN(j)){const T=at.getState().sharedByMe;if(Array.isArray(T)&&T.length,Array.isArray(T)){const M=T.findIndex(V=>V.object_type===_&&V.object_id===j);if(M!==-1){const V=T[M];if(!V.members.some(P=>P.user_id===g.user_id)){const P=[...T],F=(v=g.email)==null?void 0:v.trim().toLowerCase(),I=F?(V.pending_invites??[]).filter(R=>R.email.trim().toLowerCase()!==F):V.pending_invites??[];P[M]={...V,members:[...V.members,{user_id:g.user_id,role:g.role,allow_copy:g.allow_copy,allow_export:g.allow_export,...g.email!=null&&{email:g.email},...g.name!=null&&{name:g.name}}],pending_invites:I},at.getState().setSharedByMe(P),ar("[Sync WS] member_joined: updated sharedByMe, added member",{channel:g.channel,newMemberCount:P[M].members.length})}}else{const V={object_type:_,object_id:j,object_name:`${_} #${j}`,members:[{user_id:g.user_id,role:g.role,allow_copy:g.allow_copy,allow_export:g.allow_export,...g.email!=null&&{email:g.email},...g.name!=null&&{name:g.name}}],pending_invites:[]};at.getState().setSharedByMe([...T,V]),ar("[Sync WS] member_joined: created new sharedByMe entry",{channel:g.channel,objectType:_,objectId:j})}}}}}}else if(g.type==="invite_declined"){const k=at.getState().domainRoleByChannel[g.channel];if((k==null?void 0:k.toLowerCase())==="owner"){const N=g.channel.split(":");if(N.length===2){const _=N[0],j=parseInt(N[1],10);if(!Number.isNaN(j)){const T=at.getState().sharedByMe;if(Array.isArray(T)){const M=T.findIndex(V=>V.object_type===_&&V.object_id===j);if(M!==-1){const V=T[M],H=(S=g.email)==null?void 0:S.trim().toLowerCase();if(H&&(((C=V.pending_invites)==null?void 0:C.length)??0)>0){const P=V.pending_invites.filter(F=>F.email.trim().toLowerCase()!==H);if(P.length!==V.pending_invites.length){const F=[...T];F[M]={...V,pending_invites:P},at.getState().setSharedByMe(F),ar("[Sync WS] invite_declined: removed pending invite",{channel:g.channel,email:g.email})}}}}}}}}}}),uz(()=>{if(u)return;e.current=0;const g=at.getState(),w=P4(g);dz(w),FCe()},()=>{if(u)return;const g=Math.min(1e3*2**e.current,r);e.current+=1,t.current=setTimeout(()=>{l().then(()=>d())},g)}),DJ(h)};return d(),()=>{u=!0,t.current&&(clearTimeout(t.current),t.current=null),uz(null,null),cz(null),LJ()}},[l]),x.useEffect(()=>{if(!ya())return;const u=P4({songs:i,textNodes:s,embeddingNodes:o,visualMediaNodes:a});dz(u)},[i,s,o,a])}const HCe=[{screen:"Canvas",hotkeys:[{combo:["Space"],action:"Toggle Play/Stop"},{combo:["Space"],modifier:"Hold",action:"Chat in Voice Mode"},{combo:["Backspace"],when:"Object Selected",action:"Delete Selected Object"},{combo:["â"],when:"Bloob Selected",action:"Shift Bloob One Track Up"},{combo:["â"],when:"Bloob Selected",action:"Shift Bloob One Bar Right"},{combo:["â"],when:"Bloob Selected",action:"Shift Bloob One Track Down"},{combo:["â"],when:"Bloob Selected",action:"Shift Bloob One Bar Left"},{combo:["c"],action:"Focus Chat"},{combo:["â","a"],action:"Select All Objects"},{combo:["â","c"],when:"Object Selected",action:"Copy Object"},{combo:["d"],when:"Bloob Selected",action:"Toggle Bloob Details"},{combo:["â","e"],when:"Bloob or Song Selected",action:"Export MIDI and Audio"},{combo:["h"],action:"Show Hotkeys Screen"},{combo:["m"],when:"Bloob Selected",action:"Mute Bloob"},{combo:["p"],action:"Show Project Screen"},{combo:["r"],when:"Bloob Selected",action:"Record into Bloob"},{combo:["s"],when:"Bloob Selected",action:"Solo Bloob"},{combo:["t"],action:"Toggle Chat Display Mode"},{combo:["â","u"],action:"Show Upload Screen"},{combo:["â","v"],action:"Paste Object"},{combo:["â","z"],action:"Undo"},{combo:["â","Shift","z"],action:"Redo"},{combo:["â","/"],action:"Show/Hide Bloob IDs"}]},{screen:"Bloob Details",hotkeys:[{combo:["Space"],action:"Toggle Play/Stop"},{combo:["Backspace"],action:"Delete Selected Note(s)"},{combo:["r"],action:"Record into Bloob"},{combo:["â","a"],action:"Select All Notes"},{combo:["â","z"],action:"Undo"},{combo:["â","Shift","z"],action:"Redo"},{combo:["â","â"],action:"Shift Note(s) One Scale Degree Up"},{combo:["â"],action:"Shift Note(s) One Octave Up"},{combo:["â"],action:"Shift Note(s) One Beat Right"},{combo:["â","â"],action:"Shift Note(s) One Octave Down"},{combo:["â"],action:"Shift Note(s) One Beat Left"}]}],GCe=()=>{const{closeHotkeys:t}=Br(),{focusCanvas:e}=di(),{isMac:n}=Wl(),{isMobile:r}=Hn(),i=()=>{e(),t()},s=l=>l.combo?c.jsxs("span",{className:"flex flex-row gap-1 items-center w-full justify-between",children:[c.jsx("span",{className:"flex flex-row gap-1 items-center",children:l.combo.map((u,d)=>{let f=u;return u==="â"&&(f=n?"â":"Ctrl"),c.jsx("kbd",{className:`inline-block px-2 py-1 border border-zinc-400 dark:border-zinc-600 rounded bg-zinc-50 dark:bg-zinc-900 text-zinc-800 dark:text-zinc-100 font-mono shadow-sm select-none ${r?"text-xs":"text-sm"}`,children:f},d)})}),l.modifier&&c.jsx("span",{className:`italic text-zinc-500 ml-2 whitespace-nowrap flex-shrink-0 ${r?"text-xs":"text-sm"}`,children:l.modifier})]}):null,o=x.useRef(null);x.useEffect(()=>{o.current&&setTimeout(()=>{var l;(l=o.current)==null||l.focus()},100)},[]);const a=l=>{l.key==="h"&&i()};return c.jsx(Wr,{widthClass:r?"w-[93%]":"w-4/5",heightClass:r?"h-[84%]":"h-4/5",onClose:i,children:c.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-colors bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm text-zinc-800 dark:text-zinc-100",children:[c.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-zinc-200 dark:border-zinc-800 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(aE,{size:22,className:"text-caiBlue-500 dark:text-caiBlue-300"}),c.jsx("h1",{className:`font-semibold ${r?"text-xl":"text-2xl"}`,children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:i,className:"p-2 rounded-full hover:bg-opacity-10 transition-colors hover:bg-black/10 dark:hover:bg-white/10","aria-label":"Close hotkeys",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4 bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",onKeyDown:a,ref:o,tabIndex:0,children:c.jsx("div",{className:"flex flex-col gap-6",children:HCe.map(({screen:l,hotkeys:u})=>c.jsxs("div",{children:[c.jsx("h2",{className:`font-semibold mb-3 ${r?"text-lg":"text-xl"}`,children:l}),r?c.jsx("div",{className:"space-y-3",children:u.map((d,f)=>c.jsx("div",{className:"p-3 rounded-lg bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm border border-zinc-200 dark:border-zinc-700",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"font-medium text-sm",children:d.action}),d.when&&c.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-700 px-2 py-1 rounded",children:d.when})]}),c.jsx("div",{className:"flex items-center justify-between",children:s(d)})]})},f))}):c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"min-w-full border border-zinc-300 dark:border-zinc-700 rounded-lg bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-gradient-to-br from-zinc-200/100 to-zinc-300/25 dark:from-zinc-700/100 dar
1084k:to-zinc-800/25 backdrop-blur-sm",children:[c.jsx("th",{className:"px-4 py-2 text-left font-medium w-56 min-w-40 max-w-56 align-top",children:"Command"}),c.jsx("th",{className:"px-4 py-2 text-left font-medium w-40 min-w-32 max-w-40 align-top",children:"When"}),c.jsx("th",{className:"px-4 py-2 text-left font-medium w-80 min-w-56 max-w-80 align-top",children:"Action"})]})}),c.jsx("tbody",{children:u.map((d,f)=>c.jsxs("tr",{className:"border-t border-zinc-200 dark:border-zinc-700 hover:bg-zinc-100/50 dark:hover:bg-zinc-700/50 transition-colors",children:[c.jsx("td",{className:"px-4 py-2 whitespace-nowrap w-56 min-w-40 max-w-56 align-top",children:s(d)}),c.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-sm text-zinc-500 w-40 min-w-32 max-w-40 align-top",children:d.when||""}),c.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-base w-80 min-w-56 max-w-80 align-top",children:d.action})]},f))})]})})]},l))})})]})})},WCe=({question:t,answer:e,isDarkMode:n,defaultOpen:r=!1})=>{const[i,s]=x.useState(r),o=n?"text-zinc-300":"text-zinc-700",a=n?"text-white":"text-zinc-800",l=n?"text-caiGreen":"text-caiBlue",u=n?"border-zinc-700 hover:border-zinc-600":"border-zinc-200 hover:border-zinc-300",d=n?i?"bg-gradient-to-br from-zinc-800/50 to-zinc-900/50 backdrop-blur-sm":"bg-gradient-to-br from-zinc-900/75 to-zinc-900/75 backdrop-blur-sm":i?"bg-gradient-to-br from-zinc-50/80 to-zinc-100/80 backdrop-blur-sm":"bg-gradient-to-br from-white/95 to-zinc-50/95 backdrop-blur-sm";return c.jsxs("div",{className:`mb-4 rounded-lg border ${u} overflow-hidden transition-colors duration-300 ${d}`,children:[c.jsxs("button",{className:"w-full px-5 py-4 text-left flex justify-between items-center",onClick:()=>s(!i),children:[c.jsx("h3",{className:`font-medium text-base ${a}`,children:t}),c.jsx(Vi,{className:`transform transition-transform duration-300 ${i?"rotate-180":""} ${o}`,size:18})]}),c.jsx(Vn,{children:i&&c.jsx(et.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3},className:"overflow-hidden",children:c.jsx("div",{className:`px-5 pb-4 ${o}`,children:typeof e=="string"?e.includes("@")?c.jsx("p",{children:e.split("[email protected]").map((f,h,m)=>c.jsxs(mr.Fragment,{children:[f,h<m.length-1&&c.jsx("a",{href:"mailto:[email protected]",className:`font-medium ${l} hover:underline`,children:"[email protected]"})]},h))}):c.jsx("p",{children:e}):e})})})]})},D9=({onClose:t})=>{const{focusCanvas:e}=di(),{isMobile:n}=Hn(),{isDarkMode:r}=Pn(),i=()=>{e(),t&&t()},s=[{question:"What is Cai?",answer:"Cai is an AI-powered music creation platform that enables anyone to create professional-quality music, regardless of their musical background. Using natural language conversations, you can describe your musical ideas and Cai will help bring them to life with intelligent composition tools and virtual instruments.",defaultOpen:!0},{question:"How does Cai work?",answer:"Cai combines an intuitive canvas interface with powerful AI assistance. Create songs as containers for your musical ideas, then use natural language to describe what you want - whether it's 'add a jazz piano melody' or 'create a rock drum beat.' Cai understands musical context and helps you build, arrange, and refine your compositions."},{question:"Do I need music experience to use Cai?",answer:"No musical experience is required! Cai is designed for everyone from complete beginners to experienced musicians. The AI assistant helps bridge the gap between your creative ideas and technical implementation, making music creation accessible to all skill levels."},{question:"What types of music can I create?",answer:"Cai supports virtually any musical genre or style. From classical orchestrations to electronic dance music, jazz combos to heavy metal, folk songs to hip-hop beats - the platform adapts to your creative vision with appropriate instruments and musical patterns."},{question:"How much does Cai cost?",answer:"Cai offers two subscription tiers: Base Plan (48 takes per month, free) and Pro Plan (1000 takes per month, $5/month). Takes are used when generating new musical content with AI. You retain full ownership of all music you create."},{question:'What are "takes" and how do they work?',answer:"Takes are used when you request AI-generated musical content - like asking Cai to create a bass line or generate a drum pattern. Each AI generation request consumes one take. Playing back music, editing existing content, and using manual tools do not use takes. Takes reset monthly on your billing date."},{question:"Who owns the music I create?",answer:"You retain complete ownership of all music you create with Cai. The platform serves as a creative tool to help express your musical ideas - the resulting compositions are entirely yours to use, share, or commercialize as you see fit."},{question:"Can I export my music?",answer:"Yes! Cai allows you to export your compositions in standard audio formats (WAV, MP3) and MIDI files. This enables seamless integration with professional music software, sharing on streaming platforms, or further production in your preferred digital audio workstation."},{question:"What devices and browsers work with Cai?",answer:"Cai runs in any modern web browser on desktop, tablet, or mobile devices. For the best experience, we recommend Chrome or Firefox on desktop. The interface automatically adapts to your screen size, with touch-optimized controls for mobile devices."},{question:"Does Cai work on mobile?",answer:"Yes! Cai is fully functional on mobile devices with a touch-optimized interface. You can create, edit, and play music on smartphones and tablets. Note: On iOS devices, ensure your ringer switch is ON to hear audio playback."},{question:"How do I get help or report issues?",answer:"Access the Usage Manual from the menu for comprehensive documentation. For direct support, contact us at [email protected]. The app also includes helpful features like keyboard shortcuts (press H), interactive tutorials, and contextual help throughout the interface."},{question:"Can I use MIDI controllers with Cai?",answer:"Yes! Cai supports MIDI input from connected keyboards and controllers. Use them to record melodies, play virtual instruments, and control playback. Connect your MIDI device via USB and select a track to start recording with the R key."},{question:"Is my data safe and private?",answer:"Your musical creations are stored securely in your browser and our servers with industry-standard encryption. We collect minimal data necessary for service operation and use anonymous analytics to improve the platform. Your compositions remain private unless you choose to share them."},{question:"What file formats can I upload?",answer:"Cai supports a wide range of file formats: MIDI files (.mid), audio files (MP3, WAV, FLAC, OGG, AAC), images (JPG, PNG, GIF, WebP), videos (MP4, MOV, AVI), and text files. You can drag and drop files directly onto the canvas or use the upload button."},{question:"Can I collaborate with others?",answer:"While Cai is currently single-user focused, you can share your work by exp
1084orting audio files, MIDI data, or using link embeds to reference external content. We are exploring collaborative features for future updates to enable real-time music creation with others."}],o=r?"text-caiGreen hover:underline":"text-caiBlue hover:underline";return c.jsx(Wr,{onClose:i,widthClass:n?"w-[93%]":"w-[80%]",heightClass:n?"h-[84%]":"h-[90%]",blurBackground:!0,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors ${r?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm text-zinc-100":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm text-zinc-800"}`,children:[c.jsxs("div",{className:`flex justify-between items-center p-4 border-b ${r?"bg-gradient-to-br from-zinc-800/25 to-zinc-900/25 backdrop-blur-sm border-zinc-800":"bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 backdrop-blur-sm border-zinc-200"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(dx,{className:r?"text-caiBlue-400":"text-caiBlue-600",size:24}),c.jsx("h1",{className:"text-2xl font-semibold",children:"Frequently Asked Questions"})]}),c.jsx("button",{onClick:i,className:`p-2 rounded-full hover:bg-opacity-10 transition-colors ${r?"hover:bg-zinc-100":"hover:bg-zinc-900"}`,"aria-label":"Close FAQ",children:c.jsx(nr,{size:20})})]}),c.jsx("div",{className:`p-6 overflow-y-auto flex-1 ${r?"bg-gradient-to-br from-zinc-800/50 to-zinc-900/25 backdrop-blur-sm":"bg-gradient-to-br from-zinc-100/50 to-zinc-200/25 backdrop-blur-sm"}`,children:c.jsxs("div",{className:"space-y-6",children:[c.jsxs("p",{className:"mb-6",children:["Here are some commonly asked questions about Cai. If you don't find what you're looking for, feel free to reach out to our team at"," ",c.jsx("a",{href:"mailto:[email protected]",className:o,children:"[email protected]"}),"."]}),c.jsx("div",{className:"space-y-1",children:s.map((a,l)=>c.jsx(WCe,{question:a.question,answer:a.answer,isDarkMode:r,defaultOpen:a.defaultOpen||!1},l))})]})})]})})},qCe=()=>{const{isFetchingFromCloud:t}=Qh();return t?c.jsx(_v,{message:"Syncing latest changes..."}):null},KCe=({onSignOut:t})=>{LCe(),VCe();const{canvasWrapperRef:e,focusCanvas:n}=di(),{fetchUsage:r,fetchSubscription:i,checkKippCapitalEligibility:s,setShowSuccessModal:o,showSuccessModal:a,subscription:l}=tl(),[u,d]=x.useState(null);x.useEffect(()=>{const B=()=>{switch(window.location.hash.toLowerCase()){case"#faq":d("faq"),document.body.style.overflow="hidden";break;case"#about":d("about"),document.body.style.overflow="hidden";break;default:d(null),document.body.style.overflow="";break}};return B(),window.addEventListener("hashchange",B),()=>{window.removeEventListener("hashchange",B)}},[]);const f=x.useCallback(()=>{d(null),document.body.style.overflow="",window.history.pushState("",document.title,window.location.pathname+window.location.search),n()},[n]),[h,m]=x.useState(350),y=x.useRef(null),g=x.useRef(null);x.useEffect(()=>{(async()=>{try{const L=await dd();await Promise.all([r(),i(L.id),s()])}catch{}})()},[r,i,s]),x.useEffect(()=>{const B=new URLSearchParams(window.location.search),L=B.get("checkout_success"),$=B.get("session_id"),q=window.location.pathname==="/subscription/checkout/success";(L==="true"||$||q)&&(async()=>{try{const ie=await dd();if(await Promise.all([r(),i(ie.id)]),o(!0),q)window.history.replaceState({},"","/");else{const ge=new URL(window.location.href);ge.searchParams.delete("checkout_success"),ge.searchParams.delete("session_id"),window.history.replaceState({},"",ge.toString())}}catch{}})()},[r,i,o]);const{isMobile:w}=Hn();x.useEffect(()=>{Ji.pageview(window.location.pathname)},[]);const{uploadOpen:v,exportOpen:S,aboutOpen:C,hotkeysOpen:k,inspectStorageOpen:N,mobileSearchOpen:_,mobileRecordDetailsOpen:j,showVolumeAutomation:T}=Pn(),{detailsBloobId:M}=Ho(),{closeBloobDetails:V}=Xs(),{settingsOpen:H}=bi(),{caiChatState:P,chatPositionSide:F,workspaceView:I}=Yn(),R=x.useRef(null),[U,A]=x.useState(null);x.useLayoutEffect(()=>{if(I!=="immersed-song"){A(null);return}const B=R.current;if(!B)return;const L=new ResizeObserver($=>{var Z;const q=(Z=$[0])==null?void 0:Z.contentRect.width;q!==void 0&&A(q)});return L.observe(B),A(B.getBoundingClientRect().width),()=>{L.disconnect()}},[I]),x.useEffect(()=>{n()},[n]);const W=()=>{M&&V(),n()},D=x.useCallback(B=>{m(B)},[]);return c.jsxs(xpe,{FallbackComponent:kpe,onReset:W,children:[c.jsx("div",{className:"canvas-container",children:c.jsxs("div",{style:{display:"flex",width:"100vw",height:"100vh"},children:[c.jsx("div",{ref:y,style:{width:!w&&P===zn.MAXIMIZED&&F==="left"?`${h}px`:"0px",flexShrink:0,overflow:"visible",transition:"width 0.3s ease-in-out",position:"relative",zIndex:49}}),c.jsxs("div",{style:{flex:1,minWidth:0,height:"100vh",position:"relative",display:"flex",flexDirection:"column"},children:[c.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,position:"relative"},children:c.jsx("div",{tabIndex:-1,ref:e,className:"w-full h-full touch-none",children:I==="immersed-song"?c.jsxs("div",{ref:R,className:"flex flex-col w-full h-full min-w-0",children:[c.jsx(XL,{onSignOut:t,immer
1084sedContainerWidth:U}),c.jsx(ype,{})]}):c.jsx(Xhe,{onSignOut:t,canvasWrapperRef:e})})}),!w&&M!==null&&c.jsx(ame,{}),!w&&T&&I!=="immersed-song"&&c.jsx(pme,{}),v&&c.jsx(Ime,{}),S&&c.jsx(jme,{}),_&&c.jsx(qL,{}),w&&M!==null&&c.jsx(nme,{}),j&&c.jsx(qfe,{}),H&&c.jsx(Nme,{onSignOut:t}),k&&c.jsx(GCe,{}),C&&c.jsx(UC,{}),N&&c.jsx(kme,{}),a&&c.jsx(Tme,{isOpen:a,onClose:()=>o(!1),plan:(l==null?void 0:l.plan)||Nr.PRO}),c.jsx(Iwe,{}),c.jsx(XF,{})]}),c.jsx("div",{ref:g,style:{width:!w&&P===zn.MAXIMIZED&&F==="right"?`${h}px`:"0px",flexShrink:0,overflow:"visible",transition:"width 0.3s ease-in-out",position:"relative",zIndex:49}}),c.jsx(DCe,{onResize:D})]})}),u==="faq"&&c.jsx(D9,{onClose:f}),u==="about"&&c.jsx(UC,{onClose:f}),c.jsx(qCe,{})]})},Yb=window.matchMedia("(prefers-color-scheme: dark)"),A4=({children:t})=>{const{theme:e,useSystemTheme:n}=Pn(),{setTheme:r}=Br();x.useEffect(()=>{document.documentElement.setAttribute("data-theme",e),n||localStorage.setItem("cai-theme-preference",e),localStorage.setItem("cai-use-system-theme",String(n)),document.body.classList.add("theme-ready")},[e,n]);const i=x.useCallback(()=>{const s=Yb.matches?gi.Dark:gi.Light;r(s)},[r]);return x.useEffect(()=>(n?(Yb.addEventListener("change",i),i()):Yb.removeEventListener("change",i),()=>{Yb.removeEventListener("change",i)}),[i,n]),c.jsx(c.Fragment,{children:t})},L9=({children:t})=>{const[e,n]=x.useState(null),[r,i]=x.useState(It.red[400]),[s,o]=x.useState(!1),a=x.useCallback((l,u=1500,d=It.red[400])=>{n(l),i(d),o(!0),setTimeout(()=>{o(!1)},u)},[]);return c.jsxs(w8.Provider,{value:{showBanner:a},children:[t,c.jsx(cF,{children:c.jsx(Vn,{mode:"wait",children:s&&e&&c.jsx(et.div,{className:"fixed top-5 left-0 right-0 flex justify-center z-50",initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"},onAnimationComplete:l=>{l==="exit"&&n(null)},children:c.jsx("div",{style:{backgroundColor:r},className:"fixed 50% rounded-2xl text-lg text-zinc-50 p-3 text-center",role:"alert",children:e})})})})]})},D2=2.25,YCe=500,M4=150,B4=70,XCe=({onClick:t})=>{const e=x.useRef(null),n=x.useRef(null),r=x.useRef(null);return x.useEffect(()=>{const i=[5,M4-5],s=28,o=B4-9,a=g=>Math.sin(g*Math.PI)*.5+.5,l=(g,w,v)=>{const S=a(w/1e4),C=Math.pow(v-1,2),k=Math.pow(1.5,g-1),N=Math.pow(1.25,g-1),_=Math.pow(N,2*S-1),j=2*Math.PI*k*_;return s*C*Math.sin(j*v)},u=(g,w)=>{if(!g)return;let v=`M ${i[0]},${o}`;for(let S=i[0];S<i[1];S+=1){const C=o-w((S-i[0])/(i[1]-i[0]));v+=` L ${S},${C}`}g.setAttribute("d",v)},d=[e.current,n.current,r.current];let f=0,h=0;const m=5,y=()=>{h++,h%m===0&&(f+=YCe/60*m,d.forEach((g,w)=>u(g,v=>l(w+1,f,v)))),requestAnimationFrame(y)};y()},[]),c.jsxs("svg",{className:"cursor-pointer overflow-visible",viewBox:`0 0 ${M4} ${B4}`,preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",onClick:t,children:[c.jsx("text",{x:"50%",y:"85%",fontSize:"80px",dominantBaseline:"alphabetic",textAnchor:"middle",className:"fill-white",fontFamily:"'Times New Roman', Times, serif",children:"Cai."}),c.jsx("path",{ref:e,stroke:Si.caiBlue[500],strokeWidth:D2,strokeLinecap:"round",className:"transition-all duration-300 ease-in-out",fill:"transparent"}),c.jsx("path",{ref:n,stroke:Si.caiGreen[500],strokeWidth:D2,strokeLinecap:"round",className:"transition-all duration-300 ease-in-out",fill:"transparent"}),c.jsx("path",{ref:r,stroke:Si.caiPeach[500],strokeWidth:D2,strokeLinecap:"round",className:"transition-all duration-300 ease-in-out",fill:"transparent"})]})},L2=["Let's make something magical...","Give me a mysterious piano melody...","Text, speak, hum, or sing to me...","Give me a catchy reggaeton drum beat...","Talk to me like you'd talk to your average superproducer...","I want a smooth, soulful R&B guitar riff expressing nostalgia...","What are we making next?...","Design a futuristic, otherworldly bassline...","Ask me for some song ideas...","Can you give me a smooth, romantic saxophone solo?...","Make a holiday melody with some glistening bells...","I'm feeling some old-school funk. Hit me with some ideas...","Making music just got a whole lot easier...","How can I make this section more interesting?...","Craft an ethereal synth lead from another dimension...","Well that was easy, wasn't it?...","Generate a heartfelt, tear-jerking piano ballad...","Can this section change so that it goes like duh-duh-dah?...","So easy, even Grandma can make hits...","How can I make this chours section feel more full?...","Give me some sick, powerful rock drums to start this intro...","What are some interesting ideas for this EDM drop?...","Let's get a Grammy with this next idea...","Craft an emotional violin solo to go with this piano...","So that's how the intern got so good at producing...","Generate a gritty, chopped trap drum loop...","Give me a flamenco guitar that goes well with this piano melody...","Can I get a guitar melody that builds into this chorus?...","Stuck on that verse transition? Let's get unstuck..."],Xb=50,QCe=2e3,F9=x.forwardRef(({onSubmit:t},e)=>
1084{const[n,r]=x.useState(Xb),[i,s]=x.useState(-1),[o,a]=x.useState(""),[l,u]=x.useState(!1),[d,f]=x.useState(""),h=x.useCallback(()=>{const w=L2[i];if(o===""){const v=(i+1)%L2.length,S=L2[v];s(v),a(S.slice(0,1)),u(!1)}else l?(a(o.slice(0,-1)),r(Xb)):o===w?(u(!0),r(QCe)):(a((w==null?void 0:w.slice(0,o.length+1))??""),r(Xb))},[l,i,o]);x.useEffect(()=>{const w=setInterval(h,n);return()=>clearInterval(w)},[h,n]);const m=x.useCallback(()=>{a(""),r(Xb)},[]),y=w=>{w.key==="Enter"&&g()},g=()=>{t()};return x.useImperativeHandle(e,()=>({handleResetPlaceholder:m})),x.useEffect(()=>{const w=document.createElement("style");return w.textContent=` 1085 @keyframes caiSmoothSlide { 1086 0% { background-position: 0% 50%; } 1087 50% { background-position: 100% 50%; } 1088 100% { background-position: 0% 50%; } 1089 } 1090 1091 /* Animated gradient ring with TRANSPARENT center via mask cutout */ 1092 .cai-gradient-ring { 1093 position: absolute; 1094 inset: 0; 1095 border-radius: 9999px; 1096 padding: 2px; /* ring thickness */ 1097 pointer-events: none; 1098 background: linear-gradient( 1099 90deg, 1100 ${Si.caiPeach[500]} 0%, 1101 ${Si.caiGreen[500]} 33%, 1102 ${Si.caiBlue[500]} 66%, 1103 ${Si.caiPeach[500]} 100% 1104 ); 1105 background-size: 200% 200%; 1106 animation: caiSmoothSlide 6s linear infinite; 1107 } 1108 1109 /* Mask to remove the center so only the border shows */ 1110 .cai-gradient-ring { 1111 -webkit-mask: 1112 linear-gradient(#000 0 0) content-box, 1113 linear-gradient(#000 0 0); 1114 -webkit-mask-composite: xor; /* Safari */ 1115 mask-composite: exclude; /* Standard */ 1116 } 1117 1118 /* Use box-shadow instead of filter for glow */ 1119 .cai-chat-glow { 1120 box-shadow: 0 0 16px rgba(255, 255, 255, 0.2), 0 0 16px rgba(255, 255, 255, 0.10); 1121 } 1122 `,document.head.appendChild(w),()=>{document.head.removeChild(w)}},[]),c.jsxs("div",{className:"relative rounded-full w-full h-20 cai-chat-glow",children:[c.jsx("input",{className:["absolute inset-0 m-0.5 rounded-full","py-2 px-2 text-ellipsis text-lg md:text-xl","bg-transparent","text-center text-white placeholder:text-white placeholder:focus:text-white/70","[--pl:theme(spacing.6)]",d.trim()?"[--pr:9rem]":"[--pr:3.5rem]","pl-[var(--pl)] pr-[var(--pr)]","[text-indent:calc((var(--pr)-var(--pl)))]","transition-[background-color,color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter] duration-200"].join(" "),placeholder:o,value:d,onChange:w=>f(w.target.value),onKeyDown:y,name:"search",autoComplete:"off","data-form-type":"other",style:{WebkitTapHighlightColor:"transparent"}}),c.jsx("div",{"aria-hidden":"true",className:"cai-gradient-ring"}),c.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none",children:c.jsxs("button",{type:"button",onClick:g,className:["group pointer-events-auto","rounded-full transition-all duration-200","outline-none focus:outline-none focus-visible:outline-none","ring-0 focus:ring-0 focus-visible:ring-0","border-0 [box-shadow:none]","flex items-center",d.trim()?"bg-gradient-to-r from-caiGreen to-caiBlue px-4 py-2":"p-2"].join(" "),style:{WebkitTapHighlightColor:"transparent"},"aria-label":"Submit",children:[c.jsx(uo,{size:24,className:["transition-colors duration-200","fill-none",d.trim()?"text-white group-hover:text-zinc-100":"text-white/70 group-hover:text-white"].join(" ")}),d.trim()&&c.jsx("span",{className:"ml-2 text-white font-medium text-md transition-all duration-200",children:"Create"})]})})]})});F9.displayName="FakeCaiChat";const ZCe=({className:t="",isScrolled:e=!1,onSignInClick:n,onSignUpClick:r})=>{const{focusCanvas:i}=di(),[s,o]=x.useState(!1),a=m=>{window.location.hash=m},l=m=>{window.location.href=m,o(!1)},u=()=>{window.location.href="mailto:[email protected]",o(!1)},d=()=>{n==null||n(),o(!1)},f=()=>{r==null||r(),o(!1)};x.useEffect(()=>{const m=()=>{window.location.hash&&o(!1)};return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]);const h=()=>{o(!1),i()};return x.useEffect(()=>{const m=y=>
1122{s&&!y.target.closest(".menu-container")&&!y.target.closest(".sidebar")&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[s]),c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"menu-container",children:c.jsx("button",{onMouseDown:()=>o(!s),className:`${t} 1123 rounded-full transition-all duration-300 1124 text-zinc-100 1125 hover:bg-zinc-100 1126 hover:text-zinc-900 1127 flex items-center justify-center size-10 1128 ${e?"opacity-60":"opacity-100"} 1129 `,"aria-label":"Menu",children:c.jsx(Dte,{size:24})})}),s&&c.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-25 transition-opacity z-50",onClick:h}),c.jsx("div",{className:` 1130 sidebar 1131 fixed top-0 left-0 h-full w-64 z-50 1132 transform transition-transform duration-300 ease-in-out 1133 ${s?"translate-x-0":"-translate-x-full"} 1134 backdrop-blur-sm 1135 before:absolute before:top-0 before:right-0 before:w-[2px] before:h-full 1136 before:bg-gradient-to-b before:from-[#6b88cc] before:via-[#7dc383] before:to-[#f8c291] 1137 opacity-100 1138 `,style:{background:"linear-gradient(180deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59,
11380.85) 25%, rgba(2, 6, 23, 0.85) 60%, rgba(0, 0, 0, 0.85) 100%)",backgroundAttachment:"fixed"},children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsx("div",{className:"flex-grow overflow-y-auto pt-16",children:c.jsxs("div",{className:"px-4 space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-400",children:"Product"}),c.jsx("button",{onClick:()=>{window.open("https://calendar.app.google/BGDTtPzPuQ3LdwKs5","_blank"),o(!1)},className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1139 transition-colors duration-200 1140 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1141 text-zinc-100 1142 hover:text-zinc-900 1143 bg-transparent`,children:"Book a Demo"}),c.jsx("button",{onClick:f,className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1144 transition-colors duration-200 1145 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1146 text-zinc-100 1147 hover:text-zinc-900 1148 bg-transparent`,children:"Sign Up"}),c.jsx("button",{onClick:d,className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1149 transition-colors duration-200 1150 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1151 text-zinc-100 1152 hover:text-zinc-900 1153 bg-transparent`,children:"Sign In"})]}),c.jsx("div",{className:"my-4 border-t border-zinc-600"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-400",children:"Help & Support"}),c.jsxs("button",{onMouseDown:u,className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1154 transition-colors duration-200 1155 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1156 text-zinc-100 1157 hover:text-zinc-900 1158 bg-transparent`,children:[c.jsx(_h,{size:16,className:"mr-3"}),"Contact Us"]}),c.jsxs("button",{onMouseDown:()=>a("about"),className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1159 transition-colors duration-200 1160 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1161 text-zinc-100 1162 hover:text-zinc-900 1163 bg-transparent`,children:[c.jsx(Kc,{size:16,className:"mr-3"}),"About Cai"]}),c.jsxs("button",{onMouseDown:()=>a("faq"),className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1164 transition-colors duration-200 1165 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1166 text-zinc-100 1167 hover:text-zinc-900 1168 bg-transparent`,children:[c.jsx(dx,{size:16,className:"mr-3"}),"FAQ"]})]}),c.jsx("div",{className:"my-4 border-t border-zinc-600"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium mb-2 text-zinc-400",children:"Legal"}),c.jsxs("button",{onMouseDown:()=>l("/privacy"),className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1169 transition-colors duration-200 1170 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1171 text-zinc-100 1172 hover:text-zinc-900 1173 bg-transparent`,children:[c.jsx($i,{size:16,className:"mr-3"}),"Privacy Policy"]}),c.jsxs("button",{onMouseDown:()=>l("/cookies"),className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1174 transition-colors duration-200 1175 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1176 text-zinc-100 1177 hover:text-zinc-900 1178 bg-transparent`,children:[c.jsx($i,{size:16,className:"mr-3"}),"Cookie Policy"]}),c.jsxs("button",{onMouseDown:()=>l("/terms"),className:`flex items-center w-full px-4 py-2.5 text-base rounded-md 1179 transition-colors duration-200 1180 hover:bg-gradient-to-br hover:from-zinc-200 hover:to-zinc-500 1181 text-zinc-100 1182 hover:text-zinc-900 1183 bg-transparent`,children:[c.jsx($i,{size:16,className:"mr-3"}),"Terms of Use"]})]})]})}),c.jsx("div",{className:"px-4 pb-4",children:c.jsx("div",{className:"text-xs text-center text-zinc-400",children:"© Cai Creative, Inc. 2025"})})]})})]})},JCe=({showSignInButton:t,onSignInClick:e,onSignUpClick:n,showMenuToggle:r=!0})=>{const[i,s]=x.useState(!1);return x.useEffect(()=>{const o=()=>{const a=window.scrollY||document.documentElement.scrollTop;s(a>50)};return window.addEventListener("scroll",o),()=>window.removeEventListener("scroll",o)},[]),c.jsxs("div",{className:"fixed z-50 top-3 left-0 right-0 px-3 w-full flex justify-between pointer-events-none",children:[c.jsx("div",{className:"pointer-events-auto",children:r&&c.jsx(ZCe,{isScrolled:i,onSignInClick:e,onSignUpClick:n})}),t&&c.jsxs("div",{className:`flex items-center gap-3 pointer-events-auto transition-opacity duration-300 ${i?"opacity-60":"opacity-100"}`,children:[c.jsx("button",{className:`relative py-2 px-4 group 1184 bg-gradient-to-r from-caiBlue/100 to-caiGreen/75 1185 border border-zinc-800/40 1186 rounded-full shadow-sm transition-all duration-200 1187 text-zinc-100 hover:text-zinc-900 1188 overflow-hidden ${i?"bg-opacity-70 backdrop-blur-md":""}`,onClick:e,style:{backgroundSize:"200% 200%"},children:c.jsx("span",{className:"relative z-10",children:"Sign in"})}),c.jsxs("button",{className:`relative py-2 px-4 group 1189 bg-transparent 1190 rounded-full shadow-sm transition-all duration-200 1191 text-zinc-300 hover:text-zinc-100 1192 overflow-hidden ${i?"backdrop-blur-md":""}`,onClick:n,children:[c.jsx("div",{className:`absolute inset-0 rounded-full bg-gradient-to-r from-caiBlue to-caiGreen p-0.5 ${i?"opacity-70":"opacity-100"} transition-opacity duration-300 pointer-events-none`,style:{WebkitMask:"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)",WebkitMaskComposite:"xor",maskComposite:"exclude"}}),c.jsxs("span",{className:"relative z-10",children:[c.jsx("span",{className:"block md:hidden",children:"Sign up"}),c.jsx("span",{className:"hidden md:block",children:"Sign up for free"})]})]})]})]})};function R4(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function e_e(...t){return e=>{let n=!1;const r=t.map(i=>{const s=R4(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():R4(t[i],null)}}}}function t_e(t){const e=r_e(t),n=x.forwardRef((r,i)=>{const{children:s,...o}=r,a=x.Children.toArray(s),l=a.find(s_e);if(l){const u=l.props.children,d=a.map(f=>f===l?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:f);return c.jsx(e,{...o,ref:i,children:x.isValidElement(u)?x.cloneElement(u,void 0,d):null})}return c.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}var n_e=t_e("Slot");function r_e(t){const e=x.forwardRef((n,r)=>{const{children:i,...s}=n;
1192if(x.isValidElement(i)){const o=a_e(i),a=o_e(s,i.props);return i.type!==x.Fragment&&(a.ref=r?e_e(r,o):o),x.cloneElement(i,a)}return x.Children.count(i)>1?x.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var i_e=Symbol("radix.slottable");function s_e(t){return x.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===i_e}function o_e(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function a_e(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const O4=t=>typeof t=="boolean"?"".concat(t):t===0?"0":t,D4=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.flat(1/0).filter(Boolean).join(" ")},l_e=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return D4(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(u=>{const d=n==null?void 0:n[u],f=s==null?void 0:s[u];if(d===null)return null;const h=O4(d)||O4(f);return i[u][h]}),a=n&&Object.entries(n).reduce((u,d)=>{let[f,h]=d;return h===void 0||(u[f]=h),u},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:h,...m}=d;return Object.entries(m).every(y=>{let[g,w]=y;return Array.isArray(w)?w.includes({...s,...a}[g]):{...s,...a}[g]===w})?[...u,f,h]:u},[]);return D4(t,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},c_e=l_e("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Cc=mr.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...i},s)=>{const o=r?n_e:"button";return c.jsx(o,{className:vY(c_e({variant:e,size:n,className:t})),ref:s,...i})});Cc.displayName="Button";let Qb;const u_e=new Uint8Array(16);function d_e(){if(!Qb&&(Qb=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Qb))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Qb(u_e)}const Ki=[];for(let t=0;t<256;++t)Ki.push((t+256).toString(16).slice(1));function f_e(t,e=0){return Ki[t[e+0]]+Ki[t[e+1]]+Ki[t[e+2]]+Ki[t[e+3]]+"-"+Ki[t[e+4]]+Ki[t[e+5]]+"-"+Ki[t[e+6]]+Ki[t[e+7]]+"-"+Ki[t[e+8]]+Ki[t[e+9]]+"-"+Ki[t[e+10]]+Ki[t[e+11]]+Ki[t[e+12]]+Ki[t[e+13]]+Ki[t[e+14]]+Ki[t[e+15]]}const h_e=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L4={randomUUID:h_e};function p_e(t,e,n){if(L4.randomUUID&&!t)return L4.randomUUID();t=t||{};const r=t.random||(t.rng||d_e)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,f_e(r)}const m_e=3e3,g_e=100,b_e=100,F4="calc(100% - 2rem)",y_e="1.5rem",v_e="rgb(255, 255, 255)",x_e="rgb(26, 26, 26)",w_e="rgb(26, 26, 26)",k_e="rgb(255, 255, 255)",ks=[{id:"role",title:"How would you describe your role or interest in music?",description:["Artist: I create and perform my own music, focusing on developing my artistic voice through songwriting, recording, and live performance.","Producer: I primarily work on producing and arranging music, collaborating with artists to bring their ideas to life and perfecting tracks for release.","Instrumentalist: I play one or more instruments and enjoy performing, but I may not be focused on composition or production.","Music Enthusiast: I have a general interest in music but do not create it actively. I enjoy exploring and listening to various genres."],type:"multiple-choice",answers:["Artist","Producer","Instrumentalist","Music Enthusiast"],isMandatory:!0},{id:"expertise",title:"What describes your level of expertise in music theory?",description:["None: I have never studied music theory and do not have any formal education or understanding of musical concepts and structures.","Basic: I have a general understanding of music theory concepts, but I find them challenging to apply.","Intermediate: I can grasp basic music theory concepts and apply them in practice, but I still have room for growth.","Advanced: I have a strong understanding of music theory and can apply advanced concepts in my compositions and analyses."],type:"multiple-choice",answers:["None","Basic","Intermediate","Advanced"],isMandatory:!0},{id:"experience",title:"How would you describe your experience with digital music composition?",description:["None: I have never used a digital music composition platform and am unfamiliar with the tools and processes for it.","Beginner: I have used one of these platforms a few times but feel uncertain about my abilities and using these platforms.","Intermediate: I can navigate the basics of these platforms, but I still have some challenges with more advanced features and techniques.","Advanced: I am proficient in using these platforms and frequently utilize advanced features and techniques."],type:"multiple-choice",answers:["None","Beginner","Intermediate","Advanced"],isMandatory:!0},{id:"interest",title:"What are you most interested in getting out of Cai?",description:["Production: My primary focus is getting help with melodies, sounds, and ideas, with suggestions based on my input and current project.","Engineering: My primary focus is getting help with recording, mixing, and mastering the elements in my project."],t
1192ype:"multiple-choice",answers:["Production","Engineering"],isMandatory:!0},{id:"comments",title:"Any extra comments?",description:"Feel free to share any additional thoughts or feedback.",type:"text",fields:["comments"],isMandatory:!1},{id:"contact",title:"You'll hear from us soon.",description:"We appreciate you taking the time to fill out our interest form. Enter your information and expect to hear updates on your waitlist status soon.",type:"contact",fields:["firstName","lastName","email"],isMandatory:!0}],S_e=({fieldName:t,value:e,onChange:n,required:r,...i})=>{const s=t.split(/(?=[A-Z])/).join(" ").replace(/^\w/,o=>o.toUpperCase());return c.jsx("input",{type:t.toLowerCase()==="email"?"email":"text",placeholder:s,value:e,onChange:o=>n(o.target.value),required:r,className:"w-full p-2 border border-input rounded focus:border-primary focus:ring focus:ring-primary focus:ring-opacity-50 bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm border-zinc-300/40 dark:border-zinc-800/40 text-zinc-900 dark:text-zinc-100",...i})};function C_e({onClose:t}){const[e,n]=x.useState({currentStep:-1,answers:{},missingFields:[],mandatoryMissingFields:[],isCompleted:!1}),[r,i]=x.useState(0),[s,o]=x.useState(null),[a,l]=x.useState(null),[u,d]=x.useState(!1),[,f]=x.useState(!1),[h,m]=x.useState(!0),y=x.useRef(null),{theme:g}=Pn(),w=R=>{n(U=>({...U,...R}))},v=x.useCallback(()=>{w({currentStep:0}),f(!1)},[]),S=x.useCallback(()=>{w({isCompleted:!0})},[]),C=x.useCallback(()=>{const R=ks[e.currentStep];if(R.isMandatory&&!e.answers[R.id]){f(!0),w({mandatoryMissingFields:[R.title]});return}if(e.currentStep<ks.length-1){const U=e.currentStep+1;w({currentStep:U}),i(0),o(null),f(!1),l(null)}},[e.currentStep,e.answers]),k=x.useCallback(()=>{e.currentStep>0&&(w({currentStep:e.currentStep-1}),i(0),o(null),f(!1),l(null))},[e.currentStep]),N=x.useCallback((R,U)=>{w({answers:{...e.answers,[R]:U}})},[e.answers]),_=async R=>{if(R.preventDefault(),e.currentStep<ks.length-1)return;f(!0);const A=ks.reduce((W,D)=>(D.type==="contact"?D.fields.forEach(B=>{(!e.answers[B]||e.answers[B].trim()==="")&&W.push(B.replace(/([A-Z])/g," $1").trim())}):(D.type==="multiple-choice"||D.type==="text")&&(!e.answers[D.id]||e.answers[D.id].trim()==="")&&W.push(D.title),W),[]).filter(W=>{var D;return(D=ks.find(B=>{var L;return B.title===W||((L=B.fields)==null?void 0:L.some($=>$.toLowerCase()===W.toLowerCase()))}))==null?void 0:D.isMandatory});if(A.length>0)w({mandatoryMissingFields:A});else{d(!0);const W=new Date().toISOString(),D=p_e(),B=!1;try{const L=await ui.post("https://53kmfvxbbf.execute-api.us-east-1.amazonaws.com/prod/waitlist",{...e.answers,submissionTimestamp:W,uniqueToken:D,whitelisted:B},{headers:{"Content-Type":"application/json"}});S()}catch{}finally{d(!1)}}};x.useEffect(()=>{var R;if(e.currentStep>=0&&Array.isArray((R=ks[e.currentStep])==null?void 0:R.description)){const U=setInterval(()=>{!s&&!a&&i(A=>{const W=(A+1)%ks[e.currentStep].description.length,D=Date.now();return T(D),W})},m_e);return()=>{clearInterval(U)}}},[e.currentStep,s,a]);const[j,T]=x.useState(0),M=x.useCallback(R=>{if(e.currentStep<0)return;f(!1);const U=ks[e.currentStep].id;a===R?(l(null),w({answers:Object.fromEntries(Object.entries(e.answers
1192).filter(([A])=>A!==U))})):(l(R),N(U,R))},[e.currentStep,a,N,e.answers]),V=x.useCallback(R=>{var U;if(!(e.currentStep<0)&&(f(!1),o(R),R!==null&&Array.isArray((U=ks[e.currentStep])==null?void 0:U.description))){const A=ks[e.currentStep].answers.indexOf(R);A!==-1&&(i(A),T(Date.now()))}},[e.currentStep]);let H=null;e.currentStep>=0&&e.currentStep<ks.length&&(H=ks[e.currentStep]);const P=()=>{if(!H)return"";const R=H.description;if(Array.isArray(R))if(s){const U=H.answers.indexOf(s);return R[U]||""}else if(a){const U=H.answers.indexOf(a);return R[U]||""}else return R[r];else return R},F={backgroundColor:g===gi.Dark?w_e:v_e,color:g===gi.Dark?k_e:x_e},I=()=>{m(!1),setTimeout(()=>{t()},b_e)};return c.jsx(Vn,{children:h&&c.jsxs(et.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:g_e/1e3},className:"bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40 rounded-lg shadow-sm",style:{maxWidth:"100%",width:"100%",maxHeight:"100vh",overflowY:"auto",overflowX:"hidden"},children:[e.currentStep===-1&&c.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",style:{padding:y_e},children:[c.jsx("h2",{className:"text-2xl font-bold",children:"Welcome to Cai."}),c.jsx("p",{children:"We're building the world's best platform for intuitive, effortless, and accessible music creation. We're in the early stages of development, but we'd love to have you try it out."}),c.jsxs("div",{className:"flex flex-col items-center w-full max-w-md mx-auto space-y-4",children:[c.jsx(et.div,{whileHover:{scale:1.05},whileTap:{scale:.95},style:{width:F4},children:c.jsxs(Cc,{onClick:v,className:"w-full transition-colors duration-200 py-4 font-semibold relative overflow-hidden",style:{backgroundColor:"rgb(125, 195, 131)",color:"white"},children:[c.jsx("span",{className:"relative",children:"Apply to Cai Beta"}),c.jsx(et.div,{className:"absolute inset-0 border-4 border-primary rounded-lg",style:{filter:"blur(4px)"},animate:{scale:[1,1.05,1],opacity:[.8,.4,.8]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}})]})}),c.jsx(et.div,{whileHover:{scale:.98},whileTap:{scale:1.02},style:{width:F4},children:c.jsx(Cc,{onClick:I,className:"w-full transition-colors duration-200 py-4",style:{backgroundColor:"rgb(248, 194, 145)",color:"rgb(255, 255, 255)"},children:"Exit"})})]})]}),e.isCompleted?c.jsxs(et.div,{initial:{opacity:0,y:50},animate:{opacity:1,y:0},exit:{opacity:0,y:-50},transition:{duration:.5},className:"w-full max-w-md mx-auto p-6 space-y-6",children:[c.jsx("h2",{className:"text-2xl font-bold",children:"Thank you!"}),c.jsx("p",{children:"Your response has been submitted successfully. We appreciate your time and input."}),c.jsx(Cc,{onClick:I,className:"w-full bg-primary hover:bg-primary/90 text-primary-foreground",style:F,children:"Close"})]}):H&&c.jsxs("form",{ref:y,onSubmit:_,className:"w-full max-w-md mx-auto p-6 space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("h2",{className:"text-2xl font-bold",children:H.title}),c.jsx(Vn,{mode:"wait",children:c.jsx(et.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.5},className:"text-sm text-muted-foreground h-20 sm:h-12",children:P()},j)})]}),c.jsx(Vn,{mode:"wait",children:c.jsxs(et.div,{initial:{opacity:0,x:50},animate:{opacity:1,x:0},exit:{opacity:0,x:-50},transition:{duration:.3},children:[H.type==="multiple-choice"&&c.jsx("div",{className:"space-y-2",children:H.answers.map(R=>{const U=a===R||e.answers[H.id]===R;return c.jsx(et.button,{type:"button",onClick:()=>M(R),onMouseEnter:()=>V(R),onMouseLeave:()=>V(null),className:`w-full p-3 text-left rounded-lg transition-all bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40 text-zinc-900 dark:text-zinc-100 hover:bg-zinc-800 dark:hover:bg-zinc-100 ${U?"scale-105 ring-2 ring-caiBlue-500":""}`,whileHover:{scale:1.02},whileTap:{scale:.98},children:c.jsx("div",{className:"font-bold",children:R})},R)})}),(H.type==="contact"||H.type==="text")&&c.jsx("div",{className:"space-y-3",children:H.fields.map(R=>c.jsx(S_e,{fieldName:R,value:e.answers[R]||"",onChange:U=>N(R,U),required:H.isMandatory},R))})]},e.currentStep)}),c.jsx("div",{className:"w-full max-w-2/5 mx-auto",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx(et.div,{whileHover:{scale:1.05},whileTap:{scale:.95},children:c.jsxs(Cc,{type:"button",onClick:k,disabled:e.currentStep===0,variant:"outline",className:`border-primary text-primary hover:bg-primary hover:text-primary-foreground transition-colors duration-200 bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm border-zinc-300/40 dark:border-zinc-800/40 ${e.currentStep===0?"opacity-50 cursor-not-allowed":""}`,children:[c.jsx("span",{className:"inline sm:hidden",children:c.jsx(Sh,{className:"h-4 w-4"})}),c.jsxs("span",{className:"hidden sm:inline-flex items-center",children:[c.jsx(Sh,{className:"mr-2 h-4 w-4"}),"Previous"]})]})}),c.jsx(et.div,{whileHover:{scale:1.05},whileTap:{scale:.95},children:c.jsx(Cc,{type:"button",onClick:I,variant:"outline",className:"border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground transition-colors duration-200 bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm",style:{borderColor:"rgb(248, 194, 145)",color:"rgb(248, 194, 145)"},children:"Exit"})}),e.currentStep<ks.length-1?c.jsx(et.div,{whileHover:{scale:1.05},whileTap:{scale:.95},children:c.jsxs(Cc,{type:"button",onClick:C,disabled:H.isMandatory&&!e.answers[H.id],className:`bg-primary hover:bg-primary/90 text-primary-foreground transition-colors duration-200 bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm border border-zinc-300/40 dark:border-zinc-800/40 ${H.isMandatory&&!e.answers[H.id]?"opacity-50 cursor-not-allowed":""}`,style:F,children:[c.jsx("span",{className:"inline sm:hidden",children:c.jsx(pi,{className:"h-4 w-4"})}),c.jsxs("span",{className:"hidden sm:inline-flex items-center",children:["Next",c.jsx(pi,{className:"ml-2 h-4 w-4"})]})]})}):c.jsx(et.div,{whileHover:{scale:1.05},whileTap:{scale:.95},animate:u?{scale:[1,1.1,1]}:{},transition:{duration:.5,repeat:u?1/0:0},children:c.jsx(Cc,{type:"submit",disabled:u,className:"border-[#7dc383] text-[#7dc383] bg-primary hover:bg-primary/90 transition-colors duration-200 bg-gradient-to-br from-zinc-100/75 to-zinc-200/75 dark:from-zinc-800/75 dark:to-zinc-900/75 backdrop-blur-sm",style:{borderColor:"#7dc383",color:"#7dc383"},children:u?"Submitting...":c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"inline sm:hidden",children:c.jsx(Ml,{className:"h-4 w-4"})}),c.jsx("span",{className:"hidden sm:inline",children:"Submit"})]})})})]})}),c.jsx("div",{className:"w-full bg-secondary rounded-full h-0.5",children:c.jsx("div",{className:"bg-primary h-0.5 rounded-full transition-all duration-500 ease-in-out",style:{width:`${(e.currentStep+1)/ks.length*100}%`}})}),c.jsx("div",{className:"w-full bg-white/10 rounded-full h-0.5 mt-2",children:c.jsx("div",{className:"bg-gradient-to-r from-caiGreen-500 to-caiBlue-500 h-0.5 rounded-full transition-all duration-500 ease-in-out",style:{width:`${(e.currentStep+1)/ks.length*100}%`}})})]})]})})}const zf={background:` 1193 linear-gradient( 1194 to right, 1195 ${Si.caiPeach[500]} 0%, 1196 ${Si.caiGreen[500]} 33%, 1197 ${Si.caiBlue[500]} 66%, 1198 ${Si.caiPeach[500]} 100% 1199 ) 1200 `,backgroundSize:"200% 200%",backgroundPosition:"0% 50%"},Yp={...zf,animation:"gradientMove 1.5s ease"},__e=({size:t=20})=>c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",children:[c.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),c.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),c.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),c.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),E_e=({size:t=20})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"#1877F2",children:c.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),N_e=({size:t=20})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"#000000",children:c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),I_e=({size:t=20})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"#5865F2",children:c.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18
12001.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})}),j_e=({size:t=20})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"#1DB954",children:c.jsx("path",{d:"M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.42 1.56-.299.421-1.02.599-1.559.3z"})}),Zb=({id:t,name:e,autoComplete:n,value:r,onChange:i,placeholder:s,showPassword:o,toggleVisibility:a})=>{const[l,u]=x.useState(!1),d=h=>{h.preventDefault(),u(!0)},f=h=>{l&&u(!1),i(h)};return c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:o?"text":"password",id:t,name:e,autoComplete:n,placeholder:s,value:r,onChange:f,onInvalid:d,className:"w-full p-3 pr-10 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0}),c.jsx("button",{type:"button",onClick:h=>{h.preventDefault(),a()},className:"absolute inset-y-0 right-0 px-3 flex items-center text-zinc-400 hover:text-caiBlue-500 transition-colors",children:o?c.jsx(Jy,{size:20}):c.jsx(gD,{size:20})}),l&&c.jsxs("div",{className:"custom-validation-tooltip",children:[c.jsx(z0,{size:14}),"Please fill out this field"]})]})},$4=({onSuccess:t,onClose:e,initialState:n="SIGN_IN"})=>{const[r,i]=x.useState(n),[s,o]=x.useState(""),[a,l]=x.useState(""),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,y]=x.useState(""),[g,w]=x.useState(""),[v,S]=x.useState(!1),[C,k]=x.useState(null),[N,_]=x.useState(!1),[j,T]=x.useState(!1),[M,V]=x.useState(!1),[H,P]=x.useState(!1),F=2e3,[I,R]=x.useState(!1),[U,A]=x.useState(!1),W=300,D=50,B={FIRST:100,SECOND:400,THIRD:700},L=oe=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(oe);x.useEffect(()=>{const oe=()=>{V(!1);const Q=new URL(window.location.href);(Q.searchParams.has("error")||Q.hash.includes("error="))&&(Q.searchParams.delete("error"),Q.searchParams.delete("error_code"),Q.searchParams.delete("error_description"),Q.hash="",window.history.replaceState({},"",Q.pathname+Q.search))};return window.addEventListener("popstate",oe),()=>window.removeEventListener("popstate",oe)},[]);
1200const $=async oe=>{var Q,de;oe.preventDefault(),oe.stopPropagation(),V(!0),setTimeout(()=>{V(!1)},F);try{await Dp({provider:"google"})}catch(Ne){V(!1);const Ce=Ne;(Q=Ce.message)!=null&&Q.includes("account already exists")||(de=Ce.message)!=null&&de.includes("already associated")||Ce.name==="AliasExistsException"?k("An account with this email already exists. Please sign in with your email and password, then link your Google account in Account Settings."):k("Google sign-in failed. Please try again.")}},q=async oe=>{var Q,de;oe.preventDefault(),oe.stopPropagation(),V(!0),setTimeout(()=>{V(!1)},F);try{await Dp({provider:"facebook"})}catch(Ne){V(!1);const Ce=Ne;(Q=Ce.message)!=null&&Q.includes("account already exists")||(de=Ce.message)!=null&&de.includes("already associated")||Ce.name==="AliasExistsException"?k("An account with this email already exists. Please sign in with your email and password, then link your Facebook account in Account Settings."):k("Facebook sign-in failed. Please try again.")}},Z=async oe=>{var Q,de;oe.preventDefault(),oe.stopPropagation(),V(!0),setTimeout(()=>{V(!1)},F);try{await Dp({provider:{custom:"X"}})}catch(Ne){V(!1);const Ce=Ne;(Q=Ce.message)!=null&&Q.includes("account already exists")||(de=Ce.message)!=null&&de.includes("already associated")||Ce.name==="AliasExistsException"?k("An account with this email already exists. Please sign in with your email and password, then link your X/Twitter account in Account Settings."):k("X/Twitter sign-in failed. Please try again.")}},ie=async oe=>{var Q,de;oe.preventDefault(),oe.stopPropagation(),V(!0),setTimeout(()=>{V(!1)},F);try{await Dp({provider:{custom:"Discord"}})}catch(Ne){V(!1);const Ce=Ne;(Q=Ce.message)!=null&&Q.includes("account already exists")||(de=Ce.message)!=null&&de.includes("already associated")||Ce.name==="AliasExistsException"?k("An account with this email already exists. Please sign in with your email and password, then link your Discord account in Account Settings."):k("Discord sign-in failed. Please try again.")}},ge=async oe=>{var Q,de;oe.preventDefault(),oe.stopPropagation(),V(!0),setTimeout(()=>{V(!1)},F);try{await Dp({provider:{custom:"Spotify"}})}catch(Ne){V(!1);const Ce=Ne;(Q=Ce.message)!=null&&Q.includes("account already exists")||(de=Ce.message)!=null&&de.includes("already associated")||Ce.name==="AliasExistsException"?k("An account with this email already exists. Please sign in with your email and password, then link your Spotify account in Account Settings."):k("Spotify sign-in failed. Please try again.")}},re=oe=>{T(!0),setTimeout(()=>{i(oe),setTimeout(()=>{T(!1)},D)},W)};x.useEffect(()=>{const oe=document.createElement("style");return oe.innerHTML=` 1201 @keyframes gradientMove { 1202 0% { background-position: 0% 50%; } 1203 50% { background-position: 100% 50%; } 1204 100% { background-position: 0% 50%; } 1205 } 1206 1207 @keyframes fadeIn { 1208 0% { opacity: 0; transform: translateY(5px); } 1209 100% { opacity: 1; transform: translateY(0); } 1210 } 1211 1212 .welcome-text-word { 1213 opacity: 0; 1214 display: inline-block; 1215 } 1216 1217 .welcome-text-word-1 { 1218 animation: fadeIn 0.5s ease-out ${B.FIRST}ms forwards; 1219 } 1220 1221 .welcome-text-word-2 { 1222 animation: fadeIn 0.5s ease-out ${B.SECOND}ms forwards; 1223 } 1224 1225 .welcome-text-word-3 { 1226 animation: fadeIn 0.5s ease-out ${B.THIRD}ms forwards; 1227 } 1228 1229 /* Custom validation tooltip styles */ 1230 .custom-validation-tooltip { 1231 position: absolute; 1232 left: 50%; 1233 transform: translateX(-50%); 1234 bottom: calc(100% + 8px); 1235 background: linear-gradient(135deg, rgba(248, 113, 113, 0.95) 0%, rgba(239, 68, 68, 0.95) 100%); 1236 color: white; 1237 padding: 8px 12px; 1238 border-radius: 6px; 1239 font-size: 0.875rem; 1240 font-weight: 500; 1241 white-space: nowrap; 1242 box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15); 1243 backdrop-filter: blur(8px); 1244 z-index: 1000; 1245 display: flex; 1246 align-items: center; 1247 gap: 6px; 1248 } 1249 1250 .custom-validation-tooltip::after { 1251 content: ''; 1252 position: absolute; 1253 top: 100%; 1254 left: 50%; 1255 transform: translateX(-50%); 1256 border: 5px solid transparent; 1257 border-top-color: rgba(239, 68, 68, 0.95); 1258 } 1259 1260 /* Hide default validation messages */ 1261 input:invalid { 1262 box-shadow: none; 1263 } 1264 1265 input:invalid:focus { 1266 outline: 2px solid rgb(34 197 94); 1267 box-shadow: none; 1268 } 1269 `,document.head.appendChild(oe),()=>{document.head.removeChild(oe)}},[B.FIRST,B.SECOND,B.THIRD]);const Y=()=>{_(!0),setTimeout(()=>{_(!1)},1500)},ne=()=>{R(!I)},be=()=>{A(!U)}
1269,we=async oe=>{oe.preventDefault(),Y(),S(!0),k(null);try{await vC({username:s,password:f}),t()}catch(Q){const de=Q;de.name==="PasswordResetRequiredException"?re("FORGOT_PASSWORD"):de.name==="NotAuthorizedException"?de.message.includes("Password attempts exceeded")?k("Account locked after too many attempts. Please try again later or reset your password."):de.message.includes("Password reset required")||de.message.includes("User does not have a password")?k("This account was created using social login (Google, Facebook, etc.). Please use the social login button instead."):(L(s)&&P(!0),k("Invalid email or password. Please check your credentials and try again.")):k(de.message||"Failed to sign in")}finally{S(!1)}},te=async oe=>{var Q;oe.preventDefault(),Y(),S(!0),k(null);try{await mue({username:s,password:f,email:s,firstName:a,lastName:u}),re("CONFIRM_SIGN_UP")}catch(de){const Ne=de;Ne.name==="UsernameExistsException"||(Q=Ne.message)!=null&&Q.includes("already exists")||Ne.name==="AliasExistsException"?k("An account with this email already exists. If you signed up with social login (Google, Facebook, etc.), please use that method to sign in."):k(Ne.message||"Failed to sign up")}finally{S(!1)}},fe=async oe=>{oe.preventDefault(),Y(),S(!0),k(null);try{await gue({username:s,confirmationCode:g});try{await vC({username:s,password:f}),t()}catch(Q){k(Q.message||"Failed to sign in after confirmation"),re("SIGN_IN")}}catch(Q){k(Q.message||"Failed to confirm sign up")}finally{S(!1)}},O=async oe=>{oe.preventDefault(),Y(),S(!0),k(null);try{await F8({username:s}),re("CONFIRM_RESET_PASSWORD")}catch(Q){k(Q.message||"Failed to initiate password reset")}finally{S(!1)}},pe=async oe=>{if(oe.preventDefault(),Y(),f!==m){k("Passwords do not match");return}S(!0),k(null);try{await $8({username:s,confirmationCode:g,newPassword:f}),re("SIGN_IN")}catch(Q){k(Q.message||"Failed to reset password")}finally{S(!1)}},he=()=>c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex justify-center gap-4",children:[c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:$,disabled:v,type:"button",className:"p-2 transition-colors text-zinc-400 hover:text-caiBlue-500",children:c.jsx(__e,{size:24})}),c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:q,disabled:v,type:"button",className:"p-2 transition-colors text-zinc-400 hover:text-caiBlue-500",children:c.jsx(E_e,{size:24})}),c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:Z,disabled:v,type:"button",className:"p-2 transition-colors text-zinc-400 hover:text-caiBlue-500",children:c.jsx(N_e,{size:24})}),c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:ie,disabled:v,type:"button",className:"p-2 transition-colors text-zinc-400 hover:text-caiBlue-500",children:c.jsx(I_e,{size:24})}),c.jsx(et.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:ge,disabled:v,type:"button",className:"p-2 transition-colors text-zinc-400 hover:text-caiBlue-500",children:c.jsx(j_e,{size:24})})]}),c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:"absolute inset-0 flex items-center",children:[c.jsx("div",{className:"flex-1 max-w-16 border-t border-zinc-700"}),c.jsx("div",{className:"flex-1 max-w-16 border-t border-zinc-700 ml-auto"})]}),c.jsx("div",{className:"relative flex justify-center text-sm",children:c.jsx("span",{className:"px-4 text-zinc-500",children:"or"})})]})]}),le=()=>{switch(r){case"SIGN_IN":return c.jsxs("form",{onSubmit:we,className:`space-y-4 transition-opacity duration-${W} ${j?"opacity-0":"opacity-100"}`,children:[c.jsx("h2",{className:"text-2xl font-bold mb-6 text-center",style:{background:` 1270 linear-gradient( 1271 to right, 1272 var(--cai-primary) 0%, 1273 var(--cai-secondary) 50%, 1274 var(--cai-primary) 80%, 1275 var(--cai-secondary) 100% 1276 ) 1277 `,backgroundSize:"200% 200%",backgroundPosition:"0% 50%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:"gradientMove 10s ease infinite"},children:"Sign In to Cai"}),c.jsx(he,{}),c.jsx("div",{children:c.jsx("input",{type:"email",id:"signin-email",name:"signin-email",placeholder:"Email",value:s,onChange:oe=>{o(oe.target.value),C&&k(null),H&&P(!1)},className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0,autoComplete:"username"})}),c.jsx(Zb,{id:"signin-password",name:"password",autoComplete:"current-password",value:f,onChange:oe=>{h(oe.target.value),C&&k(null),H&&P(!1)},placeholder:"Password",showPassword:I,toggleVisibility:ne}),c.jsx("div",{className:"flex justify-end",children:c.jsx("button",{type:"button",onClick:()=>re("FORGOT_PASSWORD"),className:"text-sm text-caiBlue-500 hover:underline",children:"Forgot password?"})}),c.jsx("button",{type:"submit",disabled:v,className:"w-full p-3 text-white rounded-lg hover:opacity-90 transition-all duration-300 font-medium",style:N?Yp:zf,children:v?"Signing in...":"Sign In"}),c.jsx("div",{className:"text-center mt-4",children:c.jsxs("p",{children:["Don't have an account?"," ",c.jsx("button",{type:"button",onClick:()=>re("SIGN_UP"),style:{background:`linear-gradient(90deg,
1278 ${Si.caiBlue[400]}, 1279 ${Si.caiPeach[200]}, 1280 ${Si.caiBlue[300]})`,backgroundSize:"300% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",fontWeight:"500",backgroundPosition:"0% 50%",animation:"gradientMove 10s ease infinite"},children:"Sign Up"})]})})]});case"SIGN_UP":return c.jsxs("form",{onSubmit:te,className:`space-y-4 transition-opacity duration-${W} ${j?"opacity-0":"opacity-100"}`,children:[c.jsx("h2",{className:"text-2xl text-center font-bold mb-6",style:{background:` 1281 linear-gradient( 1282 to right, 1283 var(--cai-primary) 0%, 1284 var(--cai-secondary) 50%, 1285 var(--cai-primary) 80%, 1286 var(--cai-secondary) 100% 1287 ) 1288 `,backgroundSize:"200% 200%",backgroundPosition:"0% 50%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:"gradientMove 10s ease infinite"},children:"Create an account"}),c.jsx(he,{}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx("input",{type:"text",id:"signup-first-name",name:"signup-first-name",placeholder:"First Name",value:a,onChange:oe=>l(oe.target.value),className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0,autoComplete:"given-name"}),c.jsx("input",{type:"text",id:"signup-last-name",name:"signup-last-name",placeholder:"Last Name",value:u,onChange:oe=>d(oe.target.value),className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0,autoComplete:"family-name"})]}),c.jsx("div",{children:c.jsx("input",{type:"email",id:"signup-email",name:"signup-email",placeholder:"Email",value:s,onChange:oe=>o(oe.target.value),className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0,autoComplete:"email"})}),c.jsx(Zb,{id:"signup-password",name:"password",autoComplete:"new-password",value:f,onChange:oe=>h(oe.target.value),placeholder:"Password",showPassword:I,toggleVisibility:ne}),c.jsx("button",{type:"submit",disabled:v,className:"w-full p-3 text-white rounded-lg hover:opacity-90 transition-all duration-300 font-medium",style:N?Yp:zf,children:v?"Creating account...":"Sign Up"}),c.jsx("div",{className:"text-center mt-4",children:c.jsxs("p",{children:["Already have an account?"," ",c.jsx("button",{type:"button",onClick:()=>re("SIGN_IN"),style:{background:`linear-gradient(90deg, 1289 ${Si.caiBlue[400]}, 1290 ${Si.caiPeach[200]}, 1291 ${Si.caiBlue[300]})`,backgroundSize:"300% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",fontWeight:"500",backgroundPosition:"0% 50%",animation:"gradientMove 10s ease infinite"},children:"Sign In"})]})})]});case"CONFIRM_SIGN_UP":return c.jsxs("form",{onSubmit:fe,className:`space-y-4 transition-opacity duration-${W} ${j?"opacity-0":"opacity-100"}`,children:[c.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Confirm your account"}),c.jsx("p",{className:"text-sm mb-4",children:"We've sent a confirmation code to your email. Please enter it below."}),c.jsx("div",{children:c.jsx("input",{type:"text",placeholder:"Confirmation Code",id:"c
1291onfirmation-code",name:"confirmation-code",value:g,onChange:oe=>w(oe.target.value),className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0})}),c.jsx("button",{type:"submit",disabled:v,className:"w-full p-3 text-white rounded-lg hover:opacity-90 transition-all duration-300 font-medium",style:N?Yp:zf,children:v?"Confirming...":"Confirm Account"}),c.jsx("div",{className:"text-center mt-4",children:c.jsx("button",{type:"button",onClick:()=>re("SIGN_IN"),className:"text-caiBlue-500 hover:underline",children:"Back to Sign In"})})]});case"FORGOT_PASSWORD":return c.jsxs("form",{onSubmit:O,className:`space-y-4 transition-opacity duration-${W} ${j?"opacity-0":"opacity-100"}`,children:[c.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Reset your password"}),c.jsx("p",{className:"text-sm mb-4",children:"Enter your email and we'll send you a code to reset your password."}),c.jsx("div",{children:c.jsx("input",{type:"email",id:"reset-email",name:"reset-email",placeholder:"Email",value:s,onChange:oe=>{o(oe.target.value),C&&k(null),H&&P(!1)},className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0})}),c.jsx("button",{type:"submit",disabled:v,className:"w-full p-3 text-white rounded-lg hover:opacity-90 transition-all duration-300 font-medium",style:N?Yp:zf,children:v?"Sending code...":"Send Reset Code"}),c.jsx("div",{className:"text-center mt-4",children:c.jsx("button",{type:"button",onClick:()=>re("SIGN_IN"),className:"text-caiBlue-500 hover:underline",children:"Back to Sign In"})})]});case"CONFIRM_RESET_PASSWORD":return c.jsxs("form",{onSubmit:pe,className:`space-y-4 transition-opacity duration-${W} ${j?"opacity-0":"opacity-100"}`,children:[c.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Create new password"}),c.jsx("div",{children:c.jsx("input",{type:"text",placeholder:"Confirmation Code",id:"c
1291onfirmation-code",name:"confirmation-code",value:g,onChange:oe=>w(oe.target.value),className:"w-full p-3 border bg-gradient-to-br from-zinc-800/75 to-zinc-900/75 backdrop-blur-sm border-zinc-800/40 text-zinc-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-caiGreen-500",required:!0,autoComplete:"one-time-code"})}),c.jsx(Zb,{id:"reset-password",name:"newPassword",autoComplete:"new-password",value:f,onChange:oe=>h(oe.target.value),placeholder:"New Password",showPassword:I,toggleVisibility:ne}),c.jsx(Zb,{id:"reset-confirm-password",name:"confirmNewPassword",autoComplete:"new-password",value:m,onChange:oe=>y(oe.target.value),placeholder:"Confirm New Password",showPassword:U,toggleVisibility:be}),c.jsx("button",{type:"submit",disabled:v,className:"w-full p-3 text-white rounded-lg hover:opacity-90 transition-all duration-300 font-medium",style:N?Yp:zf,children:v?"Resetting password...":"Reset Password"})]})}};return!M&&c.jsxs(et.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"fixed inset-0 flex items-center justify-center p-4 z-50",children:[c.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-60",onClick:e}),c.jsxs(et.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"relative bg-gradient-to-br from-zinc-800/95 to-zinc-900/95 backdrop-blur-md border border-zinc-800/40 rounded-xl shadow-xl p-6 w-full max-w-md z-10 overflow-hidden",children:[c.jsx("button",{onClick:e,className:"absolute top-4 right-4 text-zinc-400 hover:text-caiPeach-500 z-20 transition-colors",children:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),c.jsxs("div",{className:"relative z-10 px-2 py-4",children:[C&&c.jsx("div",{className:"bg-red-500/10 border border-red-500/30 text-red-400 px-4 py-3 rounded-lg mb-4 backdrop-blur-sm",children:C}),H&&c.jsx("div",{className:"bg-yellow-900/90 border border-yellow-700/40 text-yellow-200 px-4 py-3 rounded-lg mb-4 backdrop-blur-sm",children:c.jsx("div",{className:"flex items-start gap-2",children:c.jsx("div",{className:"flex-1",children:c.jsxs("p",{className:"text-sm",children:["Cai account migration occured Sep 1, 2025."," ",c.jsx("button",{type:"button",onClick:()=>re("FORGOT_PASSWORD"),className:"text-caiBlue-500 hover:underline",children:"Reset your password"}
1291)," ","if unchanged since then."]})})})}),le()]})]})]})};var u_=new Map,Jb=new WeakMap,U4=0,T_e=void 0;function z_e(t){return t?(Jb.has(t)||(U4+=1,Jb.set(t,U4.toString())),Jb.get(t)):"0"}function P_e(t){return Object.keys(t).sort().filter(e=>t[e]!==void 0).map(e=>`${e}_${e==="root"?z_e(t.root):t[e]}`).toString()}function A_e(t){const e=P_e(t);let n=u_.get(e);if(!n){const r=new Map;let i;const s=new IntersectionObserver(o=>{o.forEach(a=>{var l;const u=a.isIntersecting&&i.some(d=>a.intersectionRatio>=d);t.trackVisibility&&typeof a.isVisible>"u"&&(a.isVisible=u),(l=r.get(a.target))==null||l.forEach(d=>{d(u,a)})})},t);i=s.thresholds||(Array.isArray(t.threshold)?t.threshold:[t.threshold||0]),n={id:e,observer:s,elements:r},u_.set(e,n)}return n}function M_e(t,e,n={},r=T_e){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const l=t.getBoundingClientRect();return e(r,{isIntersecting:r,target:t,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:l,intersectionRect:l,rootBounds:l}),()=>{}}const{id:i,observer:s,elements:o}=A_e(n),a=o.get(t)||[];return o.has(t)||o.set(t,a),a.push(e),s.observe(t),function(){a.splice(a.indexOf(e),1),a.length===0&&(o.delete(t),s.unobserve(t)),o.size===0&&(s.disconnect(),u_.delete(i))}}function B_e({threshold:t,delay:e,trackVisibility:n,rootMargin:r,root:i,triggerOnce:s,skip:o,initialInView:a,fallbackInView:l,onChange:u}={}){var d;const[f,h]=x.useState(null),m=x.useRef(u),[y,g]=x.useState({inView:!!a,entry:void 0});m.current=u,x.useEffect(()=>{if(o||!f)return;let C;return C=M_e(f,(k,N)=>{g({inView:k,entry:N}),m.current&&m.current(k,N),N.isIntersecting&&s&&C&&(C(),C=void 0)},{root:i,rootMargin:r,threshold:t,trackVisibility:n,delay:e},l),()=>{C&&C()}},[Array.isArray(t)?t.toString():t,f,i,r,s,o,n,l,e]);const w=(d=y.entry)==null?void 0:d.target,v=x.useRef(void 0);!f&&w&&!s&&!o&&v.current!==w&&(v.current=w,g({inView:!!a,entry:void 0}));const S=[h,y.inView,y.entry];return S.ref=S[0],S.inView=S[1],S.entry=S[2],S}const R_e=[{id:"producers",label:"For Producers",icon:c.jsx(mx,{size:18})},{id:"artists",label:"For Artists",icon:c.jsx(Rc,{size:18})},{id:"creatives",label:"For Creatives",icon:c.jsx(lE,{size:18})},{id:"education",label:"For Education",icon:c.jsx(ux,{size:18})},{id:"businesses",label:"For Businesses",icon:c.jsx(Mn,{size:18})}],O_e={producers:"from-caiBlue to-caiGreen",artists:"from-caiGreen to-caiPeach",creatives:"from-caiPeach to-caiBlue",education:"from-caiBlue to-caiGreen",businesses:"from-caiGreen to-caiBlue"},ey={producers:{title:"Intelligent Production Collaboration",description:"Cai combines intelligent generation with full digital-audio-workstation capabilities. Record MIDI, audio, and voice-to-MIDI directly, arrange on a creative canvas, and collaborate with Cai to refine your soundâall in your browser.",feature1:"MIDI + Audio Recording & Intelligence",feature2:"Powerful Production Tools"},artists:{title:"Creative Canvas for Musical Expression",description:"Express your ideas through voice, MIDI, audio recording, or intelligent generation on an unlimited canvas. Combine songs, visual media, text notes, and embedded links while Cai helps translate your vision into reality.",feature1:"Voice-to-MIDI and Multi-format Creation",feature2:"Infinite Creative Canvas"},creatives:{title:"Creative Vision Partner",description:"Cai empowers all types of creatives to bring their artistic vision to life. Create immersive projects combining recorded or generated music, visuals, notes, and embedded content. Hum melodies that turn into instruments, record directly, or use intelligent generationâperfect for any creative workflow.",feature1:"Multimedia Integration",feature2:"Adaptive Creative Iteration"},education:{title:"Music Education Partner",description:"Cai offers both theoretical explanations and practical musical examples, helping students and educators bridge the gap between music theory concepts and practical application.",feature1:"Interactive Musical Examples",feature2:"Theory-to-practice Bridge"},businesses:{title:"Brand Identity Development",description:"Cai helps businesses develop and implement consistent, professional audio identities and marketing materials, providing quick iterations and explorations of different approaches.",feature1:"Audio Identity Development",feature2:"Consistent Branded Audio"}}
1291,D_e={producers:[{type:"text",id:"static-text-prod",label:"Project Notes",content:"Focus on vintage saturation and a wide stereo field."},{type:"link",id:"static-link-prod",label:"Reference Track",url:"youtube.com/..."}],artists:[{type:"text",id:"static-text-art",label:"Lyrical Themes",content:"Explore themes of nostalgia and hope."}],creatives:[{type:"text",id:"static-text-creative",label:"Mood Board",content:"Evoke a sense of calm and wonder. Think dawn, mist."},{type:"link",id:"static-link-creative",label:"Visuals",url:"pinterest.com/..."}],education:[{type:"text",id:"static-text-edu",label:"Lesson Plan",content:"1. Introduce I-V-vi-IV. 2. Show pentatonic scale application."}],businesses:[{type:"link",id:"static-link-biz",label:"Brand Guidelines",url:"brand.com/audio"},{type:"text",id:"static-text-biz",label:"Campaign Goals",content:"Sound should be energetic, optimistic, and modern."}]},V4={producers:{chatSequence:[{user:"Create a hip hop beat at 85 BPM",ai:"I'll create a hip hop beat for you. Starting with a solid foundation at 85 BPM..."},{user:"Add a heavy 808 bass line",ai:"Adding a heavy 808 bass line with those signature low-end frequencies..."},{user:"Layer some atmospheric pads in the background",ai:"Layering atmospheric pads to create depth and space in the mix..."},{user:"Make the drums more aggressive and punchy",ai:"Enhancing the drums with more punch and aggression through velocity and timing..."}],actions:[[{type:"NEW_SONG",element:{type:"song",label:"Hip Hop Beat",bpm:85,key:"Cm",id:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Hip Hop Drums",color:oi("TR-808"),instrument:"TR-808",id:"track-1",songId:"song-1"}}],{type:"NEW_TRACK",element:{type:"bloob",label:"808 Bass",color:oi("Sub Bass"),instrument:"Sub Bass",id:"track-2",songId:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Atmospheric Pads",color:oi("Synth Pad"),instrument:"Synth Pad",id:"track-3",songId:"song-1"}},{type:"MODIFY_TRACK",trackId:"track-1",changes:{label:"Aggressive Drums",color:oi("Drums")}}]},artists:{chatSequence:[{user:"I want a dreamy piano melody, something nostalgic",ai:"Creating a dreamy, nostalgic piano melody with gentle dynamics and emotional phrasing..."},{user:"Add strings that follow the emotion of the piano",ai:"Adding string arrangements that complement and enhance the piano's emotional journey..."},{user:"Create a soft drum pattern that doesn't overpower",ai:"Adding subtle drums with brushed feel and soft dynamics to support without dominating..."},{user:"Can you add some ambient textures?",ai:"Layering gentle ambient synth textures to enhance the contemplative mood..."}],actions:[[{type:"NEW_SONG",element:{type:"song",label:"Nostalgic Ballad",bpm:72,key:"Em",id:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Dreamy Piano",color:oi("Grand Piano"),instrument:"Grand Piano",id:"track-1",songId:"song-1"}}],{type:"NEW_TRACK",element:{type:"bloob",label:"Emotional Strings",color:oi("Strings"),instrument:"Strings",id:"track-2",songId:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Soft Drums",color:oi("Brushed Kit"),instrument:"Brushed Kit",id:"track-3",songId:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Ambient Textures",color:oi("Pad"),instrument:"Pad",id:"track-4",songId:"song-1"}}]},creatives:{chatSequence:[{user:"Create an ambient soundscape for my meditation app",ai:"Designing a peaceful ambient soundscape with layered textures perfect for meditation..."},{user:"Add some gentle bell tones",ai:"Incorporating subtle bell tones that will enhance the meditative atmosphere..."},{user:"Now, add some text notes centered around our medatative landscape",ai:"Got it. Adding some calming medatative notes to match..."}],actions:[[{type:"NEW_SONG",element:{type:"song",label:"Meditation Flow",bpm:60,key:"Am",id:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Ambient Foundation",color:oi("Pad"),instrument:"Pad",id:"track-1",songId:"song-1"}}],{type:"NEW_TRACK",element:{type:"bloob",label:"Gentle Bells",color:oi("Bells"),instrument:"Bells",id:"track-2",songId:"song-1"}},{type:"ADD_OTHER",element:{type:"text",label:"Affirmation",content:"I am centered and calm.",id:"text-dynamic-1"}}]},education:{chatSequence:[{user:"Show me a I-V-vi-IV chord progression in G major",ai:"Here's the I-V-vi-IV progression in G major: G-D-Em-C. This is one of the most popular progressions in pop music..."},{user:"Add a melody that uses the pentatonic scale",ai:"Adding a pentatonic melody that works perfectly over these chords. The G major pentatonic avoids dissonance..."},{user:"Why is this progression so popular? Add a note.",ai:"This progression creates a perfect emotional arc: I (home) â V (tension) â vi (emotional depth) â IV (resolution)... Adding a note..."},{user:"Can you show the same in A major?",ai:"Transposing to A major: A-E-F#m-D. The relationships remain the same, just shifted up a whole step..."}],actions:[[{type:"NEW_SONG",element:{type:"song",label:"Theory Lesson",bpm:100,key:"G",id:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"I-V-vi-IV Chords",color:oi("Piano"),instrument:"Piano",id:"track-1",songId:"song-1"}}],{type:"NEW_TRACK",element:{type:"bloob",label:"Pentatonic Lead",color:oi("Lead Synth"),instrument:"Lead Synth",id:"track-2",songId:"song-1"}},{type:"ADD_OTHER",element:{type:"text",label:"Theory Note",content:"I-V-vi-IV creates a satisfying emotional journey.",id:"text-dynamic-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"A Major Example",color:oi("Piano"),instrument:"Piano",id:"track-3",songId:"song-1"}}]},businesses:{chatSequence:[{user:"Create an upbeat corporate intro, 15 seconds",ai:"Creating a professional 15-second corporate intro with uplifting energy and modern production..."},{user:"Make it sound more innovative and tech-focused",ai:"Adding electronic elements and modern synths to give it a cutting-edge, innovative feel..."},{user:"Add a memorable melody hook at the end",ai:"Placing a catchy melodic hook in the final 3 seconds for brand recall..."}],actions:[[{type:"NEW_SONG",element:{type:"song",label:"Brand Audio v1",bpm:120,key:"C",id:"song-1"}},{type:"NEW_TRACK",element:{type:"bloob",label:"Corporate Theme",color:oi("Synth
1291Lead"),instrument:"Synth Lead",id:"track-1",songId:"song-1"}}],{type:"MODIFY_TRACK",trackId:"track-1",changes:{label:"Tech Synth Lead",color:oi("Synth Lead")}},{type:"NEW_TRACK",element:{type:"bloob",label:"Brand Hook",color:oi("Bell"),instrument:"Bell",id:"track-2",songId:"song-1"}}]}},L_e={producers:[{icon:c.jsx(Qf,{}),title:"Adaptive Creation",description:"Describe your vision and watch it materialize in real-time with intelligent assistance"},{icon:c.jsx(mx,{}),title:"Full Control",description:"Fine-tune every aspect with professional editing tools while Cai handles the technical complexity"},{icon:c.jsx(uo,{}),title:"Intelligent Collaboration",description:"Work with Cai as your creative partner, not just a tool - it understands context and intent"}],artists:[{icon:c.jsx(Mn,{}),title:"Creative Canvas",description:"Unlimited workspace supporting songs, visuals, notes, and linksâorganize your entire creative vision in one place"},{icon:c.jsx(uo,{}),title:"Flexible Creation Methods",description:"Choose between intelligent generation, traditional recording, or hybrid approaches to bring your ideas to life"},{icon:c.jsx(Gu,{}),title:"Artistic Focus",description:"Keep your unique voice at the center while Cai amplifies your creative capabilities"}],creatives:[{icon:c.jsx(lE,{}),title:"Creative Vision",description:"Transform ideas into reality across multiple media formats with intelligent tools"},{icon:c.jsx(Qf,{}),title:"Rapid Iteration",description:"Quickly explore different creative directions and refine your artistic concepts"},{icon:c.jsx(Gu,{}),title:"Multimedia Integration",description:"Seamlessly blend audio, visual, and interactive elements in your projects"}],education:[{icon:c.jsx(ux,{}),title:"Interactive Learning",description:"Experience music theory through practical examples and real-time audio generation"},{icon:c.jsx(Gu,{}),title:"Concept Bridge",description:"Connect theoretical knowledge with hands-on practice using intelligent examples"},{icon:c.jsx(uo,{}),title:"Adaptive Teaching",description:"Cai adjusts explanations and examples to match different learning styles and levels"}],businesses:[{icon:c.jsx(hy,{}),title:"Brand Audio",description:"Develop consistent, professional audio identities that reinforce your brand message"},{icon:c.jsx(Qf,{}),title:"Rapid Production",description:"Generate custom audio content quickly for campaigns, presentations, and marketing"},{icon:c.jsx(Gu,{}),title:"Professional Quality",description:"Achieve studio-grade results without extensive audio production expertise"}]},yc=({icon:t,label:e,size:n=20})=>c.jsx("button",{"aria-label":e,className:` 1292 flex items-center justify-center 1293 transition-transform duration-150 1294 hover:text-white 1295 active:scale-90 focus:outline-none 1296 `,children:c.jsx(t,{size:n})}),F_e=({onBookDemo:t})=>{var B,L,$,q;const[e,n]=x.useState("producers"),[r,i]=x.useState(0),[s,o]=x.useState(""),[a,l]=x.useState(""),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,y]=x.useState([]),[g,w]=x.useState(null),[v,S]=x.useState({x:0,y:0,visible:!1}),[C,k]=x.useState(""),N=x.useRef(null),_=x.useRef(null),j=x.useRef({}),T=dC(0),M=dC(0),V=HP(T,{stiffness:300,damping:24,mass:.2}),H=HP(M,{stiffness:300,damping:24,mass:.2}),P=()=>{if(C.trim()){const Z=document.getElementById("sign-up");Z&&Z.click()}},F=Z=>{Z.key==="Enter"&&P()},I=x.useCallback((Z,ie,ge)=>{const{instant:re=!1,show:Y=!0}=ge||{};re?(T.set(Z),M.set(ie),S({x:Z,y:ie,visible:Y})):S(ne=>({...ne,x:Z,y:ie,visible:Y}))},[T,M]),R=x.useCallback((Z,ie)=>{const ge=j.current[Z],re=_.current;if(!ge||!re)return;const Y=re.getBoundingClientRect(),ne=ge.getBoundingClientRect(),be=ne.height<=44,we=10,te=10,fe=ne.left-Y.left+Math.min(ne.width-6,156),O=ne.top-Y.top+(be?we:te);I(fe,O,{instant:ie==null?void 0:ie.instant,show:!0})},[I]),U=x.useMemo(()=>(D_e[e]||[]).map(ie=>({...ie,key:`${e}-${ie.id}`})),[e]);x.useLayoutEffect(()=>{i(0),o(""),l(""),d(!1),h(!1),y([]),w(null);const Z=_.current;if(Z){const{width:ie,height:ge}=Z.getBoundingClientRect(),Y=40*6,ne=ie>600?-140:-80,be=ie/2,te=ge/2+ne,O=be-Y/2+Y-20,pe=Math.max(12,te-8);I(O,pe,{instant:!0,show:!1})}},[e,I]),x.useEffect(()=>{T.set(v.x),M.set(v.y)},[v.x,v.y,T,M]),x.useEffect(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[s,a,r]),x.useEffect(()=>{const Z=V4[e];if(!Z)return;let ie=null,ge=null;function re(be){const we=Z.actions[be];if(!we)return;const te=O=>{var pe,he,le;return((pe=O.find(oe=>oe.type==="MODIFY_TRACK"))==null?void 0:pe.trackId)??((he=O.find(oe=>
1296oe.type==="NEW_TRACK"))==null?void 0:he.element.id)??((le=O.find(oe=>oe.type==="ADD_OTHER"))==null?void 0:le.element.id)??null},fe=O=>{y(pe=>{let he=pe;for(const oe of O)switch(oe.type){case"NEW_SONG":case"NEW_TRACK":case"ADD_OTHER":he=[...he,oe.element];break;case"MODIFY_TRACK":he=he.map(Q=>Q.id===oe.trackId&&Q.type==="bloob"?{...Q,...oe.changes}:Q);break}const le=te(O);return le&&(w(le),setTimeout(()=>{w(Q=>Q===le?null:Q)},2200)),he})};Array.isArray(we)?setTimeout(()=>fe(we),300):setTimeout(()=>fe([we]),300)}function Y(be){if(!Z.chatSequence[be])return;const we=Z.chatSequence[be].ai;h(!0);let te=0;const fe=()=>{ge&&clearTimeout(ge),te<=we.length?(l(we.substring(0,te)),te++,ge=setTimeout(fe,30)):(h(!1),re(be),be<Z.chatSequence.length-1?ie=setTimeout(()=>{i(be+1),ne(be+1)},2e3):ie=setTimeout(()=>{i(0),y([]),ne(0)},3e3))};fe()}function ne(be){if(!Z.chatSequence[be])return;const we=Z.chatSequence[be].user;d(!0),l("");let te=0;const fe=()=>{ge&&clearTimeout(ge),te<=we.length?(o(we.substring(0,te)),te++,ge=setTimeout(fe,50)):(d(!1),ie=setTimeout(()=>{Y(be)},500))};fe()}return ie=setTimeout(()=>ne(0),800),()=>{ie&&clearTimeout(ie),ge&&clearTimeout(ge)}},[e,U]),x.useEffect(()=>{if(!g)return;let Z=0,ie=0;return Z=requestAnimationFrame(()=>{ie=requestAnimationFrame(()=>{R(g,{instant:!v.visible})})}),()=>{cancelAnimationFrame(Z),cancelAnimationFrame(ie)}},[g,v.visible,R]);const A=x.useCallback(Z=>{var we;const ie=m.filter(te=>te.type==="bloob"&&te.songId===Z.id),ge=40,re=36,Y=ge*6,ne=re+16,be=te=>{const fe=te.label,O={"Hip Hop Drums":{beats:16,notes:[{pitch:49,start:0,dur:.5,vel:105},{pitch:36,start:0,dur:.75,vel:118},{pitch:36,start:1.5,dur:.5,vel:103},{pitch:36,start:3,dur:.5,vel:108},{pitch:36,start:6.5,dur:.5,vel:120},{pitch:36,start:8,dur:.75,vel:114},{pitch:36,start:10.5,dur:.5,vel:106},{pitch:36,start:12,dur:.75,vel:120},{pitch:36,start:15.5,dur:.5,vel:110},{pitch:38,start:4,dur:.5,vel:122},{pitch:38,start:3.75,dur:.25,vel:65},{pitch:38,start:11.5,dur:.25,vel:68},{pitch:38,start:12,dur:.5,vel:122},...Array.from({length:16},(oe,Q)=>({pitch:42,start:Q,dur:.25,vel:Q%2===0?76:88})),{pitch:42,start:2.5,dur:.25,vel:92},{pitch:42,start:2.75,dur:.25,vel:95},{pitch:42,start:6.5,dur:.25,vel:92},{pitch:42,start:6.75,dur:.25,vel:95},{pitch:46,start:8,dur:.5,vel:96},{pitch:44,start:7.5,dur:.25,vel:70},{pitch:44,start:15,dur:.25,vel:72}]},"Aggressive Drums":{beats:16,notes:[{pitch:36,start:0,dur:.5,vel:120},{pitch:36,start:1,dur:.5,vel:110},{pitch:36,start:2.5,dur:.5,vel:112},{pitch:36,start:4.5,dur:.5,vel:108},{pitch:36,start:6,dur:.5,vel:120},{pitch:36,start:7.5,dur:.5,vel:112},{pitch:36,start:8,dur:.75,vel:118},{pitch:36,start:9.5,dur:.5,vel:110},{pitch:36,start:11,dur:.5,vel:108},{pitch:36,start:12.5,dur:.5,vel:120},{pitch:36,start:14,dur:.5,vel:112},{pitch:36,start:15.25,dur:.25,vel:115},{pitch:38,start:4,dur:.5,vel:122},{pitch:38,start:4.25,dur:.25,vel:88},{pitch:38,start:12,dur:.5,vel:124},{pitch:38,start:12.25,dur:.25,vel:90},{pitch:38,start:11.75,dur:.25,vel:68},{pitch:38,start:3.75,dur:.25,vel:66},...Array.from({length:16},(oe,Q)=>({pitch:42,start:Q,dur:.25,vel:Q%4===0?96:Q%2===0?82:88})),{pitch:42,start:3.5,dur:.25,vel:94},{pitch:42,start:3.75,dur:.25,vel:98},{pitch:42,start:7.5,dur:.25,vel:94},{pitch:42,start:7.75,dur:.25,vel:98},{pitch:42,start:11.5,dur:.25,vel:94},{pitch:42,start:11.75,dur:.25,vel:98},{pitch:42,start:15.5,dur:.25,vel:96},{pitch:42,start:15.75,dur:.25,vel:100},{pitch:46,start:8,dur:.5,vel:102},{pitch:49,start:0,dur:.5,vel:108}]},"808 Bass":{beats:16,notes:[{pitch:36,start:0,dur:1.5,vel:115},{pitch:39,start:1.5,dur:.5,vel:108},{pitch:36,start:2,dur:1,vel:118},{pitch:34,start:3.5,dur:.5,vel:108},{pitch:39,start:4,dur:1.5,vel:112},{pitch:41,start:5.5,dur:.5,vel:110},{pitch:36,start:6,dur:1,vel:118},{pitch:43,start:7.5,dur:.5,vel:110},{pitch:41,start:8,dur:1,vel:116},{pitch:39,start:9.5,dur:.5,vel:110},{pitch:36,start:10,dur:1.25,vel:120},{pitch:41,start:11.5,dur:.5,vel:110},{pitch:43,start:12,dur:1,vel:115},{pitch:39,start:13.5,dur:.5,vel:110},{pitch:36,start:14,dur:1.5,vel:118}]},"Atmospheric Pads":{beats:16,notes:[{pitch:48,start:0,dur:8,vel:74},{pitch:60,start:0,dur:8,vel:78},{pitch:63,start:0,dur:8,vel:78},{pitch:67,start:0,dur:8,vel:78},{pitch:56,start:8,dur:8,vel:74},{pitch:68,start:8,dur:8,vel:78},{pitch:72,start:8,dur:8,vel:78},{pitch:75,start:8,dur:8,vel:78}]},"Dreamy Piano":{beats:16,notes:[{pitch:64,start:0,dur:.5,vel:88},{pitch:67,start:.5,dur:.5,vel:86},{pitch:71,start:1,dur:.75,vel:84},{pitch:72,start:1.75,dur:.25,vel:70},{pitch:69,start:2,dur:.5,vel:86},{pitch:67,start:2.5,dur:.5,vel:84},{pitch:64,start:3,dur:.5,vel:86},{pitch:62,start:3.5,dur:.5,vel:82},{pitch:64,start:4,dur:.5,vel:88},{pitch:67,start:4.5,dur:.5,vel:86},{pitch:71,start:5,dur:.5,vel:84},{pitch:74,start:5.5,dur:.5,vel:78},{pitch:72,start:6,dur:.5,vel:80},{pitch:69,start:6.5,dur:.5,vel:82},{pitch:67,start:7,dur:.5,vel:84},{pitch:64,start:7.5,dur:.5,vel:86},{pitch:62,start:8,dur:.5,vel:86},{pitch:66,start:8.5,dur:.5,vel:84},{pitch:69,start:9,dur:.5,vel:82},{pitch:71,start:9.5,dur:.5,vel:80},{pitch:72,start:10,dur:.5,vel:80},{pitch:69,start:10.5,dur:.5,vel:82},{pitch:67,start:11,dur:.5,vel:84},{pitch:64,start:11.5,dur:.5,vel:86},{pitch:62,start:12,dur:.5,vel:84},{pitch:64,start:12.5,dur:.5,vel:86},{pitch:67,start:13,dur:.5,vel:86},{pitch:71,start:13.5,dur:.5,vel:84},{pitch:69,start:14,dur:.5,vel:82},{pitch:67,start:14.5,dur:.5,vel:82},{pitch:64,start:15,dur:1,vel:88}]}
1296,"Emotional Strings":{beats:16,notes:[{pitch:55,start:0,dur:8,vel:88},{pitch:59,start:0,dur:8,vel:88},{pitch:62,start:0,dur:8,vel:88},{pitch:57,start:2,dur:1,vel:76},{pitch:60,start:6,dur:1,vel:76},{pitch:57,start:8,dur:8,vel:88},{pitch:60,start:8,dur:8,vel:88},{pitch:64,start:8,dur:8,vel:88},{pitch:62,start:10,dur:1,vel:76}]},"Soft Drums":{beats:16,notes:[{pitch:36,start:0,dur:.75,vel:92},{pitch:36,start:8,dur:.5,vel:88},{pitch:38,start:4,dur:.5,vel:82},{pitch:38,start:12,dur:.5,vel:82},{pitch:38,start:3.5,dur:.25,vel:58},{pitch:38,start:11.5,dur:.25,vel:58},...Array.from({length:8},(oe,Q)=>({pitch:42,start:Q*2,dur:.5,vel:62+(Q%2?4:0)})),{pitch:42,start:1.5,dur:.25,vel:60},{pitch:42,start:9.5,dur:.25,vel:60}]},"Ambient Textures":{beats:16,notes:[{pitch:52,start:0,dur:16,vel:52},{pitch:47,start:0,dur:16,vel:46},{pitch:64,start:0,dur:6,vel:68},{pitch:67,start:0,dur:6,vel:66},{pitch:71,start:0,dur:6,vel:64},{pitch:66,start:6,dur:2,vel:60},{pitch:69,start:6,dur:2,vel:58},{pitch:60,start:8,dur:8,vel:66},{pitch:64,start:8,dur:8,vel:66},{pitch:67,start:8,dur:8,vel:64},{pitch:62,start:8,dur:8,vel:64},...Array.from({length:4},(oe,Q)=>({pitch:[76,79,81,79][Q],start:1+Q,dur:.5,vel:74})),...Array.from({length:4},(oe,Q)=>({pitch:[76,79,81,79][Q],start:9+Q,dur:.5,vel:74})),...[1.75,2.5,3.25,5.75,6.25,9.5,10.25,11.75,13,14.5].map((oe,Q)=>({pitch:[84,86,88,86,84,86,88,90,88,86][Q],start:oe,dur:.25,vel:78+Q%4*3})),...[7.5,7.75,15.5,15.75].map((oe,Q)=>({pitch:Q<2?74+Q*2:82+(Q-2)*2,start:oe,dur:.25,vel:82})),...[.75,2.25,3.75,5.25,8.75,10.25,11.75,13.25].map(oe=>({pitch:64,start:oe,dur:.25,vel:60})),...[4.5,5,5.5,12.5,13.5].map(oe=>({pitch:67,start:oe,dur:.25,vel:58}))]},"Ambient Foundation":{beats:16,notes:[{pitch:45,start:0,dur:16,vel:56},{pitch:52,start:0,dur:16,vel:48},{pitch:57,start:0,dur:8,vel:70},{pitch:60,start:0,dur:8,vel:66},{pitch:64,start:0,dur:8,vel:64},{pitch:53,start:8,dur:8,vel:68},{pitch:57,start:8,dur:8,vel:66},{pitch:60,start:8,dur:8,vel:66},{pitch:64,start:8,dur:8,vel:64},{pitch:55,start:7.5,dur:1,vel:60},{pitch:62,start:7.5,dur:1,vel:60},{pitch:64,start:1,dur:.5,vel:60},{pitch:67,start:2,dur:.5,vel:60},{pitch:69,start:3,dur:.5,vel:58},{pitch:67,start:4,dur:.5,vel:58},{pitch:64,start:5,dur:.5,vel:58},{pitch:62,start:6,dur:.5,vel:56},{pitch:64,start:7,dur:.5,vel:58},{pitch:57,start:0,dur:.5,vel:62},{pitch:60,start:2,dur:.5,vel:60},{pitch:64,start:4,dur:.5,vel:60},{pitch:60,start:6,dur:.5,vel:58},{pitch:53,start:8,dur:.5,vel:62},{pitch:57,start:10,dur:.5,vel:60},{pitch:60,start:12,dur:.5,vel:60},{pitch:64,start:14,dur:.5,vel:58},{pitch:76,start:4,dur:1,vel:62},{pitch:76,start:12,dur:1,vel:62},...[2.5,3.25,4.75,6.25,9.25,10.75,12.25,13.75,15.25].map((oe,Q)=>({pitch:[81,83,84,83,81,79,81,83,84][Q],start:oe,dur:.25,vel:70-Q%3*4}))]},"Gentle Bells":{beats:16,notes:[{pitch:81,start:0,dur:.25,vel:96},{pitch:84,start:1.5,dur:.25,vel:92},{pitch:83,start:2.5,dur:.25,vel:90},{pitch:81,start:3.5,dur:.25,vel:92},{pitch:84,start:4.5,dur:.25,vel:94},{pitch:86,start:5.5,dur:.25,vel:96},{pitch:83,start:6.5,dur:.25,vel:92},{pitch:81,start:7.5,dur:.25,vel:90},{pitch:84,start:8.5,dur:.25,vel:94},{pitch:83,start:9.5,dur:.25,vel:92},{pitch:86,start:10.5,dur:.25,vel:96},{pitch:88,start:11.5,dur:.25,vel:94},{pitch:84,start:12.5,dur:.25,vel:92},{pitch:83,start:13.5,dur:.25,vel:90},{pitch:81,start:14.5,dur:.25,vel:92},{pitch:84,start:15,dur:.5,vel:96}]},"I-V-vi-IV Chords":{beats:16,notes:[{pitch:43,start:0,dur:4,vel:86},{pitch:55,start:0,dur:4,vel:90},{pitch:59,start:0,dur:4,vel:90},{pitch:62,start:0,dur:4,vel:90},{pitch:38,start:4,dur:4,vel:86},{pitch:50,start:4,dur:4,vel:90},{pitch:54,start:4,dur:4,vel:90},{pitch:57,start:4,dur:4,vel:90},{pitch:40,start:8,dur:4,vel:86},{pitch:52,start:8,dur:4,vel:90},{pitch:55,start:8,dur:4,vel:90},{pitch:59,start:8,dur:4,vel:90},{pitch:36,start:12,dur:4,vel:86},{pitch:48,start:12,dur:4,vel:90},{pitch:52,start:12,dur:4,vel:90},{pitch:55,start:12,dur:4,vel:90}]},"Pentatonic Lead":{beats:16,notes:[{pitch:67,start:0,dur:.5,vel:96},{pitch:69,start:.5,dur:.5,vel:96},{pitch:72,start:1,dur:.75,vel:98},{pitch:74,start:2,dur:.5,vel:92},{pitch:72,start:2.5,dur:.5,vel:92},{pitch:69,start:3,dur:.5,vel:94},{pitch:67,start:3.5,dur:.5,vel:96},{pitch:69,start:4,dur:.5,vel:96},{pitch:72,start:4.5,dur:.5,vel:96},{pitch:76,start:5,dur:.5,vel:94},{pitch:74,start:5.5,dur:.5,vel:92},{pitch:72,start:6,dur:.5,vel:92},{pitch:69,start:6.5,dur:.5,vel:94},{pitch:67,start:7,dur:.75,vel:98},{pitch:69,start:8,dur:.5,vel:96},{pitch:72,start:8.5,dur:.5,vel:96},{pitch:74,start:9,dur:.5,vel:94},{pitch:76,start:9.5,dur:.5,vel:92},{pitch:79,start:10,dur:.5,vel:92},{pitch:76,start:10.5,dur:.5,vel:90},{pitch:74,start:11,dur:.5,vel:90},{pitch:72,start:11.5,dur:.5,vel:92},{pitch:69,start:12,dur:.5,vel:94},{pitch:67,start:12.5,dur:.5,vel:96},{pitch:69,start:13,dur:.5,vel:96},{pitch:72,start:13.5,dur:.5,vel:96},{pitch:74,start:14,dur:.5,vel:94},{pitch:72,start:14.5,dur:.5,vel:92},{pitch:69,start:15,dur:1,vel:98}]},"A Major Example":{beats:16,notes:[{pitch:45,start:0,dur:4,vel:86},{pitch:57,start:0,dur:4,vel:90},{pitch:61,start:0,dur:4,vel:90},{pitch:64,start:0,dur:4,vel:90},{pitch:40,start:4,dur:4,vel:86},{pitch:52,start:4,dur:4,vel:90},{pitch:56,start:4,dur:4,vel:90},{pitch:59,start:4,dur:4,vel:90},{pitch:42,start:8,dur:4,vel:86},{pitch:54,start:8,dur:4,vel:90},{pitch:57,start:8,dur:4,vel:90},{pitch:61,start:8,dur:4,vel:90},{pitch:38,start:12,dur:4,vel:86},{pitch:50,start:12,dur:4,vel:90},{pitch:54,start:12,dur:4,vel:90},{pitch:57,start:12,dur:4,vel:90}]},"Tech Synth Lead":{beats:16,notes:[{pitch:76,start:0,dur:.5,vel:110},{pitch:79,start:.5,dur:.5,vel:106},{pitch:83,start:1,dur:.5,vel:110},{pitch:81,start:1.5,dur:.5,vel:104},{pitch:79,start:2,dur:.5,vel:104},{pitch:83,start:2.5,dur:.5,vel:110},{pitch:86,start:3,dur:.5,vel:114},{pitch:83,start:3.5,dur:.5,vel:106},{pitch:81,start:4,dur:.5,vel:108},{pitch:83,start:4.5,dur:.5,vel:110},{pitch:86,start:5,dur:.5,vel:114},{pitch:83,start:5.5,dur:.5,vel:106},{pitch:81,start:6,dur:.5,vel:104},{pitch:79,start:6.5,dur:.5,vel:102},{pitch:76,start:7,dur:.5,vel:100},{pitch:79,start:7.5,dur:.5,vel:104},{pitch:83,start:8,dur:.5,vel:112},{pitch:86,start:8.5,dur:.5,vel:116},{pitch:83,start:9,dur:.5,vel:110},{pitch:81,start:9.5,dur:.5,vel:106},{pitch:79,start:10,dur:.5,vel:104},{pitch:83,start:10.5,dur:.5,vel:110},{pitch:86,start:11,dur:.5,vel:114},{pitch:83,start:11.5,dur:.5,vel:108},{pitch:81,start:12,dur:.5,vel:106},{pitch:83,start:12.5,dur:.5,vel:110},{pitch:79,start:13,dur:.5,vel:102},{pitch:76,start:13.5,dur:.5,vel:100},{pitch:79,start:14,dur:.5,vel:104},{pitch:83,start:14.5,dur:.5,vel:110},{pitch:86,start:15,dur:1,vel:116}]},"Corporate Theme":{beats:16,notes:[{pitch:48,start:0,dur:.5,vel:92},{pitch:48,start:2,dur:.5,vel:88},{pitch:43,start:4,dur:.5,vel:92},{pitch:43,start:6,dur:.5,vel:88},{pitch:45,start:8,dur:.5,vel:92},{pitch:45,start:10,dur:.5,vel:88},{pitch:41,start:12,dur:.5,vel:92},{pitch:41,start:14,dur:.5,vel:88},{pitch:60,start:0,dur:1,vel:96},{pitch:64,start:0,dur:1,vel:92},{pitch:67,start:0,dur:1,vel:90},{pitch:67,start:4,dur:1,vel:96},{pitch:71,start:4,dur:1,vel:92},{pitch:74,start:4,dur:1,vel:90},{pitch:69,start:8,dur:1,vel:96},{pitch:72,start:8,dur:1,vel:92},{pitch:76,start:8,dur:1,vel:90},{pitch:65,start:12,dur:1,vel:96},{pitch:69,start:12,dur:1,vel:92},{pitch:72,start:12,dur:1,vel:90},{pitch:60,start:0,dur:.5,vel:92},{pitch:64,start:.5,dur:.5,vel:88},{pitch:67,start:1,dur:.5,vel:90},{pitch:64,start:1.5,dur:.5,vel:86},{pitch:60,start:2,dur:.5,vel:88},{pitch:64,start:2.5,dur:.5,vel:86},{pitch:67,start:3,dur:.5,vel:88},{pitch:71,start:3.5,dur:.5,vel:92},{pitch:67,start:4,dur:.5,vel:92},{pitch:71,start:4.5,dur:.5,vel:90},{pitch:74,start:5,dur:.5,vel:92},{pitch:71,start:5.5,dur:.5,vel:88},{pitch:67,start:6,dur:.5,vel:90},{pitch:71,start:6.5,dur:.5,vel:88},{pitch:74,start:7,dur:.5,vel:90},{pitch:71,start:7.5,dur:.5,vel:92},{pitch:69,start:8,dur:.5,vel:92},{pitch:72,start:8.5,dur:.5,vel:90},{pitch:76,start:9,dur:.5,vel:92},{pitch:72,start:9.5,dur:.5,vel:88},{pitch:69,start:10,dur:.5,vel:90},{pitch:72,start:10.5,dur:.5,vel:88},{pitch:76,start:11,dur:.5,vel:90},{pitch:72,start:11.5,dur:.5,vel:92},{pitch:65,start:12,dur:.5,vel:92},{pitch:69,start:12.5,dur:.5,vel:90},{pitch:72,start:13,dur:.5,vel:92},{pitch:69,start:13.5,dur:.5,vel:88},{pitch:65,start:14,dur:.5,vel:90},{pitch:69,start:14.5,dur:.5,vel:88},{pitch:72,start:15,dur:.5,vel:90},{pitch:74,start:15.5,dur:.5,vel:92},{pitch:71,start:3.75,dur:.25,vel:98},{pitch:72,start:7.75,dur:.25,vel:98},{pitch:69,start:11.75,dur:.25,vel:96}]},"Brand Hook":{beats:16,notes:[{pitch:79,start:11.5,dur:.25,vel:108},{pitch:81,start:11.75,dur:.25,vel:110},{pitch:84,start:12,dur:.5,vel:114},{pitch:88,start:12.5,dur:.5,vel:110},{pitch:86,start:13,dur:.5,vel:108},{pitch:84,start:13.5,dur:.5,vel:106},{pitch:79,start:14,dur:.25,vel:108},{pitch:81,start:14.25,dur:.25,vel:110},{pitch:84,start:14.5,dur:.5,vel:112},{pitch:88,start:15,dur:1,vel:116},{pitch:67,start:12.25,dur:.25,vel:80},{pitch:69,start:12.75,dur:.25,vel:82},{pitch:67,start:13.25,dur:.25,vel:78},{pitch:64,start:13.75,dur:.25,vel:76},{pitch:67,start:14.75,dur:.25,vel:78}]}},pe={"Ambient Textures":Array.from({length:100},(oe,Q)=>.2+.15*Math.sin(Q*.1)+.05*Math.sin(Q*.53)+.02*Math.sin(Q*1.7))},he=O[fe];
1296if(he){const oe=he.beats||16,Q=he.notes,de=Q.map(je=>je.pitch),Ne=Math.min(...de)-12,Ce=Math.max(...de)+12,Ae=Math.max(1,Ce-Ne),Ue=16,Se=Ue*.65,ve=(Ue-Se)/2;return c.jsx("div",{className:"relative w-full h-full",children:Q.map((je,Te)=>c.jsx("div",{className:"absolute bg-white/90 rounded-sm",style:{left:`${je.start/oe*100}%`,width:`${Math.max(.5,je.dur/oe*100)}%`,top:`${(Ce-je.pitch)/Ae*Se+ve}px`,height:"2px",opacity:(je.vel||96)/127*.8+.2}},`note-${fe}-${Te}`))})}const le=pe[fe];if(le){const oe=Q=>{let Ae="";Q.forEach((Ue,Se)=>{const ve=Se/Q.length*100,je=8-Ue*(8*.95);Se===0?Ae+=`M ${ve},8 L ${ve},${je}`:Ae+=` L ${ve},${je}`});for(let Ue=Q.length-1;Ue>=0;Ue--){const Se=Ue/Q.length*100,ve=8+Q[Ue]*(8*.95);Ae+=` L ${Se},${ve}`}return Ae+=" Z",Ae};return c.jsxs("svg",{width:"100%",height:"16",viewBox:"0 0 100 16",preserveAspectRatio:"none",children:[c.jsx("rect",{x:"0",y:"0",width:"100%",height:"16",fill:"rgba(0,0,0,0.0)",rx:"2"}),c.jsx("line",{x1:"0",y1:"8",x2:"100%",y2:"8",stroke:"rgba(255,255,255,0.4)",strokeWidth:"0.5",strokeDasharray:"2,2"}),c.jsx("path",{d:oe(le),fill:"rgba(255,255,255,0.85)",stroke:"rgba(255,255,255,0.85)",strokeWidth:"0.75"})]})}return c.jsx(c.Fragment,{children:[...Array(60)].map((oe,Q)=>c.jsx("div",{className:"bg-white/80 rounded-sm flex-1",style:{height:`${2+(Math.sin(Q*.12+.8)+1)*5}px`}},Q))})};return c.jsxs(et.div,{drag:!0,dragConstraints:_,dragMomentum:!1,whileDrag:{scale:1.02,zIndex:50,cursor:"grabbing",boxShadow:"0 0 0 1px rgb(212 212 216)"},initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:`relative top-1/2 left-1/2 border-2 rounded-lg overflow-hidden cursor-grab border-zinc-600 ${g===Z.id?"ring-2 ring-zinc-300":""}`,style:{width:Y,minHeight:ne,marginLeft:-120,marginTop:(((we=_.current)==null?void 0:we.offsetWidth)||800)>600?-140:-80,touchAction:"none"},"aria-label":`Song: ${Z.label}`,ref:te=>{j.current[Z.id]=te},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-600/90 via-zinc-700/90 to-zinc-800/90 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-zinc-950/20 via-transparent to-zinc-100/10 rounded-lg"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-500/30 via-zinc-600/30 to-zinc-700/30 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-zinc-100/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-zinc-950/10 to-transparent rounded-b-lg"}),c.jsxs("div",{className:"relative flex flex-col min-h-full bg-zinc-900/95 rounded-lg border border-zinc-700/50",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-4 rounded-t-lg relative overflow-hidden",style:{height:`${re}px`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-600/20 via-zinc-700/20 to-zinc-800/20"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-500/30 via-zinc-600/30 to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-600/80 to-transparent"}),c.jsxs("div",{className:"relative flex items-center gap-2 min-w-0 flex-1",children:[c.jsx(hx,{className:"size-3 text-zinc-200 flex-shrink-0 drop-shadow-sm"}),c.jsx("span",{className:"text-sm font-semibold text-zinc-200 truncate drop-shadow-sm",children:Z.label})]}),c.jsxs("div",{className:"relative flex items-center gap-1 text-xs text-zinc-400 flex-shrink-0",children:[c.jsx(Nte,{className:"size-3"}),c.jsx("span",{className:"drop-shadow-sm",children:Z.bpm})]})]}),c.jsx("div",{className:"flex-1 p-2",children:c.jsx(Vn,{children:ie.map(te=>c.jsxs(et.div,{layout:!0,initial:{opacity:0}
1296,animate:{opacity:1,borderColor:g===te.id?"#f4f4f5":te.color},exit:{opacity:0},transition:{duration:.3,ease:"easeOut"},className:"relative h-10 rounded-lg border-2 overflow-hidden",style:{backgroundColor:te.color,borderColor:te.color},ref:fe=>{j.current[te.id]=fe},children:[c.jsxs("div",{"data-role":"track-header",className:"absolute top-0 left-0 px-2 py-1 flex items-center rounded-tl-lg w-full overflow-hidden backdrop-blur-sm",style:{maxHeight:18,backgroundColor:`color-mix(in srgb, ${te.color} 80%, #000000 20%)40`,borderBottom:`1px solid color-mix(in srgb, ${te.color} 70%, #000000 30%)50`},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/10 via-black/5 to-black/10",style:{backgroundColor:`color-mix(in srgb, ${te.color} 85%, #000000 15%)`,opacity:.4,filter:"blur(0.5px)"}}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/15 to-black/10",style:{backgroundColor:`color-mix(in srgb, ${te.color} 80%, #000000 20%)`,opacity:.3}}),c.jsx("div",{className:"absolute inset-0 backdrop-blur-sm",style:{backgroundColor:`color-mix(in srgb, ${te.color} 75%, #000000 25%)60`,backgroundImage:`linear-gradient(135deg, color-mix(in srgb, ${te.color} 70%, #000000 30%)70 0%, color-mix(in srgb, ${te.color} 85%, #000000 15%)40 50%, color-mix(in srgb, ${te.color} 70%, #000000 30%)70 100%)`}}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent"}),c.jsxs("div",{className:"relative flex items-center w-full",children:[c.jsx("span",{className:"text-xs font-semibold overflow-hidden text-ellipsis whitespace-nowrap w-full drop-shadow-sm text-zinc-100",children:te.label}),c.jsx("div",{className:"flex items-center flex-shrink-0 gap-1"})]})]}),c.jsx("div",{className:"absolute inset-x-0 bottom-0 top-4 px-1 pb-1",children:c.jsx("div",{className:"absolute inset-x-1 bottom-0 h-4 flex items-end gap-0.5 pb-0.5 opacity-80",children:be(te)})})]},te.id))})})]})]},Z.id)},[g,m]),W=x.useCallback(Z=>Z.map((ie,ge)=>{const re=U.some(Q=>Q.id===ie.id),Y=ie.type==="media"&&ie.mediaType==="video",ne=ie.type==="text",be=ie.type==="link",we=12,te=-60,fe=180;let O,pe,he,le;ne?(O=c.jsx(Tl,{className:"size-3 text-yellow-300 drop-shadow-sm"}),pe="bg-gradient-to-br from-yellow-500/90 via-orange-500/90 to-red-500/90",he="border-yellow-700/50",le="from-yellow-500/20 via-orange-500/20 to-red-500/20"):be?(O=c.jsx(Ka,{className:"size-3 text-blue-300 drop-shadow-sm"}),pe="bg-gradient-to-br from-blue-500/90 via-purple-500/90 to-indigo-500/90",he="border-blue-700/50",le="from-blue-500/20 via-purple-500/20 to-indigo-500/20"):Y?(O=c.jsx(Ul,{className:"size-3 text-red-300 drop-shadow-sm"}),pe="bg-gradient-to-br from-red-500/90 via-rose-500/90 to-red-700/90",he="border-red-700/50",le="from-red-500/20 via-rose-500/20 to-red-700/20"):(O=c.jsx(Gs,{className:"size-3 text-red-300 drop-shadow-sm"}),pe="bg-gradient-to-br from-red-500/90 via-rose-500/90 to-red-700/90",he="border-red-700/50",le="from-red-500/20 via-rose-500/20 to-red-700/20");const oe=re?{initial:!1,animate:{opacity:1,scale:1}}:{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.3}};return c.jsxs(et.div,{drag:!0,dragConstraints:_,dragMomentum:!1,whileDrag:{scale:1.02,zIndex:50,cursor:"grabbing",boxShadow:"0 0 0 2px rgb(212 212 216)"},...oe,className:`absolute border-2 box-border rounded-lg flex flex-col overflow-hidden cursor-grab transition-opacity duration-150 ${g===ie.id?"ring-2 ring-zinc-300":""}`,style:{width:160,borderColor:"transparent",touchAction:"none",right:we,bottom:we+ge*(fe+te)},ref:Q=>{j.current[ie.id]=Q},children:[c.jsx("div",{className:`absolute inset-0 ${pe} rounded-lg`}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-white/10 rounded-lg"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-1/2 bg-gradient-to-b from-white/20 to-transparent rounded-t-lg"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1/3 bg-gradient-to-t from-black/10 to-transparent rounded-b-lg"}),c.jsxs("div",{className:`relative flex flex-col h-full bg-zinc-900/95 rounded-lg border ${he}`,children:[c.jsxs("div",{className:"flex items-center justify-between p-2 rounded-t-lg relative overflow-hidden",style:{height:36},children:[c.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${le}`}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-600/80 to-transparent"}),c.jsxs("div",{className:"relative flex items-center gap-1",children:[O,c.jsx("span",{className:"text-xs font-semibold truncate drop-shadow-sm",children:ie.label})]}),be&&c.jsx(Ch,{className:"size-2 text-blue-400 drop-shadow-sm"})]}),c.jsx("div",{className:"flex-1 p-2 overflow-hidden",children:ne&&ie.content?c.jsx("div",{className:"w-full h-full text-xs overflow-hidden space-y-1",dangerouslySetInnerHTML:{__html:ie.content}}):ne?c.jsx("div",{className:"w-full h-full flex items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"text-xs mb-1",children:"Click to add notes..."}),c.jsx($i,{className:"size-3 mx-auto"})]})}):be&&ie.url?c.jsx("a",{href:`https://${ie.url}`,target:"_blank",rel:"noopener noreferrer",className:"block w-full h-full text-xs text-blue-500 hover:underline break-all",children:ie.url}):c.jsx("div",{className:"w-full h-full flex items-center justify-center border-2 border-dashed rounded-lg transition-colors border-zinc-600",children:c.jsxs("div",{className:"text-center",children:[c.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[c.jsx(Gs,{className:"size-3"}),c.jsx(Ul,{className:"size-3"})]}),c.jsx("p",{className:"text-xs",children:"Upload media"})]})})})]})]},ie.id)}),[U,g]),D=x.useMemo(()=>{const Z=m.filter(ie=>["text","link","media"].includes(ie.type));return[...U,...Z]},[U,m]);return c.jsxs("div",{className:"w-full max-w-8xl mx-auto flex flex-col items-center space-y-8 py-0 px-0",children:[c.jsxs("div",{className:"w-full p-2",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400 mb-6",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(bb,{size:14}),c.jsx("span",{children:"Chat"})]}),c.jsx(pi,{size:14}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Mn,{size:14}),c.jsx("span",{children:"Create"})]}),c.jsx(pi,{size:14}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Cz,{size:14}),c.jsx("span",{children:"Refine"})]}),c.jsx(pi,{size:14}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(hy,{size:14}),c.jsx("span",{children:"Produce"})]})]}),c.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-end lg:justify-between gap-6",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("h2",{className:"text-2xl sm:text-3xl font-semibold tracking-tight mb-2 text-white",children:((B=ey[e])==null?void 0:B.title)||"Creative Music Co-Pilot"}),c.jsx("p",{className:"mb-4 text-zinc-300",children:((L=ey[e])==null?void 0:L.description)||"Cai works alongside you as an intelligent music partner."}),c.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4 text-sm",children:[c.jsxs("div",{className:"flex items-center",children:[e==="producers"?c.jsx(mx,{className:"mr-1.5 text-caiBlue",size:16}):e==="artists"?c.jsx(Mn,{className:"mr-1.5 text-caiBlue",size:16}):e==="creatives"?c.jsx(lE,{className:"mr-1.5 text-caiBlue",size:16}):e==="education"?c.jsx(ux,{className:"mr-1.5 text-caiBlue",size:16}):c.jsx(hy,{className:"mr-1.5 text-caiBlue",size:16}
1296),c.jsx("span",{className:"text-zinc-300",children:(($=ey[e])==null?void 0:$.feature1)||"Fast creative workflow"})]}),c.jsxs("div",{className:"flex items-center",children:[e==="producers"?c.jsx(Mn,{className:"mr-1.5 text-caiPeach",size:16}):e==="artists"?c.jsx(Rc,{className:"mr-1.5 text-caiPeach",size:16}):e==="creatives"?c.jsx(uo,{className:"mr-1.5 text-caiPeach",size:16}):e==="education"?c.jsx(bb,{className:"mr-1.5 text-caiPeach",size:16}):c.jsx(bb,{className:"mr-1.5 text-caiPeach",size:16}),c.jsx("span",{className:"text-zinc-300",children:((q=ey[e])==null?void 0:q.feature2)||"Natural collaboration"})]})]})]}),c.jsx("div",{className:"w-full max-w-[720px] ml-auto",children:c.jsx("div",{role:"tablist","aria-label":"Audience tabs",className:`grid grid-cols-5 items-stretch gap-1 p-1 rounded-full 1297 bg-zinc-800/30 1298 border border-zinc-700/60 1299 overflow-hidden`,children:R_e.map(Z=>{const ie=e===Z.id;return c.jsxs(et.button,{role:"tab","aria-selected":ie,onClick:()=>n(Z.id),className:`min-w-0 w-full truncate flex items-center justify-center gap-2 1300 px-3 py-3.5 rounded-full text-xs font-medium transition-all 1301 ${ie?`bg-gradient-to-r ${O_e[Z.id]} text-white shadow-lg`:"text-zinc-300 hover:text-zinc-100"}`,whileHover:{scale:1.02},whileTap:{scale:.98},children:[Z.icon,c.jsx("span",{className:"hidden sm:inline truncate",children:Z.label})]},Z.id)})})})]})]}),c.jsxs("div",{className:"w-full grid grid-cols-1 lg:grid-cols-3 gap-6",children:[c.jsx("div",{className:"h-[600px] lg:h-[550px]",children:c.jsxs("div",{className:"h-full flex flex-col rounded-lg overflow-hidden border bg-zinc-800/20 border-zinc-700",children:[c.jsxs("div",{className:"border-b border-zinc-800 relative overflow-hidden w-full",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-800/75 to-zinc-900/75"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-800/30 via-zinc-750/30 to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-600/80 to-transparent"}),c.jsx("div",{className:"relative z-10 p-4",children:c.jsx("div",{className:"flex items-center justify-between",children:c.jsx("div",{className:"flex items-center gap-2 max-w-[65%]",children:c.jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/10 backdrop-blur-sm border border-white/10 w-full",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(uo,{className:"size-4 text-caiGreen"}),c.jsx("span",{className:"text-sm text-zinc-200 truncate font-medium overflow-ellipsis block w-full",title:"Cai Assistant","aria-label":"Chat title: Cai Assistant",children:"Cai Assistant"})]})})})})})]}),c.jsxs("div",{ref:N,className:"flex-1 p-4 space-y-3 overflow-y-auto [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[c.jsx(Vn,{children:V4[e].chatSequence.slice(0,r).map((Z,ie)=>c.jsxs(et.div,{initial:{opacity:0}
1301,animate:{opacity:.5},className:"opacity-50",children:[c.jsx("div",{className:"flex justify-end mb-2",children:c.jsx("div",{className:"bg-caiBlue-500 rounded-lg px-3 py-2 text-sm text-zinc-100 mb-1 max-w-[80%]",children:c.jsx("p",{className:"text-sm",children:Z.user})})}),c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx("div",{className:"size-6 rounded-full bg-gradient-to-br from-caiBlue via-caiGreen to-caiPeach flex items-center justify-center flex-shrink-0",children:c.jsx(uo,{size:12,className:"text-white"})}),c.jsx("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 text-sm text-zinc-100 mb-1 max-w-[100%]",children:c.jsx("p",{className:"text-sm",children:Z.ai})})]})]},`chat-history-${ie}`))}),s&&c.jsx("div",{className:"flex justify-end",children:c.jsx("div",{className:"bg-caiBlue-500 rounded-lg px-3 py-2 text-sm text-zinc-100 mb-1 max-w-[80%]",children:c.jsxs("p",{className:"text-sm",children:[s,u&&c.jsx("span",{className:"relative top-[2px] inline-block w-0.5 h-4 ml-1 bg-caiGreen animate-pulse"})]})})}),a&&c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx("div",{className:"size-6 rounded-full bg-gradient-to-br from-caiBlue via-caiGreen to-caiPeach flex items-center justify-center flex-shrink-0",children:c.jsx(uo,{size:12,className:"text-white"})}),c.jsx("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 text-sm text-zinc-100 mb-1 max-w-[100%]",children:c.jsxs("p",{className:"text-sm",children:[a,f&&c.jsx("span",{className:"relative top-[2px] inline-block w-0.5 h-4 ml-1 bg-caiGreen animate-pulse"})]})})]})]}),c.jsxs("div",{className:"border-t border-zinc-800 sticky bottom-0 overflow-hidden",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-800/75 to-zinc-900/75"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-zinc-800/30 via-zinc-750/30 to-zinc-700/30 backdrop-blur-sm"}),c.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-zinc-600/80 to-transparent"}),c.jsxs("div",{className:"relative z-10 p-4",children:[c.jsx("div",{style:{minHeight:"20px"},className:"mb-2",children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:"text",value:C,onChange:Z=>k(Z.target.value),onKeyDown:F,placeholder:"Describe what you want to create...",className:"w-full rounded-lg border border-zinc-700/40 bg-zinc-800/40 px-3 py-2 text-sm text-zinc-100 backdrop-blur-sm relative z-10 min-h-[20px] placeholder:text-zinc-400 focus:outline-none focus:ring-2 focus:ring-caiGreen/50 focus:border-caiGreen/50",name:"search",autoComplete:"off","data-form-type":"other"}),c.jsx("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-b from-white/5 pointer-events-none"})]})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:` 1302 p-2 rounded-md text-xs font-semibold select-none 1303 text-zinc-400 1304 transition-transform duration-200 1305 hover:scale-110 hover:text-zinc-100 1306 cursor-pointer focus:outline-none focus:ring-0 focus-visible:outline-none active:scale-110 1307 `,"aria-label":"Takes remaining",title:"Takes remaining",children:"999+"}),c.jsx(yc,{icon:fx,label:"Need inspiration?",size:16})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(yc,{icon:Rc,label:"Start recording",size:16}),c.jsx("button",{type:"button",onClick:P,className:`rounded-md p-2 transition-all duration-200 hover:scale-110 focus:outline-none focus:ring-0 focus:border-0 bg-transparent hover:bg-caiGreen-700 ${C.trim()?"text-white":"text-zinc-600"}`,"aria-label":"Send message",title:"Send message",children:c.jsx(Nh,{size:16})})]})]})]})]})]})}),c.jsx("div",{className:"lg:col-span-2",children:c.jsxs("div",{ref:_,className:"relative h-[720px] lg:h-[550px] rounded-xl overflow-hidden border-2 border-zinc-700 bg-zinc-900",children:[c.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, #52525b 1px, transparent 1px)",backgroundSize:"24px 24px",opacity:.4}}),c.jsx("div",{className:"absolute top-4 left-1/2 transform -translate-x-1/2 z-20",children:c.jsxs("div",{className:"bg-glass-dark border-glass-dark p-2 rounded-xl w-48",children:[c.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c.jsx("div",{className:"flex items-center justify-center",children:c.jsx(yc,{icon:Ya,label:"Volume",size:24})}),c.jsx("div",{className:"w-12 flex justify-center items-center",children:c.jsx(yc,{icon:Zm,label:"Pause / Play",size:24})}),c.jsx(yc,{icon:GS,label:"Repeat2",size:24}),c.jsx(yc,{icon:Yf,label:"Plus",size:24})]}),c.jsx("div",{className:"relative mt-1 px-1",children:c.jsx("div",{className:"w-full h-5 flex items-center cursor-pointer touch-action-none",children:c.jsxs("div",{className:"flex items-center py-3 w-full relative",children:[c.jsxs("div",{className:"absolute inset-0 flex items-center",children:[c.jsx("div",{className:"h-2 rounded-full bg-zinc-400",style:{width:"75%"}}),c.jsx("div",{className:"h-2 rounded-full bg-zinc-600 flex-1"})]}),c.jsx("div",{className:"size-4 bg-zinc-300 text-zinc-900 flex items-center justify-center rounded-full cursor-pointer text-xs hover:scale-110 transition-transform duration-150 relative z-10",style:{marginLeft:"70%"}})]})})})]})}),c.jsxs("div",{className:"absolute top-4 right-4 z-50 flex flex-col space-y-4",children:[c.jsx("div",{className:"w-full flex justify-end",children:c.jsx("div",{className:"bg-glass-dark border-glass-dark flex items-center justify-center size-9 rounded-xl",children:c.jsx(yc,{icon:xD,label:"Menu",size:18})})}),c.jsx("div",{className:"bg-glass-dark border-glass-dark w-9 h-9 flex items-center justify-center rounded-xl",children:c.jsx(yc,{icon:px,label:"Search",size:18})})]}),c.jsx(Vn,{mode:"sync",children:m.filter(Z=>Z.type==="song").map(Z=>A(Z))}),c.jsx(Vn,{mode:"sync",children:W(D)}),c.jsx(et.div,{style:{x:V,y:H,opacity:v.visible?1:0,top:0,left:0},className:"absolute pointer-events-none z-30","aria-hidden":!0,
1307children:c.jsx(wne,{size:18,className:"-translate-x-[1px] -translate-y-[1px] drop-shadow",strokeWidth:1.5,fill:"black",stroke:"white"})}),c.jsx(Vn,{children:g&&(()=>{const Z=m.find(ie=>ie.id===g&&ie.type==="bloob");return Z&&c.jsx(et.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"absolute top-24 left-2 w-56 bg-glass-dark border-glass-dark py-2 px-3 rounded-lg",children:c.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[c.jsxs("div",{className:"text-xl rounded-lg flex items-center justify-between gap-1 w-full",children:[c.jsx("input",{type:"text",value:Z.label,readOnly:!0,className:"bg-transparent underline underline-offset-4 decoration-4 text-zinc-100 outline-none w-full cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap",style:{textDecorationColor:Z.color}}),c.jsx("button",{className:"hover:scale-110 transition-transform p-1 rounded",title:"Delete Bloob",children:c.jsx(js,{className:"size-6 text-red-500"})})]}),c.jsxs("div",{className:"w-full flex items-center gap-2",children:[c.jsx("div",{className:"w-[40px] text-center shrink-0",children:c.jsx(Ya,{className:"size-5 text-zinc-100"})}),c.jsx("div",{className:"w-full h-8 flex items-center cursor-pointer touch-none select-none",children:c.jsxs("div",{className:"flex items-center py-3 w-full h-full relative",children:[c.jsxs("div",{className:"absolute inset-0 flex items-center",children:[c.jsx("div",{className:"h-2 rounded-full bg-zinc-300",style:{width:"75%"}}),c.jsx("div",{className:"h-2 rounded-full bg-zinc-500 flex-1"})]}),c.jsx("div",{className:"size-5 bg-zinc-100 text-zinc-900 flex items-center justify-center rounded-full cursor-pointer text-xs hover:scale-110 transition-transform duration-150 relative z-10",style:{marginLeft:"70%"}})]})})]}),c.jsx("div",{className:"w-full",children:c.jsxs("button",{className:"bg-transparent w-full px-2 py-1 border border-500 rounded-md flex items-center justify-between text-zinc-200 text-sm",title:"Instrument",children:[c.jsx("span",{className:"truncate",children:Z.instrument}),c.jsx(Vi,{className:"text-zinc-500 flex-shrink-0 ml-1",size:16})]})}),c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Ih,{className:"size-4 text-zinc-100"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Mute"})]})}),c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Eh,{className:"size-4 text-zinc-100"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Solo"})]})})]}),c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Mn,{className:"size-4 text-zinc-100"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Details"})]})}),c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(ld,{className:"size-4 text-red-500 fill-red-500"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Record"})]})})]}),c.jsxs("div",{className:"flex items-center gap-3 w-full",children:[c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(mD,{className:"size-4 text-zinc-100"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Extend"})]})}),c.jsx("button",{className:"border border-zinc-500 py-1 rounded-md flex-1 hover:bg-zinc-700",children:c.jsxs("div",{className:"flex justify-center items-center gap-2",children:[c.jsx(Do,{className:"size-4 text-zinc-100"}),c.jsx("span",{className:"text-zinc-100 text-sm",children:"Copy"})]})})]})]})})})()})]})})]}),c.jsx("div",{className:"w-full grid grid-cols-1 md:grid-cols-3 gap-4",children:L_e[e].map((Z,ie)=>c.jsxs(et.div,{className:"p-4 rounded-lg bg-zinc-800/30",initial:{opacity:0,y:20}
1307,animate:{opacity:1,y:0},transition:{delay:.6+ie*.1},children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("div",{className:"text-caiGreen",children:mr.cloneElement(Z.icon,{size:20})}),c.jsx("h4",{className:"font-medium",children:Z.title})]}),c.jsx("p",{className:"text-sm text-zinc-400",children:Z.description})]},`${e}-feature-${ie}`))}),c.jsxs("div",{className:"w-full grid grid-cols-2 md:grid-cols-4 gap-3",children:[c.jsxs("div",{className:"p-3 rounded-lg text-center bg-zinc-800/20",children:[c.jsx(uo,{className:"size-8 mx-auto mb-2 text-caiGreen"}),c.jsx("h5",{className:"text-sm font-medium mb-1",children:"Smart Intent"}),c.jsx("p",{className:"text-xs text-zinc-400",children:"Cai understands what you want to create"})]}),c.jsxs("div",{className:"p-3 rounded-lg text-center bg-zinc-800/20",children:[c.jsx(hy,{className:"size-8 mx-auto mb-2 text-caiBlue"}),c.jsx("h5",{className:"text-sm font-medium mb-1",children:"Pro Audio"}),c.jsx("p",{className:"text-xs text-zinc-400",children:"Advanced production toolkit"})]}),c.jsxs("div",{className:"p-3 rounded-lg text-center bg-zinc-800/20",children:[c.jsx(Cz,{className:"size-8 mx-auto mb-2 text-caiPeach"}),c.jsx("h5",{className:"text-sm font-medium mb-1",children:"Creative Canvas"}),c.jsx("p",{className:"text-xs text-zinc-400",children:"Intuitive interface for your creative vision"})]}),c.jsxs("div",{className:"p-3 rounded-lg text-center bg-zinc-800/20",children:[c.jsx(bb,{className:"size-8 mx-auto mb-2 text-caiGreen"}),c.jsx("h5",{className:"text-sm font-medium mb-1",children:"Natural Language"}),c.jsx("p",{className:"text-xs text-zinc-400",children:"Just describe what you want"})]})]}),c.jsx(et.div,{className:"w-full text-center mt-8",initial:{opacity:0}
1307,animate:{opacity:1},transition:{duration:.8,delay:1},children:c.jsx(et.button,{onClick:t,whileHover:{scale:1.05},whileTap:{scale:.98},className:"px-8 py-3 bg-gradient-to-r from-caiPeach via-caiBlue to-caiGreen text-white rounded-full font-semibold tracking-tight animatingBackground bg-[length:200%_auto] shadow-lg transition-all",children:"Book a demo"})})]})},$_e=({children:t})=>c.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6 bg-gradient-to-r from-caiPeach via-caiGreen to-caiBlue bg-clip-text text-transparent animate-rotatingBackground pb-1",children:t}),U_e=({onSignUp:t})=>{const[e,n]=x.useState(!1),{ref:r,inView:i}=B_e({threshold:.05,triggerOnce:!0});x.useEffect(()=>{i&&!e&&n(!0)},[i,e]);const s=()=>{window.open("https://calendar.app.google/BGDTtPzPuQ3LdwKs5","_blank")},o=()=>{t&&t()};return c.jsx("section",{ref:r,className:"w-full py-16 pb-4 transition-colors duration-300",id:"demo-section",children:c.jsxs("div",{className:"container mx-auto px-4 md:px-8",children:[c.jsxs(et.div,{initial:{opacity:0,y:40},animate:i?{opacity:1,y:0}:{opacity:0,y:40},transition:{duration:.6,ease:"easeOut"},className:"text-center mb-12",children:[c.jsxs($_e,{children:["Intelligence For Your Creativity.",c.jsx("span",{className:"text-xl align-top",children:"â¢"})]}),c.jsxs("p",{className:"text-lg max-w-2xl mx-auto text-zinc-300",children:["Bring your ideas to life, faster than ever. With intelligence and intuitive design at its core, Cai reimagines how music is made. Describe your visionâand watch it come to life. On ",c.jsx("span",{className:"bg-gradient-to-r from-caiPeach via-caiGreen to-caiBlue bg-clip-text text-transparent animate-rotatingBackgroun
1307d",children:"your"})," creative canvasâall on the web, anywhere."]})]}),c.jsx(et.div,{initial:{opacity:0,scale:.95},animate:i?{opacity:1,scale:1}:{opacity:0,scale:.95},transition:{duration:.7,delay:.2,ease:"easeOut"},className:"rounded-2xl overflow-hidden shadow-2xl",children:c.jsx("div",{className:"p-6 md:p-10 rounded-2xl backdrop-blur-sm",style:{backgroundColor:"rgba(15, 23, 42, 0.6)"},children:c.jsx(F_e,{onBookDemo:s})})}),c.jsxs(et.div,{initial:{opacity:0},animate:i?{opacity:1}:{opacity:0},transition:{duration:.5,delay:.8},className:"mt-16 text-center",children:[c.jsx("p",{className:"text-lg font-medium mb-4 text-zinc-300",children:"Ready to create your own music with Cai?"}),c.jsxs("div",{className:"flex flex-wrap gap-6 justify-center",children:[c.jsx(et.button,{onClick:o,whileHover:{scale:1.05},whileTap:{scale:.98},className:"px-8 py-3 rounded-full text-zinc-100 font-medium bg-gradient-to-r from-caiPeach via-caiGreen to-caiBlue animate-rotatingBackground",children:"Create an account"}),c.jsx(et.button,{onClick:s,whileHover:{scale:1.05},whileTap:{scale:.98},className:"px-8 py-3 rounded-full font-medium border-2 border-caiGreen text-zinc-100",children:"Enterprise solutions"})]})]})]})})},V_e=({onSignUp:t,onBookDemo:e})=>{const{isMobile:n}=Hn(),r=new Date().getFullYear(),i=n?20:18,s=({size:l=i})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),o=l=>{window.location.hash=l},a=l=>{const u=document.getElementById("demo-section");if(u&&(u.scrollIntoView({behavior:"smooth"}),l)){const d=new CustomEvent("set-demo-tab",{detail:{category:l}});document.dispatchEvent(d)}};return c.jsx(c.Fragment,{children:c.jsx("footer",{className:"w-full py-12 px-4 md:px-8 transition-colors duration-300",children:c.jsxs("div",{className:"container mx-auto max-w-6xl",children:[c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-x-4 gap-y-8 mb-8",children:[c.jsxs("div",{className:"space-y-2 col-span-2 sm:col-span-3 md:col-span-1",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3 text-white",children:"Cai"}),c.jsx("p",{className:"text-sm text-zinc-400",children:"Design your music without limits. Bring your ideas to life."}),c.jsxs("div",{className:"flex flex-wrap gap-3 lg:gap-3 pt-2",children:[c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://www.linkedin.com/company/cai-creative",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://www.instagram.com/cai.audio",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors","aria-label":"Follow us on Instagram",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259
13070-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"})})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://x.com/caicreative",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors","aria-label":"Follow us on X (formerly Twitter)",children:c.jsx(s,{size:i})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://www.facebook.com/caicreativefb",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors","aria-label":"Follow us on Facebook",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://www.reddit.com/r/caicreative/s/nLlCSNnZbB",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm0 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm-2 11.5c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5-.672-1.5-1.5-1.5zm4 0c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5-.672-1.5-1.5-1.5zm-5.148-3.578l-.348-.7c1.925-.49 4.883-.505 5.096.012l-.652.438c-.354-.395-2.592-.341-4.096.25zm5.148-1.422c.828 0 1.5-.671 1.5-1.5s-.672-1.5-1.5-1.5-1.5.671-1.5 1.5.672 1.5 1.5 1.5zm-8.22.516c-1.733 1.321-1.92 4.772-.081 6.302l-.546.532c-2.223-1.878-2.035-5.917.164-7.501l.463.667zm11.294.667c2.138 1.554 2.393 5.508.164 7.501l-.546-.532c1.838-1.529 1.651-4.981-.081-6.302l.463-.667z"})})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://discord.gg/6NSDYZgNHf",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors","aria-label":"Join our Discord",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}),c.jsx(et.a,{whileHover:{scale:1.1},whileTap:{scale:.95},href:"https://www.youtube.com/@CaiCreative",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-caiBlue transition-colors","aria-label":"Subscribe to our YouTube channel",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",children:c.jsx("path",{d:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3 text-white",children:"Product"}),c.jsxs("ul",{className:"space-y-2",children:[c.jsx("li",{children:c.jsxs("button",{onClick:t,className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"Sign Up"]})}),c.jsx("li",{children:c.jsxs("button",{onClick:e,className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"Book a Demo"]})}),c.jsx("li",{children:c.jsxs("button",{onClick:()=>a(),className:"text-sm flex items-center text-left text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"Features"]})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3 text-white",children:"Use Cases"}),c.jsxs("ul",{className:"space-y-2",children:[c.jsx("li",{children:c.jsxs("button",{onClick:()=>a("producers"),className:"text-sm flex items-center text-left text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"For Producers"]})}),c.jsx("li",{children:c.jsxs("button",{onClick:()=>a("artists"),className:"text-sm flex items-center text-left text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"For Artists"]})}),c.jsx("li",{children:c.jsxs("button",{onClick:()=>a("education"),className:"text-sm flex items-center text-left text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"For Education"]})}),c.jsx("li",{children:c.jsxs("button",{onClick:()=>a("businesses"),className:"text-sm flex items-center text-left text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(pi,{size:14,className:"mr-1"}),"For Businesses"]})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3 text-white",children:"Support"}),c.jsxs("ul",{className:"space-y-2",children:[c.jsx("li",{children:c.jsxs("a",{href:"mailto:[email protected]",className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx(_h,{size:14,className:"mr-1"}),"Contact Us"]})}),c.jsx("li",{children:c.jsxs("button",{className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",onClick:()=>o("about"),children:[c.jsx(Kc,{size:14,className:"mr-1"}),"About Cai"]})}),c.jsx("li",{children:c.jsxs("button",{className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",onClick:()=>o("faq"),children:[c.jsx(dx,{size:14,className:"mr-1"}),"FAQ"]})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3 text-white",children:"Legal"}),c.jsxs("ul",{className:"space-y-2",children:[c.jsx("li",{children:c.jsxs("a",{href:"/privacy",className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx($i,{size:14,className:"mr-1"}),"Privacy Policy"]})}),c.jsx("li",{children:c.jsxs("a",{href:"/cookies",className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx($i,{size:14,className:"mr-1"}),"Cookie Policy"]})}),c.jsx("li",{children:c.jsxs("a",{href:"/terms",className:"text-sm flex items-center text-zinc-400 hover:text-caiGreen transition-colors",children:[c.jsx($i,{size:14,className:"mr-1"}),"Terms of Use"]})})]})]})]}),c.jsx("div",{className:"w-full h-px bg-gradient-to-r from-caiPeach via-caiGreen to-caiBlue my-6"}),c.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center pt-4",children:[c.jsxs("div",{className:"text-xs text-zinc-500 mb-4 md:mb-0",children:["© ",r," Cai. All rights reserved."]}),c.jsx("div",{className:"flex items-center",children:c.jsxs("a",{href:"https://www.techstars.com",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-2",children:[c.jsx("span",{className:"text-xs text-zinc-500",children:"Backed by"}),c.jsx("img",{src:"/techstars/Techstars_Logo_Primary_White-cropped.png",alt:"Techstars",className:"h-6 md:h-8"})]})})]})]})})})},H_e=()=>{const[t,e]=x.useState(!1);return x.useEffect(()=>{const n=()=>{const r=navigator.userAgent,i=/Safari/.test(r)&&!/Chrome/.test(r)&&!/Chromium/.test(r),s=!/Mobile|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(r);e(i&&s)};
1307return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[]),t},G_e=100,W_e=()=>{const{isDarkMode:t}=Pn(),{isMobile:e}=Hn(),n=H_e(),[r,i]=x.useState(0),[s,o]=x.useState(null),a=x.useRef(null),l=x.useRef(null),[u,d]=x.useState(!1),[f,h]=x.useState(!0),[m,y]=x.useState(!1),g=e?300:400,w=x.useRef({light:null,dark:null});x.useEffect(()=>{const j=()=>{switch(window.location.hash.toLowerCase()){case"#faq":o("faq"),document.body.style.overflow="hidden";break;case"#about":o("about"),document.body.style.overflow="hidden";break;default:o(null),document.body.style.overflow="auto";break}};return j(),window.addEventListener("hashchange",j),()=>{window.removeEventListener("hashchange",j)}},[]);const v=x.useCallback(()=>{o(null),document.body.style.overflow="auto",window.history.pushState("",document.title,window.location.pathname+window.location.search)},[]);x.useEffect(()=>{if(!w.current.light||!w.current.dark){const j=new Image,T=new Image;let M=0;const V=2,H=()=>{M++,M===V&&(y(!0),setTimeout(()=>{h(!1)},100))};j.onload=()=>{w.current.light=j,H()},T.onload=()=>{w.current.dark=T,H()},j.src="/techstars/Techstars_Logo_Primary_Black-cropped.png",T.src="/techstars/Techstars_Logo_Primary_White-cropped.png"}else y(!0),setTimeout(()=>{h(!1)},100)},[]);const S=x.useCallback(j=>{j===0&&r!==0?(d(!0),i(j),setTimeout(()=>{d(!1)},G_e)):i(j)},[r]),C=x.useCallback(()=>{var j;(j=l.current)==null||j.handleResetPlaceholder(),S(0)},[S]),k=x.useCallback(()=>{window.location.reload()},[]),N=x.useCallback(()=>{S(3)},[S]),_=x.useMemo(()=>{switch(r){case 0:return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:`flex flex-col items-center space-y-4 text-4xl md:text-5xl transition-opacity duration-500 ${u?"opacity-0":"opacity-100"}`,children:[c.jsx("h1",{className:"text-center whitespace-nowrap",children:"Design Your Music"}),c.jsx("h1",{className:"text-center whitespace-nowrap bg-gradient-to-r from-caiPeach via-caiGreen to-caiBlue bg-clip-text text-transparent animate-rotatingBackgroun
1307d pb-1",children:"Without Limits."})]}),c.jsx("div",{className:`w-full mx-auto transition-opacity duration-500 ${u?"opacity-0":"opacity-100"}`,ref:a,children:c.jsx(F9,{ref:l,onSubmit:()=>S(3)})}),c.jsxs("div",{className:`flex flex-col transition-opacity duration-500 ${u?"opacity-0":"opacity-100"}`,children:[c.jsx("h1",{className:"text-zinc-400 text-xl mx-auto",children:"Backed By"}),c.jsx("a",{href:"https://www.techstars.com",target:"_blank",rel:"noopener noreferrer",className:"h-16",children:m&&c.jsx("img",{className:"w-48 md:w-64",src:"/techstars/Techstars_Logo_Primary_White-cropped.png",alt:"Techstars"})})]})]});case 1:return c.jsx("div",{ref:a,children:c.jsx(C_e,{onClose:()=>S(0)})});case 2:return c.jsx("div",{ref:a,children:c.jsx($4,{onSuccess:k,onClose:()=>S(0),initialState:"SIGN_IN"})});case 3:return c.jsx("div",{ref:a,children:c.jsx($4,{onSuccess:k,onClose:()=>S(0),initialState:"SIGN_UP"})})}},[r,u,m,k,S]);return c.jsxs("div",{className:"min-h-screen w-full relative",children:[c.jsx("div",{className:"fixed inset-0 z-0",style:{background:"linear-gradient(135deg, #0f172a 0%, #1e293b 25%, #020617 60%, #000000 100%)"}}),c.jsxs("div",{className:"relative z-10 text-white",children:[c.jsx("style",{children:` 1308 ::-webkit-scrollbar {
1309 width: 2px; 1310 } 1311 1312 ::-webkit-scrollbar-track { 1313 background: transparent; 1314 } 1315 1316 ::-webkit-scrollbar-thumb { 1317 background: rgba(156, 163, 175, 0.3); 1318 border-radius: 1px; 1319 } 1320 1321 ::-webkit-scrollbar-thumb:hover { 1322 background: rgba(156, 163, 175, 0.5); 1323 } 1324 1325 /* Firefox */ 1326 * { 1327 scrollbar-width: thin; 1328 scrollbar-color: rgba(156, 163, 175, 0.3) transparent; 1329 } 1330 `}),c.jsx(JCe,{showSignInButton:r===0,showMenuToggle:r===0,onSignInClick:()=>S(2),onSignUpClick:()=>S(3)}),c.jsx(uF,{rangeX:1500,rangeY:1e3,particleCount:g,baseSpeed:.01,rangeSpeed:n?.85:.65,attractionElementRef:a,attractionStrength:1.75,swirlStrength:.01},`vortex-${g}-${t?"dark":"light"}`),c.jsx("div",{className:"relative min-h-[70vh] md:min-h-screen z-10 flex pointer-events-auto",children:c.jsxs("div",{className:`flex flex-col items-center py-32 md:py-20 px-4 m-auto space-y-10 w-full md:w-[650px] transition-opacity duration-500 ease-in-out ${f?"opacity-0":"opacity-100"}`,children:[r!==1&&r!==2&&r!==3&&c.jsx("div",{className:`mx-auto w-60 md:w-80 transition-opacity duration-300 ${u?"opacity-0":"opacity-100"}`,children:c.jsx(XCe,{onClick:C})}),_]})}),r===0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative z-10 pointer-events-auto mt-[-60px] md:mt-0",children:c.jsx(U_e,{onSignUp:N})}),c.jsx("div",{className:"relative z-10 pointer-events-auto",children:c.jsx(V_e,{onSignUp:N,onBookDemo:()=>window.open("https://calendar.app.google/BGDTtPzPuQ3LdwKs5","_blank")})})]}),s==="faq"&&c.jsx(D9,{onClose:v}),s==="about"&&c.jsx(UC,{onClose:v})]})]})};class ga{constructor(e=!1){this.eventMap={},this.eventsSuspended=e==!0}addListener(e,n,r={}){if(typeof e=="string"&&e.length<1||e instanceof String&&e.length<1||typeof e!="string"&&!(e instanceof String)&&e!==ga.ANY_EVENT)throw new TypeError("The 'event' parameter must be a string or EventEmitter.ANY_EVENT.");if(typeof n!="function")throw new TypeError("The callback must be a function.");const i=new H4(e,this,n,r);return this.eventMap[e]||(this.eventMap[e]=[]),r.prepend?this.eventMap[e].unshift(i):this.eventMap[e].push(i),i}addOneTimeListener(e,n,r={}){r.remaining=1,this.addListener(e,n,r)}static get ANY_EVENT(){return Symbol.for("Any event")}hasListener(e,n){return e===void 0?this.eventMap[ga.ANY_EVENT]&&this.eventMap[ga.ANY_EVENT].length>0?!0:Object.entries(this.eventMap).some(([,r])=>r.length>0):this.eventMap[e]&&this.eventMap[e].length>0?n instanceof H4?this.eventMap[e].filter(i=>i===n).length>0:typeof n=="function"?this.eventMap[e].filter(i=>i.callback===n).length>0:n==null:!1}get eventNames(){return Object.keys(this.eventMap)}getListeners(e){return this.eventMap[e]||[]}suspendEvent(e){this.getListeners(e).forEach(n=>{n.suspended=!0})}unsuspendEvent(e){this.getListeners(e).forEach(n=>{n.suspended=!1})}getListenerCount(e){return this.getListeners(e).length}emit(e,...n){if(typeof e!="string"&&!(e instanceof String))throw new TypeError("The 'event' parameter must be a string.");if(this.eventsSuspended)return;let r=[],i=this.eventMap[ga.ANY_EVENT]||[];return this.eventMap[e]&&(i=i.concat(this.eventMap[e])),i.forEac
vendor: 4,696 bytes, lines 1330-1337
1330h(s=>{if(s.suspended)return;let o=[...n];Array.isArray(s.arguments)&&(o=o.concat(s.arguments)),s.remaining>0&&(r.push(s.callback.apply(s.context,o)),s.count++),--s.remaining<1&&s.remove()}),r}removeListener(e,n,r={}){if(e===void 0){this.eventMap={};return}else if(!this.eventMap[e])return;let i=this.eventMap[e].filter(s=>n&&s.callback!==n||r.remaining&&r.remaining!==s.remaining||r.context&&r.context!==s.context);i.length?this.eventMap[e]=i:delete this.eventMap[e]}async waitFor(e,n={}){return n.duration=parseInt(n.duration),(isNaN(n.duration)||n.duration<=0)&&(n.duration=1/0),new Promise((r,i)=>{let s,o=this.addListener(e,()=>{clearTimeout(s),r()},{remaining:1});n.duration!==1/0&&(s=setTimeout(()=>{o.remove(),i("The duration expired before the event was emitted.")},n.duration))})}get eventCount(){return Object.keys(this.eventMap).length}}class H4{constructor(e,n,r,i={}){if(typeof e!="string"&&!(e instanceof String)&&e!==ga.ANY_EVENT)throw new TypeError("The 'event' parameter must be a string or EventEmitter.ANY_EVENT.");if(!n)throw new ReferenceError("The 'target' parameter is mandatory.");if(typeof r!="function")throw new TypeError("The 'callback' must be a function.");i.arguments!==void 0&&!Array.isArray(i.arguments)&&(i.arguments=[i.arguments]),i=Object.assign({context:n,remaining:1/0,arguments:void 0,duration:1/0},i),i.duration!==1/0&&setTimeout(()=>this.remove(),i.duration),this.arguments=i.arguments,this.callback=r,this.context=i.context,this.count=0,this.event=e,this.remaining=parseInt(i.remaining)>=1?parseInt(i.remaining):1/0,this.suspended=!1,this.target=n}remove(){this.target.removeListener(this.event,this.callback,{context:this.context,remaining:this.remaining})}}/** 1331 * The `Enumerations` class contains enumerations and arrays of elements used throughout the 1332 * library. All its properties are static and should be referenced using the class name. For 1333 * example: `Enumerations.CHANNEL_MESSAGES`. 1334 * 1335 * @license Apache-2.0 1336 * @since 3.0.0 1337 */class vt{static get MIDI_CHANNEL_MESSAGES(){return this.validation&&console.warn("The MIDI_CHANNEL_MESSAGES enum has been deprecated. Use the Enumerations.CHANNEL_MESSAGES enum instead."),vt.CHANNEL_MESSAGES}static get CHANNEL_MESSAGES(){return{noteoff:8,noteon:9,keyaftertouch:10,controlchange:11,programchange:12,channelaftertouch:13,pitchbend:14}}static get CHANNEL_NUMBERS(){return[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}static get MIDI_CHANNEL_NUMBERS(){return this.validation&&console.warn("The MIDI_CHANNEL_NUMBERS array has been deprecated. Use the Enumerations.CHANNEL_NUMBERS array instead."),[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}static get CHANNEL_MODE_MESSAGES(){return{allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127}}static get MIDI_CHANNEL_MODE_MESSAGES(){return this.validation&&console.warn("The MIDI_CHANNEL_MODE_MESSAGES enum has been deprecated. Use the Enumerations.CHANNEL_MODE_MESSAGES enum instead."),vt.CHANNEL_MODE_MESSAGES}static get MIDI_CONTROL_CHANGE_MESSAGES(){return this.validation&&console.warn("The MIDI_CONTROL_CHANGE_MESSAGES enum has been deprecated. Use the Enumerations.CONTROL_CHANGE_MESSAGES array instead."),{bankselectcoarse:0,modulationwheelcoarse:1,breathcontrollercoarse:2,controller3:3,footcontrollercoarse:4,portamentotimecoarse:5,dataentrycoarse:6,volumecoarse:7,balancecoarse:8,controller9:9,pancoarse:10,expressioncoarse:11,effectcontrol1coarse:12,effectcontrol2coarse:13,controller14:14,controller15:15,generalpurposeslider1:16,generalpurposeslider2:17,generalpurposeslider3:18,generalpurposeslider4:19,controller20:20,controller21:21,controller22:22,controller23:23,controller24:24,controller25:25,controller26:26,controller27:27,controller28:28,controller29:29,controller30:30,controller31:31,bankselectfine:32,modulationwheelfine:33,breathcontrollerfine:34,controller35:35,footcontrollerfine:36,portamentotimefine:37,dataentryfine:38,volumefine:39,balancefine:40,controller41:41,panfine:42,expressionfine:43,effectcontrol1fine:44,effectcontrol2fine:45,controller46:46,controller47:47,controller48:48,controller49:49,controller50:50,controller51:51,controller52:52,controller53:53,controller54:54,controller55:55,controller56:56,controller57:57,controller58:58,controller59:59,controller60:60,controller61:61,controller62:62,controller63:63,holdpedal:64,portamento:65,sustenutopedal:66,softpedal:67,legatopedal:68,hold2pedal:69,soundvariation:70,resonance:71,soundreleasetime:72,soundattacktime:73,brightness:74,soundcontrol6:75,soundcontrol7:76,soundcontrol8:77,soundcontrol9:78,soundcontrol10:79,generalpurposebutton1:80,generalpurposebutton2:81,generalpurposebutton3
1337:82,generalpurposebutton4:83,controller84:84,controller85:85,controller86:86,controller87:87,controller88:88,controller89:89,controller90:90,reverblevel:91,tremololevel:92,choruslevel:93,celestelevel:94,phaserlevel:95,databuttonincrement:96,databuttondecrement:97,nonregisteredparametercoarse:98,nonregisteredparameterfine:99,registeredparametercoarse:100,registeredparameterfine:101,controller102:102,controller103:103,controller104:104,controller105:105,controller106:106,controller107:107,controller108:108,controller109:109,controller110:110,controller111:111,controller112:112,controller113:113,controller114:114,controller115:115,controller116:116,controller117:117,controller118:118,controller119:119,allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127}}static get CONTROL_CHANGE_MESSAGES(){return[{number:0,name:"bankselectcoarse",description:"Bank Select (Coarse)",position:"msb"},{number:1,name:"modulationwheelcoarse",description:"Modulation Wheel (Coarse)",position:"msb"},{number:2,name:"breathcontrollercoarse",description:"Breath Controller (Coarse)",position:"msb"},{number:3,name:"controller3",description:"Undefined",position:"msb"},{number:4,name:"footcontrollercoarse",description:"Foot Controller (Coarse)",position:"msb"},{number:5,name:"portamentotimecoarse",description:"Portamento Time (Coarse)",position:"msb"},{number:6,name:"dataentrycoarse",description:"Data Entry (Coarse)",position:"msb"},{number:7,name:"volumecoarse",description:"Channel Volume (Coarse)",position:"msb"},{number:8,name:"balancecoarse",description:"Balance (Coarse)",position:"msb"},{number:9,name:"controller9",description:"Controller 9 (Coarse)",position:"msb"},{number:10,name:"pancoarse",description:"Pan (Coarse)",position:"msb"},{number:11,name:"expressioncoarse",description:"Expression Controller (Coarse)",position:"msb"},{number:12,name:"effectcontrol1coarse",description:"Effect Control 1 (Coarse)",position:"msb"},{number:13,name:"effectcontrol2coarse",description:"Effect Control 2 (Coarse)",position:"msb"},{number:14,name:"controller14",description:"Undefined",position:"msb"},{number:15,name:"controller15",description:"Undefined",position:"msb"},{number:16,name:"generalpurposecontroller1",description:"General Purpose Controller 1 (Coarse)",position:"msb"},{number:17,name:"generalpurposecontroller2",description:"General Purpose Controller 2 (Coarse)",position:"msb"},{number:18,name:"generalpurposecontroller3",description:"General Purpose Controller 3 (Coarse)",position:"msb"},{number:19,name:"generalpurposecontroller4",description:"General Purpose Controller 4 (Coarse)",position:"msb"},{number:20,name:"controller20",description:"Undefined",position:"msb"},{number:21,name:"controller21",description:"Undefined",position:"msb"},{number:22,name:"controller22",description:"Undefined",position:"msb"},{number:23,name:"controller23",description:"Undefined",position:"msb"},{number:24,name:"controller24",description:"Undefined",position:"msb"},{number:25,name:"controller25",description:"Undefined",position:"msb"},{number:26,name:"controller26",description:"Undefined",position:"msb"},{number:27,name:"controller27",description:"Undefined",position:"msb"},{number:28,name:"controller28",description:"Undefined",position:"msb"},{number:29,name:"controller29",description:"Undefined",position:"msb"},{number:30,name:"controller30",description:"Undefined",position:"msb"},{number:31,name:"controller31",description:"Undefined",position:"msb"},{number:32,name:"bankselectfine",description:"Bank Select (Fine)",position:"lsb"},{number:33,name:"modulationwheelfine",description:"Modulation Wheel (Fine)",position:"lsb"},{number:34,name:"breathcontrollerfine",description:"Breath Controller (Fine)",position:"lsb"},{number:35,name:"controller35",description:"Undefined",position:"lsb"},{number:36,name:"footcontrollerfine",description:"Foot Controller (Fine)",position:"lsb"},{number:37,name:"portamentotimefine",description:"Portamento Time (Fine)",position:"lsb"},{number:38,name:"dataentryfine",description:"Data Entry (Fine)",position:"lsb"},{number:39,name:"channelvolumefine",description:"Channel Volume (Fine)",position:"lsb"},{number:40,name:"balancefine",description:"Balance (Fine)",position:"lsb"},{number:41,name:"controller41",description:"Undefined",position:"lsb"},{number:42,name:"panfine",description:"Pan (Fine)",position:"lsb"},{number:43,name:"expressionfine",description:"Expression Controller (Fine)",position:"lsb"},{number:44,name:"effectcontrol1fine",description:"Effect control 1 (Fine)",position:"lsb"},{number:45,name:"effectcontrol2fine",description:"Effect control 2 (Fine)",position:"lsb"},{number:46,name:"controller46",description:"Undefined",position:"lsb"},{number:47,name:"controller47",description:"Undefined",position:"lsb"},{number:48,name:"controller48",description:"General Purpose Controller 1 (Fine)",position:"lsb"},{number:49,name:"controller49",description:"General Purpose Controller 2 (Fine)",position:"lsb"},{number:50,name:"controller50",description:"General Purpose Controller 3 (Fine)",position:"lsb"},{number:51,name:"controller51",description:"General Purpose Controller 4 (Fine)",position:"lsb"},{number:52,name:"controller52",description:"Undefined",position:"lsb"},{number:53,name:"controller53",description:"Undefined",position:"lsb"},{number:54,name:"controller54",description:"Undefined",position:"lsb"},{number:55,name:"controller55",description:"Undefined",position:"lsb"},{number:56,name:"controller56",description:"Undefined",position:"lsb"},{number:57,name:"controller57",description:"Undefined",position:"lsb"},{number:58,name:"controller58",description:"Undefined",position:"lsb"},{number:59,name:"controller59",description:"Undefined",position:"lsb"},{number:60,name:"controller60",description:"Undefined",position:"lsb"},{number:61,name:"controller61",description:"Undefined",position:"lsb"},{number:62,name:"controller62",description:"Undefined",position:"lsb"},{number:63,name:"controller63",description:"Undefined",position:"lsb"},{number:64,name:"damperpedal",description:"Damper Pedal On/Off"},{number:65,name:"portamento",description:"Portamento On/Off"},{number:66,name:"sostenuto",description:"Sostenuto On/Off"},{number:67,name:"softpedal",description:"Soft Pedal On/Off"},{number:68,name:"legatopedal",description:"Legato Pedal On/Off"},{number:69,name:"hold2",description:"Hold 2 On/Off"},{number:70,name:"soundvariation",description:"Sound Variation",position:"lsb"},{number:71,name:"resonance",description:"Resonance",position:"lsb"},{number:72,name:"releasetime",description:"Release Time",position:"lsb"},{number:73,name:"attacktime",description:"Attack Time",position:"lsb"},{number:74,name:"brightness",description:"Brightness",position:"lsb"},{number:75,name:"decaytime",description:"Decay Time",position:"lsb"},{number:76,name:"vibratorate",description:"Vibrato Rate",position:"lsb"},{number:77,name:"vibratodepth",description:"Vibrato Depth",position:"lsb"},{number:78,name:"vibratodelay",description:"Vibrato Delay",position:"lsb"},{number:79,name:"controller79",description:"Undefined",position:"lsb"},{number:80,name:"generalpurposecontroller5",description:"General Purpose Controller 5",position:"lsb"},{number:81,name:"generalpurposecontroller6",description:"General Purpose Controller 6",position:"lsb"},{number:82,name:"generalpurposecontroller7",description:"General Purpose Controller 7",position:"lsb"},{number:83,name:"generalpurposecontroller8",description:"General Purpose Controller 8",position:"lsb"},{number:84,name:"portamentocontrol",description:"Portamento Control",position:"lsb"},{number:85,name:"controller85",description:"Undefined"},{number:86,name:"controller86",description:"Undefined"}
1337,{number:87,name:"controller87",description:"Undefined"},{number:88,name:"highresolutionvelocityprefix",description:"High Resolution Velocity Prefix",position:"lsb"},{number:89,name:"controller89",description:"Undefined"},{number:90,name:"controller90",description:"Undefined"},{number:91,name:"effect1depth",description:"Effects 1 Depth (Reverb Send Level)"},{number:92,name:"effect2depth",description:"Effects 2 Depth"},{number:93,name:"effect3depth",description:"Effects 3 Depth (Chorus Send Level)"},{number:94,name:"effect4depth",description:"Effects 4 Depth"},{number:95,name:"effect5depth",description:"Effects 5 Depth"},{number:96,name:"dataincrement",description:"Data Increment"},{number:97,name:"datadecrement",description:"Data Decrement"},{number:98,name:"nonregisteredparameterfine",description:"Non-Registered Parameter Number (Fine)",position:"lsb"},{number:99,name:"nonregisteredparametercoarse",description:"Non-Registered Parameter Number (Coarse)",position:"msb"},{number:100,name:"registeredparameterfine",description:"Registered Parameter Number (Fine)",position:"lsb"},{number:101,name:"registeredparametercoarse",description:"Registered Parameter Number (Coarse)",position:"msb"},{number:102,name:"controller102",description:"Undefined"},{number:103,name:"controller103",description:"Undefined"},{number:104,name:"controller104",description:"Undefined"},{number:105,name:"controller105",description:"Undefined"},{number:106,name:"controller106",description:"Undefined"},{number:107,name:"controller107",description:"Undefined"},{number:108,name:"controller108",description:"Undefined"},{number:109,name:"controller109",description:"Undefined"},{number:110,name:"controller110",description:"Undefined"},{number:111,name:"controller111",description:"Undefined"},{number:112,name:"controller112",description:"Undefined"},{number:113,name:"controller113",description:"Undefined"},{number:114,name:"controller114",description:"Undefined"},{number:115,name:"controller115",description:"Undefined"},{number:116,name:"controller116",description:"Undefined"},{number:117,name:"controller117",description:"Undefined"},{number:118,name:"controller118",description:"Undefined"},{number:119,name:"controller119",description:"Undefined"},{number:120,name:"allsoundoff",description:"All Sound Off"},{number:121,name:"resetallcontrollers",description:"Reset All Controllers"},{number:122,name:"localcontrol",description:"Local Control On/Off"},{number:123,name:"allnotesoff",description:"All Notes Off"},{number:124,name:"omnimodeoff",description:"Omni Mode Off"},{number:125,name:"omnimodeon",description:"Omni Mode On"},{number:126,name:"monomodeon",description:"Mono Mode On"},{number:127,name:"polymodeon",description:"Poly Mode On"}]}static get REGISTERED_PARAMETERS(){return{pitchbendrange:[0,0],channelfinetuning:[0,1],channelcoarsetuning:[0,2],tuningprogram:[0,3],tuningbank:[0,4],modulationrange:[0,5],azimuthangle:[61,0],elevationangle:[61,1],gain:[61,2],distanceratio:[61,3],maximumdistance:[61,4],maximumdistancegain:[61,5],referencedistanceratio:[61,6],panspreadangle:[61,7],rollangle:[61,8]}}static get MIDI_REGISTERED_PARAMETERS(){return this.validation&&console.warn("The MIDI_REGISTERED_PARAMETERS enum has been deprecated. Use the Enumerations.REGISTERED_PARAMETERS enum instead."),vt.MIDI_REGISTERED_PARAMETERS}static get SYSTEM_MESSAGES(){return{sysex:240,timecode:241,songposition:242,songselect:243,tunerequest:246,tuningrequest:246,sysexend:247,clock:248,start:250,continue:251,stop:252,activesensing:254,reset:255,midimessage:0,unknownsystemmessage:-1}}static get MIDI_SYSTEM_MESSAGES(){return this.validation&&console.warn("The MIDI_SYSTEM_MESSAGES enum has been deprecated. Use the Enumerations.SYSTEM_MESSAGES enum instead."),vt.SYSTEM_MESSAGES}static get CHANNEL_EVENTS(){return["noteoff","controlchange","noteon","keyaftertouch","programchange","channelaftertouch","pitchbend","allnotesoff","allsoundoff","localcontrol","monomode","omnimode","resetallcontrollers","nrpn","nrpn-dataentrycoarse","nrpn-dataentryfine","nrpn-dataincrement","nrpn-datadecrement","rpn","rpn-dataentrycoarse","rpn-dataentryfine","rpn-dataincrement","rpn-datadecrement","nrpn-databuttonincrement","nrpn-databuttondecrement","rpn-databuttonincrement","rpn-databuttondecrement"]}}/** 1338 * The `Note` class represents a single musical note such as `"D3"`, `"G#4"`, `"F-1"`, `"Gb7"`, etc. 1339 * 1340 * `Note` objects can be played back on a single channel by calling 1341 * [`OutputChannel.playNote()`]{@link OutputChannel#playNote} or, on multiple channels of the same 1342 * output, by calling [`Output.playNote()`]{@link Output#playNote}. 1343 * 1344 * The note has [`attack`](#attack) and [`release`](#release) velocities set at `0.5` by default. 1345 * These can be changed by passing in the appropriate option. It is also possible to set a 1346 * system-wide default for attack and release velocities by using the 1347 * [`WebMidi.defaults`](WebMidi#defaults) property. 1348 * 1349 * If you prefer to work with raw MIDI values (`0` to `127`), you can use [`rawAttack`](#rawAttack) and 1350 * [`rawRelease`](#rawRelease) to both get and set the values. 1351 * 1352 * The note may have a [`duration`](#duration). If it does, playback will be automatically stopped 1353 * when the duration has elapsed by sending a `"noteoff"` event. By default, the duration is set to 1354 * `Infinity`. In this case, it will never stop playing unless explicitly stopped by calling a 1355 * method such as [`OutputChannel.stopNote()`]{@link OutputChannel#stopNote}, 1356 * [`Output.stopNote()`]{@link Output#stopNote} or similar. 1357 * 1358 * @license Apache-2.0 1359 * @since 3.0.0 1360 */class Wf{constructor(e,n={}){this.duration=Ot.defaults.note.duration,this.attack=Ot.defaults.note.attack,this.release=Ot.defaults.note.release,n.duration!=null&&(this.duration=n.duration),n.attack!=null&&(this.attack=n.attack),n.rawAttack!=null&&(this.attack=qt.from7bitToFloat(n.rawAttack)),n.release!=null&&(this.release=n.release),n.rawRelease!=null&&(this.release=qt.from7bitToFloat(n.rawRelease)),Number.isInteger(e)?this.identifier=qt.toNoteIdentifier(e):this.identifier=e}get identifier(){return this._name+(this._accidental||"")+this._octave}set identifier(e){const n=qt.getNoteDetails(e);if(Ot.validation&&!e)throw new Error("Invalid note identifier");this._name=n.name,this._accidental=n.accidental,this._octave=n.octave}get name(){return this._name}set name(e){if(Ot.validation&&(e=e.toUpperCase(),!["C","D","E","F","G","A","B"].includes(e)))throw new Error("Invalid name value");this._name=e}get accidental(){return this._accidental}set accidental(e){if(Ot.validation&&(e=e.toLowerCase(),!["#","##","b","bb"].includes(e)))throw new Error("Invalid accidental value");this._accidental=e}get octave(){return this._octave}set octave(e){if(Ot.validation&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid octave value");this._octave=e}get duration(){return this._duration}set duration(e){if(Ot.validation&&(e=parseFloat(e),isNaN(e)||e===null||e<0))throw new RangeError("Invalid duration value.");this._duration=e}get attack(){return this._attack}set attack(e){if(Ot.validation&&(e=parseFloat(e),isNaN(e)||!(e>=0&&e<=1)))throw new RangeError("Invalid attack value.");this._attack=e}get release(){return this._release}set release(e){if(Ot.validation&&(e=parseFloat(e),isNaN(e)||!(e>=0&&e<=1)))throw new RangeError("Invalid release value.");this._release=e}get rawAttack(){return qt.fromFloatTo7Bit(this._attack)}set rawAttack(e){this._attack=qt.from7bitToFloat(e)}get rawRelease(){return qt.fromFloatTo7Bit(this._release)}set rawRelease(e){this._release=qt.from7bitToFloat(e)}get number(){return qt.toNoteNumber(this.identifier)}getOffsetNumber(e=0,n=0){return Ot.validation&&(e=parseInt(e)||0,n=parseInt(n)||0),Math.min(Math.max(this.number+e*12+n,0),127)}}/** 1361 * The `Utilities` class contains general-purpose utility methods. All methods are static and 1362 * should be called using the class name. For example: `Utilities.getNoteDetails("C4")`. 1363 * 1364 * @license Apache-2.0 1365 * @since 3.0.0 1366 */class qt{static toNoteNumber(e,n=0){if(n=n==null?0:parseInt(n),isNaN(n))throw new RangeError("Invalid 'octaveOffset' value");typeof e!="string"&&(e="");const r=this.getNoteDetails(e);if(!r)throw new TypeError("Invalid note identifier");const i={C:0,D:2,E:4,F:5,G:7,A:9,B:11};let s=(r.octave+1+n)*12;if(s+=i[r.name],r.accidental&&(r.accidental.startsWith("b")?s-=r.accidental.length:s+=r.accidental.length),s<0||s>127)throw new RangeError("Invalid octaveOffset value");return s}static getNoteDetails(e){Number.isInteger(e)&&(e=this.toNoteIdentifier(e));const n=e.match(/^([CDEFGAB])(#{0,2}|b{0,2})(-?\d+)$/i);if(!n)throw new TypeError("Invalid note identifier");const r=n[1].toUpperCase(),i=parseInt(n[3]);let s=n[2].toLowerCase();return s=s===""?void 0:s,{accidental:s,identifier:r+(s||"")+i,name:r,octave:i}}static sanitizeChannels(e){let n;if(Ot.validation){if(e==="all")n=["all"];else if(e==="none")return[]}return Array.isArray(e)?n=e:n=[e],n.indexOf("all")>-1&&(n=vt.MIDI_CHANNEL_NUMBERS),n.map(function(r){return parseInt(r)}).filter(function(r){return r>=1&&r<=16})}static toTimestamp(e){let n=!1;const r=parseFloat(e);return isNaN(r)?!1:(typeof e=="string"&&e.substring(0,1)==="+"?r>=0&&(n=Ot.time+r):r>=0&&(n=r),n)}static guessNoteNumber(e,n){n=parseInt(n)||0;let r=!1;if(Number.isInteger(e)&&e>=0&&e<=127)r=parseInt(e);else if(parseInt(e)>=0&&parseInt(e)<=127)r=parseInt(e);else if(typeof e=="string"||e instanceof String)try{r=this.toNoteNumber(e.trim(),n)}catch{return!1}return r}static toNoteIdentifier(e,n){if(e=parseInt(e),isNaN(e)||e<0||e>127)throw new RangeError("Invalid note number");if(n=n==null?0:parseInt(n),isNaN(n))throw new RangeError("Invalid octaveOffset value");const r=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],i=Math.floor(e/12-1)+n;return r[e%12]+i.toString()}static buildNote(e,n={}){if(n.octaveOffset=parseInt(n.octaveOffset)||0,e instanceof Wf)return e;let r=this.guessNoteNumber(e,n.octaveOffset);if(r===!1)throw new TypeError(`The input could not be parsed as a note (${e})`);return n.octaveOffset=void 0,new Wf(r,n)}static buildNoteArray(e,n={}){let r=[];return Array.isArray(e)||(e=[e]),e.forEach(i=>
1366{r.push(this.buildNote(i,n))}),r}static from7bitToFloat(e){return e===1/0&&(e=127),e=parseInt(e)||0,Math.min(Math.max(e/127,0),1)}static fromFloatTo7Bit(e){return e===1/0&&(e=1),e=parseFloat(e)||0,Math.min(Math.max(Math.round(e*127),0),127)}static fromMsbLsbToFloat(e,n=0){Ot.validation&&(e=Math.min(Math.max(parseInt(e)||0,0),127),n=Math.min(Math.max(parseInt(n)||0,0),127));const r=((e<<7)+n)/16383;return Math.min(Math.max(r,0),1)}static fromFloatToMsbLsb(e){Ot.validation&&(e=Math.min(Math.max(parseFloat(e)||0,0),1));const n=Math.round(e*16383);return{msb:n>>7,lsb:n&127}}static offsetNumber(e,n=0,r=0){if(Ot.validation){if(e=parseInt(e),isNaN(e))throw new Error("Invalid note number");n=parseInt(n)||0,r=parseInt(r)||0}return Math.min(Math.max(e+n*12+r,0),127)}static getPropertyByValue(e,n){return Object.keys(e).find(r=>e[r]===n)}static getCcNameByNumber(e){if(!(Ot.validation&&(e=parseInt(e),!(e>=0&&e<=127))))return vt.CONTROL_CHANGE_MESSAGES[e].name}static getCcNumberByName(e){let n=vt.CONTROL_CHANGE_MESSAGES.find(r=>r.name===e);return n?n.number:vt.MIDI_CONTROL_CHANGE_MESSAGES[e]}static getChannelModeByNumber(e){if(!(e>=120&&e<=127))return!1;for(let n in vt.CHANNEL_MODE_MESSAGES)if(vt.CHANNEL_MODE_MESSAGES.hasOwnProperty(n)&&e===vt.CHANNEL_MODE_MESSAGES[n])return n;return!1}static get isNode(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}static get isBrowser(){return typeof window<"u"&&typeof window.document<"u"}}/** 1367 * The `OutputChannel` class represents a single output MIDI channel. `OutputChannel` objects are 1368 * provided by an [`Output`](Output) port which, itself, is made available by a device. The 1369 * `OutputChannel` object is derived from the host's MIDI subsystem and should not be instantiated 1370 * directly. 1371 * 1372 * All 16 `OutputChannel` objects can be found inside the parent output's 1373 * [`channels`]{@link Output#channels} property. 1374 * 1375 * @param {Output} output The [`Output`](Output) this channel belongs to. 1376 * @param {number} number The MIDI channel number (`1` - `16`). 1377 * 1378 * @extends EventEmitter 1379 * @license Apache-2.0 1380 * @since 3.0.0 1381 */class q_e extends ga{constructor(e,n){super(),this._output=e,this._number=n,this._octaveOffset=0}destroy(){this._output=null,this._number=null,this._octaveOffset=0,this.removeListener()}send(e,n={time:0}){return this.output.send(e,n),this}sendKeyAftertouch(e,n,r={}){if(Ot.validation){if(r.useRawValue&&(r.rawValue=r.useRawValue),isNaN(parseFloat(n)))throw new RangeError("Invalid key aftertouch value.");if(r.rawValue){if(!(n>=0&&n<=127&&Number.isInteger(n)))throw new RangeError("Key aftertouch raw value must be an integer between 0 and 127.")}else if(!(n>=0&&n<=1))throw new RangeError("Key aftertouch value must be a float between 0 and 1.")}r.rawValue||(n=qt.fromFloatTo7Bit(n));const i=Ot.octaveOffset+this.output.octaveOffset+this.octaveOffset;return Array.isArray(e)||(e=[e]),qt.buildNoteArray(e).forEach(s=>{this.send([(vt.CHANNEL_MESSAGES.keyaftertouch<<4)+(this.number-1),s.getOffsetNumber(i),n],{time:qt.toTimestamp(r.time)})}),this}sendControlChange(e,n,r={}){if(typeof e=="string"&&(e=qt.getCcNumberByName(e)),Array.isArray(n)||(n=[n]),Ot.validation){if(e===void 0)throw new TypeError("Control change must be identified with a valid name or an integer between 0 and 127.");if(!Number.isInteger(e)||!(e>=0&&e<=127))throw new TypeError("Control change number must be an integer between 0 and 127.");if(n=n.map(i=>{const s=Math.min(Math.max(parseInt(i),0),127);if(isNaN(s))throw new TypeError("Values must be integers between 0 and 127");return s}),n.length===2&&e>=32)throw new TypeError("To use a value array, the controller must be between 0 and 31")}return n.forEach((i,s)=>{this.send([(vt.CHANNEL_MESSAGES.controlchange<<4)+(this.number-1),e+s*32,n[s]],{time:qt.toTimestamp(r.time)})}),this}_selectNonRegisteredParameter(e,n={}){return this.sendControlChange(99,e[0],n),this.sendControlChange(98,e[1],n),this}_deselectRegisteredParameter(e={}){return this.sendControlChange(101,127,e),this.sendControlChange(100,127,e),this}_deselectNonRegisteredParameter(e={}){return this.sendControlChange(101,127,e),this.sendControlChange(100,127,e),this}_selectRegisteredParameter(e,n={}){return this.sendControlChange(101,e[0],n),this.sendControlChange(100,e[1],n),this}_setCurrentParameter(e,n={}){return e=[].concat(e),this.sendControlChange(6,e[0],n),e.length<2?this:(this.sendControlChange(38,e[1],n),this)}
vendor: 5,434 bytes, line 1381
1381sendRpnDecrement(e,n={}){if(Array.isArray(e)||(e=vt.REGISTERED_PARAMETERS[e]),Ot.validation){if(e===void 0)throw new TypeError("The specified registered parameter is invalid.");let r=!1;if(Object.getOwnPropertyNames(vt.REGISTERED_PARAMETERS).forEach(i=>{vt.REGISTERED_PARAMETERS[i][0]===e[0]&&vt.REGISTERED_PARAMETERS[i][1]===e[1]&&(r=!0)}),!r)throw new TypeError("The specified registered parameter is invalid.")}return this._selectRegisteredParameter(e,n),this.sendControlChange(97,0,n),this._deselectRegisteredParameter(n),this}sendRpnIncrement(e,n={}){if(Array.isArray(e)||(e=vt.REGISTERED_PARAMETERS[e]),Ot.validation){if(e===void 0)throw new TypeError("The specified registered parameter is invalid.");let r=!1;if(Object.getOwnPropertyNames(vt.REGISTERED_PARAMETERS).forEach(i=>{vt.REGISTERED_PARAMETERS[i][0]===e[0]&&vt.REGISTERED_PARAMETERS[i][1]===e[1]&&(r=!0)}),!r)throw new TypeError("The specified registered parameter is invalid.")}return this._selectRegisteredParameter(e,n),this.sendControlChange(96,0,n),this._deselectRegisteredParameter(n),this}playNote(e,n={}){this.sendNoteOn(e,n);const r=Array.isArray(e)?e:[e];for(let i of r)if(parseInt(i.duration)>0){const s={time:(qt.toTimestamp(n.time)||Ot.time)+parseInt(i.duration),release:i.release,rawRelease:i.rawRelease};this.sendNoteOff(i,s)}else if(parseInt(n.duration)>0){const s={time:(qt.toTimestamp(n.time)||Ot.time)+parseInt(n.duration),release:n.release,rawRelease:n.rawRelease};this.sendNoteOff(i,s)}return this}sendNoteOff(e,n={}){if(Ot.validation){if(n.rawRelease!=null&&!(n.rawRelease>=0&&n.rawRelease<=127))throw new RangeError("The 'rawRelease' option must be an integer between 0 and 127");if(n.release!=null&&!(n.release>=0&&n.release<=1))throw new RangeError("The 'release' option must be an number between 0 and 1");n.rawVelocity&&(n.rawRelease=n.velocity,console.warn("The 'rawVelocity' option is deprecated. Use 'rawRelease' instead.")),n.velocity&&(n.release=n.velocity,console.warn("The 'velocity' option is deprecated. Use 'attack' instead."))}let r=64;n.rawRelease!=null?r=n.rawRelease:isNaN(n.release)||(r=Math.round(n.release*127));const i=Ot.octaveOffset+this.output.octaveOffset+this.octaveOffset;return qt.buildNoteArray(e,{rawRelease:parseInt(r)}).forEach(s=>{this.send([(vt.CHANNEL_MESSAGES.noteoff<<4)+(this.number-1),s.getOffsetNumber(i),s.rawRelease],{time:qt.toTimestamp(n.time)})}),this}stopNote(e,n={}){return this.sendNoteOff(e,n)}sendNoteOn(e,n={}){if(Ot.validation){if(n.rawAttack!=null&&!(n.rawAttack>=0&&n.rawAttack<=127))throw new RangeError("The 'rawAttack' option must be an integer between 0 and 127");if(n.attack!=null&&!(n.attack>=0&&n.attack<=1))throw new RangeError("The 'attack' option must be an number between 0 and 1");n.rawVelocity&&(n.rawAttack=n.velocity,n.rawRelease=n.release,console.warn("The 'rawVelocity' option is deprecated. Use 'rawAttack' or 'rawRelease'.")),n.velocity&&(n.attack=n.velocity,console.warn("The 'velocity' option is deprecated. Use 'attack' instead."))}let r=64;n.rawAttack!=null?r=n.rawAttack:isNaN(n.attack)||(r=Math.round(n.attack*127));const i=Ot.octaveOffset+this.output.octaveOffset+this.octaveOffset;return qt.buildNoteArray(e,{rawAttack:r}).forEach(s=>{this.send([(vt.CHANNEL_MESSAGES.noteon<<4)+(this.number-1),s.getOffsetNumber(i),s.rawAttack],{time:qt.toTimestamp(n.time)})}),this}sendChannelMode(e,n=0,r={}){if(typeof e=="string"&&(e=vt.CHANNEL_MODE_MESSAGES[e]),Ot.validation){if(e===void 0)throw new TypeError("Invalid channel mode message name or number.");if(isNaN(e)||!(e>=120&&e<=127))throw new TypeError("Invalid channel mode message number.");if(isNaN(parseInt(n))||n<0||n>127)throw new RangeError("Value must be an integer between 0 and 127.")}return this.send([(vt.CHANNEL_MESSAGES.controlchange<<4)+(this.number-1),e,n],{time:qt.toTimestamp(r.time)}),this}sendOmniMode(e,n={}){return e===void 0||e?this.sendChannelMode("omnimodeon",0,n):this.sendChannelMode("omnimodeoff",0,n),this}sendChannelAftertouch(e,n={}){if(Ot.validation){if(isNaN(parseFloat(e)))throw new RangeError("Invalid channel aftertouch value.");if(n.rawValue){if(!(e>=0&&e<=127&&Number.isInteger(e)))throw new RangeError("Channel aftertouch raw value must be an integer between 0 and 127.")}else if(!(e>=0&&e<=1))throw new RangeError("Channel aftertouch value must be a float between 0 and 1.")}return n.rawValue||(e=qt.fromFloatTo7Bit(e)),this.send([(vt.CHANNEL_MESSAGES.channelaftertouch<<4)+(this.number-1),Math.round(e)],{time:qt.toTimestamp(n.time)}),this}sendMasterTuning(e,n={}){if(e=parseFloat(e)||0,Ot.validation&&!(e>-65&&e<64))throw new RangeError("The value must be a decimal number larger than -65 and smaller than 64.");let r=Math.floor(e)+64,i=e-Math.floor(e);i=Math.round((i+1)/2*16383);let s=i>>7&127,o=i&127;return this.sendRpnValue("channelcoarsetuning",r,n),this.sendRpnValue("channelfinetuning",[s,o],n),this}sendModulationRange(e,n,r={}){if(Ot.validation){if(!Number.isInteger(e)||!(e>=0&&e<=127))throw new RangeError("The semitones value must be an integer between 0 and 127.");if(n!=null&&(!Number.isInteger(n)||!(n>=0&&n<=127)))throw new RangeError("If specified, the cents value must be an integer between 0 and 127.")}return n>=0&&n<=127||(n=0),this.sendRpnValue("modulationrange",[e,n],r),this}sendNrpnValue(e,n,r={}){if(n=[].concat(n),Ot.validation){if(!Array.isArray(e)||!Number.isInteger(e[0])||!Number.isInteger(e[1]))throw new TypeError("The specified NRPN is invali
1381d.");if(!(e[0]>=0&&e[0]<=127))throw new RangeError("The first byte of the NRPN must be between 0 and 127.");if(!(e[1]>=0&&e[1]<=127))throw new RangeError("The second byte of the NRPN must be between 0 and 127.");n.forEach(i=>{if(!(i>=0&&i<=127))throw new RangeError("The data bytes of the NRPN must be between 0 and 127.")})}return this._selectNonRegisteredParameter(e,r),this._setCurrentParameter(n,r),this._deselectNonRegisteredParameter(r),this}sendPitchBend(e,n={}){if(Ot.validation)if(n.rawValue&&Array.isArray(e)){if(!(e[0]>=0&&e[0]<=127))throw new RangeError("The pitch bend MSB must be an integer between 0 and 127.");if(!(e[1]>=0&&e[1]<=127))throw new RangeError("The pitch bend LSB must be an integer between 0 and 127.")}else if(n.rawValue&&!Array.isArray(e)){if(!(e>=0&&e<=127))throw new RangeError("The pitch bend MSB must be an integer between 0 and 127.")}else{if(isNaN(e)||e===null)throw new RangeError("Invalid pitch bend value.");if(!(e>=-1&&e<=1))throw new RangeError("The pitch bend value must be a float between -1 and 1.")}let r=0,i=0;if(n.rawValue&&Array.isArray(e))r=e[0],i=e[1];else if(n.rawValue&&!Array.isArray(e))r=e;else{const s=qt.fromFloatToMsbLsb((e+1)/2);r=s.msb,i=s.lsb}return this.send([(vt.CHANNEL_MESSAGES.pitchbend<<4)+(this.number-1),i,r],{time:qt.toTimestamp(n.time)}),this}sendPitchBendRange(e,n,r={}){if(Ot.validation){if(!Number.isInteger(e)||!(e>=0&&e<=127))throw new RangeError("The semitones value must be an integer between 0 and 127.");if(!Number.isInteger(n)||!(n>=0&&n<=127))throw new RangeError("The cents value must be an integer between 0 and 127.")}return this.sendRpnValue("pitchbendrange",[e,n],r),this}sendProgramChange(e,n={}){if(e=parseInt(e)||0,Ot.validation&&!(e>=0&&e<=127))throw new RangeError("The program number must be between 0 and 127.");return this.send([(vt.CHANNEL_MESSAGES.programchange<<4)+(this.number-1),e],{time:qt.toTimestamp(n.time)}),this}sendRpnValue(e,n,r={}){if(Array.isArray(e)||(e=vt.REGISTERED_PARAMETERS[e]),Ot.validation){if(!Number.isInteger(e[0])||!Number.isInteger(e[1]))throw new TypeError("The specified NRPN is invali
1381d.");if(!(e[0]>=0&&e[0]<=127))throw new RangeError("The first byte of the RPN must be between 0 and 127.");if(!(e[1]>=0&&e[1]<=127))throw new RangeError("The second byte of the RPN must be between 0 and 127.");[].concat(n).forEach(i=>{if(!(i>=0&&i<=127))throw new RangeError("The data bytes of the RPN must be between 0 and 127.")})}return this._selectRegisteredParameter(e,r),this._setCurrentParameter(n,r),this._deselectRegisteredParameter(r),this}sendTuningBank(e,n={}){if(Ot.validation&&(!Number.isInteger(e)||!(e>=0&&e<=127)))throw new RangeError("The tuning bank number must be between 0 and 127.");return this.sendRpnValue("tuningbank",e,n),this}sendTuningProgram(e,n={}){if(Ot.validation&&(!Number.isInteger(e)||!(e>=0&&e<=127)))throw new RangeError("The tuning program number must be between 0 and 127.");return this.sendRpnValue("tuningprogram",e,n),this}sendLocalControl(e,n={}){return e?this.sendChannelMode("localcontrol",127,n):this.sendChannelMode("localcontrol",0,n)}sendAllNotesOff(e={}){return this.sendChannelMode("allnotesoff",0,e)}sendAllSoundOff(e={}){return this.sendChannelMode("allsoundoff",0,e)}sendResetAllControllers(e={}){return this.sendChannelMode("resetallcontrollers",0,e)}sendPolyphonicMode(e,n={}){return e==="mono"?this.sendChannelMode("monomodeon",0,n):this.sendChannelMode("polymodeon",0,n)}get octaveOffset(){return this._octaveOffset}set octaveOffset(e){if(this.validation&&(e=parseInt(e),isNaN(e)))throw new TypeError("The 'octaveOffset' property must be an integer.");this._octaveOffset=e}get output(){return this._output}get number(){return this._number}}/** 1382 * The `Output` class represents a single MIDI output port (not to be confused with a MIDI channel). 1383 * A port is made available by a MIDI device. A MIDI device can advertise several input and output 1384 * ports. Each port has 16 MIDI channels which can be accessed via the [`channels`](#channels) 1385 * property. 1386 * 1387 * The `Output` object is automatically instantiated by the library according to the host's MIDI 1388 * subsystem and should not be directly instantiated. 1389 * 1390 * You can access all available `Output` objects by referring to the 1391 * [`WebMidi.outputs`](WebMidi#outputs) array or by using methods such as 1392 * [`WebMidi.getOutputByName()`](WebMidi#getOutputByName) or 1393 * [`WebMidi.getOutputById()`](WebMidi#getOutputById). 1394 * 1395 * @fires Output#opened 1396 * @fires Output#disconnected 1397 * @fires Output#closed 1398 * 1399 * @extends EventEmitter 1400 * @license Apache-2.0 1401 */class d_ extends ga{constructor(e){super(),this._midiOutput=e,this._octaveOffset=0,this.channels=[];for(let n=1;n<=16;n++)this.channels[n]=new q_e(this,n);this._midiOutput.onstatechange=this._onStateChange.bind(this)}async destroy(){this.removeListener(),this.channels.forEach(e=>e.destroy()),this.channels=[],this._midiOutput&&(this._midiOutput.onstatechange=null),await this.close(),this._midiOutput=null}_onStateChange(e){let n={timestamp:Ot.time};e.port.connection==="open"?(n.type="opened",n.target=this,n.port=n.target,this.emit("opened",n)):e.port.connection==="closed"&&e.port.state==="connected"?(n.type="closed",n.target=this,n.port=n.target,this.emit("closed",n)):e.port.connection==="closed"&&e.port.state==="disconnected"?(n.type="disconnected",n.port={connection:e.port.connection,id:e.port.id,manufacturer:e.port.manufacturer,name:e.port.name,state:e.port.state,type:e.port.type},this.emit("disconnected",n)):e.port.connection==="pending"&&e.port.state==="disconnected"||console.warn("This statechange event was not caught:",e.port.connection,e.port.state)}async open(){try{return await this._midiOutput.open(),Promise.resolve(this)}catch(e){return Promise.reject(e)}}async close(){this._midiOutput?await this._midiOutput.close():await Promise.resolve()}send(e,n={time:0},r=0){if(e instanceof $9&&(e=qt.isNode?e.data:e.rawData),e instanceof Uint8Array&&qt.isNode&&(e=Array.from(e)),Ot.validation){if(!Array.isArray(e)&&!(e instanceof Uint8Array)&&(e=[e],Array.isArray(n)&&(e=e.concat(n)),n=isNaN(r)?{time:0}:{time:r}),!(parseInt(e[0])>=128&&parseInt(e[0])<=255))throw new RangeError("The first byte (status) must be an integer between 128 and 255.");
1401e.slice(1).forEach(i=>{if(i=parseInt(i),!(i>=0&&i<=255))throw new RangeError("Data bytes must be integers between 0 and 255.")}),n||(n={time:0})}return this._midiOutput.send(e,qt.toTimestamp(n.time)),this}sendSysex(e,n=[],r={}){if(e=[].concat(e),n instanceof Uint8Array){const i=new Uint8Array(1+e.length+n.length+1);i[0]=vt.SYSTEM_MESSAGES.sysex,i.set(Uint8Array.from(e),1),i.set(n,1+e.length),i[i.length-1]=vt.SYSTEM_MESSAGES.sysexend,this.send(i,{time:r.time})}else{const i=e.concat(n,vt.SYSTEM_MESSAGES.sysexend);this.send([vt.SYSTEM_MESSAGES.sysex].concat(i),{time:r.time})}return this}clear(){return this._midiOutput.clear?this._midiOutput.clear():Ot.validation&&console.warn("The 'clear()' method has not yet been implemented in your environment."),this}sendTimecodeQuarterFrame(e,n={}){if(Ot.validation&&(e=parseInt(e),isNaN(e)||!(e>=0&&e<=127)))throw new RangeError("The value must be an integer between 0 and 127.");return this.send([vt.SYSTEM_MESSAGES.timecode,e],{time:n.time}),this}sendSongPosition(e=0,n={}){e=Math.floor(e)||0;var r=e>>7&127,i=e&127;return this.send([vt.SYSTEM_MESSAGES.songposition,r,i],{time:n.time}),this}sendSongSelect(e=0,n={}){if(Ot.validation&&(e=parseInt(e),isNaN(e)||!(e>=0&&e<=127)))throw new RangeError("The program value must be between 0 and 127");return this.send([vt.SYSTEM_MESSAGES.songselect,e],{time:n.time}),this}sendTuneRequest(e={}){return this.send([vt.SYSTEM_MESSAGES.tunerequest],{time:e.time}),this}sendClock(e={}){return this.send([vt.SYSTEM_MESSAGES.clock],{time:e.time}),this}sendStart(e={}){return this.send([vt.SYSTEM_MESSAGES.start],{time:e.time}),this}sendContinue(e={}){return this.send([vt.SYSTEM_MESSAGES.continue],{time:e.time}),this}sendStop(e={}){return this.send([vt.SYSTEM_MESSAGES.stop],{time:e.time}),this}sendActiveSensing(e={}){return this.send([vt.SYSTEM_MESSAGES.activesensing],{time:e.time}),this}sendReset(e={}){return this.send([vt.SYSTEM_MESSAGES.reset],{time:e.time}),this}sendTuningRequest(e={}){return Ot.validation&&console.warn("The sendTuningRequest() method has been deprecated. Use sendTuningRequest() instead."),this.sendTuneRequest(e)}sendKeyAftertouch(e,n,r={}){return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i].sendKeyAftertouch(e,n,r)}),this}sendControlChange(e,n,r={},i={}){if(Ot.validation&&(Array.isArray(r)||Number.isInteger(r)||r==="all")){const s=r;r=i,r.channels=s,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)}return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(s=>{this.channels[s].sendControlChange(e,n,r)}),this}sendPitchBendRange(e=0,n=0,r={}){return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i].sendPitchBendRange(e,n,r)}),this}setPitchBendRange(e=0,n=0,r="all",i={}){return Ot.validation&&(console.warn("The setPitchBendRange() method is deprecated. Use sendPitchBendRange() instead."),i.channels=r,i.channels==="all"&&(i.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendPitchBendRange(e,n,i)}sendRpnValue(e,n,r={}){return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i].sendRpnValue(e,n,r)}),this}setRegisteredParameter(e,n=[],r="all",i={}){return Ot.validation&&(console.warn("The setRegisteredParameter() method is deprecated. Use sendRpnValue() instead."),i.channels=r,i.channels==="all"&&(i.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendRpnValue(e,n,i)}sendChannelAftertouch(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendChannelAftertouch(e,n)}),this}sendPitchBend(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEac
1401h(i=>{this.channels[i].sendPitchBend(e,n)}),this}sendProgramChange(e=0,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendProgramChange(e,n)}),this}sendModulationRange(e,n,r={}){return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i].sendModulationRange(e,n,r)}),this}setModulationRange(e=0,n=0,r="all",i={}){return Ot.validation&&(console.warn("The setModulationRange() method is deprecated. Use sendModulationRange() instead."),i.channels=r,i.channels==="all"&&(i.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendModulationRange(e,n,i)}sendMasterTuning(e,n={}){return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(r=>{this.channels[r].sendMasterTuning(e,n)}),this}setMasterTuning(e,n={},r={}){return Ot.validation&&(console.warn("The setMasterTuning() method is deprecated. Use sendMasterTuning() instead."),r.channels=n,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendMasterTuning(e,r)}sendTuningProgram(e,n={}){return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(r=>{this.channels[r].sendTuningProgram(e,n)}),this}setTuningProgram(e,n="all",r={}){return Ot.validation&&(console.warn("The setTuningProgram() method is deprecated. Use sendTuningProgram() instead."),r.channels=n,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendTuningProgram(e,r)}sendTuningBank(e=0,n={}){return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(r=>{this.channels[r].sendTuningBank(e,n)}),this}setTuningBank(e,n="all",r={}){return Ot.validation&&(console.warn("The setTuningBank() method is deprecated. Use sendTuningBank() instead."),r.channels=n,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendTuningBank(e,r)}sendChannelMode(e,n=0,r={},i={}){if(Ot.validation&&(Array.isArray(r)||Number.isInteger(r)||r==="all")){const s=r;r=i,r.channels=s,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)}return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEach(s=>{this.channels[s].sendChannelMode(e,n,r)}),this}sendAllSoundOff(e={}){return e.channels==null&&(e.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(e.channels).forEach(n=>{this.channels[n].sendAllSoundOff(e)}),this}sendAllNotesOff(e={}){return e.channels==null&&(e.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(e.channels).forEach(n=>{this.channels[n].sendAllNotesOff(e)}),this}sendResetAllControllers(e={},n={}){if(Ot.validation&&(Array.isArray(e)||Number.isInteger(e)||e==="all")){const r=e;e=n,e.channels=r,e.channels==="all"&&(e.channels=vt.MIDI_CHANNEL_NUMBERS)}return e.channels==null&&(e.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(e.channels).forEach(r=>{this.channels[r].sendResetAllControllers(e)}),this}sendPolyphonicMode(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendPolyphonicMode(e,n)}),this}sendLocalControl(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendLocalControl(e,n)}),this}sendOmniMode(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendOmniMode(e,n)}),this}sendNrpnValue(e,n,r={}){return r.channels==null&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).forEac
1401h(i=>{this.channels[i].sendNrpnValue(e,n,r)}),this}setNonRegisteredParameter(e,n=[],r="all",i={}){return Ot.validation&&(console.warn("The setNonRegisteredParameter() method is deprecated. Use sendNrpnValue() instead."),i.channels=r,i.channels==="all"&&(i.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendNrpnValue(e,n,i)}sendRpnIncrement(e,n={}){return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(r=>{this.channels[r].sendRpnIncrement(e,n)}),this}incrementRegisteredParameter(e,n="all",r={}){return Ot.validation&&(console.warn("The incrementRegisteredParameter() method is deprecated. Use sendRpnIncrement() instead."),r.channels=n,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendRpnIncrement(e,r)}sendRpnDecrement(e,n={}){return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(r=>{this.channels[r].sendRpnDecrement(e,n)}),this}decrementRegisteredParameter(e,n="all",r={}){return Ot.validation&&(console.warn("The decrementRegisteredParameter() method is deprecated. Use sendRpnDecrement() instead."),r.channels=n,r.channels==="all"&&(r.channels=vt.MIDI_CHANNEL_NUMBERS)),this.sendRpnDecrement(e,r)}sendNoteOff(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendNoteOff(e,n)}),this}stopNote(e,n){return this.sendNoteOff(e,n)}playNote(e,n={},r={}){if(Ot.validation&&(n.rawVelocity&&console.warn("The 'rawVelocity' option is deprecated. Use 'rawAttack' instead."),n.velocity&&console.warn("The 'velocity' option is deprecated. Use 'velocity' instead."),Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].playNote(e,n)}),this}sendNoteOn(e,n={},r={}){if(Ot.validation&&(Array.isArray(n)||Number.isInteger(n)||n==="all")){const i=n;n=r,n.channels=i,n.channels==="all"&&(n.channels=vt.MIDI_CHANNEL_NUMBERS)}return n.channels==null&&(n.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(n.channels).forEach(i=>{this.channels[i].sendNoteOn(e,n)}),this}get name(){return this._midiOutput.name}get id(){return this._midiOutput.id}get connection(){return this._midiOutput.connection}get manufacturer(){return this._midiOutput.manufacturer}get state(){return this._midiOutput.state}get type(){return this._midiOutput.type}get octaveOffset(){return this._octaveOffset}set octaveOffset(e){if(this.validation&&(e=parseInt(e),isNaN(e)))throw new TypeError("The 'octaveOffset' property must be an integer.");this._octaveOffset=e}}/** 1402 * The `Forwarder` class allows the forwarding of MIDI messages to predetermined outputs. When you 1403 * call its [`forward()`](#forward) method, it will send the specified [`Message`](Message) object 1404 * to all the outputs listed in its [`destinations`](#destinations) property. 1405 * 1406 * If specific channels or message types have been defined in the [`channels`](#channels) or 1407 * [`types`](#types) properties, only messages matching the channels/types will be forwarded. 1408 * 1409 * While it can be manually instantiated, you are more likely to come across a `Forwarder` object as 1410 * the return value of the [`Input.addForwarder()`](Input#addForwarder) method. 1411 * 1412 * @license Apache-2.0 1413 * @since 3.0.0 1414 */class G4{constructor(e=[],n={}){this.destinations=[],this.types=[...Object.keys(vt.SYSTEM_MESSAGES),...Object.keys(vt.CHANNEL_MESSAGES)],this.channels=vt.MIDI_CHANNEL_NUMBERS,this.suspended=!1,Array.isArray(e)||(e=[e]),n.types&&!Array.isArray(n.types)&&(n.types=[n.types]),n.channels&&!Array.isArray(n.channels)&&(n.channels=[n.channels]),Ot.validation&&(e.forEach(r=>{if(!(r instanceof d_))throw new TypeError("Destinations must be of type 'Output'.")}),n.types!==void 0&&n.types.forEach(r=>{if(!vt.SYSTEM_MESSAGES.hasOwnProperty(r)&&!vt.CHANNEL_MESSAGES.hasOwnProperty(r))throw new TypeError("Type must be a valid message type.")}
1414),n.channels!==void 0&&n.channels.forEach(r=>{if(!vt.MIDI_CHANNEL_NUMBERS.includes(r))throw new TypeError("MIDI channel must be between 1 and 16.")})),this.destinations=e,n.types&&(this.types=n.types),n.channels&&(this.channels=n.channels)}forward(e){this.suspended||this.types.includes(e.type)&&(e.channel&&!this.channels.includes(e.channel)||this.destinations.forEach(n=>{Ot.validation&&!(n instanceof d_)||n.send(e)}))}}/** 1415 * The `InputChannel` class represents a single MIDI input channel (1-16) from a single input 1416 * device. This object is derived from the host's MIDI subsystem and should not be instantiated 1417 * directly. 1418 * 1419 * All 16 `InputChannel` objects can be found inside the input's [`channels`](Input#channels) 1420 * property. 1421 * 1422 * @fires InputChannel#midimessage 1423 * @fires InputChannel#unknownmessage 1424 * 1425 * @fires InputChannel#noteoff 1426 * @fires InputChannel#noteon 1427 * @fires InputChannel#keyaftertouch 1428 * @fires InputChannel#programchange 1429 * @fires InputChannel#channelaftertouch 1430 * @fires InputChannel#pitchbend 1431 * 1432 * @fires InputChannel#allnotesoff 1433 * @fires InputChannel#allsoundoff 1434 * @fires InputChannel#localcontrol 1435 * @fires InputChannel#monomode 1436 * @fires InputChannel#omnimode 1437 * @fires InputChannel#resetallcontrollers 1438 * 1439 * @fires InputChannel#event:nrpn 1440 * @fires InputChannel#event:nrpn-dataentrycoarse 1441 * @fires InputChannel#event:nrpn-dataentryfine 1442 * @fires InputChannel#event:nrpn-dataincrement 1443 * @fires InputChannel#event:nrpn-datadecrement 1444 * @fires InputChannel#event:rpn 1445 * @fires InputChannel#event:rpn-dataentrycoarse 1446 * @fires InputChannel#event:rpn-dataentryfine 1447 * @fires InputChannel#event:rpn-dataincrement 1448 * @fires InputChannel#event:rpn-datadecrement 1449 * 1450 * @fires InputChannel#controlchange 1451 * @fires InputChannel#event:controlchange-controllerxxx 1452 * @fires InputChannel#event:controlchange-bankselectcoarse 1453 * @fires InputChannel#event:controlchange-modulationwheelcoarse 1454 * @fires InputChannel#event:controlchange-breathcontrollercoarse 1455 * @fires InputChannel#event:controlchange-footcontrollercoarse 1456 * @fires InputChannel#event:controlchange-portamentotimecoarse 1457 * @fires InputChannel#event:controlchange-dataentrycoarse 1458 * @fires InputChannel#event:controlchange-volumecoarse 1459 * @fires InputChannel#event:controlchange-balancecoarse 1460 * @fires InputChannel#event:controlchange-pancoarse 1461 * @fires InputChannel#event:controlchange-expressioncoarse 1462 * @fires InputChannel#event:controlchange-effectcontrol1coarse 1463 * @fires InputChannel#event:controlchange-effectcontrol2coarse 1464 * @fires InputChannel#event:controlchange-generalpurposecontroller1 1465 * @fires InputChannel#event:controlchange-generalpurposecontroller2 1466 * @fires InputChannel#event:controlchange-generalpurposecontroller3 1467 * @fires InputChannel#event:controlchange-generalpurposecontroller4 1468 * @fires InputChannel#event:controlchange-bankselectfine 1469 * @fires InputChannel#event:controlchange-modulationwheelfine 1470 * @fires InputChannel#event:controlchange-breathcontrollerfine 1471 * @fires InputChannel#event:controlchange-footcontrollerfine 1472 * @fires InputChannel#event:controlchange-portamentotimefine 1473 * @fires InputChannel#event:controlchange-dataentryfine 1474 * @fires InputChannel#event:controlchange-channelvolumefine 1475 * @fires InputChannel#event:controlchange-balancefine 1476 * @fires InputChannel#event:controlchange-panfine 1477 * @fires InputChannel#event:controlchange-expressionfine 1478 * @fires InputChannel#event:controlchange-effectcontrol1fine 1479 * @fires InputChannel#event:controlchange-effectcontrol2fine 1480 * @fires InputChannel#event:controlchange-damperpedal 1481 * @fires InputChannel#event:controlchange-portamento 1482 * @fires InputChannel#event:controlchange-sostenuto 1483 * @fires InputChannel#event:controlchange-softpedal 1484 * @fires InputChannel#event:controlchange-legatopedal 1485 * @fires InputChannel#event:controlchange-hold2 1486 * @fires InputChannel#event:controlchange-soundvariation 1487 * @fires InputChannel#event:controlchange-resonance 1488 * @fires InputChannel#event:controlchange-releasetime 1489 * @fires InputChannel#event:controlchange-attacktime 1490 * @fires InputChannel#event:controlchange-brightness 1491 * @fires InputChannel#event:controlchange-decaytime 1492 * @fires InputChannel#event:controlchange-vibratorate 1493 * @fires InputChannel#event:controlchange-vibratodepth 1494 * @fires InputChannel#event:controlchange-vibratodelay 1495 * @fires InputChannel#event:controlchange-generalpurposecontroller5 1496 * @fires InputChannel#event:controlchange-generalpurposecontroller6 1497 * @fires InputChannel#event:controlchange-generalpurposecontroller7 1498 * @fires InputChannel#event:controlchange-generalpurposecontroller8 1499 * @fires InputChannel#event:controlchange-portamentocontrol 1500 * @fires InputChannel#event:controlchange-highresolutionvelocityprefix 1501 * @fires InputChannel#event:controlchange-effect1depth 1502 * @fires InputChannel#event:controlchange-effect2depth 1503 * @fires InputChannel#event:controlchange-effect3depth 1504 * @fires InputChannel#event:controlchange-effect4depth 1505 * @fires InputChannel#event:controlchange-effect5depth 1506 * @fires InputChannel#event:controlchange-dataincrement 1507 * @fires InputChannel#event:controlchange-datadecrement 1508 * @fires InputChannel#event:controlchange-nonregisteredparameterfine 1509 * @fires InputChannel#event:controlchange-nonregisteredparametercoarse 1510 * @fires InputChannel#event:controlchange-registeredparameterfine 1511 * @fires InputChannel#event:controlchange-registeredparametercoarse 1512 * @fires InputChannel#event:controlchange-allsoundoff 1513 * @fires InputChannel#event:controlchange-resetallcontrollers 1514 * @fires InputChannel#event:controlchange-localcontrol 1515 * @fires InputChannel#event:controlchange-allnotesoff 1516 * @fires InputChannel#event:controlchange-omnimodeoff 1517 * @fires InputChannel#event:controlchange-omnimodeon 1518 * @fires InputChannel#event:controlchange-monomodeon 1519 * @fires InputChannel#event:controlchange-polymodeon 1520 * @fires InputChannel#event: 1521 *
1522 * @extends EventEmitter 1523 * @license Apache-2.0 1524 * @since 3.0.0 1525 */class K_e extends ga{constructor(e,n){super(),this._input=e,this._number=n,this._octaveOffset=0,this._nrpnBuffer=[],this._rpnBuffer=[],this.parameterNumberEventsEnabled=!0,this.notesState=new Array(128).fill(!1)}destroy(){this._input=null,this._number=null,this._octaveOffset=0,this._nrpnBuffer=[],this.notesState=new Array(128).fill(!1),this.parameterNumberEventsEnabled=!1,this.removeListener()}_processMidiMessageEvent(e){const n=Object.assign({},e);n.port=this.input,n.target=this,n.type="midimessage",this.emit(n.type,n),this._parseEventForStandardMessages(n)}_parseEventForStandardMessages(e){const n=Object.assign({},e);n.type=n.message.type||"unknownmessage";const r=e.message.dataBytes[0],i=e.message.dataBytes[1];if(n.type==="noteoff"||n.type==="noteon"&&i===0)this.notesState[r]=!1,n.type="noteoff",n.note=new Wf(qt.offsetNumber(r,this.octaveOffset+this.input.octaveOffset+Ot.octaveOffset),{rawAttack:0,rawRelease:i}),n.value=qt.from7bitToFloat(i),n.rawValue=i,n.velocity=n.note.release,n.rawVelocity=n.note.rawRelease;else if(n.type==="noteon")this.notesState[r]=!0,n.note=new Wf(qt.offsetNumber(r,this.octaveOffset+this.input.octaveOffset+Ot.octaveOffset),{rawAttack:i}),n.value=qt.from7bitToFloat(i),n.rawValue=i,n.velocity=n.note.attack,n.rawVelocity=n.note.rawAttack;else if(n.type==="keyaftertouch")n.note=new Wf(qt.offsetNumber(r,this.octaveOffset+this.input.octaveOffset+Ot.octaveOffset)),n.value=qt.from7bitToFloat(i),n.rawValue=i,n.identifier=n.note.identifier,n.key=n.note.number,n.rawKey=r;else if(n.type==="controlchange"){n.controller={number:r,name:vt.CONTROL_CHANGE_MESSAGES[r].name,description:vt.CONTROL_CHANGE_MESSAGES[r].description,position:vt.CONTROL_CHANGE_MESSAGES[r].position},n.subtype=n.controller.name||"controller"+r,n.value=qt.from7bitToFloat(i),n.rawValue=i;const s=Object.assign({},n);s.type=`${n.type}-controller${r}`,delete s.subtype,this.emit(s.type,s);const o=Object.assign({},n);o.type=`${n.type}-`+vt.CONTROL_CHANGE_MESSAGES[r].name,delete o.subtype,o.type.indexOf("controller")!==0&&this.emit(o.type,o),n.message.dataBytes[0]>=120&&this._parseChannelModeMessage(n),this.parameterNumberEventsEnabled&&this._isRpnOrNrpnController(n.message.dataBytes[0])&&this._parseEventForParameterNumber(n)}else n.type==="programchange"?(n.value=r,n.rawValue=n.value):n.type==="channelaftertouch"?(n.value=qt.from7bitToFloat(r),n.rawValue=r):n.type==="pitchbend"?(n.value=((i<<7)+r-8192)/8192,n.rawValue=(i<<7)+r):n.type="unknownmessage";this.emit(n.type,n)}_parseChannelModeMessage(e){const n=Object.assign({},e);n.type=n.controller.name,n.type==="localcontrol"&&(n.value=n.message.data[2]===127,n.rawValue=n.message.data[2]),n.type==="omnimodeon"?(n.type="omnimode",n.value=!0,n.rawValue=n.message.data[2]):n.type==="omnimodeoff"&&(n.type="omnimode",n.value=!1,n.rawValue=n.message.data[2]),n.type==="monomodeon"?(n.type="monomode",n.value=!0,n.rawValue=n.message.data[2]):n.type==="polymodeon"&&(n.type="monomode",n.value=!1,n.rawValue=n.message.data[2]),this.emit(n.type,n)}_parseEventForParameterNumber(e){const n=e.message.dataBytes[0],r=e.message.dataBytes[1];n===99||n===101?(this._nrpnBuffer=[],this._rpnBuffer=[],n===99?this._nrpnBuffer=[e.message]:r!==127&&(this._rpnBuffer=[e.message])):n===98||n===100?n===98?(this._rpnBuffer=[],this._nrpnBuffer.length===1?this._nrpnBuffer.push(e.message):this._nrpnBuffer=[]):(this._nrpnBuffer=[],this._rpnBuffer.length===1&&r!==127?this._rpnBuffer.push(e.message):this._rpnBuffer=[]):(n===6||n===38||n===96||n===97)&&(this._rpnBuffer.length===2?this._dispatchParameterNumberEvent("rpn",this._rpnBuffer[0].dataBytes[1],this._rpnBuffer[1].dataBytes[1],e):this._nrpnBuffer.length===2?this._dispatchParameterNumberEvent("nrpn",this._nrpnBuffer[0].dataBytes[1],this._nrpnBuffer[1].dataBytes[1],e):(this._nrpnBuffer=[],this._rpnBuffer=[]))}_isRpnOrNrpnController(e){return e===6||e===38||e===96||e===97||e===98||e===99||e===100||e===101}_dispatchParameterNumberEvent(e,n,r,i){e=e==="nrpn"?"nrpn":"rpn";const s={target:i.target,timestamp:i.timestamp,message:i.message,parameterMsb:n,parameterLsb:r,value:qt.from7bitToFloat(i.message.dataBytes[1]),rawValue:i.message.dataBytes[1]};e==="rpn"?s.parameter=Object.keys(vt.REGISTERED_PARAMETERS).find(l=>vt.REGISTERED_PARAMETERS[l][0]===n&&vt.REGISTERED_PARAMETERS[l][1]===r):s.parameter=(n<<7)+r;const o=vt.CONTROL_CHANGE_MESSAGES[i.message.dataBytes[0]].name;s.type=`${e}-${o}
1525`,this.emit(s.type,s);const a=Object.assign({},s);a.type==="nrpn-dataincrement"?a.type="nrpn-databuttonincrement":a.type==="nrpn-datadecrement"?a.type="nrpn-databuttondecrement":a.type==="rpn-dataincrement"?a.type="rpn-databuttonincrement":a.type==="rpn-datadecrement"&&(a.type="rpn-databuttondecrement"),this.emit(a.type,a),s.type=e,s.subtype=o,this.emit(s.type,s)}getChannelModeByNumber(e){return Ot.validation&&(console.warn("The 'getChannelModeByNumber()' method has been moved to the 'Utilities' class."),e=Math.floor(e)),qt.getChannelModeByNumber(e)}getCcNameByNumber(e){if(Ot.validation&&(console.warn("The 'getCcNameByNumber()' method has been moved to the 'Utilities' class."),e=parseInt(e),!(e>=0&&e<=127)))throw new RangeError("Invalid control change number.");return qt.getCcNameByNumber(e)}getNoteState(e){e instanceof Wf&&(e=e.identifier);const n=qt.guessNoteNumber(e,Ot.octaveOffset+this.input.octaveOffset+this.octaveOffset);return this.notesState[n]}get octaveOffset(){return this._octaveOffset}set octaveOffset(e){if(this.validation&&(e=parseInt(e),isNaN(e)))throw new TypeError("The 'octaveOffset' property must be an integer.");this._octaveOffset=e}get input(){return this._input}get number(){return this._number}get nrpnEventsEnabled(){return this.parameterNumberEventsEnabled}set nrpnEventsEnabled(e){this.validation&&(e=!!e),this.parameterNumberEventsEnabled=e}}/** 1526 * The `Message` class represents a single MIDI message. It has several properties that make it 1527 * easy to make sense of the binary data it contains. 1528 * 1529 * @license Apache-2.0 1530 * @since 3.0.0 1531 */class $9{constructor(e){this.rawData=e,this.data=Array.from(this.rawData),this.statusByte=this.rawData[0],this.rawDataBytes=this.rawData.slice(1),this.dataBytes=this.data.slice(1),this.isChannelMessage=!1,this.isSystemMessage=!1,this.command=void 0,this.channel=void 0,this.manufacturerId=void 0,this.type=void 0,this.statusByte<240?(this.isChannelMessage=!0,this.command=this.statusByte>>4,this.channel=(this.statusByte&15)+1):(this.isSystemMessage=!0,this.command=this.statusByte),this.isChannelMessage?this.type=qt.getPropertyByValue(vt.CHANNEL_MESSAGES,this.command):this.isSystemMessage&&(this.type=qt.getPropertyByValue(vt.SYSTEM_MESSAGES,this.command)),this.statusByte===vt.SYSTEM_MESSAGES.sysex&&(this.dataBytes[0]===0?(this.manufacturerId=this.dataBytes.slice(0,3),this.dataBytes=this.dataBytes.slice(3,this.rawDataBytes.length-1),this.rawDataBytes=this.rawDataBytes.slice(3,this.rawDataBytes.length-1)):(this.manufacturerId=[this.dataBytes[0]],this.dataBytes=this.dataBytes.slice(1,this.dataBytes.length-1),this.rawDataBytes=this.rawDataBytes.slice(1,this.rawDataBytes.length-1)))}}/** 1532 * The `Input` class represents a single MIDI input port. This object is automatically instantiated 1533 * by the library according to the host's MIDI subsystem and does not need to be directly 1534 * instantiated. Instead, you can access all `Input` objects by referring to the 1535 * [`WebMidi.inputs`](WebMidi#inputs) array. You can also retrieve inputs by using methods such as 1536 * [`WebMidi.getInputByName()`](WebMidi#getInputByName) and 1537 * [`WebMidi.getInputById()`](WebMidi#getInputById). 1538 * 1539 * Note that a single MIDI device may expose several inputs and/or outputs. 1540 * 1541 * **Important**: the `Input` class does not directly fire channel-specific MIDI messages 1542 * (such as [`noteon`](InputChannel#event:noteon) or 1543 * [`controlchange`](InputChannel#event:controlchange), etc.). The [`InputChannel`](InputChannel) 1544 * object does that. However, you can still use the 1545 * [`Input.addListener()`](#addListener) method to listen to channel-specific events on multiple 1546 * [`InputChannel`](InputChannel) objects at once. 1547 * 1548 * @fires Input#opened 1549 * @fires Input#disconnected 1550 * @fires Input#closed 1551 * @fires Input#midimessage 1552 * 1553 * @fires Input#sysex 1554 * @fires Input#timecode 1555 * @fires Input#songposition 1556 * @fires Input#songselect 1557 * @fires Input#tunerequest 1558 * @fires Input#clock 1559 * @fires Input#start 1560 * @fires Input#continue 1561 * @fires Input#stop 1562 * @fires Input#activesensing 1563 * @fires Input#reset 1564 * 1565 * @fires Input#unknownmidimessage 1566 *
1567 * @extends EventEmitter 1568 * @license Apache-2.0 1569 */class Y_e extends ga{constructor(e){super(),this._midiInput=e,this._octaveOffset=0,this.channels=[];for(let n=1;n<=16;n++)this.channels[n]=new K_e(this,n);this._forwarders=[],this._midiInput.onstatechange=this._onStateChange.bind(this),this._midiInput.onmidimessage=this._onMidiMessage.bind(this)}async destroy(){this.removeListener(),this.channels.forEach(e=>e.destroy()),this.channels=[],this._forwarders=[],this._midiInput&&(this._midiInput.onstatechange=null,this._midiInput.onmidimessage=null),await this.close(),this._midiInput=null}_onStateChange(e){let n={timestamp:Ot.time,target:this,port:this};e.port.connection==="open"?(n.type="opened",this.emit("opened",n)):e.port.connection==="closed"&&e.port.state==="connected"?(n.type="closed",this.emit("closed",n)):e.port.connection==="closed"&&e.port.state==="disconnected"?(n.type="disconnected",n.port={connection:e.port.connection,id:e.port.id,manufacturer:e.port.manufacturer,name:e.port.name,state:e.port.state,type:e.port.type},this.emit("disconnected",n)):e.port.connection==="pending"&&e.port.state==="disconnected"||console.warn("This statechange event was not caught: ",e.port.connection,e.port.state)}_onMidiMessage(e){const n=new $9(e.data),r={port:this,target:this,message:n,timestamp:e.timeStamp,type:"midimessage",data:n.data,rawData:n.data,statusByte:n.data[0],dataBytes:n.dataBytes};this.emit("midimessage",r),n.isSystemMessage?this._parseEvent(r):n.isChannelMessage&&this.channels[n.channel]._processMidiMessageEvent(r),this._forwarders.forEach(i=>i.forward(n))}_parseEvent(e){const n=Object.assign({},e);n.type=n.message.type||"unknownmidimessage",n.type==="songselect"&&(n.song=e.data[1]+1,n.value=e.data[1],n.rawValue=n.value),this.emit(n.type,n)}async open(){try{await this._midiInput.open()}catch(e){return Promise.reject(e)}return Promise.resolve(this)}async close(){if(!this._midiInput)return Promise.resolve(this);try{await this._midiInput.close()}catch(e){return Promise.reject(e)}return Promise.resolve(this)}getChannelModeByNumber(){Ot.validation&&console.warn("The 'getChannelModeByNumber()' method has been moved to the 'Utilities' class.")}addListener(e,n,r={}){if(Ot.validation&&typeof r=="function"){let i=n!=null?[].concat(n):void 0;n=r,r={channels:i}}if(vt.CHANNEL_EVENTS.includes(e)){r.channels===void 0&&(r.channels=vt.MIDI_CHANNEL_NUMBERS);let i=[];return qt.sanitizeChannels(r.channels).forEach(s=>{i.push(this.channels[s].addListener(e,n,r))}),i}else return super.addListener(e,n,r)}addOneTimeListener(e,n,r={}){return r.remaining=1,this.addListener(e,n,r)}on(e,n,r,i){return this.addListener(e,n,r,i)}hasListener(e,n,r={}){if(Ot.validation&&typeof r=="function"){let i=[].concat(n);n=r,r={channels:i}}return vt.CHANNEL_EVENTS.includes(e)?(r.channels===void 0&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),qt.sanitizeChannels(r.channels).every(i=>this.channels[i].hasListener(e,n))):super.hasListener(e,n)}removeListener(e,n,r={}){if(Ot.validation&&typeof r=="function"){let i=[].concat(n);n=r,r={channels:i}}if(r.channels===void 0&&(r.channels=vt.MIDI_CHANNEL_NUMBERS),e==null)return qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i]&&this.channels[i].removeListener()}),super.removeListener();vt.CHANNEL_EVENTS.includes(e)?qt.sanitizeChannels(r.channels).forEach(i=>{this.channels[i].removeListener(e,n,r)}):super.removeListener(e,n,r)}addForwarder(e,n={}){let r;return e instanceof G4?r=e:r=new G4(e,n),this._forwarders.push(r),r}removeForwarder(e){this._forwarders=this._forwarders.filter(n=>n!==e)}hasForwarder(e){return this._forwarders.includes(e)}get name(){return this._midiInput.name}get id(){return this._midiInput.id}get connection(){return this._midiInput.connection}get manufacturer(){return this._midiInput.manufacturer}get octaveOffset(){return this._octaveOffset}set octaveOffset(e){if(this.validation&&(e=parseInt(e),isNaN(e)))throw new TypeError("The 'octaveOffset' property must be an integer.");this._octaveOffset=e}get state(){return this._midiInput.state}get type(){return this._midiInput.type}get nrpnEventsEnabled(){return Ot.validation&&console.warn("The 'nrpnEventsEnabled' property has been moved to the 'InputChannel' class."),!1}}/** 1570 * The `WebMidi` object makes it easier to work with the low-level Web MIDI API. Basically, it 1571 * simplifies sending outgoing MIDI messages and reacting to incoming MIDI messages. 1572 * 1573 * When using the WebMidi.js library, you should know that the `WebMidi` class has already been 1574 * instantiated. You cannot instantiate it yourself. If you use the **IIFE** version, you should 1575 * simply use the global object called `WebMidi`. If you use the **CJS** (CommonJS) or **ESM** (ES6
1576 * module) version, you get an already-instantiated object when you import the module. 1577 * 1578 * @fires WebMidi#connected 1579 * @fires WebMidi#disabled 1580 * @fires WebMidi#disconnected 1581 * @fires WebMidi#enabled 1582 * @fires WebMidi#error 1583 * @fires WebMidi#midiaccessgranted 1584 * @fires WebMidi#portschanged 1585 * 1586 * @extends EventEmitter 1587 * @license Apache-2.0 1588 */class X_e extends ga{constructor(){super(),this.defaults={note:{attack:qt.from7bitToFloat(64),release:qt.from7bitToFloat(64),duration:1/0}},this.interface=null,this.validation=!0,this._inputs=[],this._disconnectedInputs=[],this._outputs=[],this._disconnectedOutputs=[],this._stateChangeQueue=[],this._octaveOffset=0}async enable(e={},n=!1){if(qt.isNode)try{window.navigator}catch{let a=await Object.getPrototypeOf(async function(){}).constructor(` 1589 let jzz = await import("jzz"); 1590 return jzz.default; 1591 `)();global.navigator||(global.navigator={}),Object.assign(global.navigator,a)}if(this.validation=e.validation!==!1,this.validation&&(typeof e=="function"&&(e={callback:e,sysex:n}),n&&(e.sysex=!0)),this.enabled)return typeof e.callback=="function"&&e.callback(),Promise.resolve();const r={timestamp:this.time,target:this,type:"error",error:void 0},i={timestamp:this.time,target:this,type:"midiaccessgranted"},s={timestamp:this.time,target:this,type:"enabled"};try{typeof e.requestMIDIAccessFunction=="function"?this.interface=await e.requestMIDIAccessFunction({sysex:e.sysex,software:e.software}):this.interface=await navigator.requestMIDIAccess({sysex:e.sysex,software:e.software})}catch(o){return r.error=o,this.emit("error",r),typeof e.callback=="function"&&e.callback(o),Promise.reject(o)}this.emit("midiaccessgranted",i),this.interface.onstatechange=this._onInterfaceStateChange.bind(this);try{await this._updateInputsAndOutputs()}catch(o){return r.error=o,this.emit("error",r),typeof e.callback=="function"&&e.callback(o),Promise.reject(o)}return this.emit("enabled",s),typeof e.callback=="function"&&e.callback(),Promise.resolve(this)}async disable(){return this.interface&&(this.interface.onstatechange=void 0),this._destroyInputsAndOutputs().then(()=>{navigator&&typeof navigator.close=="function"&&navigator.close(),this.interface=null;let e={timestamp:this.time,target:this,type:"disabled"};this.emit("disabled",e),this.removeListener()})}getInputById(e,n={disconnected:!1}){if(this.validation){if(!this.enabled)throw new Error("WebMidi is not enabled.");if(!e)return}if(n.disconnected){for(let r=0;r<this._disconnectedInputs.length;r++)if(this._disconnectedInputs[r].id===e.toString())return this._disconnectedInputs[r]}else for(let r=0;r<this.inputs.length;r++)if(this.inputs[r].id===e.toString())return this.inputs[r]}getInputByName(e,n={disconnected:!1}){if(this.validation){if(!this.enabled)throw new Error("WebMidi is not enabled.");if(!e)return;e=e.toString()}if(n.disconnected){for(let r=0;r<this._disconnectedInputs.length;r++)if(~this._disconnectedInputs[r].name.indexOf(e))return this._disconnectedInputs[r]}else for(let r=0;r<this.inputs.length;r++)if(~this.inputs[r].name.indexOf(e))return this.inputs[r]}getOutputByName(e,n={disconnected:!1}){if(this.validation){if(!this.enabled)throw new Error("WebMidi is not enabled.");if(!e)return;e=e.toString()}if(n.disconnected){for(let r=0;r<this._disconnectedOutputs.length;r++)if(~this._disconnectedOutputs[r].name.indexOf(e))return this._disconnectedOutputs[r]}else for(let r=0;r<this.outputs.length;r++)if(~this.outputs[r].name.indexOf(e))return this.outputs[r]}getOutputById(e,n={disconnected:!1}){if(this.validation){if(!this.enabled)throw new Error("WebMidi is not enabled.");if(!e)return}if(n.disconnected){for(let r=0;r<this._disconnectedOutputs.length;r++)if(this._disconnectedOutputs[r].id===e.toString())return this._disconnectedOutputs[r]}else for(let r=0;r<this.outputs.length;r++)if(this.outputs[r].id===e.toString())return this.outputs[r]}noteNameToNumber(e){return this.validation&&console.warn("The noteNameToNumber() method is deprecated. Use Utilities.toNoteNumber() instead."),qt.toNoteNumber(e,this.octaveOffset)}getOctave(e){return this.validation&&(console.warn("The getOctave()is deprecated. Use Utilities.getNoteDetails() instead"),e=parseInt(e)),!isNaN(e)&&e>=0&&e<=127?qt.getNoteDetails(qt.offsetNumber(e,this.octaveOffset)).octave:!1}sanitizeChannels(e){return this.validation&&console.warn("The sanitizeChannels() method has been moved to the utilities class."),qt.sanitizeChannels(e)}toMIDIChannels(e){return this.validation&&console.warn("The toMIDIChannels() method has been deprecated. Use Utilities.sanitizeChannels() instead."),qt.sanitizeChannels(e)}guessNoteNumber(e){return this.validation&&console.warn("The guessNoteNumber() method has been deprecated. Use Utilities.guessNoteNumber() instead."),qt.guessNoteNumber(e,this.octaveOffset)}getValidNoteArray(e,n={}){return this.validation&&console.warn("The getValidNoteArray() method has been moved to the Utilities.buildNoteArray()"),qt.buildNoteArray(e,n)}convertToTimestamp(e){return this.validation&&console.warn("The convertToTimestamp() method has been moved to Utilities.toTimestamp()."),qt.toTimestamp(e)}async _destroyInputsAndOutputs(){let e=[];
1591return this.inputs.forEach(n=>e.push(n.destroy())),this.outputs.forEach(n=>e.push(n.destroy())),Promise.all(e).then(()=>{this._inputs=[],this._outputs=[]})}_onInterfaceStateChange(e){this._updateInputsAndOutputs();let n={timestamp:e.timeStamp,type:e.port.state,target:this};if(e.port.state==="connected"&&e.port.connection==="open"){e.port.type==="output"?n.port=this.getOutputById(e.port.id):e.port.type==="input"&&(n.port=this.getInputById(e.port.id)),this.emit(e.port.state,n);const r=Object.assign({},n);r.type="portschanged",this.emit(r.type,r)}else if(e.port.state==="disconnected"&&e.port.connection==="pending"){e.port.type==="input"?n.port=this.getInputById(e.port.id,{disconnected:!0}):e.port.type==="output"&&(n.port=this.getOutputById(e.port.id,{disconnected:!0})),this.emit(e.port.state,n);const r=Object.assign({},n);r.type="portschanged",this.emit(r.type,r)}}async _updateInputsAndOutputs(){return Promise.all([this._updateInputs(),this._updateOutputs()])}async _updateInputs(){if(!this.interface)return;for(let n=this._inputs.length-1;n>=0;n--){const r=this._inputs[n];Array.from(this.interface.inputs.values()).find(s=>s===r._midiInput)||(this._disconnectedInputs.push(r),this._inputs.splice(n,1))}let e=[];return this.interface.inputs.forEach(n=>{if(!this._inputs.find(r=>r._midiInput===n)){let r=this._disconnectedInputs.find(i=>i._midiInput===n);r||(r=new Y_e(n)),this._inputs.push(r),e.push(r.open())}}),Promise.all(e)}async _updateOutputs(){if(!this.interface)return;for(let n=this._outputs.length-1;n>=0;n--){const r=this._outputs[n];Array.from(this.interface.outputs.values()).find(s=>s===r._midiOutput)||(this._disconnectedOutputs.push(r),this._outputs.splice(n,1))}let e=[];return this.interface.outputs.forEach(n=>{if(!this._outputs.find(r=>r._midiOutput===n)){let r=this._disconnectedOutputs.find(i=>i._midiOutput===n);r||(r=new d_(n)),this._outputs.push(r),e.push(r.open())}}),Promise.all(e)}get enabled(){return this.interface!==null}get inputs(){return this._inputs}get isNode(){return this.validation&&console.warn("WebMidi.isNode has been deprecated. Use Utilities.isNode instead."),qt.isNode}get isBrowser(){return this.validation&&console.warn("WebMidi.isBrowser has been deprecated. Use Utilities.isBrowser instead."),qt.isBrowser}get octaveOffset(){return this._octaveOffset}set octaveOffset(e){if(this.validation&&(e=parseInt(e),isNaN(e)))throw new TypeError("The 'octaveOffset' property must be an integer.");this._octaveOffset=e}get outputs(){return this._outputs}get supported(){return typeof navigator<"u"&&!!navigator.requestMIDIAccess}get sysexEnabled(){return!!(this.interface&&this.interface.sysexEnabled)}get time(){return performance.now()}get version(){return"3.1.12"}get flavour(){return"esm"}get CHANNEL_EVENTS(){return this.validation&&console.warn("The CHANNEL_EVENTS enum has been moved to Enumerations.CHANNEL_EVENTS."),vt.CHANNEL_EVENTS}get MIDI_SYSTEM_MESSAGES(){return this.validation&&console.warn("The MIDI_SYSTEM_MESSAGES enum has been moved to Enumerations.SYSTEM_MESSAGES."),vt.SYSTEM_MESSAGES}get MIDI_CHANNEL_MODE_MESSAGES(){return this.validation&&console.warn("The MIDI_CHANNEL_MODE_MESSAGES enum has been moved to Enumerations.CHANNEL_MODE_MESSAGES."),vt.CHANNEL_MODE_MESSAGES}get MIDI_CONTROL_CHANGE_MESSAGES(){return this.validation&&console.warn("The MIDI_CONTROL_CHANGE_MESSAGES enum has been replaced by the Enumerations.CONTROL_CHANGE_MESSAGES array."),vt.MIDI_CONTROL_CHANGE_MESSAGES}get MIDI_REGISTERED_PARAMETER(){return this.validation&&console.warn("The MIDI_REGISTERED_PARAMETER enum has been moved to Enumerations.REGISTERED_PARAMETERS."),vt.REGISTERED_PARAMETERS}get NOTES(){return this.validation&&console.warn("The NOTES enum has been deprecated."),["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]}}const Ot=new X_e;Ot.constructor=null;const wl=t=>{switch(t.type){case"instrument":return`${t.type}-${t.instrument}`;case"audioFile":return`${t.type}-${t.audioFileId}`}};class Q_e{constructor(e,n,r){Xt(this,"audioContext");Xt(this,"audioFilePlayerPort");Xt(this,"instrumentPlayerPort");Xt(this,"currentlyLoadingAssets");Xt(this,"loadedAssets");Xt(this,"instrumentPlayerMessageHandler");Xt(this,"audioFilePlayerMessageHandler");this.audioContext=e,this.audioFilePlayerPort=n,this.instrumentPlayerPort=r,this.loadedAssets=new Set,this.currentlyLoadingAssets=new Set,this.instrumentPlayerMessageHandler=i=>{switch(i.data.type){case Du.LoadInstrumentConfirmedMessage:this.handleLoadInstrumentConfirmedMessage(i.data);break}},this.audioFilePlayerMessageHandler=i=>
1591{switch(i.data.type){case GI.LoadAudioFileConfirmedMessage:this.handleLoadAudioFileConfirmedMessage(i.data);break}},this.instrumentPlayerPort.addEventListener("message",this.instrumentPlayerMessageHandler),this.audioFilePlayerPort.addEventListener("message",this.audioFilePlayerMessageHandler)}dispose(){this.instrumentPlayerPort.removeEventListener("message",this.instrumentPlayerMessageHandler),this.audioFilePlayerPort.removeEventListener("message",this.audioFilePlayerMessageHandler)}handleLoadAudioFileConfirmedMessage(e){const n=wl({type:"audioFile",audioFileId:e.audioFileId});this.loadedAssets.add(n)}handleLoadInstrumentConfirmedMessage(e){const n=wl({type:"instrument",instrument:e.instrument});this.loadedAssets.add(n)}isAudioFileLoaded(e){const n=wl({type:"audioFile",audioFileId:e});return this.loadedAssets.has(n)}isInstrumentLoaded(e){const n=wl({type:"instrument",instrument:e});return this.loadedAssets.has(n)}isAudioAssetLoaded(e){const n=wl(e);return this.loadedAssets.has(n)}isCurrentlyLoadingAudioAsset(e){const n=wl(e);return this.currentlyLoadingAssets.has(n)}async waitForAudioAssetLoad(e,n=20){const r=Date.now(),i=wl(e);for(;!this.isAudioAssetLoaded(e);){if(Date.now()-r>n*1e3)throw new Error(`Timeout waiting for audio asset ${i} to load`);await new Promise(s=>setTimeout(s,100))}this.currentlyLoadingAssets.delete(i)}async loadAudioFile(e){const n={type:"audioFile",audioFileId:e};if(this.isAudioAssetLoaded(n))return;if(this.isCurrentlyLoadingAudioAsset(n)){await this.waitForAudioAssetLoad(n);return}this.currentlyLoadingAssets.add(wl(n));const r=await at.getState().getAudioFileData(e);if(!r)throw new Error("Audio file not found");this.audioFilePlayerPort.postMessage({type:GI.LoadAudioFileControlMessage,audioFileId:e,audioData:r}),await this.waitForAudioAssetLoad(n)}async loadInstrument(e){const n={type:"instrument",instrument:e};if(!Bf(e)||this.isAudioAssetLoaded(n))return;if(this.isCurrentlyLoadingAudioAsset(n)){await this.waitForAudioAssetLoad(n);return}this.currentlyLoadingAssets.add(wl(n));const r=$u(e);let i;const s=ci(e);switch(s){case $r.BuiltInInstrument:{const o=await this.getGleitzMidiJsData(e);i=await this.midiJsDataToInstrumentSamples(o,5);break}case $r.GeneratedInstrument:{const o=await this.getGeneratedInstrumentMidiJsData(e);i=await this.midiJsDataToInstrumentSamples(o);break}case $r.BuiltInDrumMachine:{i=await this.getDrumMachineSampleData(e);break}}this.instrumentPlayerPort.postMessage({type:Du.LoadInstrumentControlMessage,instrument:e,instrumentType:s,instrumentId:r,instrumentSamples:i}),await this.waitForAudioAssetLoad(n)}async getGleitzMidiJsData(e){const n=`https://gleitz.github.io/midi-js-soundfonts/MusyngKite/${e}-mp3.js`;return await(await fetch(n)).text()}async getGeneratedInstrumentMidiJsData(e){return await at.getState().getRender(e)}async midiJsDataToInstrumentSamples(e,n=1){const r=e.indexOf("MIDI.Soundfont.");if(r<0)throw Error("Invalid MIDI.js Soundfont format");const i=e.indexOf("=",r)+2,s=e.lastIndexOf(","),o=JSON.parse(e.slice(i,s)+"}"),a=Object.keys(o),l={};return await Promise.all(a.map(async u=>{const d=o[u],f=this.removeSampleDataPrefix(d),h=this.base64ToArrayBuffer(f),m=await this.audioContext.decodeAudioData(h),y=[];for(let w=0;w<m.numberOfChannels;w++)y.push(m.getChannelData(w).map(v=>v*n));const g=Oo(u);l[g]=y})),l}removeSampleDataPrefix(e){return e.slice(e.indexOf(",")+1)}base64ToArrayBuffer(e){const n=window.atob(e),r=n.length,i=new Uint8Array(r);for(let s=0;s<r;s++)i[s]=n.charCodeAt(s);return i.buffer}async getDrumMachineSampleData(e){const n="https://smpldsnds.github.io/drum-machines",r=e===m0.RolandCR8000?"Roland-CR-8000":e,i=`${n}/${r}/dm.json`,o=await(await fetch(i)).json(),a={};return await Promise.all(o.samples.map(async l=>{const u=`${n}/${r}/${l}.m4a`,f=await(await fetch(u)).arrayBuffer(),h=await this.audioContext.decodeAudioData(f),m=[];for(let g=0;g<h.numberOfChannels;g++)m.push(h.getChannelData(g));const y=l.split("/")[0];a[y]||(a[y]=[]),a[y].push(m)})),a}}const Z_e="/assets/SongScheduler-Cd9AqAnL.js",J_e="/assets/AudioFilePlayer-CfWvNM_N.js",eEe="/assets/InstrumentPlayer-BLA_WZLz.js",t
1591Ee=({children:t})=>{const[e,n]=x.useState(null),{isPlaying:r,getPlaybackPosition:i,seekPreviewPlaybackPosition:s}=zs();return x.useEffect(()=>{if(r){let o;const a=()=>{n(i()),o=requestAnimationFrame(a)};return o=requestAnimationFrame(a),()=>cancelAnimationFrame(o)}if(s){n(s);return}n(null)},[i,r,s]),c.jsx(PL.Provider,{value:{playheadPosition:e},children:t})},nEe=({children:t})=>{const{isAudioInitialized:e}=es(),{startNote:n,stopNote:r,stopAllNotes:i}=rN(),{getBloobById:s}=mn(),{selectedSingleCaiObject:o}=Yn(),{generalSettings:a}=bi(),l=x.useRef(null),u=x.useRef(null),d=x.useRef(void 0),f=x.useMemo(()=>({instrument:a.defaultInstrument,volume:1}),[a.defaultInstrument]),h=x.useMemo(()=>{if(!o||o.type!==J.Bloob)return f;const g=s(o.id);return!g||!ln(g)?f:{instrument:g.instrument,volume:g.volume,trackIndex:g.songPosition.track}},[f,s,o]),m=x.useCallback(g=>{const w=g.note.number,v=Math.floor(g.velocity*127),S=d.current;S&&n(w,v,S.instrument,S.volume,S.trackIndex)},[n]),y=x.useCallback(g=>{const w=g.note.number,v=d.current;v&&r(w,v.instrument,v.trackIndex)},[r]);return x.useEffect(()=>{var w,v;if(!e)return;const g=(w=d.current)==null?void 0:w.instrument;return d.current=h,((v=d.current)==null?void 0:v.instrument)!==g&&g&&i(g),Ot.inputs.map(S=>{S.removeListener("noteon",l.current),S.removeListener("noteoff",u.current),l.current=m,u.current=y,S.addListener("noteon",l.current),S.addListener("noteoff",u.current)}),()=>{Ot.inputs.map(S=>{S.removeListener("noteon",l.current),S.removeListener("noteoff",u.current)})}},[e,i,m,y,a.defaultInstrument,h]),t};class rEe{constructor(){Xt(this,"webmidiNoteOnHandlers");Xt(this,"webmidiNoteOffHandlers");this.webmidiNoteOnHandlers={},this.webmidiNoteOffHandlers={}}handleWebmidiNoteOn(e,n,r){const i=e.note.number,s=Math.floor(e.velocity*127);r({pitchInt:i,velocity:s,inputName:n})}handleWebmidiNoteOff(e,n,r){const i=e.note.number;r({pitchInt:i,inputName:n})}createWebmidiNoteOnHandler(e,n){return r=>this.handleWebmidiNoteOn(r,e,n)}createWebmidiNoteOffHandler(e,n){return r=>this.handleWebmidiNoteOff(r,e,n)}startRecording(e,n){if(Ot.enabled)Ot.inputs.map(r=>{const i=this.createWebmidiNoteOnHandler(r.name,e),s=this.createWebmidiNoteOffHandler(r.name,n);this.webmidiNoteOnHandlers[r.name]=i,this.webmidiNoteOffHandlers[r.name]=s,r.addListener("noteon",i),r.addListener("noteoff",s)});else throw new Error("Cannot start recording without WebMIDI enabled")}stopRecording(){if(Ot.enabled)Ot.inputs.map(e=>{this.webmidiNoteOnHandlers[e.name]&&e.removeListener("noteon",this.webmidiNoteOnHandlers[e.name]),this.webmidiNoteOffHandlers[e.name]&&e.removeListener("noteoff",this.webmidiNoteOffHandlers[e.name])});else throw new Error("Cannot stop recording without WebMIDI enabled")}}const iEe="/assets/FundamentalDetector-MHs18pxv.js",_u="voice midi control",Xp=t=>{const e=[...t].sort((r,i)=>r-i),n=Math.floor(e.length/2);return e.length%2===0?(e[n-1]+e[n])/2:e[n]},W4=(t,e)=>t>e?(t/e-1)*100:(e/t-1)*100,F2=(t,e,n,r)=>((t-1)*n+e)/r;class sEe{constructor(){Xt(this,"audioContext");Xt(this,"fundamentalDetectorNode");Xt(this,"stream");Xt(this,"micSource");Xt(this,"fundamentalDetectionParams",{windowSize:2048,hopSize:1024,clarityThreshold:.6,minVolumeDecibels:-25});Xt(this,"fundamentalBufferLength",10);Xt(this,"lastFundamentals");Xt(this,"currentlySoundingFundamental");Xt(this,"currentlySoundingPitchInt");Xt(this,"currentlySoundingFundamentalHistory");Xt(this,"isInitialized",!1);Xt(this,"eventDelaySeconds")}async initialize(e){if(!e)throw new Error("AudioContext is required for voice recording");if(!e.audioWorklet)throw new Error("AudioWorklet not supported on this platform");this.audioContext=e,await this.audioContext.audioWorklet.addModule(iEe),this.eventDelaySeconds=F2(this.fundamentalBufferLength,this.fundamentalDetectionParams.windowSize,this.fundamentalDetectionParams.hopSize,e.sampleRate),this.isInitialized=!0}async addPitchListener(){this.fundamentalDetectorNode=new AudioWorkletNode(this.audioContext,"fundamental-detector"),this.fundamentalDetectorNode.port.postMessage({type:UI.SET_PARAMS,...this.fundamentalDetectionParams}),this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),this.micSource=this.audioContext.createMediaStreamSource(this.stream),this.micSource.connect(this.fund
1591amentalDetectorNode)}removePitchListener(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=void 0),this.fundamentalDetectorNode.disconnect(),this.micSource.disconnect(),this.fundamentalDetectorNode=void 0,this.micSource=void 0}handleFundamentalDetectorMessage(e,n,r,i,s,o){const a=e.data;if(this.lastFundamentals.push(a),this.lastFundamentals.length<this.fundamentalBufferLength)return;for(;this.lastFundamentals.length>this.fundamentalBufferLength;)this.lastFundamentals.shift();const l=this.lastFundamentals[0],u=this.lastFundamentals.filter(f=>f===0).length,d=o?7:5;if(this.currentlySoundingFundamental===0){if(l!==0&&u<=this.fundamentalBufferLength*.2){if(Xp(this.lastFundamentals.slice(4))===0)return;this.currentlySoundingFundamental=Xp(this.lastFundamentals.slice(4)),this.currentlySoundingPitchInt=g1(this.currentlySoundingFundamental,o),this.currentlySoundingFundamentalHistory=[l];const h={pitchInt:this.currentlySoundingPitchInt,velocity:100,delay:this.eventDelaySeconds,inputName:_u};n(h)}}
1591else{const f=W4(this.lastFundamentals[0],this.currentlySoundingFundamental),h=Xp(this.lastFundamentals.slice(4)),m=W4(h,this.currentlySoundingFundamental);if(l===0&&u>=this.fundamentalBufferLength*.8)if(F2(this.currentlySoundingFundamentalHistory.length,this.fundamentalDetectionParams.windowSize,this.fundamentalDetectionParams.hopSize,this.audioContext.sampleRate)<.2){const g={pitchInt:this.currentlySoundingPitchInt,inputName:_u};i(g)}else{const g={pitchInt:this.currentlySoundingPitchInt,delay:this.eventDelaySeconds,inputName:_u};r(g),this.currentlySoundingFundamental=0,this.currentlySoundingPitchInt=0,this.currentlySoundingFundamentalHistory=[]}else if(l!==0&&f>d&&h!==0&&m>d){if(F2(this.currentlySoundingFundamentalHistory.length,this.fundamentalDetectionParams.windowSize,this.fundamentalDetectionParams.hopSize,this.audioContext.sampleRate)<.2){const w={pitchInt:this.currentlySoundingPitchInt,inputName:_u};i(w)}else{const w={pitchInt:this.currentlySoundingPitchInt,delay:this.eventDelaySeconds,inputName:_u};r(w)}this.currentlySoundingFundamental=Xp(this.lastFundamentals.slice(4).filter(w=>w!==0)),this.currentlySoundingPitchInt=g1(this.currentlySoundingFundamental,o),this.currentlySoundingFundamentalHistory=[l];const g={pitchInt:this.currentlySoundingPitchInt,velocity:100,delay:this.eventDelaySeconds,inputName:_u};n(g)}else if(this.currentlySoundingFundamentalHistory.push(l),this.currentlySoundingFundamentalHistory.length>this.fundamentalBufferLength){const y=Xp(this.currentlySoundingFundamentalHistory.slice(4).filter(w=>w!==0)),g=g1(y,o);if(g!==this.currentlySoundingPitchInt){const w={originalPitchInt:this.currentlySoundingPitchInt,newPitchInt:g,inputName:_u};s(w),this.currentlySoundingFundamental=y,this.currentlySoundingPitchInt=g}}}}startRecording(e,n,r,i,s){if(!this.isInitialized)throw new Error("VoiceMidiRecorder not initialized");this.addPitchListener(),this.lastFundamentals=[],this.currentlySoundingFundamental=0,this.currentlySoundingPitchInt=0,this.currentlySoundingFundamentalHistory=[],this.fundamentalDetectorNode.port.onmessage=o=>{this.handleFundamentalDetectorMessage(o,e,n,r,i,s)}}stopRecording(){this.fundamentalDetectorNode.port.postMessage({type:UI.STOP_DETECTION}),this.removePitchListener()}}class oEe{constructor(){Xt(this,"audioContext");Xt(this,"mediaRecorder",null)}async initialize(e){this.audioContext=e}async startRecording(e){const n=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});this.mediaRecorder=new MediaRecorder(n),this.mediaRecorder.start(),e()}async retrieveOriginalRecording(e){if(e.data.size<=0)throw new Error("No audio data recorded");const n=await e.data.arrayBuffer();return await this.audioContext.decodeAudioData(n)}trimOrPadRecording(e,n,r,i){const s=n-r,o=Math.round(s*e.sampleRate),a=Math.round(i*e.sampleRate),l=new AudioBuffer({numberOfChannels:e.numberOfChannels,length:a,sampleRate:e.sampleRate});for(let u=0;u<l.numberOfChannels;u++){const d=e.getChannelData(u),f=l.getChannelData(u),h=Math.max(0,d.length-o),m=Math.min(h,a);m>0&&f.set(d.subarray(o,o+m))}return this.normalizeAudioBuffer(l),l}normalizeAudioBuffer(e,n=.8){let r=0;for(let i=0;i<e.numberOfChannels;i++){const s=e.getChannelData(i);for(let o=0;o<s.length;o++){const a=Math.abs(s[o]);a>r&&(r=a)}}if(r>0){const i=n/r;
1591for(let s=0;s<e.numberOfChannels;s++){const o=e.getChannelData(s);for(let a=0;a<o.length;a++)o[a]*=i}}}async stopRecording(e,n,r){if(!this.mediaRecorder)throw new Error("No recording in progress");return new Promise((i,s)=>{this.mediaRecorder.ondataavailable=async o=>{try{const a=await this.retrieveOriginalRecording(o),l=this.trimOrPadRecording(a,e,n,r);this.mediaRecorder=null,i(l)}catch(a){s(a)}},this.mediaRecorder.stop()})}}const q4=(t,e)=>{let n;switch(e){case Hu.EighthNote:n=1/2;break;case Hu.Triplet:n=1/3;break;case Hu.SixteenthNote:n=1/4;break;case Hu.ThirtySecondNote:n=1/8;break}return Math.round(t/n)*n},U9=x.forwardRef(({children:t},e)=>{const[n,r]=x.useState(),[i,s]=x.useState({midiInstrument:cs.Disabled,voice2Midi:la.Disabled,audio:ca.Disabled}),{getBloobById:o,getSongById:a}=mn(),{detailsBloobId:l,bloobDetailsOpen:u}=Ho(),{selectNotes:d}=Xs(),{addNotes:f,addAudioFile:h,convertToAudioBloob:m,updateBloobDetails:y}=Gn(),[g,w]=x.useState(null),[v,S]=x.useState([]),[C,k]=x.useState(null),N=x.useMemo(()=>C!==null,[C]),{getCurrentAudioContext:_,loadBloobAudio:j}=es(),{commitToStore:T}=Ln(),{getNextNewRecordingName:M}=rE(),{getPlaybackPosition:V,playbackStartTimeInSeconds:H}=zs(),{selectedSingleCaiObject:P}=Yn(),{audioEnabledSource:F,audioDisabledSource:I}=uD(),{recordingSettings:R}=bi(),{snapToGrid:U,gridDivision:A,snapToKey:W}=R,D=x.useRef(new rEe),B=x.useRef(new sEe),L=x.useRef(new oEe),$=x.useCallback(async()=>{try{const te=_();await B.current.initialize(te),await L.current.initialize(te)}catch{}},[_]),q=Ot.inputs.length>0;x.useEffect(()=>{if(u)s({midiInstrument:q?cs.Enabled:cs.NoDevices,voice2Midi:la.Enabled,audio:ca.Disabled}),r(F);else if((P==null?void 0:P.type)===J.Bloob){const te=o(P.id);Gh(te)?(s({midiInstrument:q?cs.Enabled:cs.NoDevices,voice2Midi:la.Enabled,audio:ca.Enabled}),r(F)):ln(te)?(s({midiInstrument:q?cs.Enabled:cs.NoDevices,voice2Midi:la.Enabled,audio:ca.Disabled}),r(I)):En(te)&&(s({midiInstrument:cs.Disabled,voice2Midi:la.Disabled,audio:ca.Enabled}),r(zr.Audio))}else(P==null?void 0:P.type)===J.Song?(s({midiInstrument:q?cs.Enabled:cs.NoDevices,voice2Midi:la.Enabled,audio:ca.Enabled}),r(F)):(s({midiInstrument:cs.Disabled,voice2Midi:la.Disabled,audio:ca.Enabled}),r(zr.Audio))},[I,F,u,o,q,P]);const Z=x.useRef({source:null,bloob:null,parentSong:null,getPlaybackPosition:null});x.useEffect(()=>{Z.current.getPlaybackPosition=V},[V]);const ie=x.useCallback(te=>{const{bloob:fe,parentSong:O,getPlaybackPosition:pe}=Z.current,he=Km(te.pitchInt),le=hS(he,O.key.chroma);let de=pe().bar*O.timeSignature.beatsPerBar-fe.songPosition.bar*O.timeSignature.beatsPerBar;U&&(de=q4(de,A));const Ne={type:J.Note,noteDetailsHash:"",pitchInt:te.pitchInt,pitch:le,velocity:te.velocity,bloobId:fe.id,startBeat:Math.max(de,0),durationInBeats:void 0,inputName:te.inputName};S(Ce=>[Ne,...Ce])},[A,U]),ge=x.useCallback(te=>{const{bloob:fe,parentSong:O,getPlaybackPosition:pe}=Z.current,le=(pe().bar-fe.songPosition.bar)*O.timeSignature.beatsPerBar,oe=U?q4(le,A):le;S(Q=>Q.map(de=>(de.pitchInt===te.pitchInt&&de.durationInBeats===void 0&&de.inputName===te.inputName&&(de.durationInBeats=oe-de.startBeat),de)))},[A,U]),re=x.useCallback(te=>{S(fe=>fe.filter(O=>!(O.pitchInt===te.pitchInt&&O.durationInBeats===void 0&&O.inputName===te.inputName)))},[]),Y=x.useCallback(te=>{const{parentSong:fe}=Z.current;S(O=>O.map(pe=>{if(pe.pitchInt===te.originalPitchInt&&pe.durationInBeats===void 0&&pe.inputName===te.inputName){const he=Km(te.newPitchInt),le=hS(he,fe.key.chroma);pe.pitchInt=te.newPitchInt,pe.pitch=le}return pe}))},[]),ne=x.useCallback(()=>{const te=_().currentTime;w(te)},[_]),be=x.useCallback(async te=>{k(te);const fe=o(te),O=a(fe.songId);switch(S([]),Z.current.source=n,Z.current.bloob=fe,Z.current.parentSong=O,n){case zr.VoiceToMidi:B.current.startRecording(ie,ge,re,Y,W?O.key:void 0);break;case zr.MidiInstrument:D.current.startRecording(ie,ge);break;case zr.Audio:await L.current.startRecording(ne);break}},[o,a,n,ie,ge,re,Y,W,ne]),we=x.useCallback(async()=>{if(!N)return;const{source:te,bloob:fe,parentSong:O,getPlaybackPosition:pe}=Z.current;if([zr.MidiInstrument,zr.VoiceToMidi].includes(te)){const le=pe().bar*O.timeSignature.beatsPerBar,oe=fe.bars*O.timeSignature.beatsPerBar,Q=v.map(Ne=>{if(Ne.durationInBeats===void 0){const Ce=Math.min(le,oe)-Ne.startBeat;return{...Ne,durationInBeats:Ce}}else return Ne}),de=f(fe.id,Q);l===fe.id&&d(de,!1),te===zr.VoiceToMidi?B.current.stopRecording():te===zr.MidiInstrument&&D.current.stopRecording(),S([])}else if(te===zr.Audio){const he=ua(fe.bars,O.timeSignature,O.bpm),le=await L.current.stopRecording(H,g,he),oe=M(),Q=await h(oe,le,{originalKey:O.key,originalBpm:O.bpm}),de=Ga.getInstance();de&&de.queueAndUploadAudioFile(Q),En(fe)?y(fe.id,{audioFileId:Q,playbackRate:1}):m(fe.id,Q),j(fe.id)}T(),Z.current.bloob=null,Z.current.parentSong=null,Z.current.source=null,k(null)},[h,f,T,m,l,M,N,j,H,v,g,d,y]);return x.useImperativeHandle(e,()=>({startRecording:be,stopRecording:we,isRecording:N})),c.jsx(rL.Provider,{value:{initialize:$,recordingBloobId:C,isRecording:N,recordingNotes:v,currentSource:n,setCurrentSource:r,recordingSourcesStatus:i},children:t})});U9.displayName="BloobRecordingProvider";const aEe=3,lEe=.1,cEe=(t,e,n,r)=>t<r&&n<e,$2=(t,e,n,r)=>{const i=e-t;if(i<=0)return n;const o=((n-t+r)%i+i)%i;return t+o};function K4(t,e){const n=t.volumeAutomation;if(!n||n.length===0)return t.volume;if(e<=n[0].bar)return t.volume*n[0].value;const r=n[n.length-1];if(e>=r.bar)return t.volume*r.value;for(let i=0;i<n.length-1;i++){const s=n[i],o=n[i+1];if(e>=s.bar&&e<=o.bar){const a=(e-s.bar)/(o.bar-s.bar);return t.volume*(s.value+a*(o.value-s.value))}}return t.volume}const uEe=({children:t})=>{const{getBloobById:e,getSongById:n,getNoteById:r,getSongBloobContentBoundary:i,noteDetails:s}=mn(),{selectedSingleCaiObject:o}=Yn(),{audioSettings:a}=bi(),{getCurrentAudioContext:l,getScheduler:u,getInstrumentPlayer:d,loadBloobAudio:f,waitForAudioInitialization:h}
1591=es(),m=x.useRef(null),[y,g]=x.useState(null),[w,v]=x.useState(null),S=x.useRef(null),[C,k]=x.useState(!1),N=x.useRef(null),_=x.useRef(null),[j,T]=x.useState({}),M=x.useRef(null),V=x.useRef(null),H=x.useRef(null),[P,F]=x.useState(null),I=x.useMemo(()=>o&&[J.Song,J.Bloob].includes(o.type)?o:null,[o]),R=x.useMemo(()=>w!==null,[w]);x.useEffect(()=>{S.current&&(S.current.shouldLoop=a.loop&&!S.current.isRecording,S.current.metronomeSettings=a.metronome)},[a.loop,a.metronome]);const U=x.useCallback(O=>{T(pe=>{const he={...pe};return O.notesStarted&&Array.isArray(O.notesStarted)&&O.notesStarted.forEach(le=>{if(le&&typeof le.bloobId<"u"&&typeof le.noteId<"u"){const oe=le.bloobId,Q=le.noteId;he[oe]||(he[oe]=new Set),he[oe].has(Q)||(he[oe]=new Set(he[oe]),he[oe].add(Q))}}),O.notesStopped&&Array.isArray(O.notesStopped)&&O.notesStopped.forEach(le=>{if(le&&typeof le.bloobId<"u"&&typeof le.noteId<"u"){const oe=le.bloobId,Q=le.noteId;he[oe]&&he[oe].has(Q)&&(he[oe]=new Set(he[oe]),he[oe].delete(Q))}}),he})},[]),A=x.useCallback((O,pe,he,le,oe)=>{const Q=n(O),de=ua(1,Q.timeSignature,Q.bpm),Ne=[];if(Q.bloobIds.forEach(Ce=>{const Ae=e(Ce);if(Ae.muted||Q.hasSoloedBloobs&&!Ae.soloed)return;const Ue=Ae.songPosition.bar,Se=Ue+Ae.bars;if(cEe(Ue,Se,pe,he)){if(En(Ae)){let ve=Math.max(Ue,pe);const je=Math.min(Se,he),Te=H2(lEe,Q.timeSignature,Q.bpm),ce=Ae.loopContentBars?ua(Ae.loopContentBars,Q.timeSignature,Q.bpm):void 0;for(;ve<je;){const ye=(ve-pe)*de,ke=ve-Ue,ze=ke*de,qe=ve+Te,Ze=(Math.min(qe,Se)-ve)*de;let _t=ze+(Ae.audioClipStartInSeconds??0);ce&&ce>0&&(_t=(Ae.audioClipStartInSeconds??0)+ze%ce);const tt={type:qg.AudioFilePlaybackEvent,trackIndex:Ae.songPosition.track,audioFileId:Ae.audioFileId,volume:K4(Ae,ke),startTimeInSeconds:le+ye,audioFileStartTimeInSeconds:_t,durationInSeconds:Ze,playbackRate:Ae.playbackRate};Ne.push(tt),ve+=Te}}else if(ln(Ae)){const ve=Ae.loopContentBars,je=ve?ve*Q.timeSignature.beatsPerBar:void 0,Te=Ae.bars*Q.timeSignature.beatsPerBar,ce=ve&&ve>0?Math.ceil(Ae.bars/ve):1;Ae.noteIds.forEach(se=>{const ye=r(se);if(!ye)return;const ke=s[ye.noteDetailsHash];if(ke&&!(je&&ke.startBeat>=je))for(let ze=0;ze<ce;ze++){const qe=ze*(je??Te),ot=ke.startBeat+qe;if(ot>=Te)break;const Ze=Ue+ot/Q.timeSignature.beatsPerBar;if(Ze>=pe&&Ze<he){const _t=Math.min(ke.durationInBeats,Te-ot),tt=_$(_t,Q.bpm),dt=(Ze-pe)*de,wt={type:qg.MidiPlaybackEvent,bloobId:Ae.id,noteId:ye.id,trackIndex:Ae.songPosition.track,instrumentType:ci(Ae.instrument),instrumentId:$u(Ae.instrument),pitchInt:ke.pitchInt,velocity:ke.velocity,volume:K4(Ae,Ze-Ue),durationInSeconds:tt,startTimeInSeconds:le+dt};Ne.push(wt)}}})}}}),a.metronome.active===ls.AlwaysOn||a.metronome.active===ls.WhileRecordingOnly&&m.current.isRecording){const Ce=Oo(a.metronome.pitch),Ae=$u(a.metronome.sound);for(let Ue=Math.floor(pe);Ue<he;Ue++)for(let Se=0;Se<Q.timeSignature.beatsPerBar;Se++){const ve=Ue+Se/Q.timeSignature.beatsPerBar;if(ve<pe)continue;if(ve>=he)break;const Te=(ve-pe)*de,ce={type:qg.MidiPlaybackEvent,trackIndex:0,instrumentType:ci(a.metronome.sound),instrumentId:Ae,pitchInt:Ce,velocity:100,volume:a.metronome.volume/100,durationInSeconds:0,startTimeInSeconds:le+Te};Ne.push(ce)}}return Ne},[e,r,n,s,a.metronome]),W=x.useCallback(O=>{if(!I)throw new Error("cannot start playback when nothing is selected");let pe,he,le;if(I.type===J.Song){const Q=i(I.id);pe=I.id,he=Q.firstBarWithBloobContent,le=Q.lastBarWithBloobContent+1}else if(I.type===J.Bloob){const Q=e(I.id);pe=Q.songId,he=Q.songPosition.bar,a.loop||O?le=Q.songPosition.bar+Q.bars:le=i(Q.songId).lastBarWithBloobContent+1}let oe=he;if(!O){const{timelineCursorBar:Q,timelineCursorSongId:de,timelineLoopRegion:Ne}=at.getState(),Ce=de===null||de===pe;if(Ce&&Ne&&(he=Math.max(he,Ne.startBar),le=Math.min(le,Ne.endBar),le<=he&&(le=he+1)),I.type===J.Song&&a.loop&&!Ne){const Ae=n(I.id),Ue=i(I.id),Se=Ue.firstBarWithBloobContent!==1/0&&Ue.lastBarWithBloobContent!==-1/0?Ue.lastBarWithBloobContent+1:Ae.bars;he=0,le=Math.max(Se,he+1e-6),Ce&&Q!==null?oe=Math.max(0,Math.min(Q,le-1e-6)):oe=0}else if(Ce&&Q!==null){const Ae=Math.max(he,Math.min(Q,le-1e-6));he=Math.max(0,Ae),he>=le&&(he=Math.max(0,le-1e-6)),oe=he}else oe=he}S.current={shouldLoop:a.loop&&!O,isRecording:O,songId:pe,startBar:he,endBar:le,playbackAnchorBar:oe,metronomeSettings:a.metronome}},[e,n,i,a.loop,a.metronome,I]),D=x.useCallback(()=>
1591{if(!R)return null;const O=l(),he=O.currentTime-O.baseLatency-w,le=S.current;if(!le)return null;const oe=n(le.songId),Q=ua(1,oe.timeSignature,oe.bpm),de=he/Q;return{songId:le.songId,bar:$2(le.startBar,le.endBar,le.playbackAnchorBar,de)}},[l,n,R,w]),B=x.useCallback(O=>{F(null),v(O.schedulerStartTimeInSeconds)},[]),L=x.useCallback(()=>{const O=N.current,pe=S.current;if(!pe)throw new Error("cannot get playback information with no parameters");const he=n(pe.songId),le=ua(1,he.timeSignature,he.bpm),oe=O.windowOffsetInSeconds/le,Q=$2(pe.startBar,pe.endBar,pe.playbackAnchorBar,oe);let de=Q+O.windowSizeInSeconds/le,Ne=Q,Ce=de,Ae=-1;if(de>pe.endBar){const je=de-pe.endBar;Ae=O.windowSizeInSeconds-je*le,pe.shouldLoop&&(Ne=pe.startBar,Ce=Ne+je),de=pe.endBar}const Ue=A(pe.songId,Q,de,O.windowOffsetInSeconds+O.schedulerStartTimeInSeconds,pe.metronomeSettings),Se=Ae===-1?[]:A(pe.songId,Ne,Ce,O.schedulerStartTimeInSeconds+O.windowOffsetInSeconds+Ae,pe.metronomeSettings),ve=Ue.concat(Se);if(Ae!==-1&&!pe.shouldLoop){const je={type:qg.StopPlaybackEvent,startTimeInSeconds:O.schedulerStartTimeInSeconds+O.windowOffsetInSeconds+Ae};ve.push(je)}ve.sort((je,Te)=>je.startTimeInSeconds-Te.startTimeInSeconds),u().port.postMessage({type:uu.WindowResponseMessage,windowOffsetInSeconds:O.windowOffsetInSeconds,playbackEvents:ve}),N.current=null,_.current=null},[A,u,n]),$=x.useCallback(O=>{N.current&&O.windowOffsetInSeconds<=N.current.windowOffsetInSeconds||(N.current=O,_.current!==null&&clearTimeout(_.current),_.current=setTimeout(L,0))},[L]),q=x.useCallback(()=>{const O=u(),pe=d();O.port.removeEventListener("message",M.current),pe.port.removeEventListener("message",V.current)},[d,u]),Z=x.useCallback(()=>{if(w===null)return;const O=S.current;if(!O)return;const pe=l(),le=pe.currentTime-pe.baseLatency-w,oe=n(O.songId),Q=ua(1,oe.timeSignature,oe.bpm),de=le/Q;if(O.endBar-O.startBar<=0)return;const Ce=$2(O.startBar,O.endBar,O.playbackAnchorBar,de),{timelineLoopRegion:Ae,setTimelineCursorBar:Ue}=at.getState();Ue(Ae?Ae.startBar:Ce,O.songId)},[l,n,w]),ie=x.useCallback(O=>{if(O!=null&&O.skipTimelineCursorSync||Z(),!u())throw new Error("scheduler node not initialized");q(),H.current=null,F(null),v(null),T({}),g(null)},[u,q,Z]),ge=x.useCallback(()=>{const O=H.current;H.current=null,m.current.isRecording&&m.current.stopRecording(),ie({skipTimelineCursorSync:!!O}),O==null||O()},[ie]),re=x.useCallback(O=>{switch(O.data.type){case uu.StartControlConfirmedMessage:{B(O.data);break}case uu.WindowRequestMessage:{$(O.data);break}case uu.StopRequestMessage:{ge();break}}},[B,ge,$]),Y=x.useCallback(O=>{switch(O.data.type){case Du.BloobNoteMessage:{U(O.data);break}}},[U]),ne=x.useCallback(()=>{const O=u();if(!O)throw new Error("scheduler node not initialized");M.current=re,O.port.addEventListener("message",M.current);const pe=d();if(!pe)throw new Error("instrument player note initialized");V.current=Y,pe.port.addEventListener("message",V.current)},[u,re,d,Y]),be=x.useCallback(()=>{const O=u();if(!O)throw new Error("scheduler node not initialized");ne();const pe=n(S.current.songId),he=H2(aEe,pe.timeSignature,pe.bpm),le=A(S.current.songId,S.current.playbackAnchorBar,S.current.playbackAnchorBar+he,0,S.current.metronomeSettings);O.port.postMessage({type:uu.StartControlMessage,startPlaybackEvents:le}),g(S.current.songId)},[ne,A,u,n]),we=x.useCallback(async()=>{const O=n(S.current.songId);await Promise.all(Array.from(O.bloobIds).map(async pe=>{await f(pe)}))},[n,f]),te=x.useCallback((O=!1)=>{if(R)m.current.isRecording&&m.current.stopRecording(),ie(),u().port.postMessage({type:uu.StopControlMessage});else if(I){if(O&&I.type!==J.Bloob)throw new Error("cannot record into a non-bloob");W(O),(async()=>(k(!0),await h(),await we(),k(!1),O&&await m.current.startRecording(I.id),be()))()}},[u,R,I,W,be,ie,h,we]),fe=x.useCallback(()=>{!R||!I||(H.current=()=>{W(!1);const O=S.current;O&&F({songId:O.songId,bar:O.playbackAnchorBar}),(async()=>{try{k(!0),await h(),await we(),k(!1),be()}catch{k(!1),F(null)}})()},u().port.postMessage({type:uu.StopControlMessage}))},[R,I,u,W,be,h,we]);return c.jsx(o8.Provider,{value:{isAwaitingAudioLoad:C,togglePlayStop:te,seekPlayback:fe,playbackStartTimeInSeconds:w,isPlaying:R,currentlyPlayingSongId:y,currentlyPlayingNotes:j,getPlaybackPosition:D,seekPreviewPlaybackPosition:P},children:c.jsx(U9,{ref:m,children:t})})},dEe=({children:t})=>{const{getInstrumentPlayer:e}=es(),n=x.useCallback((o,a,l,u=1,d)=>{const f=e();if(!f)throw new Error("Instrument player not found");if(!Bf(l))throw new Error("Instrument type not supported");f.port.postMessage({type:Du.StartNoteMessage,trackIndex:d,instrumentType:ci(l),instrumentId:$u(l),pitchInt:o,velocity:a,volume:u})},[e]),r=x.useCallback((o,a,l)=>{const u=e();if(!u)throw new Error("Instrument player not found");if(!Bf(a))throw new Error("Instrument type not supported");u.port.postMessage({type:Du.StopNoteMessage,trackIndex:l,instrumentType:ci(a),instrumentId:$u(a),pitchInt:o})},[e]),i=x.useCallback(o=>{const a=e();if(!a)throw new Error("Instrument player not found");if(!Bf(o))throw new Error("Instrument type not supported");a.port.postMessage({type:Du.StopAllNotesMessage,instrumentType:ci(o),instrumentId:$u(o)})},[e]),s=x.useCallback((o,a,l,u=1,d=.2,f)=>{const h=e();if(!h)throw new Error("Instrument player not found");if(!Bf(l))throw new Error("Instrument type not supported");h.port.postMessage({type:Du.StartNoteMessage,trackIndex:f,instrumentType:ci(l),instrumentId:$u(l),pitchInt:o,velocity:a,volume:u,durationInSec:d})},[e]);return c.jsx(JL.Provider,{value:{startNote:n,stopNote:r,stopAllNotes:i,playNote:s},children:t})},ro=.02;class fEe{constructor(e,n,r){Xt(this,"input");Xt(this,"lowShelf");Xt(this,"peaking");Xt(this,"highShelf");Xt(this,"compressor");Xt(this,"outputGain");Xt(this,"reverbSend");Xt(this,"eqEnabled",!1);Xt(this,"compressorEnabled",!1);Xt(this,"reverbEnabled",!1);this.ctx=e,this.input=e.createGain(),this.lowShelf=e.createBiquadFilter(),this.lowShelf.type="lowshelf",this.lowShelf.frequency.value=320,this.lowShelf.gain.value=0,this.peaking=e.createBiquadFilter(),this.peaking.type="peaking",this.peaking.frequency.value=1e3,this.peaking.Q.value=.5,this.peaking.gain.value=0,this.highShelf=e.createBiquadFilter(),this.highShelf.type="highshelf",this.highShelf.frequency.value=3200,this.highShelf.gain.value=0,this.compressor=e.createDynamicsCompressor(),this.compressor.threshold.value=-24,this.compressor.ratio.value=1,this.compressor.attack.value=.003,this.compressor.release.value=.25,this.compressor.knee.value=5,this.outputGain=e.createGain(),this.reverbSend=e.createGain(),this.reverbSend.gain.value=0,this.input.connect(this.lowShelf),this.lowShelf.connect(this.peaking),this.peaking.connect(this.highShelf),this.highShelf.connect(this.compressor),this.compressor.connect(this.outputGain),this.outputGain.connect(n),this.outputGain.connect(this.reverbSend),this.reverbSend.connect(r)}updateEq(e){const n=this.ctx.currentTime;this.eqEnabled=e.enabled,e.enabled?(this.lowShelf.gain.setTargetAtTime(e.lowGain,n,ro),this.peaking.gain.setTargetAtTime(e.midGain,n,ro),this.highShelf.gain.setTargetAtTime(e.highGain,n,ro)):(this.lowShelf.gain.setTargetAtTime(0,n,ro),this.peaking.gain.setTargetAtTime(0,n,ro),this.highShelf.gain.setTargetAtTime(0,n,ro))}updateCompressor(e){const n=this.ctx.currentTime;this.compressorEnabled=e.enabled,e.enabled?(this.compressor.threshold.setTargetAtTime(e.threshold,n,ro),this.compressor.ratio.setTargetAtTime(e.ratio,n,ro),this.compressor.attack.setTargetAtTime(e.attack,n,ro),this.compressor.release.setTargetAtTime(e.release,n,ro)):this.compressor.ratio.setTargetAtTime(1,n,ro)}updateReverb(e){const n=this.ctx.currentTime;this.reverbEnabled=e.enabled,e.enabled?this.reverbSend.gain.setTargetAtTime(e.send,n,ro):this.reverbSend.gain.setTargetAtTime(0,n,ro)}dispose(){this.input.disconnect(),this.lowShelf.disconnect(),this.peaking.disconnect(),this.highShelf.disconnect(),this.compressor.disconnect(),this.outputGain.disconnect(),this.reverbSend.disconnect()}}class hEe{constructor(e,n,r=1.5){Xt(this,"input");Xt(this,"convolver");Xt(this,"wetGain");Xt(this,"decaySeconds");this.ctx=e,this.decaySeconds=r,this.input=e.createGain(),this.convolver=e.createConvolver(),this.convolver.buffer=this.generateImpulseResponse(r),this.wetGain=e.createGain(),this.wetGain.gain.value=1,this.input.connect(this.convolver),this.convolver.connect(this.wetGain),this.wetGain.connect(n)}updateDecay(e){e!==this.decaySeconds&&(this.decaySeconds=e,this.convolver.buffer=this.generateImpulseResponse(e))}generateImpulseResponse(e){const n=this.ctx.sampleRate,r=Math.floor(n*e),i=this.ctx.createBuffer(2,r,n);for(let s=0;s<2;s++){const o=i.getChannelData(s);for(let a=0;a<r;a++)o[a]=(Math.random()*2-1)*Math.exp(-3*a/r)}return i}dispose(){this.input.disconnect(),this.convolver.disconnect(),this.wetGain.disconnect()}}const Sf=16,pEe=({children:t})=>{const[e,n]=x.useState(!1),r=x.useRef(!1),i=x.useRef(void 0),s=x.useRef(void 0),o=x.useRef(void 0),a=x.useRef(void 0),l=x.useRef(void 0),u=x.useRef(void 0),d=x.useRef([]),f=x.useRef(void 0);lx();const{bloobs:h,tracks:m,getBloobById:y}=mn(),{audioSettings:g,generalSettings:w}=bi(),v=x.useCallback(()=>
1591{if(!i.current)throw new Error("Audio context not found");return i.current},[]),S=x.useCallback(()=>{const B=s.current;if(!B)throw new Error("Master gain node not found");return B},[]),C=x.useCallback(()=>{const B=o.current;if(!B)throw new Error("Scheduler node not found");return B},[]),k=x.useCallback(()=>{const B=a.current;if(!B)throw new Error("Audio file player node not found");return B},[]),N=x.useCallback(()=>{const B=l.current;if(!B)throw new Error("Instrument player node not found");return B},[]),_=x.useCallback(()=>d.current,[]),j=x.useCallback(async B=>{var L,$;if(Bf(B)){if((L=u.current)!=null&&L.isInstrumentLoaded(B))return}else return;await(($=u.current)==null?void 0:$.loadInstrument(B))},[]),T=x.useCallback(async B=>{var L,$;(L=u.current)!=null&&L.isAudioFileLoaded(B)||await(($=u.current)==null?void 0:$.loadAudioFile(B))},[]),M=x.useCallback(async B=>{const L=y(B);if(!L)throw new Error("Bloob not found");ln(L)?await j(L.instrument):En(L)&&L.audioFileId&&await T(L.audioFileId)},[y,T,j]);x.useEffect(()=>{r.current=e},[e]);const V=x.useCallback(()=>{if(r.current)return Promise.resolve();let B;return Promise.race([new Promise(L=>{B=setInterval(()=>{r.current&&(clearInterval(B),L())},100)}),new Promise((L,$)=>{setTimeout(()=>{clearInterval(B),$(new Error("Audio initialization timed out after 1 minute."))},1e3*5)})])},[]),H=x.useCallback(()=>{const B=v(),L=B.createDynamicsCompressor();L.threshold.value=-3,L.knee.value=0,L.ratio.value=20,L.attack.value=.001,L.release.value=.1,L.connect(B.destination);const $=B.createGain();$.gain.value=g.masterVolume,$.connect(L),s.current=$},[v,g.masterVolume]),P=x.useCallback(async()=>{try{"requestMIDIAccess"in navigator&&(Ot.enabled||await Ot.enable({sysex:!0,software:!0}))}catch{}},[]),F=x.useCallback(()=>{const L=VI.BYTES_PER_ELEMENT*(1+100*VI.MESSAGE_SIZE);return new SharedArrayBuffer(L)},[]),I=x.useCallback(()=>{const L=HI.BYTES_PER_ELEMENT*(1+100*HI.MESSAGE_SIZE);return new SharedArrayBuffer(L)},[]),R=x.useCallback(()=>{const B=Int32Array.BYTES_PER_ELEMENT*1;return new SharedArrayBuffer(B)},[]),U=x.useCallback(async()=>{const B=v();await B.audioWorklet.addModule(Z_e),await B.audioWorklet.addModule(J_e),await B.audioWorklet.addModule(eEe);const L=F(),$=I(),q=R(),Z=new Array(Sf).fill(2),ie=new AudioWorkletNode(B,"song-scheduler",{processorOptions:{audioFilePlaybackMessageBuffer:L,instrumentPlaybackMessageBuffer:$,stopPlaybackMessageBuffer:q}}),ge=new AudioWorkletNode(B,"audio-file-player",{numberOfOutputs:Sf,outputChannelCount:Z,processorOptions:{audioFilePlaybackMessageBuffer:L,stopPlaybackMessageBuffer:q,maxTrackOutputs:Sf}}),re=new AudioWorkletNode(B,"instrument-player",{numberOfOutputs:Sf,outputChannelCount:Z,processorOptions:{instrumentPlaybackMessageBuffer:$,stopPlaybackMessageBuffer:q,maxTrackOutputs:Sf}});ie.port.start(),ge.port.start(),re.port.start(),ie.connect(ge),ie.connect(re);const Y=S(),ne=new hEe(B,Y);f.current=ne;const be=[];for(let we=0;we<Sf;we++){const te=new fEe(B,Y,ne.input);be.push(te),re.connect(te.input,we),ge.connect(te.input,we)}d.current=be,o.current=ie,a.current=ge,l.current=re},[F,v,I,S,R]),A=x.useCallback(async()=>{await Promise.all(Object.keys(h).map(async B=>{const L=parseInt(B);await M(L)})),await j(w.defaultInstrument),await j(g.metronome.sound)},[h,w.defaultInstrument,M,j,g.metronome.sound]),W=x.useCallback(async()=>{let B;i.current?B=i.current:B=new AudioContext,await B.resume(),i.current=B},[]),D=x.useCallback(async()=>{await W(),H(),await U(),await P(),u.current=new Q_e(v(),k().port,N().port),A(),n(!0)},[U,H,P,k,v,N,W,A]);return x.useEffect(()=>{s.current&&(s.current.gain.value=g.masterVolume)},[g.masterVolume]),x.useEffect(()=>{const B=d.current;if(!(!B.length||!e))for(const L of Object.values(m)){const $=B[L.trackIndex];$&&($.updateEq(L.effects.eq),$.updateCompressor(L.effects.compressor),$.updateReverb(L.effects.reverb))}},[m,e]),x.useEffect(()=>()=>{var B,L;d.current.forEach($=>$.dispose()),(B=f.current)==null||B.dispose(),(L=i.current)==null||L.close(),Ot.enabled&&Ot.disable()},[]),c.jsx(L8.Provider,{value:{getCurrentAudioContext:v,getPreMasterOutput:S,getScheduler:C,getInstrumentPlayer:N,getTrackEffectChains:_,isAudioInitialized:e,initAudio:D,waitForAudioInitialization:V,loadBloobAudio:M},children:c.jsx(dEe,{children:c.jsx(nEe,{children:c.jsx(uEe,{children:c.jsx(tEe,{children:t})})})})})},mEe=({children:t})=>{const{replaceStorageFile:e}=_d(),{selectedCaiObjects:n}
1591=Yn(),{getSongById:r,getBloobById:i}=mn(),{addSong:s,addAudioBloob:o,addAudioFile:a,addVisualMediaNode:l,addEmbeddingNode:u,addTextNode:d}=Gn(),{commitToStore:f}=Ln(),{showBanner:h}=ts(),{uploadOpen:m,aboutOpen:y,welcomeOpen:g,inspectStorageOpen:w,initialSettingsOpen:v}=Pn(),{settingsOpen:S}=bi(),{createSongFromFiles:C,addBloobsToSongFromMidiFiles:k}=dF(),{getCurrentAudioContext:N}=es(),_=m||S||y||g||w||v;return x.useEffect(()=>{const j=W=>{if(_)return;const D=W.target;D!=null&&D.closest('#modal-dialog, [data-testid="modal-dialog"], [role="dialog"][aria-modal="true"]')||(W.preventDefault(),W.stopPropagation(),H(W.dataTransfer))},T=W=>{if(_)return;const D=W.target;D!=null&&D.closest('#modal-dialog, [data-testid="modal-dialog"], [role="dialog"][aria-modal="true"]')||(W.preventDefault(),W.stopPropagation(),H(W.dataTransfer))},M=W=>{if(_)return;const D=W.target;D!=null&&D.closest('#modal-dialog, [data-testid="modal-dialog"], [role="dialog"][aria-modal="true"]')||(W.preventDefault(),W.stopPropagation(),W.relatedTarget)},V=async W=>{var re,Y,ne,be,we;if(_)return;const D=W.target;if((D==null?void 0:D.closest('#modal-dialog, [data-testid="modal-dialog"], [role="dialog"][aria-modal="true"]'))||(W.preventDefault(),W.stopPropagation(),!((Y=(re=W.dataTransfer)==null?void 0:re.files)!=null&&Y.length)&&!((ne=W.dataTransfer)!=null&&ne.getData("text/plain"))&&!((be=W.dataTransfer)!=null&&be.getData("text/uri-list"))))return;if(((we=W.dataTransfer)==null?void 0:we.items.length)===1){const te=W.dataTransfer.items[0].getAsFile();if(te&&te.name.toLowerCase().endsWith(".cai")){const fe=await te.text();await e(fe),h("Loaded project from file");return}}const L=Array.from(W.dataTransfer.files).filter(te=>te.type==="audio/midi"||te.name.toLowerCase().endsWith(".mid")),$=Array.from(W.dataTransfer.files).filter(te=>te.type==="audio/mp3"||te.name.toLowerCase().endsWith(".mp3")||te.type==="audio/wav"||te.name.toLowerCase().endsWith(".wav")||te.type==="audio/mpeg"||te.type==="audio/x-wav"||te.type==="audio/mp4"||te.type==="audio/m4a"||te.name.toLowerCase().endsWith(".m4a")||te.type==="audio/aiff"||te.type==="audio/x-aiff"||te.name.toLowerCase().endsWith(".aif")||te.name.toLowerCase().endsWith(".aiff")||te.type==="audio/flac"||te.name.toLowerCase().endsWith(".flac")||te.type==="audio/ogg"||te.name.toLowerCase().endsWith(".ogg")||te.type==="audio/webm"||te.name.toLowerCase().endsWith(".webm")||te.type==="audio/aac"||te.name.toLowerCase().endsWith(".aac")||te.type==="audio/x-ms-wma"||te.name.toLowerCase().endsWith(".wma")),q=Array.from(W.dataTransfer.files).filter(te=>te.type.startsWith("image/")||te.type.startsWith("video/")||te.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|mp4|mov|avi|mkv|webm|m4v)$/));let Z="",ie=!1;try{Z=W.dataTransfer.getData("text/plain")||W.dataTransfer.getData("text/uri-list")||"",ie=Z&&(Z.startsWith("http://")||Z.startsWith("https://")||Z.includes("youtube.com")||Z.includes("youtu.be")||Z.includes("spotify.com")||Z.includes("soundcloud.com")||Z.includes("music.apple.com")||Z.includes("bandcamp.com")||Z.includes("tidal.com")||Z.includes("deezer.com")||Z.includes("music.amazon.com")||Z.includes("pandora.com"))}catch{Z="",ie=!1}const ge=Array.from(W.dataTransfer.files).filter(te=>te.type==="text/plain"||te.name.toLowerCase().endsWith(".txt")||te.name.toLowerCase().endsWith(".md")||te.name.toLowerCase().endsWith(".rtf"));if(L.length===0&&$.length===0&&q.length===0&&ge.length===0&&!ie){h("No compatible files found. Please drop MIDI, audio, image, video, text files, or supported links only.");return}try{const te={x:200,y:200};if(L.length>0){if(n.length!==1)return;const fe=n[0];if((fe==null?void 0:fe.type)===J.Song){const O=r(fe.id);await k(L,O),h(`Added ${L.length} MIDI track(s) to song`)}else if((fe==null?void 0:fe.type)===J.Bloob){const O=i(fe.id),pe=r(O.songId);await k(L,pe),h(`Added ${L.length} MIDI track(s) to song`)}else await C(L,te),h(`Created new song from ${L.length} MIDI file(s)`)}$.length>0&&(await F($,te),h(`Processed ${$.length} audio file(s)`)),q.length>0&&(await R(q,te),h(`Added ${q.length} visual media file(s)`)),ge.length>0&&(await I(ge,te),h(`Added ${ge.length} text file(s)`)),ie&&(await U(Z,te),h("Added link to canvas")),f()}catch{h("Error processing files. Please try again.")}},H=W=>{var D;if(!((D=W==null?void 0:W.items)!=null&&D.length))return!1;if((W==null?void 0:W.items.length)===1){const B=W.items[0].getAsFile();if(B&&B.name.toLowerCase().endsWith(".cai"))return!0}for(let B=0;B<W.items.length;B++){const L=W.items[B];if(L.kind==="file"){const $=L.getAsFile();if($&&($.type==="audio/midi"||$.name.toLowerCase().endsWith(".mid")||$.type==="audio/mp3"||$.name.toLowerCase().endsWith(".mp3")||$.type==="audio/wav"||$.name.toLowerCase().endsWith(".wav")||$.type==="audio/mpeg"||$.type==="audio/x-wav"||$.type==="audio/mp4"||$.type==="audio/m4a"||$.name.toLowerCase().endsWith(".m4a")||$.type==="audio/aiff"||$.type==="audio/x-aiff"||$.name.toLowerCase().endsWith(".aif")||$.name.toLowerCase().endsWith(".aiff")||$.type==="audio/flac"||$.name.toLowerCase().endsWith(".flac")||$.type==="audio/ogg"||$.name.toLowerCase().endsWith(".ogg")||$.type==="audio/webm"||$.name.toLowerCase().endsWith(".webm")||$.type==="audio/aac"||$.name.toLowerCase().endsWith(".aac")||$.type==="audio/x-ms-wma"||$.name.toLowerCase().endsWith(".wma")||$.type.startsWith("image/")||$.type.startsWith("video/")||$.type==="text/plain"||$.name.toLowerCase().endsWith(".txt")||$.name.toLowerCase().endsWith(".md")||$.name.toLowerCase().endsWith(".rtf")||$.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|mp4|mov|avi|mkv|webm|m4v)$/)))return!0}
1591if(L.kind==="string"&&(L.type==="text/plain"||L.type==="text/uri-list"))return!0}return!1},P=async W=>{const B=await N().decodeAudioData(await W.arrayBuffer());return await a(W.name,B)},F=async(W,D)=>{const B=n.length===1?n[0]:null;for(const L of W){const $=await A(L),q=4;if((B==null?void 0:B.type)===J.Song){const Z=r(B.id),ie=Z.bpm/60,ge=Math.ceil($*ie/Z.timeSignature.beatsPerBar)||q,re=i(Z.id);let Y=-1;Array.isArray(re)&&(Y=Math.max(...re.map(be=>be.songPosition.track),-1));const ne=await P(L);o(Z.id,ne,ge,{bar:1,track:Y+1})}else if((B==null?void 0:B.type)===J.Bloob){const Z=i(B.id),ie=r(Z.songId),ge=ie.bpm/60,re=Math.ceil($*ge/ie.timeSignature.beatsPerBar)||q,Y=i(ie.id);let ne=-1;Array.isArray(Y)&&(ne=Math.max(...Y.map(we=>we.songPosition.track),-1));const be=await P(L);o(ie.id,be,re,{bar:1,track:ne+1})}else{const Z=nD(L.name),ie=s(Z.originalKey||{chroma:"C",quality:"Major"},Z.originalBpm||120,{beatsPerBar:4,beatDuration:4},D,L.name.replace(/\.[^/.]+$/,"")),ge=await P(L),re=120/60,Y=Math.ceil($*re/4)||q;o(ie,ge,Y,{bar:1,track:1})}}},I=async(W,D)=>{for(let L=0;L<W.length;L++){const $=W[L];try{const q=await $.text(),Z={x:D.x+L*50,y:D.y+L*50};d(Z,$.name.replace(/\.[^/.]+$/,""),q)}catch(q){pr(`Error reading text file ${$.name}:`,q);const Z={x:D.x+L*50,y:D.y+L*50};d(Z,$.name.replace(/\.[^/.]+$/,""),`Error reading file: ${$.name}`)}}},R=async(W,D)=>{for(let L=0;L<W.length;L++){const $=W[L];try{const q=new FileReader,Z=await new Promise((ge,re)=>{q.onload=Y=>{var ne;return ge((ne=Y.target)==null?void 0:ne.result)},q.onerror=re,q.readAsDataURL($)}),ie={x:D.x+L*50,y:D.y+L*50};l(ie,$.name.replace(/\.[^/.]+$/,""),Z)}catch(q){pr(`Error processing visual media file ${$.name}:`,q)}}},U=async(W,D)=>{let B="Link";try{const $=new URL(W).hostname.replace("www.","");$.includes("youtube.com")||$.includes("youtu.be")?B="YouTube":$.includes("spotify.com")?B="Spotify":$.includes("soundcloud.com")?B="SoundCloud":$.includes("music.apple.com")?B="Apple Music":$.includes("bandcamp.com")?B="Bandcamp":$.includes("tidal.com")?B="Tidal":$.includes("deezer.com")?B="Deezer":$.includes("music.amazon.com")?B="Amazon Music":$.includes("pandora.com")?B="Pandora":B=$.charAt(0).toUpperCase()+$.slice(1)}catch{B=W.length>30?W.substring(0,30)+"...":W}u(D,B,W)},A=W=>new Promise(D=>{const B=new Audio;B.onloadedmetadata=()=>{D(B.duration)},B.onerror=()=>{D(8)},B.src=URL.createObjectURL(W)});return window.addEventListener("dragover",j),window.addEventListener("dragenter",T),window.addEventListener("dragleave",M),window.addEventListener("drop",V),()=>{window.removeEventListener("dragover",j),window.removeEventListener("dragenter",T),window.removeEventListener("dragleave",M),window.removeEventListener("drop",V)}},[_,n,r,i,o,k,C,f,h,s,N,a,l,u,d,e]),c.jsx(c.Fragment,{children:t})},gEe=x.createContext(null),bEe=({children:t})=>c.jsx(gEe.Provider,{value:null,children:c.jsx(Kv,{children:t})}),yEe=()=>{const[t,e]=x.useState(!0),[n,r]=x.useState(null),[i,s]=x.useState(!1),{createCheckoutSession:o}=tl(),{theme:a}=Pn(),l=a===gi.Dark,u=x.useMemo(()=>new URLSearchParams(window.location.search),[]);return x.useEffect(()=>{if(i)return;(async()=>{var f;try{s(!0);const h=u.get("plan"),m=u.get("userId");if(!h||!m){pr("Missing plan or user ID"),r("Missing plan or user ID"),e(!1);return}const y=await o(m,h,"month");(f=y.session)!=null&&f.url?window.location.href=y.session.url:(pr("No checkout URL in result"),r("Failed to create checkout session"),e(!1))}catch{r("Payment processing failed"),e(!1)}})()},[u,o,i]),n?c.jsx("div",{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm ${l?"text-zinc-100":"text-zinc-900"}`,children:c.jsx(et.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut"},className:`max-w-md w-full rounded-xl shadow-2xl p-6 border bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm ${l?"border-zinc-700":"border-zinc-300"}`,children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:`w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center ${l?"bg-red-900/20":"bg-red-100"}`,children:c.jsx("svg",{className:"w-8 h-8 text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),c.jsx("h1",{className:`text-xl font-semibold mb-2 ${l?"text-zinc-100":"text-zinc-900"}`,children:"Payment Error"}),c.jsx("p",{className:`mb-6 ${l?"text-zinc-300":"text-zinc-600"}`,children:n}),c.jsx("button",{onClick:()=>window.history.back(),className:"px-6 py-3 rounded-lg font-medium transition-all duration-200 bg-gradient-to-r from-caiBlue-500 to-caiGreen-500 hover:from-caiBlue-600 hover:to-caiGreen-600 text-white shadow-lg hover:shadow-xl",children:"Go Back"})]})})}):t?c.jsx("div",{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm ${l?"text-zinc-100":"text-zinc-900"}`,children:c.jsx(et.div,{initial:{opacity:0,y:20}
1591,animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut"},className:`max-w-md w-full rounded-xl shadow-2xl p-6 border bg-gradient-to-br from-zinc-100/100 to-zinc-200/25 dark:from-zinc-800/25 dark:to-zinc-900/25 backdrop-blur-sm ${l?"border-zinc-700":"border-zinc-300"}`,children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:`w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center ${l?"bg-caiBlue-900/20":"bg-caiBlue-100"}`,children:c.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-caiBlue-500"})}),c.jsx("h1",{className:`text-xl font-semibold mb-2 ${l?"text-zinc-100":"text-zinc-900"}`,children:"Your Upgrade Awaits..."}),c.jsx("p",{className:`${l?"text-zinc-300":"text-zinc-600"}`,children:"Redirecting to secure payment..."})]})})}):null},vEe=({isOpen:t,onClose:e,hasExportableData:n=!1,onDownload:r,onDelete:i})=>{const{theme:s}=Pn(),o=s===gi.Dark;return t?c.jsx(Wr,{onClose:e,widthClass:"w-[700px]",blurBackground:!0,closeOnEscape:!1,closeOnBackdropClick:!1,children:c.jsxs("div",{className:`flex flex-col h-full overflow-hidden transition-colors ${o?"bg-gradient-to-br from-zinc-800/95 to-zinc-900/95 backdrop-blur-sm text-zinc-100":"bg-gradient-to-br from-zinc-100/95 to-zinc-200/95 backdrop-blur-sm text-zinc-800"}`,children:[c.jsx("div",{className:`flex justify-between items-center p-4 border-b ${o?"border-zinc-700":"border-zinc-300"}`,children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(T0,{size:24,className:"text-amber-500"}),c.jsx("h2",{className:"text-xl font-semibold",children:"Data reset required"})]})}),c.jsxs("div",{className:"flex-1 p-6 overflow-y-auto space-y-3",children:[c.jsx("p",{className:`text-sm leading-relaxed ${o?"text-zinc-300":"text-zinc-600"}`,children:"Due to the latest update to improve the experience of Cai users, your data is being reset."}),n?c.jsx("p",{className:`text-sm leading-relaxed ${o?"text-zinc-300":"text-zinc-600"}`,children:"Legacy storage has been detected. You can download your midi data before resetting, or delete without downloading. You can then import the midi data later."}):c.jsx("p",{className:`text-sm leading-relaxed ${o?"text-zinc-300":"text-zinc-600"}`,children:"Legacy storage has been detected, but no midi data were found. Your other stored data will be reset."})]}),c.jsxs("div",{className:`p-4 border-t flex flex-col gap-2 ${o?"border-zinc-700":"border-zinc-300"} justify-center items-center`,children:[n&&r&&c.jsxs("button",{onClick:async()=>{const a=r();a instanceof Promise&&await a,e()},className:`w-full px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2 ${o?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-zinc-200 hover:bg-zinc-300 text-zinc-900"}`,children:[c.jsx(cd,{size:18}),"Download midi"]}),i&&c.jsx("button",{onClick:async()=>{const a=i();a instanceof Promise&&await a,e()},className:`w-full px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2 ${n?o?"bg-red-900/50 hover:bg-red-800/60 text-red-200":"bg-red-100 hover:bg-red-200 text-red-800":o?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-zinc-200 hover:bg-zinc-300 text-zinc-900"}`,children:n?c.jsxs(c.Fragment,{children:[c.jsx(js,{size:18}),"Delete without downloading"]}):"Understood"}),!i&&c.jsx("button",{onClick:e,className:`w-full px-4 py-2 rounded-lg font-medium transition-colors ${o?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-zinc-200 hover:bg-zinc-300 text-zinc-900"}`,children:"Understood"})]})]})}):null},ty=t=>t instanceof Set?t:Array.isArray(t)?new Set(t.map(Number).filter(e=>!isNaN(e))):t&&typeof t=="object"&&!Array.isArray(t)?new Set(Object.keys(t).map(Number).filter(e=>!isNaN(e))):new Set,xEe=t=>t&&typeof t=="object"&&"chroma"in t&&"quality"in t?{chroma:t.chroma||"C",quality:t.quality||"Major"}:{chroma:"C",quality:"Major"},wEe=t=>t&&typeof t=="object"&&"beatsPerBar"in t?{beatsPerBar:Number(t.beatsPerBar)||4,beatDuration:Number(t.beatDuration)||4}:{beatsPerBar:4,beatDuration:4},kEe=t=>t&&typeof t=="object"&&"bar"in t?{bar:Number(t.bar)||0,track:Number(t.track)||0}:{bar:0,track:0},SEe=t=>t&&typeof t=="object"&&"x"in t&&"y"in t?{x:Number(t.x)||0,y:Number(t.y)||0}:{x:0,y:0};function V9(t){if(t==null)return null;if(typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const e=JSON.parse(t);return V9(e)}catch{return null}return null}function CEe(t){const e=t.json;if(e&&typeof e=="object"&&!Array.isArray(e)){const r=e;if(r.state&&typeof r.state=="object")return r.state}const n=t.state??t;if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;return"state"in r&&r.state&&typeof r.state=="object"?r.state:r}return null}function H9(t){const e=V9(t);if(!e)return null;const n=CEe(e);if(!n||typeof n!="object")return null;const r=n.songs,i=n.bloobs,s=n.notes,o=n.audioFiles,a={};if(r&&typeof r=="object")for(const[f,h]of Object.entries(r)){const m=parseInt(f,10);if(isNaN(m)||!h||typeof h!="object")continue;const y=h;a[m]={type:J.Song,id:m,nextInSongId:Number(y.nextInSongId)??0,label:String(y.label??"Untitled"),key:xEe(y.key),bpm:Number(y.bpm)||120,timeSignature:wEe(y.timeSignature),canvasPosition:SEe(y.canvasPosition),bars:Number(y.bars)||4,tracks:Number(y.tracks)||4,bloobIds:ty(y.bloobIds),trackIds:ty(y.trackIds),threadIds:ty(y.threadIds),hasSoloedBloobs:!!y.hasSoloedBloobs,metadata:y.metadata??{},createdAt:Number(y.createdAt)||0,lastModified:Number(y.lastModified)||0}}const l={};if(i&&typeof i=="object")for(const[f,h]of Object.entries(i)){const m=parseInt(f,10);if(isNaN(m)||!h||typeof h!="object")continue;const y=h,g=String(y.bloobType??"Midi"),w={type:J.Bloob,id:m,songId:Number(y.songId)??0,inSongId:Number(y.inSongId)??0,label:String(y.label??"Untitled"),color:String(y.color??"#6B88CC"),muted:!!y.muted,soloed:!!y.soloed,songPosition:kEe(y.songPosition),bars:Number(y.bars)||4,volume:Number(y.volume)??.75,melodicRole:y.melodicRole??"None",metadata:String(y.metadata??""),metadataOutdated:!!y.metadataOutdated,createdAt:Number(y.createdAt)||0,lastModified:Number(y.lastModified)||0};g==="Audio"?l[m]={...w,bloobType:Us.Audio,audioFileId:Number(y.audioFileId)??0,playbackRate:Number(y.playbackRate)??1,audioClipStartInSeconds:Number(y.audioClipStartInSeconds)||0}:l[m]={...w,bloobType:Us.Midi,instrument:String(y.instrument??"acoustic_grand_piano"),noteIds:ty(y.noteIds),notes:[]}}const u={};if(s&&typeof s=="object")for(const[f,h]of Object.entries(s)){const m=parseInt(f,10);if(isNaN(m)||!h||typeof h!="object")continue;const y=h,g=Number(y.pitchInt);
1591isNaN(g)||(u[m]={id:m,bloobId:Number(y.bloobId)??0,pitchInt:g,startBeat:Number(y.startBeat)??0,durationInBeats:Number(y.durationInBeats)??1,velocity:Number(y.velocity)??100})}const d={};if(o&&typeof o=="object")for(const[f,h]of Object.entries(o)){const m=parseInt(f,10);if(isNaN(m)||!h||typeof h!="object")continue;const y=h;d[m]={id:m,...y,referenceCount:y.referenceCount??1}}return{songs:a,bloobs:l,notes:u,audioFiles:d}}function _Ee(t){return e=>Object.values(t.notes).filter(n=>n.bloobId===e)}function EEe(t){const e=Object.keys(t.songs).length>0,n=Object.keys(t.bloobs).length>0;return e||n}function NEe(t){return Object.values(t.songs).map(e=>{const r=Array.from(e.bloobIds).map(i=>t.bloobs[i]).filter(i=>i!=null);return{song:e,bloobs:r}})}const Pf=t=>t.replace(/[\\/:*?"<>|]/g,"").trim()||"untitled";async function IEe(t,e){const n=Object.entries(t);if(!n.length)return;if(n.length===1){const[a,l]=n[0],u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=a,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u);return}const r=new AL;n.forEach(([a,l])=>r.file(a,l));const i=await r.generateAsync({type:"blob"}),s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=`${Pf(e)}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}async function jEe(t){return await jn.getItem(`audioFileData-${t}`)??null}async function TEe(t){var a;const e=H9(t);if(!e)return{success:!1,error:"Could not parse legacy storage data"};const n=_Ee(e),r=NEe(e);if(r.length===0)return{success:!1,error:"No songs found in legacy storage"};const i={};let s=0;for(const{song:l,bloobs:u}of r){const d=u.filter(ln),f=u.filter(En);for(const h of d){const m=$L(h,l,n);if(m){const y=((a=h.instrument)==null?void 0:a.toLowerCase())??"",w=y.includes("drum")||y.includes("percussion")||y.includes("kit")?`_${l.bpm}_BPM`:`_${l.key.chroma}_${l.key.quality}_${l.bpm}_BPM`,S=`${Pf(l.label).replace(/ /g,"_")}_s${l.id}_${Pf(h.label)}_b${h.id}${w}.mid`;i[S]=m,s++}}if(d.length>1){const h=UL(l,d,n);if(h){const m=`_${l.key.chroma}_${l.key.quality}_${l.bpm}_BPM`,y=Pf(l.label).replace(/ /g,"_");i[`${y}_s${l.id}_All_Midi${m}.mid`]=h,s++}}for(const h of f){const m=await jEe(h.audioFileId);if(m&&m.length>0){const y=DL(m),g=e.audioFiles[h.audioFileId];let w="";if(g){const C=[],k=g.originalKey;k!=null&&k.chroma&&C.push(`${k.chroma}_${k.quality??""}`);const N=g.originalBpm;N!=null&&C.push(`${N}_BPM`),C.length&&(w=`_${C.join("_")}`)}const S=`${Pf(l.label).replace(/ /g,"_")}_s${l.id}_${Pf(h.label)}_b${h.id}${w}.wav`;i[S]=y,s++}}}if(s===0)return{success:!1,error:"No exportable content found in legacy storage"};const o=`legacy-export-${new Date().toISOString().slice(0,10)}`;return await IEe(i,o),{success:!0}}Ji.initialize(kJ);const zEe=({onSignOut:t})=>{const[e,n]=x.useState(!1);return x.useEffect(()=>{const r=setTimeout(()=>{n(!0)},50);return()=>clearTimeout(r)},[]),x.useEffect(()=>(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.overflow="",document.documentElement.style.overflow=""}),[]),x.useEffect(()=>{const r=window.location.hash.toLowerCase();["#faq","#about"].includes(r)&&window.history.replaceState("",document.title,window.location.pathname+window.location.search)},[]),c.jsx("div",{className:`transition-opacity duration-500 ease-in-out ${e?"opacity-100":"opacity-0"}`,children:c.jsx(pEe,{children:c.jsx(L9,{children:c.jsx(mEe,{children:c.jsx(bEe,{children:c.jsx(KCe,{onSignOut:t})})})})})})};function PEe(){const[t,e]=x.useState(!1),[n,r]=x.useState(!0),[i,s]=x.useState(!1),[o,a]=x.useState(!1),[l,u]=x.useState(!1),d=lx(),{isInitializing:f,cloudDataStatus:h}=aD(t),m=Hn(),y=window.location.pathname,g=y.startsWith("/payments/"),w=y.startsWith("/subscription/"),v=y==="/"||g||w;x.useEffect(()=>{(()=>{const j=window.location.pathname;let T;switch(j){case"/":T="https://www.cai.audio/";break;default:j.startsWith("/payments/")?T=`https://www.cai.audio${j}`:T="https://www.cai.audio/"}const M=document.querySelector('link[rel="canonical"]');
1591if(M)M.href=T;else{const V=document.createElement("link");V.rel="canonical",V.href=T,document.head.appendChild(V)}})()},[y]);const S=x.useCallback(async()=>{var _;r(!0);try{const{data:{session:j}}=await xr.auth.getSession();j?(Iu((_=j.user)==null?void 0:_.email),Ji.event({category:qs.USER_ACTIONS,action:Jt.SIGN_IN,label:bo.AUTHENTICATION}),e(!0)):(Iu(null),e(!1))}catch{Iu(null),e(!1)}finally{r(!1)}},[]);x.useEffect(()=>{S();const{data:{subscription:_}}=xr.auth.onAuthStateChange(async(j,T)=>{var M;j==="SIGNED_IN"&&T?(Iu((M=T.user)==null?void 0:M.email),e(!0),Ji.event({category:qs.USER_ACTIONS,action:Jt.SIGN_IN,label:bo.AUTHENTICATION})):j==="SIGNED_OUT"&&(Iu(null),e(!1))});return()=>_.unsubscribe()},[S]),x.useEffect(()=>{n||(async()=>{if(new URLSearchParams(window.location.search).get("code")||window.location.hash.includes("access_token"))try{const{data:M,error:V}=await xr.auth.getSession();V?pr("OAuth redirect error:",V):M.session&&window.history.replaceState({},"",window.location.pathname)}catch{}})()},[n]),x.useEffect(()=>{Ji.pageview(window.location.pathname)},[]),x.useEffect(()=>{},[]),x.useEffect(()=>{if(!t)return;(async()=>{try{const T=await jn.getItem("user-session-<userId>");if(T!=null){const M=H9(T);if(M!=null){const V=EEe(M);u(V),a(!0)}}}catch{}})()},[t]),x.useEffect(()=>{!t&&!n&&(document.body.style.overflow="",document.documentElement.style.overflow="")},[t,n]);const C=async()=>{s(!0);try{await xr.auth.signOut(),Iu(null),await jn.clear(),Ji.event({category:qs.USER_ACTIONS,action:Jt.SIGN_OUT,label:bo.AUTHENTICATION}),e(!1)}catch{}finally{s(!1)}},k=x.useCallback(async()=>{try{const _="user-session-<userId>",j=await jn.getItem(_);if(j==null){a(!1);return}const T=await TEe(j);T.success?(await jn.removeItem(_),a(!1)):(pr("Legacy export failed:",T.error),alert(T.error??"Export failed"))}catch{alert("Export failed. Please try again.")}},[]),N=x.useCallback(async()=>{try{await jn.removeItem("user-session-<userId>"),a(!1)}catch{alert("Delete failed. Please try again.")}},[]);return x.useEffect(()=>{if(m){let _=document.querySelector('meta[name="viewport"]');_||(_=document.createElement("meta"),_.setAttribute("name","viewport"),document.head.appendChild(_)),_.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),document.body.style.overscrollBehavior="none",document.body.style.webkitUserSelect="none",document.body.style.userSelect="none";let j=document.querySelector('meta[name="apple-mobile-web-app-capable"]');j||(j=document.createElement("meta"),j.setAttribute("name","apple-mobile-web-app-capable"),j.setAttribute("content","yes"),document.head.appendChild(j));let T=document.querySelector('meta[name="mobile-web-app-capable"]');T||(T=document.createElement("meta"),T.setAttribute("name","mobile-web-app-capable"),T.setAttribute("content","yes"),document.head.appendChild(T))}},[m]),n||!d||f?c.jsx("div",{className:"w-screen h-screen flex items-center justify-center bg-cai-primary",children:f&&c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-white mx-auto mb-4"}),c.jsxs("p",{className:"text-white text-lg",children:[h==="loading"&&"Loading your data from cloud...",h==="none"&&"Setting up your workspace...",h==="error"&&"Loading...",h==="checking"&&"Loading..."]})]})}):v?g?c.jsx(A4,{children:c.jsx(L9,{children:c.jsx(yEe,{})})}):c.jsx("div",{className:"relative w-full min-h-full overflow-x-hidden overflow-y-auto",children:c.jsxs(A4,{children:[t?c.jsx("div",{className:`transition-opacity duration-500 ${i?"opacity-0":"opacity-100"}`,children:c.jsx(zEe,{onSignOut:C})}):c.jsx(W_e,{}),o&&c.jsx(vEe,{isOpen:o,onClose:()=>a(!1),hasExportableData:l,onDownload:l?k:void 0,onDelete:N})]})}):(window.location.replace("/404.html"),null)}R$.createRoot(document.getElementById("root")).render(c.jsx(mr.StrictMode,{children:c.jsx(PEe,{})}));export{tr as a,DL as b,Yh as c,pr as e,ar as w};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.