arpeggi-framer-components 0.0.42 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
@@ -66,5 +66,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
66
66
|
*
|
67
67
|
* This source code is licensed under the MIT license found in the
|
68
68
|
* LICENSE file in the root directory of this source tree.
|
69
|
-
*/var yo;function Il(){return yo||(yo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function i(A){{for(var R=arguments.length,v=new Array(R>1?R-1:0),O=1;O<R;O++)v[O-1]=arguments[O];n("error",A,v)}}function n(A,R,v){{var O=t.ReactDebugCurrentFrame,L=O.getStackAddendum();L!==""&&(R+="%s",v=v.concat([L]));var j=v.map(function(Y){return String(Y)});j.unshift("Warning: "+R),Function.prototype.apply.call(console[A],console,j)}}function r(A,R){return A===R&&(A!==0||1/A===1/R)||A!==A&&R!==R}var o=typeof Object.is=="function"?Object.is:r,a=e.useState,s=e.useEffect,c=e.useLayoutEffect,p=e.useDebugValue,l=!1,u=!1;function f(A,R,v){l||e.startTransition!==void 0&&(l=!0,i("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var O=R();if(!u){var L=R();o(O,L)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var j=a({inst:{value:O,getSnapshot:R}}),Y=j[0].inst,K=j[1];return c(function(){Y.value=O,Y.getSnapshot=R,x(Y)&&K({inst:Y})},[A,O,R]),s(function(){x(Y)&&K({inst:Y});var re=function(){x(Y)&&K({inst:Y})};return A(re)},[A]),p(O),O}function x(A){var R=A.getSnapshot,v=A.value;try{var O=R();return!o(v,O)}catch{return!0}}function g(A,R,v){return R()}var h=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!h,m=E?g:f,C=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m;ai.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ai}var bo;function Bl(){return bo||(bo=1,process.env.NODE_ENV==="production"?xn.exports=Pl():xn.exports=Il()),xn.exports}var wo=Bl();const et=()=>{},Ae=et(),si=Object,H=e=>e===Ae,$e=e=>typeof e=="function",Ne=(e,t)=>({...e,...t}),Ll=e=>$e(e.then),vn=new WeakMap;let Ml=0;const Bt=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(si(e)===e&&!n&&i!=RegExp){if(r=vn.get(e),r)return r;if(r=++Ml+"~",vn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=Bt(e[o])+",";vn.set(e,r)}if(i==si){r="#";const a=si.keys(e).sort();for(;!H(o=a.pop());)H(e[o])||(r+=o+":"+Bt(e[o])+",");vn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ge=new WeakMap,ci={},gn={},li="undefined",hn=typeof window!=li,pi=typeof document!=li,zl=()=>hn&&typeof window.requestAnimationFrame!=li,ui=(e,t)=>{const i=Ge.get(e);return[()=>!H(t)&&e.get(t)||ci,n=>{if(!H(t)){const r=e.get(t);t in gn||(gn[t]=r),i[5](t,Ne(r,n),r||ci)}},i[6],()=>!H(t)&&t in gn?gn[t]:!H(t)&&e.get(t)||ci]};let di=!0;const $l=()=>di,[fi,mi]=hn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[et,et],Nl=()=>{const e=pi&&document.visibilityState;return H(e)||e!=="hidden"},ql=e=>(pi&&document.addEventListener("visibilitychange",e),fi("focus",e),()=>{pi&&document.removeEventListener("visibilitychange",e),mi("focus",e)}),Wl=e=>{const t=()=>{di=!0,e()},i=()=>{di=!1};return fi("online",t),fi("offline",i),()=>{mi("online",t),mi("offline",i)}},Ul={isOnline:$l,isVisible:Nl},Vl={initFocus:ql,initReconnect:Wl},Lt=!w.useId,dt=!hn||"Deno"in window,Eo=e=>zl()?window.requestAnimationFrame(e):setTimeout(e,1),tt=dt?w.useEffect:w.useLayoutEffect,xi=typeof navigator<"u"&&navigator.connection,So=!dt&&xi&&(["slow-2g","2g"].includes(xi.effectiveType)||xi.saveData),Mt=e=>{if($e(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Bt(e):"",[e,t]};let Hl=0;const Et=()=>++Hl,To=0,Ro=1,ko=2;var Ye={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:To,MUTATE_EVENT:ko,RECONNECT_EVENT:Ro};async function vi(...e){const[t,i,n,r]=e,o=Ne({populateCache:!0,throwOnError:!0},typeof r=="boolean"?{revalidate:r}:r||{});let a=o.populateCache;const s=o.rollbackOnError;let c=o.optimisticData;const p=f=>typeof s=="function"?s(f):s!==!1,l=o.throwOnError;if($e(i)){const f=i,x=[],g=t.keys();for(const h of g)!/^\$(inf|sub)\$/.test(h)&&f(t.get(h)._k)&&x.push(h);return Promise.all(x.map(u))}return u(i);async function u(f){const[x]=Mt(f);if(!x)return;const[g,h]=ui(t,x),[E,m,C,A]=Ge.get(t),R=()=>{const Q=E[x];return($e(o.revalidate)?o.revalidate(g().data,f):o.revalidate!==!1)&&(delete C[x],delete A[x],Q&&Q[0])?Q[0](ko).then(()=>g().data):g().data};if(e.length<3)return R();let v=n,O;const L=Et();m[x]=[L,0];const j=!H(c),Y=g(),K=Y.data,re=Y._c,oe=H(re)?K:re;if(j&&(c=$e(c)?c(oe,K):c,h({data:c,_c:oe})),$e(v))try{v=v(oe)}catch(Q){O=Q}if(v&&Ll(v))if(v=await v.catch(Q=>{O=Q}),L!==m[x][0]){if(O)throw O;return v}else O&&j&&p(O)&&(a=!0,h({data:oe,_c:Ae}));if(a&&!O)if($e(a)){const Q=a(v,oe);h({data:Q,error:Ae,_c:Ae})}else h({data:v,error:Ae,_c:Ae});if(m[x][1]=Et(),Promise.resolve(R()).then(()=>{h({_c:Ae})}),O){if(l)throw O;return}return v}}const Co=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},Gl=(e,t)=>{if(!Ge.has(e)){const i=Ne(Vl,t),n={},r=vi.bind(Ae,e);let o=et;const a={},s=(l,u)=>{const f=a[l]||[];return a[l]=f,f.push(u),()=>f.splice(f.indexOf(u),1)},c=(l,u,f)=>{e.set(l,u);const x=a[l];if(x)for(const g of x)g(u,f)},p=()=>{if(!Ge.has(e)&&(Ge.set(e,[n,{},{},{},r,c,s]),!dt)){const l=i.initFocus(setTimeout.bind(Ae,Co.bind(Ae,n,To))),u=i.initReconnect(setTimeout.bind(Ae,Co.bind(Ae,n,Ro)));o=()=>{l&&l(),u&&u(),Ge.delete(e)}}};return p(),[e,r,p,o]}return[e,Ge.get(e)[4]]},Yl=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!H(o)&&a>o||setTimeout(n,s,r)},Kl=(e,t)=>Bt(e)==Bt(t),[Oo,Jl]=Gl(new Map),Xl=Ne({onLoadingSlow:et,onSuccess:et,onError:et,onErrorRetry:Yl,onDiscarded:et,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:So?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:So?5e3:3e3,compare:Kl,isPaused:()=>!1,cache:Oo,mutate:Jl,fallback:{}},Ul),Zl=(e,t)=>{const i=Ne(e,t);if(t){const{use:n,fallback:r}=e,{use:o,fallback:a}=t;n&&o&&(i.use=n.concat(o)),r&&a&&(i.fallback=Ne(r,a))}return i},Ql=w.createContext({}),ep="$inf$",_o=hn&&window.__SWR_DEVTOOLS_USE__,tp=_o?window.__SWR_DEVTOOLS_USE__:[],np=()=>{_o&&(window.__SWR_DEVTOOLS_REACT__=w)},Ao=e=>$e(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],jo=()=>Ne(Xl,w.useContext(Ql)),ip=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=Mt(t),[,,,s]=Ge.get(Oo);if(a.startsWith(ep))return i(...o);const c=s[a];return H(c)?i(...o):(delete s[a],c)}),n),rp=tp.concat(ip),Do=e=>function(...i){const n=jo(),[r,o,a]=Ao(i),s=Zl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat(rp);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},Fo=(e,t,i)=>{const n=t[e]||(t[e]=[]);return n.push(i),()=>{const r=n.indexOf(i);r>=0&&(n[r]=n[n.length-1],n.pop())}},op=(e,t)=>(...i)=>{const[n,r,o]=Ao(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};np();const Po=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),gi={dedupe:!0},ap=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,g,h,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),R=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,z=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&z),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||R.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!h[m]||!ke.dedupe,ie=()=>Lt?!R.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=h[m];S&&S[1]===V&&delete h[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),h[m]=[I(C),Et()]),[ee,V]=h[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!h[m]||h[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=Ae;const S=g[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(Ae,gi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return R.current=!1,v.current=m,A.current=!0,re({_k:C}),z&&(H(M)||dt?b():Eo(b)),()=>{R.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(gi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,R.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Po(I)}if(H(W)){const I=q(gi);H(J)||(I.status="fulfilled",I.value=!0),Po(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Io=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),hi={dedupe:!0},sp=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,g,h,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),R=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,z=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&z),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||R.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!h[m]||!ke.dedupe,ie=()=>Lt?!R.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=h[m];S&&S[1]===V&&delete h[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),h[m]=[I(C),Et()]),[ee,V]=h[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!h[m]||h[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=Ae;const S=g[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(Ae,hi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return R.current=!1,v.current=m,A.current=!0,re({_k:C}),z&&(H(M)||dt?b():Eo(b)),()=>{R.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(hi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,R.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Io(I)}if(H(W)){const I=q(hi);H(J)||(I.status="fulfilled",I.value=!0),Io(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Bo=Lt?e=>{e()}:w.startTransition,cp=e=>{const[,t]=w.useState({}),i=w.useRef(!1),n=w.useRef(e),r=w.useRef({data:!1,error:!1,isValidating:!1}),o=w.useCallback(a=>{let s=!1;const c=n.current;for(const p in a){const l=p;c[l]!==a[l]&&(c[l]=a[l],r.current[l]&&(s=!0))}s&&!i.current&&t({})},[]);return tt(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},lp=op(sp,()=>(e,t,i={})=>{const{mutate:n}=jo(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=cp({data:Ae,error:Ae,isMutating:!1}),u=c.current,f=w.useCallback(async(g,h)=>{const[E,m]=Mt(r.current);if(!o.current)throw new Error("Can’t trigger the mutation: missing fetcher.");if(!E)throw new Error("Can’t trigger the mutation: missing key.");const C=Ne(Ne({populateCache:!1,throwOnError:!0},a.current),h),A=Et();s.current=A,l({isMutating:!0});try{const R=await n(E,o.current(m,{arg:g}),Ne(C,{throwOnError:!0}));return s.current<=A&&(Bo(()=>l({data:R,isMutating:!1,error:void 0})),C.onSuccess==null||C.onSuccess.call(C,R,E,C)),R}catch(R){if(s.current<=A&&(Bo(()=>l({error:R,isMutating:!1})),C.onError==null||C.onError.call(C,R,E,C),C.throwOnError))throw R}},[]),x=w.useCallback(()=>{s.current=Et(),l({data:Ae,error:Ae,isMutating:!1})},[]);return tt(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:x,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),pp=e=>{const t=r=>typeof r=="object"&&!(r instanceof Date)&&!(r instanceof File)&&r!==null,i=(r,o,a)=>{for(const s in o){const c=o[s];t(c)?i(`${r}[${s}]`,c,a):c!==void 0&&a.append(`${r}[${s}]`,c===null?"":c)}},n=new FormData;for(const r in e){const o=e[r];o instanceof File?n.append(r,o,o.name):o!==void 0&&(t(o)?i(r,o,n):n.append(r,o===null?"":o))}return n},up=De("div",{"--progress":"-100%",height:"4px",width:"100%",background:"rgba(255, 255, 255, 0.1)",borderRadius:"12px",position:"relative",overflow:"hidden"}),dp=De("div",{height:"100%",width:"100%",background:"#ffffff",transform:"translateX(var(--progress))",borderRadius:"12px"}),nt={Root:up,Bar:dp};function yn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function bn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ft(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255,t[i+2]=e>>16&255,t[i+3]=e>>24&255}function fp(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function mp(e,t,i,n){let r=0,o=0;const a=e.length,s=e.numberOfChannels;let c,p;for(r=0;r<a;++r)for(o=0;o<s;++o)if(c=e.getChannelData(o),n===16)p=c[r]*32768,p=Math.max(-32768,Math.min(p,32767)),bn(p,t,i),i+=2;else if(n===32)p=fp(c[r]),ft(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function xp(e,t){let i=e instanceof Blob?e:new Blob(e);const n=URL.createObjectURL(i),o=await(await fetch(n)).arrayBuffer();return await new AudioContext(t).decodeAudioData(o)}async function vp(e,t=!1){const i=e.length,n=e.numberOfChannels,r=e.sampleRate,o=t?32:16,a=o/8,s=r*n*o/8,c=n*o/8,p=i*n*a,u=44+p,f=new Uint8Array(u),x=16,g=p,h=4+(8+x)+(8+g);return yn("RIFF",f,0),ft(h,f,4),yn("WAVE",f,8),yn("fmt ",f,12),ft(x,f,16),bn(t?3:1,f,20),bn(n,f,22),ft(r,f,24),ft(s,f,28),bn(c,f,32),ft(o,f,34),yn("data",f,36),ft(g,f,40),mp(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function gp(e,t=!1,i){const n=await xp(e,i);return vp(n,t)}const hp=128;class yp{constructor(){En(this,"mediaRecorder",null);En(this,"stream",null);En(this,"__data",null)}async checkMicrophonePermission(){var n;return!!(await((n=navigator==null?void 0:navigator.mediaDevices)==null?void 0:n.enumerateDevices())).find(r=>r.kind==="audioinput"&&!!r.label)}async startRecording(){var t;if(((t=this.mediaRecorder)==null?void 0:t.state)==="recording")return!0;try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.mediaRecorder=new MediaRecorder(this.stream,{bitsPerSecond:hp*1e3}),this.mediaRecorder.ondataavailable=i=>this.__data=i.data}catch(i){return console.error(i),!1}return this.mediaRecorder.start(),!0}stopRecording(){return new Promise(t=>{var i;if(((i=this.mediaRecorder)==null?void 0:i.state)!=="recording"){t(!0);return}this.mediaRecorder.stop(),this.mediaRecorder.onstop=()=>{var n;(n=this.stream)==null||n.getTracks().forEach(r=>r.stop()),this.mediaRecorder=null,this.stream=null,t(!0)}})}async getWavBlob(){return this.__data?await gp(this.__data):null}}const wn=new yp,yi="Recording.wav",Lo=1500,bp=e=>{const[t,i]=w.useState(!1),[n,r]=w.useState(!1),[o,a]=w.useState(!1);return w.useEffect(()=>{var p;const c=async()=>{wn.checkMicrophonePermission().then(i)};return c(),(p=navigator==null?void 0:navigator.mediaDevices)==null||p.addEventListener("devicechange",c),()=>{var l;return(l=navigator==null?void 0:navigator.mediaDevices)==null?void 0:l.removeEventListener("devicechange",c)}},[]),{hasMicAccess:t,isRecording:n,hasMinTimeElapsed:o,handleClick:async()=>{if(n){if(!o)return;r(!1),a(!1),await wn.stopRecording();const p=await wn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],yi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await wn.startRecording();r(c),setTimeout(()=>{a(!0)},Lo)}}},Mo=_e.create({baseURL:"https://arpeggi.io/api/v2/"}),wp=async(e,{arg:t})=>{var n;return(await Mo.post("/ml-inference-jobs",pp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,strapiDemoId:t.strapiDemoId,metadata:{isRecordedAudio:((n=t.file)==null?void 0:n.name)===yi}}),{params:{type:"audio"}})).data},Ep=async e=>e===null?null:(await Mo.get(e)).data,Sp=e=>{const t=e>0;return ap(t?`/ml-inference-jobs/${e}`:null,Ep,{refreshInterval:i=>(i==null?void 0:i.jobStatus)==="success"?0:1e3})},Tp=()=>{const[e,t]=w.useState("file"),[i,n]=w.useState(void 0),[r,o]=w.useState(void 0),[a,s]=w.useState(0),[c,p]=w.useState(0),{data:l,isLoading:u}=Sp(a),{trigger:f,isMutating:x}=lp("/ml-inference-jobs",wp),[g,h]=w.useState(!1);return{demo:i,setDemo:n,file:r,setFile:o,mlijId:a,setMlijId:s,voiceModelId:c,setVoiceModelId:p,data:l,isLoading:u,handleSelectVoice:async A=>{if(!(!r&&!i)){if(s(0),p(A),i){h(!0),setTimeout(()=>{h(!1)},1e3);return}f({file:r,voiceModelId:A},{onSuccess:R=>{console.log("created mlij",R),s(R.id)}})}},reset:()=>{t("file"),n(void 0),o(void 0),s(0),p(0)},isMutating:x||g,step:e,setStep:t}},zo=w.createContext({}),zt=()=>w.useContext(zo),Rp=({children:e})=>{const t=Tp();return $.jsx(jr,{children:$.jsx(zo.Provider,{value:t,children:e})})},kp=De("button",{background:"#ffffff",flexShrink:0,borderRadius:"12px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out, transform 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99",transform:"scale(1.05)"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"rgba(255, 255, 255, 0.3)",transform:"none",cursor:"not-allowed"}}),Cp=De("div",{fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"#ffffff",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400}),Op=e=>{var u;const{data:t,isMutating:i,demo:n,voiceModelId:r}=zt(),a=(n==null?void 0:n.cachedResults[r])||((u=t==null?void 0:t.lossyOutputFile)==null?void 0:u.url),{player:s,playPause:c}=Un(a),p=w.useRef(null),l=w.useRef();return w.useEffect(()=>{if(!s.isPlaying)return()=>{cancelAnimationFrame(l.current)};const f=()=>{var g;const x=s.audioRef.current.currentTime/s.audioRef.current.duration;(g=p.current)==null||g.style.setProperty("--progress",`${-100+x*100}%`),l.current=requestAnimationFrame(f)};return l.current=requestAnimationFrame(f),()=>{cancelAnimationFrame(l.current)}},[s.isPlaying,s.audioRef]),$.jsxs(Me,{row:!0,align:"center",flex:"1",gap:"16",...e,children:[$.jsx(kp,{onClick:c,disabled:s.isLoading||!a,children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:s.isLoading||(t==null?void 0:t.jobStatus)==="running"||i,children:$.jsx(kr,{})}),$.jsx(Ie.If,{isTrue:s.isPlaying,children:$.jsx(Cr,{})}),$.jsx(Ie.Else,{children:$.jsx(Or,{})})]})}),$.jsxs(Me,{flex:"1",column:!0,gap:"12",children:[$.jsx(Cp,{children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:(t==null?void 0:t.jobStatus)==="running",children:"Converting audio"}),$.jsx(Ie.If,{isTrue:i,children:"Uploading audio"}),$.jsx(Ie.Else,{children:"Converted audio"})]})}),$.jsx(nt.Root,{ref:p,children:$.jsx(nt.Bar,{})})]})]})},_p=30,$o=e=>{const t=w.useRef(),i=w.useRef(null);return w.useEffect(()=>{let n=0;return t.current=setInterval(()=>{var o;n+=e;let r=Math.round(Math.atan(n)/(Math.PI/2)*100*1e3)/1e3;(o=i.current)==null||o.style.setProperty("--progress",`${-100+r}%`)},50),()=>clearInterval(t.current)},[]),i},Ap=()=>{const e=$o(.1);return $.jsx(nt.Root,{ref:e,children:$.jsx(nt.Bar,{})})},jp=()=>$.jsx(nt.Root,{children:$.jsx(nt.Bar,{})}),Dp=()=>$.jsx(nt.Root,{style:{"--progress":"0%"},children:$.jsx(nt.Bar,{})}),Fp=()=>{const{data:e}=zt();return e?e.jobStatus==="success"?$.jsx(Dp,{}):$.jsx(Ap,{},e==null?void 0:e.id):$.jsx(jp,{})},Pp=1,Ip=100*1024*1024,Bp=1,Lp=({children:e})=>{const{setFile:t}=zt(),i=n=>t(n[0]);return $.jsx(Rr,{files:[],onFileAccepted:i,maxFileCount:Pp,maxSizeBytes:Ip,minSizeBytes:Bp,maxDurationS:_p,children:e})},Mp=De(Me,{width:"100%",height:"100%",display:"flex",overflow:"hidden",borderRadius:"16px",background:"#ffffff10",flexDirection:"column",alignItems:"stretch",justifyContent:"center"}),zp=De(Me,{paddingTop:"32px",paddingBottom:"16px",alignItems:"center",display:"flex",justifyContent:"center",fontSize:"22px",lineHeight:"1.4em",letterSpacing:"0.01em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:500}),$p=De(Me,{flex:1,gap:"12px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px"}),Np=De("div",{padding:"20px",background:"rgba(255, 255, 255, 0.03)",border:"1px solid transparent",borderRadius:"12px",display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",transition:"background 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.06)"},"&:active":{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"},variants:{selected:{true:{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"}}}}),qp=De("div",{fontSize:"16px",lineHeight:"1.2em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:400}),Wp=De("button",{border:"none",background:"transparent",cursor:"pointer",padding:"0",margin:"0",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center","& > svg":{width:"24px",height:"24px"},color:"#ffffff",position:"relative",transition:"transform 0.2s ease-in-out","&:hover":{transform:"scale(1.1)"}}),Up=({demo:e,onSelect:t,selected:i})=>{const{playPause:n,player:r}=Un(e.audioUrl),o=a=>{a.stopPropagation(),n()};return $.jsxs(Np,{onClick:()=>t(e),selected:i,children:[$.jsx(Wp,{onClick:o,disabled:r.isLoading,children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:r.isLoading,children:$.jsx(kr,{})}),$.jsx(Ie.If,{isTrue:r.isPlaying,children:$.jsx(Cr,{})}),$.jsx(Ie.Else,{children:$.jsx(Or,{})})]})}),$.jsx(qp,{children:e.label})]})},Vp=({demos:e})=>{const{setDemo:t}=zt();return $.jsxs(Mp,{children:[$.jsx(zp,{children:"Select demo audio"}),$.jsx($p,{children:$.jsx(Me,{column:!0,css:{maxWidth:"724px"},children:e.map(i=>$.jsx(Up,{demo:i,onSelect:t},i.id))})})]})};pe.AudioFilePickerRoot=Rr,pe.Box=Me,pe.ConvertStep=rc,pe.DemoPicker=Vp,pe.FilePicker=Lp,pe.GuestConvertProvider=Rp,pe.InferenceProgress=Fp,pe.MIN_RECORDING_LENGTH_MS=Lo,pe.PlayButton=Op,pe.PlayerProvider=jr,pe.RECORDED_AUDIO_NAME=yi,pe.useAudioFilePickerContext=Xs,pe.useFakeProgress=$o,pe.useGuestConvertContext=zt,pe.useMediaQuery=Zo,pe.usePlayback=Un,pe.usePlayer=Ar,pe.usePlayerControls=pc,pe.useRecorder=bp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
|
69
|
+
*/var yo;function Il(){return yo||(yo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function i(A){{for(var R=arguments.length,v=new Array(R>1?R-1:0),O=1;O<R;O++)v[O-1]=arguments[O];n("error",A,v)}}function n(A,R,v){{var O=t.ReactDebugCurrentFrame,L=O.getStackAddendum();L!==""&&(R+="%s",v=v.concat([L]));var j=v.map(function(Y){return String(Y)});j.unshift("Warning: "+R),Function.prototype.apply.call(console[A],console,j)}}function r(A,R){return A===R&&(A!==0||1/A===1/R)||A!==A&&R!==R}var o=typeof Object.is=="function"?Object.is:r,a=e.useState,s=e.useEffect,c=e.useLayoutEffect,p=e.useDebugValue,l=!1,u=!1;function f(A,R,v){l||e.startTransition!==void 0&&(l=!0,i("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var O=R();if(!u){var L=R();o(O,L)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var j=a({inst:{value:O,getSnapshot:R}}),Y=j[0].inst,K=j[1];return c(function(){Y.value=O,Y.getSnapshot=R,x(Y)&&K({inst:Y})},[A,O,R]),s(function(){x(Y)&&K({inst:Y});var re=function(){x(Y)&&K({inst:Y})};return A(re)},[A]),p(O),O}function x(A){var R=A.getSnapshot,v=A.value;try{var O=R();return!o(v,O)}catch{return!0}}function g(A,R,v){return R()}var h=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!h,m=E?g:f,C=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m;ai.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ai}var bo;function Bl(){return bo||(bo=1,process.env.NODE_ENV==="production"?xn.exports=Pl():xn.exports=Il()),xn.exports}var wo=Bl();const et=()=>{},Ae=et(),si=Object,H=e=>e===Ae,$e=e=>typeof e=="function",Ne=(e,t)=>({...e,...t}),Ll=e=>$e(e.then),vn=new WeakMap;let Ml=0;const Bt=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(si(e)===e&&!n&&i!=RegExp){if(r=vn.get(e),r)return r;if(r=++Ml+"~",vn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=Bt(e[o])+",";vn.set(e,r)}if(i==si){r="#";const a=si.keys(e).sort();for(;!H(o=a.pop());)H(e[o])||(r+=o+":"+Bt(e[o])+",");vn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ge=new WeakMap,ci={},gn={},li="undefined",hn=typeof window!=li,pi=typeof document!=li,zl=()=>hn&&typeof window.requestAnimationFrame!=li,ui=(e,t)=>{const i=Ge.get(e);return[()=>!H(t)&&e.get(t)||ci,n=>{if(!H(t)){const r=e.get(t);t in gn||(gn[t]=r),i[5](t,Ne(r,n),r||ci)}},i[6],()=>!H(t)&&t in gn?gn[t]:!H(t)&&e.get(t)||ci]};let di=!0;const $l=()=>di,[fi,mi]=hn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[et,et],Nl=()=>{const e=pi&&document.visibilityState;return H(e)||e!=="hidden"},ql=e=>(pi&&document.addEventListener("visibilitychange",e),fi("focus",e),()=>{pi&&document.removeEventListener("visibilitychange",e),mi("focus",e)}),Wl=e=>{const t=()=>{di=!0,e()},i=()=>{di=!1};return fi("online",t),fi("offline",i),()=>{mi("online",t),mi("offline",i)}},Ul={isOnline:$l,isVisible:Nl},Vl={initFocus:ql,initReconnect:Wl},Lt=!w.useId,dt=!hn||"Deno"in window,Eo=e=>zl()?window.requestAnimationFrame(e):setTimeout(e,1),tt=dt?w.useEffect:w.useLayoutEffect,xi=typeof navigator<"u"&&navigator.connection,So=!dt&&xi&&(["slow-2g","2g"].includes(xi.effectiveType)||xi.saveData),Mt=e=>{if($e(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Bt(e):"",[e,t]};let Hl=0;const Et=()=>++Hl,To=0,Ro=1,ko=2;var Ye={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:To,MUTATE_EVENT:ko,RECONNECT_EVENT:Ro};async function vi(...e){const[t,i,n,r]=e,o=Ne({populateCache:!0,throwOnError:!0},typeof r=="boolean"?{revalidate:r}:r||{});let a=o.populateCache;const s=o.rollbackOnError;let c=o.optimisticData;const p=f=>typeof s=="function"?s(f):s!==!1,l=o.throwOnError;if($e(i)){const f=i,x=[],g=t.keys();for(const h of g)!/^\$(inf|sub)\$/.test(h)&&f(t.get(h)._k)&&x.push(h);return Promise.all(x.map(u))}return u(i);async function u(f){const[x]=Mt(f);if(!x)return;const[g,h]=ui(t,x),[E,m,C,A]=Ge.get(t),R=()=>{const Q=E[x];return($e(o.revalidate)?o.revalidate(g().data,f):o.revalidate!==!1)&&(delete C[x],delete A[x],Q&&Q[0])?Q[0](ko).then(()=>g().data):g().data};if(e.length<3)return R();let v=n,O;const L=Et();m[x]=[L,0];const j=!H(c),Y=g(),K=Y.data,re=Y._c,oe=H(re)?K:re;if(j&&(c=$e(c)?c(oe,K):c,h({data:c,_c:oe})),$e(v))try{v=v(oe)}catch(Q){O=Q}if(v&&Ll(v))if(v=await v.catch(Q=>{O=Q}),L!==m[x][0]){if(O)throw O;return v}else O&&j&&p(O)&&(a=!0,h({data:oe,_c:Ae}));if(a&&!O)if($e(a)){const Q=a(v,oe);h({data:Q,error:Ae,_c:Ae})}else h({data:v,error:Ae,_c:Ae});if(m[x][1]=Et(),Promise.resolve(R()).then(()=>{h({_c:Ae})}),O){if(l)throw O;return}return v}}const Co=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},Gl=(e,t)=>{if(!Ge.has(e)){const i=Ne(Vl,t),n={},r=vi.bind(Ae,e);let o=et;const a={},s=(l,u)=>{const f=a[l]||[];return a[l]=f,f.push(u),()=>f.splice(f.indexOf(u),1)},c=(l,u,f)=>{e.set(l,u);const x=a[l];if(x)for(const g of x)g(u,f)},p=()=>{if(!Ge.has(e)&&(Ge.set(e,[n,{},{},{},r,c,s]),!dt)){const l=i.initFocus(setTimeout.bind(Ae,Co.bind(Ae,n,To))),u=i.initReconnect(setTimeout.bind(Ae,Co.bind(Ae,n,Ro)));o=()=>{l&&l(),u&&u(),Ge.delete(e)}}};return p(),[e,r,p,o]}return[e,Ge.get(e)[4]]},Yl=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!H(o)&&a>o||setTimeout(n,s,r)},Kl=(e,t)=>Bt(e)==Bt(t),[Oo,Jl]=Gl(new Map),Xl=Ne({onLoadingSlow:et,onSuccess:et,onError:et,onErrorRetry:Yl,onDiscarded:et,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:So?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:So?5e3:3e3,compare:Kl,isPaused:()=>!1,cache:Oo,mutate:Jl,fallback:{}},Ul),Zl=(e,t)=>{const i=Ne(e,t);if(t){const{use:n,fallback:r}=e,{use:o,fallback:a}=t;n&&o&&(i.use=n.concat(o)),r&&a&&(i.fallback=Ne(r,a))}return i},Ql=w.createContext({}),ep="$inf$",_o=hn&&window.__SWR_DEVTOOLS_USE__,tp=_o?window.__SWR_DEVTOOLS_USE__:[],np=()=>{_o&&(window.__SWR_DEVTOOLS_REACT__=w)},Ao=e=>$e(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],jo=()=>Ne(Xl,w.useContext(Ql)),ip=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=Mt(t),[,,,s]=Ge.get(Oo);if(a.startsWith(ep))return i(...o);const c=s[a];return H(c)?i(...o):(delete s[a],c)}),n),rp=tp.concat(ip),Do=e=>function(...i){const n=jo(),[r,o,a]=Ao(i),s=Zl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat(rp);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},Fo=(e,t,i)=>{const n=t[e]||(t[e]=[]);return n.push(i),()=>{const r=n.indexOf(i);r>=0&&(n[r]=n[n.length-1],n.pop())}},op=(e,t)=>(...i)=>{const[n,r,o]=Ao(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};np();const Po=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),gi={dedupe:!0},ap=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,g,h,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),R=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,z=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&z),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||R.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!h[m]||!ke.dedupe,ie=()=>Lt?!R.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=h[m];S&&S[1]===V&&delete h[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),h[m]=[I(C),Et()]),[ee,V]=h[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!h[m]||h[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=Ae;const S=g[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(Ae,gi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return R.current=!1,v.current=m,A.current=!0,re({_k:C}),z&&(H(M)||dt?b():Eo(b)),()=>{R.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(gi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,R.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Po(I)}if(H(W)){const I=q(gi);H(J)||(I.status="fulfilled",I.value=!0),Po(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Io=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),hi={dedupe:!0},sp=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,g,h,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),R=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,z=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&z),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||R.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!h[m]||!ke.dedupe,ie=()=>Lt?!R.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=h[m];S&&S[1]===V&&delete h[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),h[m]=[I(C),Et()]),[ee,V]=h[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!h[m]||h[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=Ae;const S=g[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(Ae,hi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return R.current=!1,v.current=m,A.current=!0,re({_k:C}),z&&(H(M)||dt?b():Eo(b)),()=>{R.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(hi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,R.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Io(I)}if(H(W)){const I=q(hi);H(J)||(I.status="fulfilled",I.value=!0),Io(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Bo=Lt?e=>{e()}:w.startTransition,cp=e=>{const[,t]=w.useState({}),i=w.useRef(!1),n=w.useRef(e),r=w.useRef({data:!1,error:!1,isValidating:!1}),o=w.useCallback(a=>{let s=!1;const c=n.current;for(const p in a){const l=p;c[l]!==a[l]&&(c[l]=a[l],r.current[l]&&(s=!0))}s&&!i.current&&t({})},[]);return tt(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},lp=op(sp,()=>(e,t,i={})=>{const{mutate:n}=jo(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=cp({data:Ae,error:Ae,isMutating:!1}),u=c.current,f=w.useCallback(async(g,h)=>{const[E,m]=Mt(r.current);if(!o.current)throw new Error("Can’t trigger the mutation: missing fetcher.");if(!E)throw new Error("Can’t trigger the mutation: missing key.");const C=Ne(Ne({populateCache:!1,throwOnError:!0},a.current),h),A=Et();s.current=A,l({isMutating:!0});try{const R=await n(E,o.current(m,{arg:g}),Ne(C,{throwOnError:!0}));return s.current<=A&&(Bo(()=>l({data:R,isMutating:!1,error:void 0})),C.onSuccess==null||C.onSuccess.call(C,R,E,C)),R}catch(R){if(s.current<=A&&(Bo(()=>l({error:R,isMutating:!1})),C.onError==null||C.onError.call(C,R,E,C),C.throwOnError))throw R}},[]),x=w.useCallback(()=>{s.current=Et(),l({data:Ae,error:Ae,isMutating:!1})},[]);return tt(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:x,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),pp=e=>{const t=r=>typeof r=="object"&&!(r instanceof Date)&&!(r instanceof File)&&r!==null,i=(r,o,a)=>{for(const s in o){const c=o[s];t(c)?i(`${r}[${s}]`,c,a):c!==void 0&&a.append(`${r}[${s}]`,c===null?"":c)}},n=new FormData;for(const r in e){const o=e[r];o instanceof File?n.append(r,o,o.name):o!==void 0&&(t(o)?i(r,o,n):n.append(r,o===null?"":o))}return n},up=De("div",{"--progress":"-100%",height:"4px",width:"100%",background:"rgba(255, 255, 255, 0.1)",borderRadius:"12px",position:"relative",overflow:"hidden"}),dp=De("div",{height:"100%",width:"100%",background:"#ffffff",transform:"translateX(var(--progress))",borderRadius:"12px"}),nt={Root:up,Bar:dp};function yn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function bn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ft(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255,t[i+2]=e>>16&255,t[i+3]=e>>24&255}function fp(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function mp(e,t,i,n){let r=0,o=0;const a=e.length,s=e.numberOfChannels;let c,p;for(r=0;r<a;++r)for(o=0;o<s;++o)if(c=e.getChannelData(o),n===16)p=c[r]*32768,p=Math.max(-32768,Math.min(p,32767)),bn(p,t,i),i+=2;else if(n===32)p=fp(c[r]),ft(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function xp(e,t){let i=e instanceof Blob?e:new Blob(e);const n=URL.createObjectURL(i),o=await(await fetch(n)).arrayBuffer();return await new AudioContext(t).decodeAudioData(o)}async function vp(e,t=!1){const i=e.length,n=e.numberOfChannels,r=e.sampleRate,o=t?32:16,a=o/8,s=r*n*o/8,c=n*o/8,p=i*n*a,u=44+p,f=new Uint8Array(u),x=16,g=p,h=4+(8+x)+(8+g);return yn("RIFF",f,0),ft(h,f,4),yn("WAVE",f,8),yn("fmt ",f,12),ft(x,f,16),bn(t?3:1,f,20),bn(n,f,22),ft(r,f,24),ft(s,f,28),bn(c,f,32),ft(o,f,34),yn("data",f,36),ft(g,f,40),mp(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function gp(e,t=!1,i){const n=await xp(e,i);return vp(n,t)}const hp=128;class yp{constructor(){En(this,"mediaRecorder",null);En(this,"stream",null);En(this,"__data",null)}async checkMicrophonePermission(){var n;return!!(await((n=navigator==null?void 0:navigator.mediaDevices)==null?void 0:n.enumerateDevices())).find(r=>r.kind==="audioinput"&&!!r.label)}async startRecording(){var t;if(((t=this.mediaRecorder)==null?void 0:t.state)==="recording")return!0;try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.mediaRecorder=new MediaRecorder(this.stream,{bitsPerSecond:hp*1e3}),this.mediaRecorder.ondataavailable=i=>this.__data=i.data}catch(i){return console.error(i),!1}return this.mediaRecorder.start(),!0}stopRecording(){return new Promise(t=>{var i;if(((i=this.mediaRecorder)==null?void 0:i.state)!=="recording"){t(!0);return}this.mediaRecorder.stop(),this.mediaRecorder.onstop=()=>{var n;(n=this.stream)==null||n.getTracks().forEach(r=>r.stop()),this.mediaRecorder=null,this.stream=null,t(!0)}})}async getWavBlob(){return this.__data?await gp(this.__data):null}}const wn=new yp,yi="Recording.wav",Lo=1500,bp=e=>{const[t,i]=w.useState(!1),[n,r]=w.useState(!1),[o,a]=w.useState(!1);return w.useEffect(()=>{var p;const c=async()=>{wn.checkMicrophonePermission().then(i)};return c(),(p=navigator==null?void 0:navigator.mediaDevices)==null||p.addEventListener("devicechange",c),()=>{var l;return(l=navigator==null?void 0:navigator.mediaDevices)==null?void 0:l.removeEventListener("devicechange",c)}},[]),{hasMicAccess:t,isRecording:n,hasMinTimeElapsed:o,handleClick:async()=>{if(n){if(!o)return;r(!1),a(!1),await wn.stopRecording();const p=await wn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],yi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await wn.startRecording();r(c),setTimeout(()=>{a(!0)},Lo)}}},Mo=_e.create({baseURL:"https://arpeggi.io/api/v2/"}),wp=async(e,{arg:t})=>{var n;return(await Mo.post("/ml-inference-jobs",pp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,strapiDemoId:t.strapiDemoId,metadata:{isRecordedAudio:((n=t.file)==null?void 0:n.name)===yi}}),{params:{type:"audio"}})).data},Ep=async e=>e===null?null:(await Mo.get(e)).data,Sp=e=>{const t=e>0;return ap(t?`/ml-inference-jobs/${e}`:null,Ep,{refreshInterval:i=>(i==null?void 0:i.jobStatus)==="success"?0:1e3})},Tp=()=>{const[e,t]=w.useState("file"),[i,n]=w.useState(void 0),[r,o]=w.useState(void 0),[a,s]=w.useState(0),[c,p]=w.useState(0),{data:l,isLoading:u}=Sp(a),{trigger:f,isMutating:x}=lp("/ml-inference-jobs",wp),[g,h]=w.useState(!1);return{demo:i,setDemo:n,file:r,setFile:o,mlijId:a,setMlijId:s,voiceModelId:c,setVoiceModelId:p,data:l,isLoading:u,handleSelectVoice:async A=>{if(!(!r&&!i)){if(s(0),p(A),i){h(!0),setTimeout(()=>{h(!1)},1e3);return}f({file:r,voiceModelId:A},{onSuccess:R=>{console.log("created mlij",R),s(R.id)}})}},reset:()=>{t("file"),n(void 0),o(void 0),s(0),p(0)},isMutating:x||g,step:e,setStep:t}},zo=w.createContext({}),zt=()=>w.useContext(zo),Rp=({children:e})=>{const t=Tp();return $.jsx(jr,{children:$.jsx(zo.Provider,{value:t,children:e})})},kp=De("button",{background:"#ffffff",flexShrink:0,borderRadius:"12px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out, transform 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99",transform:"scale(1.05)"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"rgba(255, 255, 255, 0.3)",transform:"none",cursor:"not-allowed"}}),Cp=De("div",{fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"#ffffff",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400}),Op=e=>{var u;const{data:t,isMutating:i,demo:n,voiceModelId:r}=zt(),a=(n==null?void 0:n.cachedResults[r])||((u=t==null?void 0:t.lossyOutputFile)==null?void 0:u.url),{player:s,playPause:c}=Un(a),p=w.useRef(null),l=w.useRef();return w.useEffect(()=>{if(!s.isPlaying)return()=>{cancelAnimationFrame(l.current)};const f=()=>{var g;const x=s.audioRef.current.currentTime/s.audioRef.current.duration;(g=p.current)==null||g.style.setProperty("--progress",`${-100+x*100}%`),l.current=requestAnimationFrame(f)};return l.current=requestAnimationFrame(f),()=>{cancelAnimationFrame(l.current)}},[s.isPlaying,s.audioRef]),$.jsxs(Me,{row:!0,align:"center",flex:"1",gap:"16",...e,children:[$.jsx(kp,{onClick:c,disabled:s.isLoading||!a,children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:s.isLoading||(t==null?void 0:t.jobStatus)==="running"||i,children:$.jsx(kr,{})}),$.jsx(Ie.If,{isTrue:s.isPlaying,children:$.jsx(Cr,{})}),$.jsx(Ie.Else,{children:$.jsx(Or,{})})]})}),$.jsxs(Me,{flex:"1",column:!0,gap:"12",children:[$.jsx(Cp,{children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:(t==null?void 0:t.jobStatus)==="running",children:"Converting audio"}),$.jsx(Ie.If,{isTrue:i,children:"Uploading audio"}),$.jsx(Ie.Else,{children:"Converted audio"})]})}),$.jsx(nt.Root,{ref:p,children:$.jsx(nt.Bar,{})})]})]})},_p=30,$o=e=>{const t=w.useRef(),i=w.useRef(null);return w.useEffect(()=>{let n=0;return t.current=setInterval(()=>{var o;n+=e;let r=Math.round(Math.atan(n)/(Math.PI/2)*100*1e3)/1e3;(o=i.current)==null||o.style.setProperty("--progress",`${-100+r}%`)},50),()=>clearInterval(t.current)},[]),i},Ap=()=>{const e=$o(.1);return $.jsx(nt.Root,{ref:e,children:$.jsx(nt.Bar,{})})},jp=()=>$.jsx(nt.Root,{children:$.jsx(nt.Bar,{})}),Dp=()=>$.jsx(nt.Root,{style:{"--progress":"0%"},children:$.jsx(nt.Bar,{})}),Fp=()=>{const{data:e}=zt();return e?e.jobStatus==="success"?$.jsx(Dp,{}):$.jsx(Ap,{},e==null?void 0:e.id):$.jsx(jp,{})},Pp=1,Ip=100*1024*1024,Bp=1,Lp=({children:e})=>{const{setFile:t}=zt(),i=n=>t(n[0]);return $.jsx(Rr,{files:[],onFileAccepted:i,maxFileCount:Pp,maxSizeBytes:Ip,minSizeBytes:Bp,maxDurationS:_p,children:e})},Mp=De(Me,{width:"100%",height:"100%",display:"flex",overflow:"hidden",borderRadius:"16px",background:"#ffffff10",flexDirection:"column",alignItems:"stretch",justifyContent:"center"}),zp=De(Me,{paddingTop:"32px",paddingBottom:"16px",alignItems:"center",display:"flex",justifyContent:"center",fontSize:"22px",lineHeight:"1.4em",letterSpacing:"0.01em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:500}),$p=De(Me,{flex:1,gap:"12px",display:"flex",flexDirection:"column",alignItems:"stretch",justifyContent:"center",padding:"32px"}),Np=De("div",{padding:"20px",background:"rgba(255, 255, 255, 0.03)",border:"1px solid transparent",borderRadius:"12px",display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",transition:"background 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.06)"},"&:active":{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"},variants:{selected:{true:{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"}}}}),qp=De("div",{fontSize:"16px",lineHeight:"1.2em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:400}),Wp=De("button",{border:"none",background:"transparent",cursor:"pointer",padding:"0",margin:"0",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center","& > svg":{width:"24px",height:"24px"},color:"#ffffff",position:"relative",transition:"transform 0.2s ease-in-out","&:hover":{transform:"scale(1.1)"}}),Up=({demo:e,onSelect:t,selected:i})=>{const{playPause:n,player:r}=Un(e.audioUrl),o=a=>{a.stopPropagation(),n()};return $.jsxs(Np,{onClick:()=>t(e),selected:i,children:[$.jsx(Wp,{onClick:o,disabled:r.isLoading,children:$.jsxs(Ie,{children:[$.jsx(Ie.If,{isTrue:r.isLoading,children:$.jsx(kr,{})}),$.jsx(Ie.If,{isTrue:r.isPlaying,children:$.jsx(Cr,{})}),$.jsx(Ie.Else,{children:$.jsx(Or,{})})]})}),$.jsx(qp,{children:e.label})]})},Vp=({demos:e})=>{const{setDemo:t}=zt();return $.jsxs(Mp,{children:[$.jsx(zp,{children:"Select demo audio"}),$.jsx($p,{children:$.jsx(Me,{column:!0,css:{maxWidth:"724px"},children:e.map(i=>$.jsx(Up,{demo:i,onSelect:t},i.id))})})]})};pe.AudioFilePickerRoot=Rr,pe.Box=Me,pe.ConvertStep=rc,pe.DemoPicker=Vp,pe.FilePicker=Lp,pe.GuestConvertProvider=Rp,pe.InferenceProgress=Fp,pe.MIN_RECORDING_LENGTH_MS=Lo,pe.PlayButton=Op,pe.PlayerProvider=jr,pe.RECORDED_AUDIO_NAME=yi,pe.useAudioFilePickerContext=Xs,pe.useFakeProgress=$o,pe.useGuestConvertContext=zt,pe.useMediaQuery=Zo,pe.usePlayback=Un,pe.usePlayer=Ar,pe.usePlayerControls=pc,pe.useRecorder=bp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
|
70
70
|
//# sourceMappingURL=index.umd.js.map
|