arpeggi-framer-components 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +5 -5
- 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 oo;function gl(){return oo||(oo=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(_){{for(var k=arguments.length,b=new Array(k>1?k-1:0),j=1;j<k;j++)b[j-1]=arguments[j];n("error",_,b)}}function n(_,k,b){{var j=t.ReactDebugCurrentFrame,q=j.getStackAddendum();q!==""&&(k+="%s",b=b.concat([q]));var F=b.map(function(Y){return String(Y)});F.unshift("Warning: "+k),Function.prototype.apply.call(console[_],console,F)}}function r(_,k){return _===k&&(_!==0||1/_===1/k)||_!==_&&k!==k}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(_,k,b){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 j=k();if(!u){var q=k();o(j,q)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var F=a({inst:{value:j,getSnapshot:k}}),Y=F[0].inst,H=F[1];return c(function(){Y.value=j,Y.getSnapshot=k,m(Y)&&H({inst:Y})},[_,j,k]),s(function(){m(Y)&&H({inst:Y});var oe=function(){m(Y)&&H({inst:Y})};return _(oe)},[_]),p(j),j}function m(_){var k=_.getSnapshot,b=_.value;try{var j=k();return!o(b,j)}catch{return!0}}function v(_,k,b){return k()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!g,x=E?v:f,O=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x;ei.useSyncExternalStore=O,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ei}var ao;function hl(){return ao||(ao=1,process.env.NODE_ENV==="production"?dn.exports=vl():dn.exports=gl()),dn.exports}var so=hl();const Ze=()=>{},Ae=Ze(),ti=Object,N=e=>e===Ae,ze=e=>typeof e=="function",Le=(e,t)=>({...e,...t}),yl=e=>ze(e.then),fn=new WeakMap;let bl=0;const It=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(ti(e)===e&&!n&&i!=RegExp){if(r=fn.get(e),r)return r;if(r=++bl+"~",fn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=It(e[o])+",";fn.set(e,r)}if(i==ti){r="#";const a=ti.keys(e).sort();for(;!N(o=a.pop());)N(e[o])||(r+=o+":"+It(e[o])+",");fn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ue=new WeakMap,ni={},mn={},ii="undefined",xn=typeof window!=ii,ri=typeof document!=ii,wl=()=>xn&&typeof window.requestAnimationFrame!=ii,oi=(e,t)=>{const i=Ue.get(e);return[()=>!N(t)&&e.get(t)||ni,n=>{if(!N(t)){const r=e.get(t);t in mn||(mn[t]=r),i[5](t,Le(r,n),r||ni)}},i[6],()=>!N(t)&&t in mn?mn[t]:!N(t)&&e.get(t)||ni]};let ai=!0;const El=()=>ai,[si,ci]=xn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ze,Ze],Sl=()=>{const e=ri&&document.visibilityState;return N(e)||e!=="hidden"},Rl=e=>(ri&&document.addEventListener("visibilitychange",e),si("focus",e),()=>{ri&&document.removeEventListener("visibilitychange",e),ci("focus",e)}),Tl=e=>{const t=()=>{ai=!0,e()},i=()=>{ai=!1};return si("online",t),si("offline",i),()=>{ci("online",t),ci("offline",i)}},kl={isOnline:El,isVisible:Sl},Ol={initFocus:Rl,initReconnect:Tl},Bt=!w.useId,lt=!xn||"Deno"in window,co=e=>wl()?window.requestAnimationFrame(e):setTimeout(e,1),Qe=lt?w.useEffect:w.useLayoutEffect,li=typeof navigator<"u"&&navigator.connection,lo=!lt&&li&&(["slow-2g","2g"].includes(li.effectiveType)||li.saveData),zt=e=>{if(ze(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?It(e):"",[e,t]};let Cl=0;const wt=()=>++Cl,po=0,uo=1,fo=2;var Ve={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:po,MUTATE_EVENT:fo,RECONNECT_EVENT:uo};async function pi(...e){const[t,i,n,r]=e,o=Le({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(ze(i)){const f=i,m=[],v=t.keys();for(const g of v)!/^\$(inf|sub)\$/.test(g)&&f(t.get(g)._k)&&m.push(g);return Promise.all(m.map(u))}return u(i);async function u(f){const[m]=zt(f);if(!m)return;const[v,g]=oi(t,m),[E,x,O,_]=Ue.get(t),k=()=>{const ne=E[m];return(ze(o.revalidate)?o.revalidate(v().data,f):o.revalidate!==!1)&&(delete O[m],delete _[m],ne&&ne[0])?ne[0](fo).then(()=>v().data):v().data};if(e.length<3)return k();let b=n,j;const q=wt();x[m]=[q,0];const F=!N(c),Y=v(),H=Y.data,oe=Y._c,ve=N(oe)?H:oe;if(F&&(c=ze(c)?c(ve,H):c,g({data:c,_c:ve})),ze(b))try{b=b(ve)}catch(ne){j=ne}if(b&&yl(b))if(b=await b.catch(ne=>{j=ne}),q!==x[m][0]){if(j)throw j;return b}else j&&F&&p(j)&&(a=!0,g({data:ve,_c:Ae}));if(a&&!j)if(ze(a)){const ne=a(b,ve);g({data:ne,error:Ae,_c:Ae})}else g({data:b,error:Ae,_c:Ae});if(x[m][1]=wt(),Promise.resolve(k()).then(()=>{g({_c:Ae})}),j){if(l)throw j;return}return b}}const mo=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},_l=(e,t)=>{if(!Ue.has(e)){const i=Le(Ol,t),n={},r=pi.bind(Ae,e);let o=Ze;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 m=a[l];if(m)for(const v of m)v(u,f)},p=()=>{if(!Ue.has(e)&&(Ue.set(e,[n,{},{},{},r,c,s]),!lt)){const l=i.initFocus(setTimeout.bind(Ae,mo.bind(Ae,n,po))),u=i.initReconnect(setTimeout.bind(Ae,mo.bind(Ae,n,uo)));o=()=>{l&&l(),u&&u(),Ue.delete(e)}}};return p(),[e,r,p,o]}return[e,Ue.get(e)[4]]},Al=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!N(o)&&a>o||setTimeout(n,s,r)},Dl=(e,t)=>It(e)==It(t),[xo,jl]=_l(new Map),Fl=Le({onLoadingSlow:Ze,onSuccess:Ze,onError:Ze,onErrorRetry:Al,onDiscarded:Ze,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:lo?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:lo?5e3:3e3,compare:Dl,isPaused:()=>!1,cache:xo,mutate:jl,fallback:{}},kl),Pl=(e,t)=>{const i=Le(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=Le(r,a))}return i},Il=w.createContext({}),Bl="$inf$",vo=xn&&window.__SWR_DEVTOOLS_USE__,zl=vo?window.__SWR_DEVTOOLS_USE__:[],Ll=()=>{vo&&(window.__SWR_DEVTOOLS_REACT__=w)},go=e=>ze(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],ho=()=>Le(Fl,w.useContext(Il)),Ml=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=zt(t),[,,,s]=Ue.get(xo);if(a.startsWith(Bl))return i(...o);const c=s[a];return N(c)?i(...o):(delete s[a],c)}),n),$l=zl.concat(Ml),yo=e=>function(...i){const n=ho(),[r,o,a]=go(i),s=Pl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat($l);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},bo=(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())}},Nl=(e,t)=>(...i)=>{const[n,r,o]=go(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};Ll();const wo=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)}),ui={dedupe:!0},ql=yo((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,[m,v,g,E]=Ue.get(n),[x,O]=zt(e),_=w.useRef(!1),k=w.useRef(!1),b=w.useRef(x),j=w.useRef(t),q=w.useRef(i),F=()=>q.current,Y=()=>F().isVisible()&&F().isOnline(),[H,oe,ve,ne]=oi(n,x),V=w.useRef({}).current,pe=N(a)?i.fallback[x]:a,Re=(y,P)=>{for(const X in V){const $=X;if($==="data"){if(!r(y[$],P[$])&&(!N(y[$])||!r(G,P[$])))return!1}else if(P[$]!==y[$])return!1}return!0},Te=w.useMemo(()=>{const y=!x||!t?!1:N(s)?F().isPaused()||o?!1:N(c)?!0:c:s,P=ee=>{const we=Le(ee);return delete we._k,y?{isValidating:!0,isLoading:!0,...we}:we},X=H(),$=ne(),de=P(X),ke=X===$?de:P($);let Q=de;return[()=>{const ee=P(H());return Re(ee,Q)?(Q.data=ee.data,Q.isLoading=ee.isLoading,Q.isValidating=ee.isValidating,Q.error=ee.error,Q):(Q=ee,ee)},()=>ke]},[n,x]),ue=so.useSyncExternalStore(w.useCallback(y=>ve(x,(P,X)=>{Re(X,P)||y()}),[n,x]),Te[0],Te[1]),be=!_.current,R=m[x]&&m[x].length>0,C=ue.data,B=N(C)?pe:C,W=ue.error,z=w.useRef(B),G=f?N(C)?z.current:C:B,L=R&&!N(W)?!1:be&&!N(s)?s:F().isPaused()?!1:o?N(B)?!1:c:N(B)||c,U=!!(x&&t&&be&&L),J=N(ue.isValidating)?U:ue.isValidating,te=N(ue.isLoading)?U:ue.isLoading,M=w.useCallback(async y=>{const P=j.current;if(!x||!P||k.current||F().isPaused())return!1;let X,$,de=!0;const ke=y||{},Q=!g[x]||!ke.dedupe,ee=()=>Bt?!k.current&&x===b.current&&_.current:x===b.current,we={isValidating:!1,isLoading:!1},Ye=()=>{oe(we)},Ne=()=>{const S=g[x];S&&S[1]===$&&delete g[x]},Ke={isValidating:!0};N(H().data)&&(Ke.isLoading=!0);try{if(Q&&(oe(Ke),i.loadingTimeout&&N(H().data)&&setTimeout(()=>{de&&ee()&&F().onLoadingSlow(x,i)},i.loadingTimeout),g[x]=[P(O),wt()]),[X,$]=g[x],X=await X,Q&&setTimeout(Ne,i.dedupingInterval),!g[x]||g[x][1]!==$)return Q&&ee()&&F().onDiscarded(x),!1;we.error=Ae;const S=v[x];if(!N(S)&&($<=S[0]||$<=S[1]||S[1]===0))return Ye(),Q&&ee()&&F().onDiscarded(x),!1;const A=H().data;we.data=r(A,X)?A:X,Q&&ee()&&F().onSuccess(X,x,i)}catch(S){Ne();const A=F(),{shouldRetryOnError:ae}=A;A.isPaused()||(we.error=S,Q&&ee()&&(A.onError(S,x,A),(ae===!0||ze(ae)&&ae(S))&&(!F().revalidateOnFocus||!F().revalidateOnReconnect||Y())&&A.onErrorRetry(S,x,A,me=>{const Oe=m[x];Oe&&Oe[0]&&Oe[0](Ve.ERROR_REVALIDATE_EVENT,me)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return de=!1,Ye(),!0},[x,n]),ge=w.useCallback((...y)=>pi(n,b.current,...y),[]);if(Qe(()=>{j.current=t,q.current=i,N(C)||(z.current=C)}),Qe(()=>{if(!x)return;const y=M.bind(Ae,ui);let P=0;const $=bo(x,m,(de,ke={})=>{if(de==Ve.FOCUS_EVENT){const Q=Date.now();F().revalidateOnFocus&&Q>P&&Y()&&(P=Q+F().focusThrottleInterval,y())}else if(de==Ve.RECONNECT_EVENT)F().revalidateOnReconnect&&Y()&&y();else{if(de==Ve.MUTATE_EVENT)return M();if(de==Ve.ERROR_REVALIDATE_EVENT)return M(ke)}});return k.current=!1,b.current=x,_.current=!0,oe({_k:O}),L&&(N(B)||lt?y():co(y)),()=>{k.current=!0,$()}},[x]),Qe(()=>{let y;function P(){const $=ze(p)?p(H().data):p;$&&y!==-1&&(y=setTimeout(X,$))}function X(){!H().error&&(l||F().isVisible())&&(u||F().isOnline())?M(ui).then(P):P()}return P(),()=>{y&&(clearTimeout(y),y=-1)}},[p,l,u,x]),w.useDebugValue(G),o&&N(B)&&x){if(!Bt&<)throw new Error("Fallback data is required when using suspense in SSR.");j.current=t,q.current=i,k.current=!1;const y=E[x];if(!N(y)){const P=ge(y);wo(P)}if(N(W)){const P=M(ui);N(G)||(P.status="fulfilled",P.value=!0),wo(P)}else throw W}return{mutate:ge,get data(){return V.data=!0,G},get error(){return V.error=!0,W},get isValidating(){return V.isValidating=!0,J},get isLoading(){return V.isLoading=!0,te}}}),Eo=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)}),di={dedupe:!0},Wl=yo((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,[m,v,g,E]=Ue.get(n),[x,O]=zt(e),_=w.useRef(!1),k=w.useRef(!1),b=w.useRef(x),j=w.useRef(t),q=w.useRef(i),F=()=>q.current,Y=()=>F().isVisible()&&F().isOnline(),[H,oe,ve,ne]=oi(n,x),V=w.useRef({}).current,pe=N(a)?i.fallback[x]:a,Re=(y,P)=>{for(const X in V){const $=X;if($==="data"){if(!r(y[$],P[$])&&(!N(y[$])||!r(G,P[$])))return!1}else if(P[$]!==y[$])return!1}return!0},Te=w.useMemo(()=>{const y=!x||!t?!1:N(s)?F().isPaused()||o?!1:N(c)?!0:c:s,P=ee=>{const we=Le(ee);return delete we._k,y?{isValidating:!0,isLoading:!0,...we}:we},X=H(),$=ne(),de=P(X),ke=X===$?de:P($);let Q=de;return[()=>{const ee=P(H());return Re(ee,Q)?(Q.data=ee.data,Q.isLoading=ee.isLoading,Q.isValidating=ee.isValidating,Q.error=ee.error,Q):(Q=ee,ee)},()=>ke]},[n,x]),ue=so.useSyncExternalStore(w.useCallback(y=>ve(x,(P,X)=>{Re(X,P)||y()}),[n,x]),Te[0],Te[1]),be=!_.current,R=m[x]&&m[x].length>0,C=ue.data,B=N(C)?pe:C,W=ue.error,z=w.useRef(B),G=f?N(C)?z.current:C:B,L=R&&!N(W)?!1:be&&!N(s)?s:F().isPaused()?!1:o?N(B)?!1:c:N(B)||c,U=!!(x&&t&&be&&L),J=N(ue.isValidating)?U:ue.isValidating,te=N(ue.isLoading)?U:ue.isLoading,M=w.useCallback(async y=>{const P=j.current;if(!x||!P||k.current||F().isPaused())return!1;let X,$,de=!0;const ke=y||{},Q=!g[x]||!ke.dedupe,ee=()=>Bt?!k.current&&x===b.current&&_.current:x===b.current,we={isValidating:!1,isLoading:!1},Ye=()=>{oe(we)},Ne=()=>{const S=g[x];S&&S[1]===$&&delete g[x]},Ke={isValidating:!0};N(H().data)&&(Ke.isLoading=!0);try{if(Q&&(oe(Ke),i.loadingTimeout&&N(H().data)&&setTimeout(()=>{de&&ee()&&F().onLoadingSlow(x,i)},i.loadingTimeout),g[x]=[P(O),wt()]),[X,$]=g[x],X=await X,Q&&setTimeout(Ne,i.dedupingInterval),!g[x]||g[x][1]!==$)return Q&&ee()&&F().onDiscarded(x),!1;we.error=Ae;const S=v[x];if(!N(S)&&($<=S[0]||$<=S[1]||S[1]===0))return Ye(),Q&&ee()&&F().onDiscarded(x),!1;const A=H().data;we.data=r(A,X)?A:X,Q&&ee()&&F().onSuccess(X,x,i)}catch(S){Ne();const A=F(),{shouldRetryOnError:ae}=A;A.isPaused()||(we.error=S,Q&&ee()&&(A.onError(S,x,A),(ae===!0||ze(ae)&&ae(S))&&(!F().revalidateOnFocus||!F().revalidateOnReconnect||Y())&&A.onErrorRetry(S,x,A,me=>{const Oe=m[x];Oe&&Oe[0]&&Oe[0](Ve.ERROR_REVALIDATE_EVENT,me)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return de=!1,Ye(),!0},[x,n]),ge=w.useCallback((...y)=>pi(n,b.current,...y),[]);if(Qe(()=>{j.current=t,q.current=i,N(C)||(z.current=C)}),Qe(()=>{if(!x)return;const y=M.bind(Ae,di);let P=0;const $=bo(x,m,(de,ke={})=>{if(de==Ve.FOCUS_EVENT){const Q=Date.now();F().revalidateOnFocus&&Q>P&&Y()&&(P=Q+F().focusThrottleInterval,y())}else if(de==Ve.RECONNECT_EVENT)F().revalidateOnReconnect&&Y()&&y();else{if(de==Ve.MUTATE_EVENT)return M();if(de==Ve.ERROR_REVALIDATE_EVENT)return M(ke)}});return k.current=!1,b.current=x,_.current=!0,oe({_k:O}),L&&(N(B)||lt?y():co(y)),()=>{k.current=!0,$()}},[x]),Qe(()=>{let y;function P(){const $=ze(p)?p(H().data):p;$&&y!==-1&&(y=setTimeout(X,$))}function X(){!H().error&&(l||F().isVisible())&&(u||F().isOnline())?M(di).then(P):P()}return P(),()=>{y&&(clearTimeout(y),y=-1)}},[p,l,u,x]),w.useDebugValue(G),o&&N(B)&&x){if(!Bt&<)throw new Error("Fallback data is required when using suspense in SSR.");j.current=t,q.current=i,k.current=!1;const y=E[x];if(!N(y)){const P=ge(y);Eo(P)}if(N(W)){const P=M(di);N(G)||(P.status="fulfilled",P.value=!0),Eo(P)}else throw W}return{mutate:ge,get data(){return V.data=!0,G},get error(){return V.error=!0,W},get isValidating(){return V.isValidating=!0,J},get isLoading(){return V.isLoading=!0,te}}}),So=Bt?e=>{e()}:w.startTransition,Ul=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 Qe(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},Vl=Nl(Wl,()=>(e,t,i={})=>{const{mutate:n}=ho(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=Ul({data:Ae,error:Ae,isMutating:!1}),u=c.current,f=w.useCallback(async(v,g)=>{const[E,x]=zt(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 O=Le(Le({populateCache:!1,throwOnError:!0},a.current),g),_=wt();s.current=_,l({isMutating:!0});try{const k=await n(E,o.current(x,{arg:v}),Le(O,{throwOnError:!0}));return s.current<=_&&(So(()=>l({data:k,isMutating:!1,error:void 0})),O.onSuccess==null||O.onSuccess.call(O,k,E,O)),k}catch(k){if(s.current<=_&&(So(()=>l({error:k,isMutating:!1})),O.onError==null||O.onError.call(O,k,E,O),O.throwOnError))throw k}},[]),m=w.useCallback(()=>{s.current=wt(),l({data:Ae,error:Ae,isMutating:!1})},[]);return Qe(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:m,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),Hl=e=>Ee.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",...e,children:[Ee.jsx("path",{opacity:"0.15",d:"M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"}),Ee.jsx("path",{d:"M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2",strokeLinecap:"round"})]}),Gl=ga({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Yl=Ge(Hl,{animation:`${Gl} 2s linear infinite`,variants:{size:{sm:{width:"16px",height:"16px",strokeWidth:"1px"},md:{width:"24px",height:"24px",strokeWidth:"1.5px"},lg:{width:"32px",height:"32px",strokeWidth:"2px"}}}}),Kl=e=>Ee.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Ee.jsx("path",{d:"M6.04995 2.74998C6.04995 2.44623 5.80371 2.19998 5.49995 2.19998C5.19619 2.19998 4.94995 2.44623 4.94995 2.74998V12.25C4.94995 12.5537 5.19619 12.8 5.49995 12.8C5.80371 12.8 6.04995 12.5537 6.04995 12.25V2.74998ZM10.05 2.74998C10.05 2.44623 9.80371 2.19998 9.49995 2.19998C9.19619 2.19998 8.94995 2.44623 8.94995 2.74998V12.25C8.94995 12.5537 9.19619 12.8 9.49995 12.8C9.80371 12.8 10.05 12.5537 10.05 12.25V2.74998Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})}),Jl=({...e})=>Ee.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",xmlns:"http://www.w3.orkllg/2000/svg",fill:"currentColor",...e,children:Ee.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.1869 3.71487C5.42703 3.57009 5.72543 3.56159 5.9734 3.69247L20.3734 11.2925C20.6358 11.431 20.8 11.7033 20.8 12C20.8 12.2967 20.6358 12.569 20.3734 12.7075L5.9734 20.3075C5.72543 20.4384 5.42703 20.4299 5.1869 20.2851C4.94679 20.1403 4.79999 19.8803 4.79999 19.6V4.39998C4.79999 4.11959 4.94679 3.85966 5.1869 3.71487Z",fill:"currentColor"})}),Xl=e=>{if(!e)return!1;const t=e.split("?")[1];if(!t)return!1;const n=new URLSearchParams(t).get("Expires");return n?new Date(n)<new Date:!1},Ro=e=>e&&e.split("?")[0],Zl=(e,t)=>Ro(e)===Ro(t),Ql=()=>{const[e,t]=w.useState("paused"),i=()=>{if(typeof window>"u")return null;const p=new Audio;return p.addEventListener("play",()=>t("playing")),p},n=w.useMemo(i,[]),r=w.useRef(n);return{audioRef:r,state:e,setAudio:p=>new Promise(l=>{const u=r==null?void 0:r.current;u&&(u.setAttribute("src",p),t("loading"),u.addEventListener("loadedmetadata",()=>{t("paused"),l()},{once:!0}))}),play:()=>{var p,l;(p=r.current)==null||p.play(),(l=r.current)==null||l.addEventListener("ended",()=>t("paused"),{once:!0})},pause:()=>{var p;(p=r.current)==null||p.pause(),t("paused")},stop:()=>{var l;r.current&&((l=r.current)==null||l.pause(),r.current.currentTime=0),t("paused")}}},fi=w.createContext(null),To=e=>{var a;const t=w.useContext(fi),i=Zl((a=t.audioRef.current)==null?void 0:a.src,e),n=t.state==="loading"&&i,r=t.state==="playing"&&i;return{...t,isMySrc:i,isLoading:n,isPlaying:r,play:async()=>{var c;const s=(c=t.audioRef.current)==null?void 0:c.src;(!i||Xl(s))&&await t.setAudio(e),t.play()}}},ep=()=>w.useContext(fi),ko=({children:e})=>{const t=Ql();return Ee.jsx(fi.Provider,{value:t,children:e})},Oo=(e,t,i)=>{const n=To(e),r=w.useRef(!1),o=()=>{r.current||(r.current=!0),n.isPlaying?(n.pause(),i==null||i()):(n.play(),t==null||t())};return w.useEffect(()=>()=>{n.isPlaying&&n.pause()},[]),{player:n,playPause:o}},pt=({limit:e,isTrue:t,children:i})=>{const n=[];return t!==!0?null:(Mo.Children.map(i,r=>{const{isTrue:o}=(r==null?void 0:r.props)||{};o===!0&&(!e||n.length<e)&&n.push(r)}),Ee.jsx(Ee.Fragment,{children:n}))};pt.defaultProps={limit:1,isTrue:!0},pt.If=({children:e,isTrue:t})=>e;const Co=({children:e})=>e;Co.defaultProps={isTrue:!0},pt.Else=Co;const tp=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};function vn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function gn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ut(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 np(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function ip(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)),gn(p,t,i),i+=2;else if(n===32)p=np(c[r]),ut(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function rp(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 op(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),m=16,v=p,g=4+(8+m)+(8+v);return vn("RIFF",f,0),ut(g,f,4),vn("WAVE",f,8),vn("fmt ",f,12),ut(m,f,16),gn(t?3:1,f,20),gn(n,f,22),ut(r,f,24),ut(s,f,28),gn(c,f,32),ut(o,f,34),vn("data",f,36),ut(v,f,40),ip(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function ap(e,t=!1,i){const n=await rp(e,i);return op(n,t)}const sp=128;class cp{constructor(){yn(this,"mediaRecorder",null);yn(this,"stream",null);yn(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:sp*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 ap(this.__data):null}}const hn=new cp,mi="Recording.wav",_o=1500,lp=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()=>{hn.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 hn.stopRecording();const p=await hn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],mi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await hn.startRecording();r(c),setTimeout(()=>{a(!0)},_o)}}},Ao=_e.create({baseURL:"https://arpeggi.io/api/v2/"}),pp=async(e,{arg:t})=>(await Ao.post("/ml-inference-jobs",tp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,metadata:{splitInstrumental:!0,isRecordedAudio:t.file.name===mi}}),{params:{type:"audio"}})).data,up=async e=>e===null?null:(await Ao.get(e)).data,dp=e=>{const t=e>0;return ql(t?`/ml-inference-jobs/${e}`:null,up,{refreshInterval:1e3})},fp=()=>{const[e,t]=w.useState(null),[i,n]=w.useState(0),[r,o]=w.useState(0),{data:a,isLoading:s}=dp(i),{trigger:c,isMutating:p}=Vl("/ml-inference-jobs",pp);return{file:e,setFile:t,mlijId:i,setMlijId:n,voiceModelId:r,setVoiceModelId:o,data:a,isLoading:s,handleSelectVoice:async f=>{e&&(o(f),c({file:e,voiceModelId:f},{onSuccess:m=>{console.log("created mlij",m),n(m.id)}}))},reset:()=>{t(null),n(0),o(0)},isMutating:p}},Do=w.createContext({}),xi=()=>w.useContext(Do),mp=({children:e})=>{const t=fp();return Ee.jsx(ko,{children:Ee.jsx(Do.Provider,{value:t,children:e})})},xp=Ge("button",{background:"#ffffff",borderRadius:"8px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"#ffffff99",cursor:"not-allowed"}}),vp=()=>{var r;const{data:e}=xi(),t=(r=e==null?void 0:e.recombinedAudioUrl)==null?void 0:r.url,{player:i,playPause:n}=Oo(t);return Ee.jsx(xp,{onClick:n,disabled:i.isLoading||!t,children:Ee.jsxs(pt,{children:[Ee.jsx(pt.If,{isTrue:i.isLoading||(e==null?void 0:e.jobStatus)==="running",children:Ee.jsx(Yl,{})}),Ee.jsx(pt.If,{isTrue:i.isPlaying,children:Ee.jsx(Kl,{})}),Ee.jsx(pt.Else,{children:Ee.jsx(Jl,{})})]})})},gp=1,hp=100*1024*1024,yp=1,bp=100,wp=({children:e})=>{const{setFile:t}=xi(),i=n=>t(n[0]);return Ee.jsx(yr,{files:[],onFileAccepted:i,maxFileCount:gp,maxSizeBytes:hp,minSizeBytes:yp,maxDurationS:bp,children:e})};ye.AudioFilePickerRoot=yr,ye.ConvertStep=Hs,ye.FilePicker=wp,ye.GuestConvertProvider=mp,ye.MIN_RECORDING_LENGTH_MS=_o,ye.PlayButton=vp,ye.PlayerProvider=ko,ye.RECORDED_AUDIO_NAME=mi,ye.useAudioFilePickerContext=Ms,ye.useGuestConvertContext=xi,ye.usePlayback=Oo,ye.usePlayer=To,ye.usePlayerControls=ep,ye.useRecorder=lp,Object.defineProperty(ye,Symbol.toStringTag,{value:"Module"})});
|
69
|
+
*/var oo;function gl(){return oo||(oo=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(_){{for(var k=arguments.length,b=new Array(k>1?k-1:0),j=1;j<k;j++)b[j-1]=arguments[j];n("error",_,b)}}function n(_,k,b){{var j=t.ReactDebugCurrentFrame,q=j.getStackAddendum();q!==""&&(k+="%s",b=b.concat([q]));var F=b.map(function(Y){return String(Y)});F.unshift("Warning: "+k),Function.prototype.apply.call(console[_],console,F)}}function r(_,k){return _===k&&(_!==0||1/_===1/k)||_!==_&&k!==k}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(_,k,b){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 j=k();if(!u){var q=k();o(j,q)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var F=a({inst:{value:j,getSnapshot:k}}),Y=F[0].inst,H=F[1];return c(function(){Y.value=j,Y.getSnapshot=k,m(Y)&&H({inst:Y})},[_,j,k]),s(function(){m(Y)&&H({inst:Y});var oe=function(){m(Y)&&H({inst:Y})};return _(oe)},[_]),p(j),j}function m(_){var k=_.getSnapshot,b=_.value;try{var j=k();return!o(b,j)}catch{return!0}}function v(_,k,b){return k()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!g,x=E?v:f,O=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x;ei.useSyncExternalStore=O,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ei}var ao;function hl(){return ao||(ao=1,process.env.NODE_ENV==="production"?dn.exports=vl():dn.exports=gl()),dn.exports}var so=hl();const Ze=()=>{},Ae=Ze(),ti=Object,N=e=>e===Ae,ze=e=>typeof e=="function",Le=(e,t)=>({...e,...t}),yl=e=>ze(e.then),fn=new WeakMap;let bl=0;const It=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(ti(e)===e&&!n&&i!=RegExp){if(r=fn.get(e),r)return r;if(r=++bl+"~",fn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=It(e[o])+",";fn.set(e,r)}if(i==ti){r="#";const a=ti.keys(e).sort();for(;!N(o=a.pop());)N(e[o])||(r+=o+":"+It(e[o])+",");fn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ue=new WeakMap,ni={},mn={},ii="undefined",xn=typeof window!=ii,ri=typeof document!=ii,wl=()=>xn&&typeof window.requestAnimationFrame!=ii,oi=(e,t)=>{const i=Ue.get(e);return[()=>!N(t)&&e.get(t)||ni,n=>{if(!N(t)){const r=e.get(t);t in mn||(mn[t]=r),i[5](t,Le(r,n),r||ni)}},i[6],()=>!N(t)&&t in mn?mn[t]:!N(t)&&e.get(t)||ni]};let ai=!0;const El=()=>ai,[si,ci]=xn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ze,Ze],Sl=()=>{const e=ri&&document.visibilityState;return N(e)||e!=="hidden"},Rl=e=>(ri&&document.addEventListener("visibilitychange",e),si("focus",e),()=>{ri&&document.removeEventListener("visibilitychange",e),ci("focus",e)}),Tl=e=>{const t=()=>{ai=!0,e()},i=()=>{ai=!1};return si("online",t),si("offline",i),()=>{ci("online",t),ci("offline",i)}},kl={isOnline:El,isVisible:Sl},Ol={initFocus:Rl,initReconnect:Tl},Bt=!w.useId,lt=!xn||"Deno"in window,co=e=>wl()?window.requestAnimationFrame(e):setTimeout(e,1),Qe=lt?w.useEffect:w.useLayoutEffect,li=typeof navigator<"u"&&navigator.connection,lo=!lt&&li&&(["slow-2g","2g"].includes(li.effectiveType)||li.saveData),zt=e=>{if(ze(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?It(e):"",[e,t]};let Cl=0;const wt=()=>++Cl,po=0,uo=1,fo=2;var Ve={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:po,MUTATE_EVENT:fo,RECONNECT_EVENT:uo};async function pi(...e){const[t,i,n,r]=e,o=Le({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(ze(i)){const f=i,m=[],v=t.keys();for(const g of v)!/^\$(inf|sub)\$/.test(g)&&f(t.get(g)._k)&&m.push(g);return Promise.all(m.map(u))}return u(i);async function u(f){const[m]=zt(f);if(!m)return;const[v,g]=oi(t,m),[E,x,O,_]=Ue.get(t),k=()=>{const ne=E[m];return(ze(o.revalidate)?o.revalidate(v().data,f):o.revalidate!==!1)&&(delete O[m],delete _[m],ne&&ne[0])?ne[0](fo).then(()=>v().data):v().data};if(e.length<3)return k();let b=n,j;const q=wt();x[m]=[q,0];const F=!N(c),Y=v(),H=Y.data,oe=Y._c,ve=N(oe)?H:oe;if(F&&(c=ze(c)?c(ve,H):c,g({data:c,_c:ve})),ze(b))try{b=b(ve)}catch(ne){j=ne}if(b&&yl(b))if(b=await b.catch(ne=>{j=ne}),q!==x[m][0]){if(j)throw j;return b}else j&&F&&p(j)&&(a=!0,g({data:ve,_c:Ae}));if(a&&!j)if(ze(a)){const ne=a(b,ve);g({data:ne,error:Ae,_c:Ae})}else g({data:b,error:Ae,_c:Ae});if(x[m][1]=wt(),Promise.resolve(k()).then(()=>{g({_c:Ae})}),j){if(l)throw j;return}return b}}const mo=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},_l=(e,t)=>{if(!Ue.has(e)){const i=Le(Ol,t),n={},r=pi.bind(Ae,e);let o=Ze;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 m=a[l];if(m)for(const v of m)v(u,f)},p=()=>{if(!Ue.has(e)&&(Ue.set(e,[n,{},{},{},r,c,s]),!lt)){const l=i.initFocus(setTimeout.bind(Ae,mo.bind(Ae,n,po))),u=i.initReconnect(setTimeout.bind(Ae,mo.bind(Ae,n,uo)));o=()=>{l&&l(),u&&u(),Ue.delete(e)}}};return p(),[e,r,p,o]}return[e,Ue.get(e)[4]]},Al=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!N(o)&&a>o||setTimeout(n,s,r)},Dl=(e,t)=>It(e)==It(t),[xo,jl]=_l(new Map),Fl=Le({onLoadingSlow:Ze,onSuccess:Ze,onError:Ze,onErrorRetry:Al,onDiscarded:Ze,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:lo?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:lo?5e3:3e3,compare:Dl,isPaused:()=>!1,cache:xo,mutate:jl,fallback:{}},kl),Pl=(e,t)=>{const i=Le(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=Le(r,a))}return i},Il=w.createContext({}),Bl="$inf$",vo=xn&&window.__SWR_DEVTOOLS_USE__,zl=vo?window.__SWR_DEVTOOLS_USE__:[],Ll=()=>{vo&&(window.__SWR_DEVTOOLS_REACT__=w)},go=e=>ze(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],ho=()=>Le(Fl,w.useContext(Il)),Ml=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=zt(t),[,,,s]=Ue.get(xo);if(a.startsWith(Bl))return i(...o);const c=s[a];return N(c)?i(...o):(delete s[a],c)}),n),$l=zl.concat(Ml),yo=e=>function(...i){const n=ho(),[r,o,a]=go(i),s=Pl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat($l);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},bo=(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())}},Nl=(e,t)=>(...i)=>{const[n,r,o]=go(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};Ll();const wo=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)}),ui={dedupe:!0},ql=yo((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,[m,v,g,E]=Ue.get(n),[x,O]=zt(e),_=w.useRef(!1),k=w.useRef(!1),b=w.useRef(x),j=w.useRef(t),q=w.useRef(i),F=()=>q.current,Y=()=>F().isVisible()&&F().isOnline(),[H,oe,ve,ne]=oi(n,x),V=w.useRef({}).current,pe=N(a)?i.fallback[x]:a,Re=(y,P)=>{for(const X in V){const $=X;if($==="data"){if(!r(y[$],P[$])&&(!N(y[$])||!r(G,P[$])))return!1}else if(P[$]!==y[$])return!1}return!0},Te=w.useMemo(()=>{const y=!x||!t?!1:N(s)?F().isPaused()||o?!1:N(c)?!0:c:s,P=ee=>{const we=Le(ee);return delete we._k,y?{isValidating:!0,isLoading:!0,...we}:we},X=H(),$=ne(),de=P(X),ke=X===$?de:P($);let Q=de;return[()=>{const ee=P(H());return Re(ee,Q)?(Q.data=ee.data,Q.isLoading=ee.isLoading,Q.isValidating=ee.isValidating,Q.error=ee.error,Q):(Q=ee,ee)},()=>ke]},[n,x]),ue=so.useSyncExternalStore(w.useCallback(y=>ve(x,(P,X)=>{Re(X,P)||y()}),[n,x]),Te[0],Te[1]),be=!_.current,R=m[x]&&m[x].length>0,C=ue.data,B=N(C)?pe:C,W=ue.error,z=w.useRef(B),G=f?N(C)?z.current:C:B,L=R&&!N(W)?!1:be&&!N(s)?s:F().isPaused()?!1:o?N(B)?!1:c:N(B)||c,U=!!(x&&t&&be&&L),J=N(ue.isValidating)?U:ue.isValidating,te=N(ue.isLoading)?U:ue.isLoading,M=w.useCallback(async y=>{const P=j.current;if(!x||!P||k.current||F().isPaused())return!1;let X,$,de=!0;const ke=y||{},Q=!g[x]||!ke.dedupe,ee=()=>Bt?!k.current&&x===b.current&&_.current:x===b.current,we={isValidating:!1,isLoading:!1},Ye=()=>{oe(we)},Ne=()=>{const S=g[x];S&&S[1]===$&&delete g[x]},Ke={isValidating:!0};N(H().data)&&(Ke.isLoading=!0);try{if(Q&&(oe(Ke),i.loadingTimeout&&N(H().data)&&setTimeout(()=>{de&&ee()&&F().onLoadingSlow(x,i)},i.loadingTimeout),g[x]=[P(O),wt()]),[X,$]=g[x],X=await X,Q&&setTimeout(Ne,i.dedupingInterval),!g[x]||g[x][1]!==$)return Q&&ee()&&F().onDiscarded(x),!1;we.error=Ae;const S=v[x];if(!N(S)&&($<=S[0]||$<=S[1]||S[1]===0))return Ye(),Q&&ee()&&F().onDiscarded(x),!1;const A=H().data;we.data=r(A,X)?A:X,Q&&ee()&&F().onSuccess(X,x,i)}catch(S){Ne();const A=F(),{shouldRetryOnError:ae}=A;A.isPaused()||(we.error=S,Q&&ee()&&(A.onError(S,x,A),(ae===!0||ze(ae)&&ae(S))&&(!F().revalidateOnFocus||!F().revalidateOnReconnect||Y())&&A.onErrorRetry(S,x,A,me=>{const Oe=m[x];Oe&&Oe[0]&&Oe[0](Ve.ERROR_REVALIDATE_EVENT,me)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return de=!1,Ye(),!0},[x,n]),ge=w.useCallback((...y)=>pi(n,b.current,...y),[]);if(Qe(()=>{j.current=t,q.current=i,N(C)||(z.current=C)}),Qe(()=>{if(!x)return;const y=M.bind(Ae,ui);let P=0;const $=bo(x,m,(de,ke={})=>{if(de==Ve.FOCUS_EVENT){const Q=Date.now();F().revalidateOnFocus&&Q>P&&Y()&&(P=Q+F().focusThrottleInterval,y())}else if(de==Ve.RECONNECT_EVENT)F().revalidateOnReconnect&&Y()&&y();else{if(de==Ve.MUTATE_EVENT)return M();if(de==Ve.ERROR_REVALIDATE_EVENT)return M(ke)}});return k.current=!1,b.current=x,_.current=!0,oe({_k:O}),L&&(N(B)||lt?y():co(y)),()=>{k.current=!0,$()}},[x]),Qe(()=>{let y;function P(){const $=ze(p)?p(H().data):p;$&&y!==-1&&(y=setTimeout(X,$))}function X(){!H().error&&(l||F().isVisible())&&(u||F().isOnline())?M(ui).then(P):P()}return P(),()=>{y&&(clearTimeout(y),y=-1)}},[p,l,u,x]),w.useDebugValue(G),o&&N(B)&&x){if(!Bt&<)throw new Error("Fallback data is required when using suspense in SSR.");j.current=t,q.current=i,k.current=!1;const y=E[x];if(!N(y)){const P=ge(y);wo(P)}if(N(W)){const P=M(ui);N(G)||(P.status="fulfilled",P.value=!0),wo(P)}else throw W}return{mutate:ge,get data(){return V.data=!0,G},get error(){return V.error=!0,W},get isValidating(){return V.isValidating=!0,J},get isLoading(){return V.isLoading=!0,te}}}),Eo=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)}),di={dedupe:!0},Wl=yo((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,[m,v,g,E]=Ue.get(n),[x,O]=zt(e),_=w.useRef(!1),k=w.useRef(!1),b=w.useRef(x),j=w.useRef(t),q=w.useRef(i),F=()=>q.current,Y=()=>F().isVisible()&&F().isOnline(),[H,oe,ve,ne]=oi(n,x),V=w.useRef({}).current,pe=N(a)?i.fallback[x]:a,Re=(y,P)=>{for(const X in V){const $=X;if($==="data"){if(!r(y[$],P[$])&&(!N(y[$])||!r(G,P[$])))return!1}else if(P[$]!==y[$])return!1}return!0},Te=w.useMemo(()=>{const y=!x||!t?!1:N(s)?F().isPaused()||o?!1:N(c)?!0:c:s,P=ee=>{const we=Le(ee);return delete we._k,y?{isValidating:!0,isLoading:!0,...we}:we},X=H(),$=ne(),de=P(X),ke=X===$?de:P($);let Q=de;return[()=>{const ee=P(H());return Re(ee,Q)?(Q.data=ee.data,Q.isLoading=ee.isLoading,Q.isValidating=ee.isValidating,Q.error=ee.error,Q):(Q=ee,ee)},()=>ke]},[n,x]),ue=so.useSyncExternalStore(w.useCallback(y=>ve(x,(P,X)=>{Re(X,P)||y()}),[n,x]),Te[0],Te[1]),be=!_.current,R=m[x]&&m[x].length>0,C=ue.data,B=N(C)?pe:C,W=ue.error,z=w.useRef(B),G=f?N(C)?z.current:C:B,L=R&&!N(W)?!1:be&&!N(s)?s:F().isPaused()?!1:o?N(B)?!1:c:N(B)||c,U=!!(x&&t&&be&&L),J=N(ue.isValidating)?U:ue.isValidating,te=N(ue.isLoading)?U:ue.isLoading,M=w.useCallback(async y=>{const P=j.current;if(!x||!P||k.current||F().isPaused())return!1;let X,$,de=!0;const ke=y||{},Q=!g[x]||!ke.dedupe,ee=()=>Bt?!k.current&&x===b.current&&_.current:x===b.current,we={isValidating:!1,isLoading:!1},Ye=()=>{oe(we)},Ne=()=>{const S=g[x];S&&S[1]===$&&delete g[x]},Ke={isValidating:!0};N(H().data)&&(Ke.isLoading=!0);try{if(Q&&(oe(Ke),i.loadingTimeout&&N(H().data)&&setTimeout(()=>{de&&ee()&&F().onLoadingSlow(x,i)},i.loadingTimeout),g[x]=[P(O),wt()]),[X,$]=g[x],X=await X,Q&&setTimeout(Ne,i.dedupingInterval),!g[x]||g[x][1]!==$)return Q&&ee()&&F().onDiscarded(x),!1;we.error=Ae;const S=v[x];if(!N(S)&&($<=S[0]||$<=S[1]||S[1]===0))return Ye(),Q&&ee()&&F().onDiscarded(x),!1;const A=H().data;we.data=r(A,X)?A:X,Q&&ee()&&F().onSuccess(X,x,i)}catch(S){Ne();const A=F(),{shouldRetryOnError:ae}=A;A.isPaused()||(we.error=S,Q&&ee()&&(A.onError(S,x,A),(ae===!0||ze(ae)&&ae(S))&&(!F().revalidateOnFocus||!F().revalidateOnReconnect||Y())&&A.onErrorRetry(S,x,A,me=>{const Oe=m[x];Oe&&Oe[0]&&Oe[0](Ve.ERROR_REVALIDATE_EVENT,me)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return de=!1,Ye(),!0},[x,n]),ge=w.useCallback((...y)=>pi(n,b.current,...y),[]);if(Qe(()=>{j.current=t,q.current=i,N(C)||(z.current=C)}),Qe(()=>{if(!x)return;const y=M.bind(Ae,di);let P=0;const $=bo(x,m,(de,ke={})=>{if(de==Ve.FOCUS_EVENT){const Q=Date.now();F().revalidateOnFocus&&Q>P&&Y()&&(P=Q+F().focusThrottleInterval,y())}else if(de==Ve.RECONNECT_EVENT)F().revalidateOnReconnect&&Y()&&y();else{if(de==Ve.MUTATE_EVENT)return M();if(de==Ve.ERROR_REVALIDATE_EVENT)return M(ke)}});return k.current=!1,b.current=x,_.current=!0,oe({_k:O}),L&&(N(B)||lt?y():co(y)),()=>{k.current=!0,$()}},[x]),Qe(()=>{let y;function P(){const $=ze(p)?p(H().data):p;$&&y!==-1&&(y=setTimeout(X,$))}function X(){!H().error&&(l||F().isVisible())&&(u||F().isOnline())?M(di).then(P):P()}return P(),()=>{y&&(clearTimeout(y),y=-1)}},[p,l,u,x]),w.useDebugValue(G),o&&N(B)&&x){if(!Bt&<)throw new Error("Fallback data is required when using suspense in SSR.");j.current=t,q.current=i,k.current=!1;const y=E[x];if(!N(y)){const P=ge(y);Eo(P)}if(N(W)){const P=M(di);N(G)||(P.status="fulfilled",P.value=!0),Eo(P)}else throw W}return{mutate:ge,get data(){return V.data=!0,G},get error(){return V.error=!0,W},get isValidating(){return V.isValidating=!0,J},get isLoading(){return V.isLoading=!0,te}}}),So=Bt?e=>{e()}:w.startTransition,Ul=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 Qe(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},Vl=Nl(Wl,()=>(e,t,i={})=>{const{mutate:n}=ho(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=Ul({data:Ae,error:Ae,isMutating:!1}),u=c.current,f=w.useCallback(async(v,g)=>{const[E,x]=zt(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 O=Le(Le({populateCache:!1,throwOnError:!0},a.current),g),_=wt();s.current=_,l({isMutating:!0});try{const k=await n(E,o.current(x,{arg:v}),Le(O,{throwOnError:!0}));return s.current<=_&&(So(()=>l({data:k,isMutating:!1,error:void 0})),O.onSuccess==null||O.onSuccess.call(O,k,E,O)),k}catch(k){if(s.current<=_&&(So(()=>l({error:k,isMutating:!1})),O.onError==null||O.onError.call(O,k,E,O),O.throwOnError))throw k}},[]),m=w.useCallback(()=>{s.current=wt(),l({data:Ae,error:Ae,isMutating:!1})},[]);return Qe(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:m,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),Hl=e=>Ee.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",...e,children:[Ee.jsx("path",{opacity:"0.15",d:"M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"}),Ee.jsx("path",{d:"M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2",strokeLinecap:"round"})]}),Gl=ga({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Yl=Ge(Hl,{animation:`${Gl} 2s linear infinite`,variants:{size:{sm:{width:"16px",height:"16px",strokeWidth:"1px"},md:{width:"24px",height:"24px",strokeWidth:"1.5px"},lg:{width:"32px",height:"32px",strokeWidth:"2px"}}}}),Kl=e=>Ee.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Ee.jsx("path",{d:"M6.04995 2.74998C6.04995 2.44623 5.80371 2.19998 5.49995 2.19998C5.19619 2.19998 4.94995 2.44623 4.94995 2.74998V12.25C4.94995 12.5537 5.19619 12.8 5.49995 12.8C5.80371 12.8 6.04995 12.5537 6.04995 12.25V2.74998ZM10.05 2.74998C10.05 2.44623 9.80371 2.19998 9.49995 2.19998C9.19619 2.19998 8.94995 2.44623 8.94995 2.74998V12.25C8.94995 12.5537 9.19619 12.8 9.49995 12.8C9.80371 12.8 10.05 12.5537 10.05 12.25V2.74998Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})}),Jl=({...e})=>Ee.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",xmlns:"http://www.w3.orkllg/2000/svg",fill:"currentColor",...e,children:Ee.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.1869 3.71487C5.42703 3.57009 5.72543 3.56159 5.9734 3.69247L20.3734 11.2925C20.6358 11.431 20.8 11.7033 20.8 12C20.8 12.2967 20.6358 12.569 20.3734 12.7075L5.9734 20.3075C5.72543 20.4384 5.42703 20.4299 5.1869 20.2851C4.94679 20.1403 4.79999 19.8803 4.79999 19.6V4.39998C4.79999 4.11959 4.94679 3.85966 5.1869 3.71487Z",fill:"currentColor"})}),Xl=e=>{if(!e)return!1;const t=e.split("?")[1];if(!t)return!1;const n=new URLSearchParams(t).get("Expires");return n?new Date(n)<new Date:!1},Ro=e=>e&&e.split("?")[0],Zl=(e,t)=>Ro(e)===Ro(t),Ql=()=>{const[e,t]=w.useState("paused"),i=()=>{if(typeof window>"u")return null;const p=new Audio;return p.addEventListener("play",()=>t("playing")),p},n=w.useMemo(i,[]),r=w.useRef(n);return{audioRef:r,state:e,setAudio:p=>new Promise(l=>{const u=r==null?void 0:r.current;u&&(u.setAttribute("src",p),t("loading"),u.addEventListener("loadedmetadata",()=>{t("paused"),l()},{once:!0}))}),play:()=>{var p,l;(p=r.current)==null||p.play(),(l=r.current)==null||l.addEventListener("ended",()=>t("paused"),{once:!0})},pause:()=>{var p;(p=r.current)==null||p.pause(),t("paused")},stop:()=>{var l;r.current&&((l=r.current)==null||l.pause(),r.current.currentTime=0),t("paused")}}},fi=w.createContext(null),To=e=>{var a;const t=w.useContext(fi),i=Zl((a=t.audioRef.current)==null?void 0:a.src,e),n=t.state==="loading"&&i,r=t.state==="playing"&&i;return{...t,isMySrc:i,isLoading:n,isPlaying:r,play:async()=>{var c;const s=(c=t.audioRef.current)==null?void 0:c.src;(!i||Xl(s))&&await t.setAudio(e),t.play()}}},ep=()=>w.useContext(fi),ko=({children:e})=>{const t=Ql();return Ee.jsx(fi.Provider,{value:t,children:e})},Oo=(e,t,i)=>{const n=To(e),r=w.useRef(!1),o=()=>{r.current||(r.current=!0),n.isPlaying?(n.pause(),i==null||i()):(n.play(),t==null||t())};return w.useEffect(()=>()=>{n.isPlaying&&n.pause()},[]),{player:n,playPause:o}},pt=({limit:e,isTrue:t,children:i})=>{const n=[];return t!==!0?null:(Mo.Children.map(i,r=>{const{isTrue:o}=(r==null?void 0:r.props)||{};o===!0&&(!e||n.length<e)&&n.push(r)}),Ee.jsx(Ee.Fragment,{children:n}))};pt.defaultProps={limit:1,isTrue:!0},pt.If=({children:e,isTrue:t})=>e;const Co=({children:e})=>e;Co.defaultProps={isTrue:!0},pt.Else=Co;const tp=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};function vn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function gn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ut(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 np(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function ip(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)),gn(p,t,i),i+=2;else if(n===32)p=np(c[r]),ut(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function rp(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 op(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),m=16,v=p,g=4+(8+m)+(8+v);return vn("RIFF",f,0),ut(g,f,4),vn("WAVE",f,8),vn("fmt ",f,12),ut(m,f,16),gn(t?3:1,f,20),gn(n,f,22),ut(r,f,24),ut(s,f,28),gn(c,f,32),ut(o,f,34),vn("data",f,36),ut(v,f,40),ip(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function ap(e,t=!1,i){const n=await rp(e,i);return op(n,t)}const sp=128;class cp{constructor(){yn(this,"mediaRecorder",null);yn(this,"stream",null);yn(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:sp*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 ap(this.__data):null}}const hn=new cp,mi="Recording.wav",_o=1500,lp=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()=>{hn.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 hn.stopRecording();const p=await hn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],mi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await hn.startRecording();r(c),setTimeout(()=>{a(!0)},_o)}}},Ao=_e.create({baseURL:"https://arpeggi.io/api/v2/"}),pp=async(e,{arg:t})=>(await Ao.post("/ml-inference-jobs",tp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,metadata:{splitInstrumental:!0,isRecordedAudio:t.file.name===mi}}),{params:{type:"audio"}})).data,up=async e=>e===null?null:(await Ao.get(e)).data,dp=e=>{const t=e>0;return ql(t?`/ml-inference-jobs/${e}`:null,up,{refreshInterval:1e3})},fp=()=>{const[e,t]=w.useState(null),[i,n]=w.useState(0),[r,o]=w.useState(0),{data:a,isLoading:s}=dp(i),{trigger:c,isMutating:p}=Vl("/ml-inference-jobs",pp);return{file:e,setFile:t,mlijId:i,setMlijId:n,voiceModelId:r,setVoiceModelId:o,data:a,isLoading:s,handleSelectVoice:async f=>{e&&(o(f),c({file:e,voiceModelId:f},{onSuccess:m=>{console.log("created mlij",m),n(m.id)}}))},reset:()=>{t(null),n(0),o(0)},isMutating:p}},Do=w.createContext({}),xi=()=>w.useContext(Do),mp=({children:e})=>{const t=fp();return Ee.jsx(ko,{children:Ee.jsx(Do.Provider,{value:t,children:e})})},xp=Ge("button",{background:"#ffffff",borderRadius:"8px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"#ffffff99",cursor:"not-allowed"}}),vp=()=>{var o;const{data:e,isMutating:t}=xi(),i=(o=e==null?void 0:e.lossyOutputFile)==null?void 0:o.url,{player:n,playPause:r}=Oo(i);return Ee.jsx(xp,{onClick:r,disabled:n.isLoading||!i,children:Ee.jsxs(pt,{children:[Ee.jsx(pt.If,{isTrue:n.isLoading||(e==null?void 0:e.jobStatus)==="running"||t,children:Ee.jsx(Yl,{})}),Ee.jsx(pt.If,{isTrue:n.isPlaying,children:Ee.jsx(Kl,{})}),Ee.jsx(pt.Else,{children:Ee.jsx(Jl,{})})]})})},gp=1,hp=100*1024*1024,yp=1,bp=100,wp=({children:e})=>{const{setFile:t}=xi(),i=n=>t(n[0]);return Ee.jsx(yr,{files:[],onFileAccepted:i,maxFileCount:gp,maxSizeBytes:hp,minSizeBytes:yp,maxDurationS:bp,children:e})};ye.AudioFilePickerRoot=yr,ye.ConvertStep=Hs,ye.FilePicker=wp,ye.GuestConvertProvider=mp,ye.MIN_RECORDING_LENGTH_MS=_o,ye.PlayButton=vp,ye.PlayerProvider=ko,ye.RECORDED_AUDIO_NAME=mi,ye.useAudioFilePickerContext=Ms,ye.useGuestConvertContext=xi,ye.usePlayback=Oo,ye.usePlayer=To,ye.usePlayerControls=ep,ye.useRecorder=lp,Object.defineProperty(ye,Symbol.toStringTag,{value:"Module"})});
|
70
70
|
//# sourceMappingURL=index.umd.js.map
|