text: (this.webpackJsonpamuseing=this.webpackJsonpamuseing||[]).push([[0],{45:function(e,t,a){},46:function(e,t,a){},54:function(e,t,a){},56:function(e,t,a){},58:function(e,t,a){},76:function(e,t,a){},77:function(e,t,a){"use strict";a.r(t);var n=a(1),c=a.n(n),r=a(36),s=a.n(r),i=(a(45),a(40)),l=a(6),u=(a(46),a(8)),o=a(16),j=a(0);var d=function(e){return Object(j.jsx)(o.b,{to:e.to,children:Object(j.jsxs)("button",{className:e.active?"active":null,children:[Object(j.jsx)(u.a,{icon:e.icon}),Object(j.jsx)("span",{children:e.children})]})})},b=a(5),h={search:b.i,library:b.b},p=(a(54),a(3));var O=function(){var e=Object(p.f)();return Object(j.jsxs)("nav",{id:"sidebar",children:[Object(j.jsx)(d,{active:"/"===e.pathname,icon:h.library,to:"/",children:"Library"}),Object(j.jsx)(d,{active:"/search"===e.pathname,icon:h.search,to:"/search",children:"Search"})]})};a(55),a(56);var x=function(){return Object(j.jsx)("header",{})},f=(a(25),a(7)),v=a.n(f),m=a(13);a(58);var g=a(15),y=a.n(g),k="",N=a(38),w=/^(?:https:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([A-z0-9\-_]{11})(?:&.*)?|(?:https:\/\/)?youtu.be\/([A-z0-9\-_]{11})$/;function S(e){var t=Object(n.useState)(""),a=Object(l.a)(t,2),c=a[0],r=a[1],s=Object(n.useState)([]),i=Object(l.a)(s,2),o=i[0],d=i[1],h=Object(n.useState)(!1),p=Object(l.a)(h,2),O=p[0],x=p[1],f=Object(n.useState)(""),g=Object(l.a)(f,2),k=g[0],S=g[1],C=Object(n.useState)([]),P=Object(l.a)(C,2),E=P[0],I=P[1],B=Object(n.useState)(null),F=Object(l.a)(B,2),T=F[0],L=F[1],M=Object(n.useCallback)(function(e,t,a){var n;return function(){var c=this,r=arguments,s=function(){n=null,a||e.apply(c,r)},i=a&&!n;clearTimeout(n),n=setTimeout(s,t),i&&e.apply(c,r)}}(q,300),[]);function q(e){return A.apply(this,arguments)}function A(){return(A=Object(m.a)(v.a.mark((function t(a){var n,c;return v.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(""===a&&!0===e.bar){t.next=15;break}return n="",!0!==e.bar&&(n="true"),t.prev=3,t.next=6,y.a.get("/search/query",{params:{q:a,random:n}});case 6:(c=t.sent).data.hasOwnProperty("error")?d([]):d(c.data),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(3),console.error("Failed to search!");case 13:t.next=16;break;case 15:e.bar&&d([]);case 16:case"end":return t.stop()}}),t,null,[[3,10]])})))).apply(this,arguments)}var _=function(){var e=Object(m.a)(v.a.mark((function e(){var t,a,n,r,s;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=k.match(w))){e.next=7;break}a=t[1]||t[2],n="/yt/download/"+a,r=setInterval(Object(m.a)(v.a.mark((function e(){var t,a,s,i;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=b.j,a="Loading...",s=!0,e.prev=3,e.next=6,y.a.get(n);case 6:i=e.sent,e.next=11;break;case 9:e.prev=9,e.t0=e.catch(3);case 11:"error"===i.data.status?(t=b.d,a="An error occurred: "+i.data.error,s=!1,clearInterval(r)):"queued"===i.data.status?(t=b.m,a="Queued. Position: "+i.data.position,s=!1):"processing"===i.data.status?(t=b.j,a="Processing",s=!0):"completed"===i.data.status&&(t=b.a,a="Complete",s=!1,clearInterval(r),setTimeout(Object(m.a)(v.a.mark((function e(){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(c);case 2:case"end":return e.stop()}}),e)}))),1e3)),L(Object(j.jsxs)("div",{className:"status",children:[Object(j.jsx)(u.a,{icon:t,spin:s}),Object(j.jsx)("p",{children:a})]}));case 13:case"end":return e.stop()}}),e,null,[[3,9]])}))),1e3),e.next=17;break;case 7:if(""===k){e.next=17;break}return e.prev=8,e.next=11,y.a.get("/search/yt",{params:{q:k}});case 11:s=e.sent,e.next=16;break;case 14:e.prev=14,e.t0=e.catch(8);case 16:s.data.error||s.data.results&&(console.log(s.data.results),I(s.data.results));case 17:case"end":return e.stop()}}),e,null,[[8,14]])})));return function(){return e.apply(this,arguments)}}();return Object(n.useEffect)((function(){return q(c)}),[e.bar]),Object(n.useEffect)((function(){M(c)}),[c,M]),Object(j.jsxs)("div",{className:"panel",children:[!0===e.bar?Object(j.jsx)("input",{className:"searchBox",value:c,onChange:function(e){return r(e.target.value)}}):null,Object(j.jsxs)("div",{className:"results",children:[o.map((function(t){return Object(j.jsxs)("div",{onClick:function(){return e.setPlaying(t)},className:"song",children:[Object(j.jsx)("div",{className:"song-icon",style:{backgroundImage:"url("+t.iconUrl+")"},children:Object(j.jsx)("div",{className:"song-icon-play",children:Object(j.jsx)(u.a,{icon:b.f})})}),Object(j.jsx)("div",{className:"song-title",children:t.title}),Object(j.jsx)("div",{className:"song-artists",children:t.all_artists.replace(/,/g,", ")})]},t._id)})),Object(j.jsxs)("div",{className:"song",onClick:function(){x(!O),S(""),L(null),I([])},children:[Object(j.jsx)("div",{className:"song-icon youtube",children:Object(j.jsx)(u.a,{icon:N.a})}),Object(j.jsx)("div",{className:"song-title",children:"YouTube"}),Object(j.jsx)("div",{className:"song-artists",children:"Get more songs from youtube!"})]}),O?Object(j.jsx)("div",{className:"dialog-background",children:Object(j.jsxs)("div",{className:"dialog",children:[Object(j.jsx)("button",{className:"close",onClick:function(){return x(!1)},children:"\xd7"}),Object(j.jsx)("p",{className:"title",children:"Get From Youtube!"}),Object(j.jsx)("p",{className:"subtitle",children:"Enter a URL to a video or a search query."}),Object(j.jsx)("input",{className:"yt-link",value:k,onChange:function(e){return S(e.target.value)}}),Object(j.jsx)("button",{className:"yt-search",onClick:_,children:"Search"}),T,Object(j.jsx)("div",{className:"search-results",children:E.map((function(e){return Object(j.jsxs)("div",{onClick:Object(m.a)(v.a.mark((function t(){return v.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return S("https://youtu.be/"+e.id),k="https://youtu.be/"+e.id,t.next=4,_();case 4:case"end":return t.stop()}}),t)}))),className:"search-result",children:[Object(j.jsx)("div",{className:"search-results-icon",style:{backgroundImage:"url("+e.thumbnails.high.url+")"},children:Object(j.jsx)("div",{className:"search-results-icon-play",children:Object(j.jsx)(u.a,{icon:b.c})})}),Object(j.jsx)("div",{className:"search-results-title",children:e.title}),Object(j.jsx)("div",{className:"search-results-artists",children:e.channelTitle})]},e.id)}))})]})}):null]})]})}a(76);var C=a(39),P=a.n(C);function E(){return I.apply(this,arguments)}function I(){return(I=Object(m.a)(v.a.mark((function e(){var t;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,y.a.get("/search/query",{params:{random:"true"}});case 3:if(!(t=e.sent).data.hasOwnProperty("error")){e.next=8;break}return e.abrupt("return",[]);case 8:return e.abrupt("return",t.data);case 9:e.next=14;break;case 11:return e.prev=11,e.t0=e.catch(0),e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,null,[[0,11]])})))).apply(this,arguments)}function B(e){var t=Object(n.useState)(0),a=Object(l.a)(t,2),c=a[0],r=a[1],s=Object(n.useState)(0),i=Object(l.a)(s,2),o=i[0],d=i[1],h=Object(n.useState)(!1),p=Object(l.a)(h,2),O=p[0],x=p[1],f=Object(n.useState)(!1),g=Object(l.a)(f,2),y=g[0],N=g[1],w=Object(n.useState)(!0),S=Object(l.a)(w,2),C=S[0],I=S[1],B=Object(n.useState)([]),F=Object(l.a)(B,2),T=F[0],L=F[1],M=!1,q=function(){var e=Object(m.a)(v.a.mark((function e(){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=L,e.next=3,E();case 3:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(n.useEffect)((function(){q()}),[]);var A=function(){0!==T.length&&e.setPlaying(T[Math.floor(Math.random()*T.length)])};Object(n.useEffect)((function(){if(!1!==e.playing)try{document.title=e.playing.title+" | Amuseing",navigator.mediaSession.metadata=new window.MediaMetadata({title:e.playing.title,artist:e.playing.all_artists.split(",").join(", "),artwork:[{src:k+e.playing.iconUrl}]})}catch(t){}}),[e.playing]);try{navigator.mediaSession.setActionHandler("nexttrack",A)}catch(U){}Object(n.useEffect)((function(){r(0),d(0)}),[e.playing]);var _=function(e){var t=(e=Math.floor(e))%60;return((e-t)/60).toFixed(0)+":"+t.toFixed(0).padStart(2,"0")};return e.playing?Object(j.jsxs)("div",{className:"player",children:[Object(j.jsxs)("div",{className:"track-info",children:[Object(j.jsx)("div",{className:"track-icon",style:{backgroundImage:"url("+e.playing.iconUrl+")"}}),Object(j.jsx)("div",{className:"track-title",children:e.playing.title}),Object(j.jsx)("div",{className:"track-artists",children:e.playing.all_artists.replace(/,/g,", ")})]}),Object(j.jsx)(P.a,{src:k+e.playing.audioUrl,ref:function(e){return M=e},autoPlay:!0,loop:y,listenInterval:1e3,onListen:function(e){return d(e)},onSeeked:function(e){return d(e.target.currentTime)},onLoadedMetadata:function(e){return r(e.target.duration)},onPause:function(){return x(!1)},onPlay:function(){return x(!0)},onError:function(){return x(!1)},onEnded:function(){x(!1),!y&&C&&A()}}),Object(j.jsxs)("div",{className:"controls",children:[Object(j.jsx)("div",{className:"shuffle",onClick:function(){return I(!C)},children:Object(j.jsx)(u.a,{icon:b.g,className:C?"icon-enabled":""})}),Object(j.jsx)("div",{className:"skip back"+(e.canSkipBackward()?"":" disabled"),onClick:e.skipBackward,children:Object(j.jsx)(u.a,{icon:b.k,className:C?"icon-enabled":""})}),Object(j.jsx)("div",{className:"playPause",onClick:function(){M.audioEl.current.paused?M.audioEl.current.play():M.audioEl.current.pause()},children:O?Object(j.jsx)(u.a,{icon:b.e}):Object(j.jsx)(u.a,{icon:b.f})}),Object(j.jsx)("div",{className:"skip",onClick:A,children:Object(j.jsx)(u.a,{icon:b.l,className:C?"icon-enabled":""})}),Object(j.jsx)("div",{className:"repeat",onClick:function(){return N(!y)},children:Object(j.jsx)(u.a,{icon:b.h,className:y?"icon-enabled":""})})]}),Object(j.jsxs)("div",{className:"trackInfoProgress",children:[Object(j.jsx)("p",{children:_(o)}),Object(j.jsx)("div",{className:"progressBar",children:Object(j.jsx)("div",{className:"progressBar-progress",style:{width:0===c?0:(o/c*100).toFixed(2)+"%"}})}),Object(j.jsx)("p",{children:_(c)})]})]}):Object(j.jsx)("div",{className:"player"})}var F=function(){var e=Object(n.useState)([]),t=Object(l.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)(!1),s=Object(l.a)(r,2),u=s[0],d=s[1],b=function(e){!1!==u&&c([].concat(Object(i.a)(a),[u])),d(e)},h=function(){f()&&d(a.pop())};try{navigator.mediaSession.setActionHandler("previoustrack",h)}catch(v){}var f=function(){return a.length>0};return Object(j.jsx)("main",{children:Object(j.jsxs)(o.a,{children:[Object(j.jsx)(x,{}),Object(j.jsx)(O,{}),Object(j.jsxs)(p.c,{children:[Object(j.jsx)(p.a,{path:"/search",children:Object(j.jsx)(S,{bar:!0,setPlaying:b})}),Object(j.jsx)(p.a,{path:"/",children:Object(j.jsx)(S,{setPlaying:b})})]}),Object(j.jsx)(B,{playing:u,setPlaying:b,skipBackward:h,canSkipBackward:f})]})})},T=function(e){e&&e instanceof Function&&a.e(3).then(a.bind(null,78)).then((function(t){var a=t.getCLS,n=t.getFID,c=t.getFCP,r=t.getLCP,s=t.getTTFB;a(e),n(e),c(e),r(e),s(e)}))};s.a.render(Object(j.jsx)(c.a.StrictMode,{children:Object(j.jsx)(F,{})}),document.getElementById("root")),T()}},[[77,1,2]]]);
  //# sourceMappingURL=main.d37f54ad.chunk.js.map