home-atom 1.0.1 → 1.0.2
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/client/.vite/manifest.json +33 -33
- package/dist/client/_next/static/chunks/{app-top-nav-Dh0jEt8u.js → app-top-nav-Co7RIixU.js} +1 -1
- package/dist/client/_next/static/chunks/{index-hn3AiVww.js → index-BUxxgh38.js} +3 -3
- package/dist/client/_next/static/chunks/{layout-segment-context-DRM8YCgm.js → layout-segment-context-D_cL7vkY.js} +1 -1
- package/dist/client/_next/static/chunks/manage-profiles-modal-CWi3qgd4.js +1 -0
- package/dist/client/_next/static/chunks/netflix-browser-BrXQctI5.js +2 -0
- package/dist/client/_next/static/chunks/playback-activity-66FeikYZ.js +1 -0
- package/dist/client/_next/static/chunks/playback-activity-track-switcher-BzvHiv7c.js +1 -0
- package/dist/client/_next/static/chunks/{step-forward-CV8I5pPb.js → provider-registry-CWHfJn3B.js} +1 -1
- package/dist/client/_next/static/chunks/spotify-app-CJimeMR0.js +1 -0
- package/dist/client/_next/static/chunks/storefront-CCeanBPs.js +1 -0
- package/dist/client/_next/static/css/index.8o3Y-jts.css +1 -0
- package/dist/client/_next/static/css/layout.D2NsWbhP.css +1 -0
- package/dist/client/_next/static/css/layout.D4D5fsiD.css +1 -0
- package/dist/client/_next/static/css/manage-profiles-modal.BOKESpxI.css +1 -0
- package/dist/client/vinext-client-entry-manifest.json +1 -1
- package/dist/server/BUILD_ID +1 -1
- package/dist/server/__vite_rsc_assets_manifest.js +35 -35
- package/dist/server/_next/static/{app-page-cache-DcrtN14Y.js → app-page-cache-CQaSjBaF.js} +1 -1
- package/dist/server/_next/static/{app-page-cache-render-DoCquoNb.js → app-page-cache-render-Dty3aMiv.js} +1 -1
- package/dist/server/_next/static/{app-route-handler-dispatch-Be2YIqVp.js → app-route-handler-dispatch-DCSrhGNV.js} +1 -1
- package/dist/server/_next/static/{cache-headers-BQ-QuzWN.js → cache-headers-lY59goLh.js} +1 -1
- package/dist/server/_next/static/css/index.8o3Y-jts.css +1 -0
- package/dist/server/_next/static/css/layout.D2NsWbhP.css +1 -0
- package/dist/server/_next/static/css/layout.D4D5fsiD.css +1 -0
- package/dist/server/_next/static/database-D79CeUrn.js +161 -0
- package/dist/server/_next/static/{db-BE1J0NNS.js → db-x8J3Vuoa.js} +1 -1
- package/dist/server/_next/static/{downloader-DgnjNL5T.js → downloader-0G-gq1D-.js} +3 -3
- package/dist/server/_next/static/episode-sync-Ct5CeY25.js +1 -0
- package/dist/server/_next/static/{isr-decision-D1zHgPSI.js → isr-decision-BOA4L6nr.js} +1 -1
- package/dist/server/_next/static/netflix-page-Cpp2PgD1.js +1 -0
- package/dist/server/_next/static/{page-Cs-erYTy.js → page-BvzzZVuW.js} +1 -1
- package/dist/server/_next/static/{page-DlBGATQp.js → page-C27wjUYW.js} +1 -1
- package/dist/server/_next/static/{page-DlRXyzSQ.js → page-Rnpx_OjW.js} +1 -1
- package/dist/server/_next/static/{providers-B3YELr_F.js → providers-DwLUa_U_.js} +13 -13
- package/dist/server/_next/static/{providers-CMBIwNGs.js → providers-_uOQh6hB.js} +1 -1
- package/dist/server/_next/static/{request-profile-B1yGQ0l6.js → request-profile-ClcH0i0T.js} +1 -1
- package/dist/server/_next/static/route-4xkmbpc4.js +1 -0
- package/dist/server/_next/static/{route-CeVsDcbj2.js → route-B0L_rsrg2.js} +1 -1
- package/dist/server/_next/static/{route-xtz48fti.js → route-B6q-wR2F.js} +1 -1
- package/dist/server/_next/static/{route-DXTJyFWD.js → route-B6zrlXB5.js} +1 -1
- package/dist/server/_next/static/{route-CNNiXZoM2.js → route-B99Pvusz2.js} +1 -1
- package/dist/server/_next/static/route-B9YeBtG6.js +1 -0
- package/dist/server/_next/static/route-BHbJ9hFI2.js +1 -0
- package/dist/server/_next/static/{route-mzLdjDCs2.js → route-BR3Y_0V42.js} +1 -1
- package/dist/server/_next/static/{route-Cim7D4XQ.js → route-BaGo5TEW.js} +1 -1
- package/dist/server/_next/static/{route-DslPFTAK.js → route-BczKcyvV.js} +1 -1
- package/dist/server/_next/static/{route-B0WNLJZp.js → route-BiSvZr_s.js} +1 -1
- package/dist/server/_next/static/{route-Dbs39TkC.js → route-Bj7s6WXI.js} +1 -1
- package/dist/server/_next/static/{route-vD15s2A8.js → route-CGH08Y8C.js} +1 -1
- package/dist/server/_next/static/{route-CkH7Cg-p.js → route-CJmc17Dq.js} +1 -1
- package/dist/server/_next/static/{route-C74RA7va.js → route-CLvr0Ue3.js} +1 -1
- package/dist/server/_next/static/route-CUaIuP8a.js +1 -0
- package/dist/server/_next/static/{route-BPcAdbz_.js → route-CcrNbScT.js} +1 -1
- package/dist/server/_next/static/route-CiOFTfyw2.js +1 -0
- package/dist/server/_next/static/route-Cn7l9eYT.js +1 -0
- package/dist/server/_next/static/route-CnKXQb5r2.js +1 -0
- package/dist/server/_next/static/{route-CVPPmUto.js → route-D93PQ3NI2.js} +1 -1
- package/dist/server/_next/static/{route-D_G2SOlz.js → route-D9ZD1_5T.js} +1 -1
- package/dist/server/_next/static/{route-DAyF4BHS.js → route-DWPhX9kT2.js} +1 -1
- package/dist/server/_next/static/route-DihT2xS82.js +1 -0
- package/dist/server/_next/static/route-Dn-sYYEs.js +1 -0
- package/dist/server/_next/static/route-DpzLCx1V.js +1 -0
- package/dist/server/_next/static/route-Dswz7MvP2.js +1 -0
- package/dist/server/_next/static/route-Dwk0kt8B.js +1 -0
- package/dist/server/_next/static/route-DxLQx9eD.js +1 -0
- package/dist/server/_next/static/{route-zazqen-A2.js → route-FwNLcs2r2.js} +1 -1
- package/dist/server/_next/static/route-GmbSJZjk2.js +1 -0
- package/dist/server/_next/static/route-iUxcDN2r.js +1 -0
- package/dist/server/_next/static/{route-UWQN8uYr.js → route-j61HPczh.js} +1 -1
- package/dist/server/_next/static/{route-CHJzaQu2.js → route-qJ1EJhxJ.js} +1 -1
- package/dist/server/_next/static/{route-BWk9YK7r.js → route-sNW0pw7C.js} +1 -1
- package/dist/server/_next/static/{seed-cache-oCd9Lfdw.js → seed-cache-DsYPqBld.js} +1 -1
- package/dist/server/_next/static/{server-CS40XqUP.js → server-DwVU6UyP.js} +1 -1
- package/dist/server/_next/static/storage-fxaUbjG1.js +322 -0
- package/dist/server/_next/static/streamer-DUAWx_Tm.js +2 -0
- package/dist/server/_next/static/{subtitles-DYBlMnha.js → subtitles-4c0GFlaW.js} +1 -1
- package/dist/server/_next/static/{title-progress-CQBrSxvN.js → title-progress-BTypVYBz.js} +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/prerendered-routes/404.html +2 -2
- package/dist/server/prerendered-routes/index.html +2 -2
- package/dist/server/prerendered-routes/index.rsc +2 -2
- package/dist/server/ssr/__vite_rsc_assets_manifest.js +35 -35
- package/dist/server/ssr/_next/static/css/refresh-cw.BOKESpxI.css +1 -0
- package/dist/server/ssr/_next/static/minimize-gPI5ytrc.js +1 -0
- package/dist/server/ssr/_next/static/netflix-browser-CXJEizJ6.js +2 -0
- package/dist/server/ssr/_next/static/{pin-BQre-tQY.js → pin-DiZl7z2n.js} +1 -1
- package/dist/server/ssr/_next/static/playback-activity-AIsC-eO5.js +1 -0
- package/dist/server/ssr/_next/static/refresh-cw-DNvHlOAy.js +1 -0
- package/dist/server/ssr/_next/static/spotify-app-xyDH0rho.js +1 -0
- package/dist/server/ssr/_next/static/storefront-DMeL08z3.js +1 -0
- package/dist/server/ssr/index.js +1 -1
- package/dist/server/ssr/vinext-client-assets.js +1 -1
- package/dist/server/ssr/vinext-server.json +1 -1
- package/dist/server/vinext-client-assets.js +1 -1
- package/dist/server/vinext-prerender-paths.json +1 -1
- package/dist/server/vinext-prerender.json +16 -1
- package/dist/server/vinext-server.json +1 -1
- package/package.json +4 -2
- package/dist/client/_next/static/chunks/manage-profiles-modal-Doi6QM4e.js +0 -1
- package/dist/client/_next/static/chunks/netflix-browser-L_Vb9wXK.js +0 -2
- package/dist/client/_next/static/chunks/playback-activity-Dug3BRYr.js +0 -1
- package/dist/client/_next/static/chunks/playback-activity-track-switcher-CbO6kl8K.js +0 -1
- package/dist/client/_next/static/chunks/spotify-app-f93K4FG_.js +0 -1
- package/dist/client/_next/static/chunks/storefront-C_nmcuvH.js +0 -1
- package/dist/client/_next/static/css/index.BGXy8e6j.css +0 -1
- package/dist/client/_next/static/css/layout.AKSLtSR6.css +0 -1
- package/dist/client/_next/static/css/layout.D8T68cCD.css +0 -1
- package/dist/client/_next/static/css/manage-profiles-modal.BAVyxRRR.css +0 -1
- package/dist/server/_next/static/css/index.BGXy8e6j.css +0 -1
- package/dist/server/_next/static/css/layout.AKSLtSR6.css +0 -1
- package/dist/server/_next/static/css/layout.D8T68cCD.css +0 -1
- package/dist/server/_next/static/database-BNnYfHmT.js +0 -114
- package/dist/server/_next/static/netflix-page-BRbORN1F.js +0 -1
- package/dist/server/_next/static/route-96DdgJBs.js +0 -1
- package/dist/server/_next/static/route-BBmE0xf12.js +0 -1
- package/dist/server/_next/static/route-BdG5ojMj2.js +0 -1
- package/dist/server/_next/static/route-BovNctFc.js +0 -1
- package/dist/server/_next/static/route-C2LuSjoh.js +0 -1
- package/dist/server/_next/static/route-CCUsQ7AG.js +0 -1
- package/dist/server/_next/static/route-CN6VdJwN.js +0 -1
- package/dist/server/_next/static/route-CjUCKwSj2.js +0 -1
- package/dist/server/_next/static/route-Cn40NftM.js +0 -1
- package/dist/server/_next/static/route-DWAMZHLa.js +0 -1
- package/dist/server/_next/static/route-DiT9UYUd.js +0 -1
- package/dist/server/_next/static/route-jMq6H_yh.js +0 -1
- package/dist/server/_next/static/storage-D1zF0J_t.js +0 -288
- package/dist/server/_next/static/streamer-B1PRR-dj.js +0 -2
- package/dist/server/ssr/_next/static/css/refresh-cw.BAVyxRRR.css +0 -1
- package/dist/server/ssr/_next/static/minimize-C9JLgte-.js +0 -1
- package/dist/server/ssr/_next/static/netflix-browser-CMAehdwi.js +0 -2
- package/dist/server/ssr/_next/static/playback-activity-D5TYX2Ae.js +0 -1
- package/dist/server/ssr/_next/static/refresh-cw-CWdWHjqY.js +0 -1
- package/dist/server/ssr/_next/static/spotify-app-CE-RaTjZ.js +0 -1
- package/dist/server/ssr/_next/static/storefront-C5NNzPMa.js +0 -1
- /package/dist/client/_next/static/{e1ce9af7-d770-43d6-845a-511443f19971 → 7c810a6d-59fd-41d6-b465-cf61efaea04f}/_buildManifest.js +0 -0
- /package/dist/client/_next/static/{e1ce9af7-d770-43d6-845a-511443f19971 → 7c810a6d-59fd-41d6-b465-cf61efaea04f}/_ssgManifest.js +0 -0
- /package/dist/server/_next/static/{layout-Ds3pFa6r.js → layout-D1iejeee.js} +0 -0
- /package/dist/server/_next/static/{layout-ClEWbCcj.js → layout-DpOw0OgX.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t}from"./framework-BQUlGUOV.js";import{s as n}from"./navigation-errors-C_V42-00.js";import"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t}from"./framework-BQUlGUOV.js";import{s as n}from"./navigation-errors-C_V42-00.js";import"./index-BUxxgh38.js";var r=e(t(),1),i=new Map;function a(e,t){return e?{...e,...t}:t}function o({providerId:e,segmentMap:t,children:o}){let s=(0,r.useRef)(null),c=n(),l=a(s.current??(e?i.get(e)??null:null),t);return(0,r.useEffect)(()=>{s.current=l,e&&i.set(e,l)},[l,e]),c?(0,r.createElement)(c.Provider,{value:l},o):o}export{o as LayoutSegmentProvider,a as mergeLayoutSegmentMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n}from"./framework-BQUlGUOV.js";import{n as r}from"./chevron-left-Dn3noAqV.js";var i=r(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),a=r(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),o=r(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),s=r(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),c=r(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),l=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),u=r(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),d=r(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),f=r(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),p=r(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),m=r(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),h=r(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),g=r(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),_=r(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),v=r(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),y=r(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),b=r(`volume-x`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),x=r(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),S=e(n()),C=Object.defineProperty,w=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||={})T.call(t,n)&&D(e,n,t[n]);if(w)for(var n of w(t))E.call(t,n)&&D(e,n,t[n]);return e},k=(e,t)=>{var n={};for(var r in e)T.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&w)for(var r of w(e))t.indexOf(r)<0&&E.call(e,r)&&(n[r]=e[r]);return n},A;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(A||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(A||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(A||={});var j=A,M={L:j.QrCode.Ecc.LOW,M:j.QrCode.Ecc.MEDIUM,Q:j.QrCode.Ecc.QUARTILE,H:j.QrCode.Ecc.HIGH},N=128,P=`L`,F=`#FFFFFF`,I=`#000000`,L=!1,R=1,z=4,B=0,V=.1;function H(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function U(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function W(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*V),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function G(e,t){return t==null?e?z:B:Math.max(Math.floor(t),0)}function K({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=S.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...j.QrSegment.makeSegments(t)),e),[]);return j.QrCode.encodeSegments(r,M[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=S.useMemo(()=>{let e=c.getModules(),t=G(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:W(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var q=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ee=S.forwardRef(function(e,t){let n=e,{value:r,size:i=N,level:a=P,bgColor:o=F,fgColor:s=I,includeMargin:c=L,minVersion:l=R,boostLevel:u,marginSize:d,imageSettings:f}=n,p=k(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=k(p,[`style`]),g=f?.src,_=S.useRef(null),v=S.useRef(null),y=S.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=S.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=K({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});S.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=v.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=U(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,q?t.fill(new Path2D(H(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),S.useEffect(()=>{x(!1)},[g]);let D=O({height:i,width:i},m),A=null;return g!=null&&(A=S.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:E?.crossOrigin})),S.createElement(S.Fragment,null,S.createElement(`canvas`,O({style:D,height:i,width:i,ref:y,role:`img`},h)),A)});ee.displayName=`QRCodeCanvas`;var J=S.forwardRef(function(e,t){let n=e,{value:r,size:i=N,level:a=P,bgColor:o=F,fgColor:s=I,includeMargin:c=L,minVersion:l=R,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=k(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=K({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=U(g,v.excavation)),b=S.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=H(y,h);return S.createElement(`svg`,O({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&S.createElement(`title`,null,d),S.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),S.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});J.displayName=`QRCodeSVG`;var Y=t();function X(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select();let n=document.execCommand(`copy`);if(t.remove(),!n)throw Error(`Copy is not available.`)}function te({id:e=`access-popover`,className:t=``,theme:n=`dark`}={}){let[r,a]=(0,S.useState)(`lan`),[o,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(``),[p,h]=(0,S.useState)(!1),g=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=new AbortController;return fetch(`/api/access?path=%2F`,{cache:`no-store`,signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Could not detect network addresses.`);u(t)}).catch(t=>{e.signal.aborted||f(t instanceof Error?t.message:`Could not detect network addresses.`)}),()=>{e.abort(),g.current&&clearTimeout(g.current)}},[]);let _=o?.[r]??null,v=r===`lan`?`LAN`:`VPN (Tailscale)`,y=async()=>{if(_){try{navigator.clipboard?.writeText?await navigator.clipboard.writeText(_.url):X(_.url)}catch{X(_.url)}h(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>h(!1),1800)}},b=`${e}-tab-panel`;return(0,Y.jsxs)(`div`,{className:`access-popover${n===`light`?` access-popover--light`:``}${t?` ${t}`:``}`,id:e,role:`dialog`,"aria-label":`Access Home Atom from another device`,children:[(0,Y.jsx)(`div`,{className:`access-caret`}),(0,Y.jsxs)(`div`,{className:`access-heading`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(m,{})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`b`,{children:`Open on another device`}),(0,Y.jsx)(`small`,{children:`Scan or copy an address on the same network`})]})]}),(0,Y.jsx)(`div`,{className:`access-tabs`,role:`tablist`,"aria-label":`Network`,children:[[`lan`,`LAN`],[`vpn`,`VPN (Tailscale)`]].map(([e,t])=>(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,"aria-controls":b,onClick:()=>{a(e),h(!1)},children:t},e))}),(0,Y.jsx)(`div`,{className:`access-tab-panel`,id:b,role:`tabpanel`,children:!o&&!d?(0,Y.jsxs)(`div`,{className:`access-loading`,role:`status`,children:[(0,Y.jsx)(l,{className:`access-spin`}),`Detecting `,v,` address…`]}):d?(0,Y.jsxs)(`div`,{className:`access-unavailable`,role:`alert`,children:[(0,Y.jsx)(m,{}),(0,Y.jsx)(`b`,{children:`Network address unavailable`}),(0,Y.jsx)(`small`,{children:d})]}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`access-url-row`,children:[(0,Y.jsxs)(`a`,{href:_.url,target:`_blank`,rel:`noreferrer`,title:_.url,children:[(0,Y.jsx)(`span`,{children:_.url}),(0,Y.jsx)(c,{"aria-hidden":`true`})]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Copy ${v} URL`,onClick:()=>void y(),children:[p?(0,Y.jsx)(i,{}):(0,Y.jsx)(s,{}),(0,Y.jsx)(`span`,{children:p?`Copied`:`Copy`})]})]}),(0,Y.jsx)(`div`,{className:`access-qr`,children:(0,Y.jsx)(J,{value:_.url,size:184,level:`M`,marginSize:3,title:`${v} access QR code`})}),(0,Y.jsx)(`p`,{children:`Scan with your phone or tablet to open Home Atom.`})]}):(0,Y.jsxs)(`div`,{className:`access-unavailable`,role:`status`,children:[(0,Y.jsx)(m,{}),(0,Y.jsxs)(`b`,{children:[v,` address not found`]}),(0,Y.jsx)(`small`,{children:r===`lan`?`Connect the server to your local network and try again.`:`Install and start Tailscale on the server, then reopen this panel.`}),r===`vpn`?(0,Y.jsxs)(`a`,{className:`access-unavailable-link`,href:`https://tailscale.com/download`,target:`_blank`,rel:`noreferrer`,children:[(0,Y.jsx)(`span`,{children:`Download Tailscale`}),(0,Y.jsx)(c,{"aria-hidden":`true`})]}):null]})})]})}function ne({id:e=`access-popover`,buttonClassName:t=``,wrapClassName:n=``,popoverClassName:r=``,label:i=`Open on another device`,icon:a,theme:o=`dark`,open:s,onOpenChange:c}){let[l,u]=(0,S.useState)(!1),d=(0,S.useRef)(null),f=(0,S.useRef)(c),p=s!==void 0,h=s??l;return(0,S.useEffect)(()=>{f.current=c}),(0,S.useEffect)(()=>{if(!h)return;let e=()=>{p||u(!1),f.current?.(!1)},t=t=>{t.target instanceof Node&&!d.current?.contains(t.target)&&e()},n=t=>{t.key===`Escape`&&(t.stopPropagation(),e())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n,!0)}},[p,h]),(0,Y.jsxs)(`div`,{className:`access-popover-wrap${n?` ${n}`:``}`,ref:d,children:[(0,Y.jsx)(`button`,{type:`button`,className:t,"aria-label":i,"aria-expanded":h,"aria-haspopup":`dialog`,"aria-controls":e,onClick:()=>{let e=!h;p||u(e),c?.(e)},children:a??(0,Y.jsx)(m,{})}),h&&(0,Y.jsx)(te,{id:e,className:r,theme:o})]})}var Z={backdrop:`_backdrop_ttlmb_1`,"backdrop-in":`_backdrop-in_ttlmb_1`,modal:`_modal_ttlmb_15`,"modal-in":`_modal-in_ttlmb_1`,close:`_close_ttlmb_29`,header:`_header_ttlmb_59`,icon:`_icon_ttlmb_66`,list:`_list_ttlmb_91`,row:`_row_ttlmb_98`,avatar:`_avatar_ttlmb_113`,name:`_name_ttlmb_125`,iconButton:`_iconButton_ttlmb_142`,button:`_button_ttlmb_161`,iconButtonDanger:`_iconButtonDanger_ttlmb_170`,editor:`_editor_ttlmb_179`,editorFields:`_editorFields_ttlmb_189`,addForm:`_addForm_ttlmb_196`,editorActions:`_editorActions_ttlmb_218`,buttonPrimary:`_buttonPrimary_ttlmb_244`,buttonQuiet:`_buttonQuiet_ttlmb_249`,buttonDanger:`_buttonDanger_ttlmb_253`,colorPicker:`_colorPicker_ttlmb_263`,deleteConfirm:`_deleteConfirm_ttlmb_313`,error:`_error_ttlmb_349`,spin:`_spin_ttlmb_355`},Q=[`#1565c0`,`#f05b47`,`#6a4c93`,`#00897b`,`#ef6c00`,`#ad1457`];function re(e){let t=(0,S.useRef)(null),n=(0,S.useRef)(e);return(0,S.useEffect)(()=>{n.current=e},[e]),(0,S.useEffect)(()=>{let e=document.activeElement,r=document.body.style.overflow;document.body.style.overflow=`hidden`;let i=()=>Array.from(t.current?.querySelectorAll(`button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)??[]).filter(e=>!e.hasAttribute(`disabled`)),a=window.requestAnimationFrame(()=>i()[0]?.focus()),o=e=>{if(e.key===`Escape`){e.preventDefault(),n.current();return}if(e.key!==`Tab`)return;let r=i();if(!r.length)return;let a=r[0],o=r[r.length-1];e.shiftKey&&document.activeElement===a?(e.preventDefault(),o.focus()):(!e.shiftKey&&document.activeElement===o||document.activeElement&&!t.current?.contains(document.activeElement))&&(e.preventDefault(),a.focus())};return document.addEventListener(`keydown`,o),()=>{window.cancelAnimationFrame(a),document.removeEventListener(`keydown`,o),document.body.style.overflow=r,e?.isConnected&&e.focus()}},[]),t}function ie({profiles:e,activeProfile:t,onClose:n,onProfilesChanged:r}){let a=re(n),[o,s]=(0,S.useState)(``),[c,u]=(0,S.useState)(Q[2]),[f,m]=(0,S.useState)(null),[h,g]=(0,S.useState)(``),[_,y]=(0,S.useState)(Q[0]),[b,C]=(0,S.useState)(null),[w,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(``),O=async e=>{let t=await e.json();if(!e.ok||!t.profiles||!t.activeProfile)throw Error(t.error||`Profiles could not be saved.`);await r(t.profiles,t.activeProfile)},k=async t=>{t.preventDefault(),T(!0),D(``);try{let t=await fetch(`/api/netflix/profiles`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:o,avatarColor:c})});await O(t),s(``),u(Q[(e.length+1)%Q.length])}catch(e){D(e instanceof Error?e.message:`Profile could not be added.`)}finally{T(!1)}},A=async e=>{if(e.preventDefault(),f){T(!0),D(``);try{let e=await fetch(`/api/netflix/profiles/${encodeURIComponent(f)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:h,avatarColor:_})});await O(e),m(null)}catch(e){D(e instanceof Error?e.message:`Profile could not be updated.`)}finally{T(!1)}}},j=async()=>{if(b){T(!0),D(``);try{let e=await fetch(`/api/netflix/profiles/${encodeURIComponent(b.id)}`,{method:`DELETE`});await O(e),C(null),f===b.id&&m(null)}catch(e){D(e instanceof Error?e.message:`Profile could not be deleted.`)}finally{T(!1)}}},M=e=>{m(e.id),g(e.name),y(e.avatarColor),C(null),D(``)};return(0,Y.jsx)(`div`,{className:Z.backdrop,onMouseDown:n,children:(0,Y.jsxs)(`article`,{ref:a,className:Z.modal,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`manage-profiles-title`,onMouseDown:e=>e.stopPropagation(),children:[(0,Y.jsx)(`button`,{className:Z.close,"aria-label":`Close`,onClick:n,children:(0,Y.jsx)(x,{})}),(0,Y.jsxs)(`header`,{className:Z.header,children:[(0,Y.jsx)(`span`,{className:Z.icon,children:(0,Y.jsx)(d,{})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{id:`manage-profiles-title`,children:`Manage Profiles`}),(0,Y.jsx)(`p`,{children:`Each profile keeps its own list and exact watch position.`})]})]}),(0,Y.jsx)(`div`,{className:Z.list,children:e.map(n=>f===n.id?(0,Y.jsxs)(`form`,{className:Z.editor,onSubmit:A,children:[(0,Y.jsx)(`span`,{className:Z.avatar,style:{backgroundColor:_},"aria-hidden":`true`,children:h.slice(0,1).toUpperCase()||`?`}),(0,Y.jsxs)(`div`,{className:Z.editorFields,children:[(0,Y.jsx)(`label`,{htmlFor:`profile-name-${n.id}`,children:`Profile name`}),(0,Y.jsx)(`input`,{id:`profile-name-${n.id}`,required:!0,maxLength:30,value:h,onChange:e=>g(e.currentTarget.value)}),(0,Y.jsx)($,{name:`edit-color-${n.id}`,value:_,onChange:y})]}),(0,Y.jsxs)(`div`,{className:Z.editorActions,children:[(0,Y.jsx)(`button`,{type:`button`,className:`${Z.button} ${Z.buttonQuiet}`,onClick:()=>m(null),children:`Cancel`}),(0,Y.jsxs)(`button`,{type:`submit`,className:`${Z.button} ${Z.buttonPrimary}`,disabled:w,children:[(0,Y.jsx)(i,{}),` Save`]})]})]},n.id):(0,Y.jsxs)(`article`,{className:Z.row,children:[(0,Y.jsx)(`span`,{className:Z.avatar,style:{backgroundColor:n.avatarColor},"aria-hidden":`true`,children:n.name.slice(0,1).toUpperCase()}),(0,Y.jsxs)(`span`,{className:Z.name,children:[(0,Y.jsx)(`b`,{children:n.name}),(0,Y.jsx)(`small`,{children:n.id===t.id?`Currently watching`:`Separate viewing data`})]}),(0,Y.jsx)(`button`,{type:`button`,className:Z.iconButton,"aria-label":`Edit ${n.name}`,onClick:()=>M(n),children:(0,Y.jsx)(d,{})}),(0,Y.jsx)(`button`,{type:`button`,className:`${Z.iconButton} ${Z.iconButtonDanger}`,"aria-label":`Delete ${n.name}`,disabled:e.length===1,onClick:()=>{C(n),m(null)},children:(0,Y.jsx)(v,{})})]},n.id))}),b&&(0,Y.jsxs)(`div`,{className:Z.deleteConfirm,role:`alert`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`b`,{children:[`Delete `,b.name,`?`]}),(0,Y.jsx)(`small`,{children:`Their list and watch history will also be deleted.`})]}),(0,Y.jsx)(`button`,{type:`button`,className:`${Z.button} ${Z.buttonQuiet}`,onClick:()=>C(null),children:`Keep profile`}),(0,Y.jsx)(`button`,{type:`button`,className:`${Z.button} ${Z.buttonDanger}`,disabled:w,onClick:()=>void j(),children:`Delete`})]}),(0,Y.jsxs)(`form`,{className:Z.addForm,onSubmit:k,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`new-profile-name`,children:`Add a profile`}),(0,Y.jsx)(`input`,{id:`new-profile-name`,required:!0,maxLength:30,placeholder:`Profile name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,Y.jsx)($,{name:`new-profile-color`,value:c,onChange:u}),(0,Y.jsxs)(`button`,{type:`submit`,className:`${Z.button} ${Z.buttonPrimary}`,disabled:w,children:[w?(0,Y.jsx)(l,{className:Z.spin}):(0,Y.jsx)(p,{}),`Add profile`]})]}),E&&(0,Y.jsx)(`p`,{className:Z.error,role:`alert`,children:E})]})})}function $({name:e,value:t,onChange:n}){return(0,Y.jsxs)(`fieldset`,{className:Z.colorPicker,children:[(0,Y.jsx)(`legend`,{children:`Avatar color`}),(0,Y.jsx)(`div`,{children:Q.map((r,i)=>(0,Y.jsxs)(`label`,{title:`Color ${i+1}`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:e,value:r,checked:t===r,onChange:()=>n(r)}),(0,Y.jsx)(`span`,{style:{backgroundColor:r}})]},r))})]})}export{a as _,y as a,h as c,f as d,d as f,o as g,c as h,b as i,m as l,l as m,ne as n,_ as o,u as p,x as r,g as s,ie as t,p as u,i as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n}from"./framework-BQUlGUOV.js";import{r}from"./index-BUxxgh38.js";import{n as i,t as a}from"./chevron-left-Dn3noAqV.js";import{a as o,c as s,d as c,i as l,l as u,n as d,o as f,r as p,s as m,t as ee,u as te}from"./provider-registry-CWHfJn3B.js";import{a as h,c as ne,i as re,l as g,n as _,o as v,r as ie,s as y,t as ae}from"./playback-activity-66FeikYZ.js";import{_ as b,a as oe,c as x,d as S,f as C,g as w,i as se,m as T,n as ce,o as le,p as ue,r as de,s as E,t as D,u as fe,v as O}from"./manage-profiles-modal-CWi3qgd4.js";var pe=i(`arrow-down-narrow-wide`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h4`,key:`6d7r33`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h10`,key:`1438ji`}]]),me=i(`arrow-up-narrow-wide`,[[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}],[`path`,{d:`M11 16h7`,key:`uosisv`}],[`path`,{d:`M11 20h10`,key:`jvxblo`}]]),he=i(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),ge=i(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),_e=i(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ve=i(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ye=i(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),be=i(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),xe=i(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Se=i(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Ce=i(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),k=i(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),A=e(n(),1);function j(e){return e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/\b(?:19|20)\d{2}\b/g,` `).replace(/&/g,` and `).replace(/[^a-z0-9]+/g,` `).trim()}function M(e){return Array.from(new Set([e.title,e.originalTitle].filter(e=>!!e?.trim()).map(j).filter(Boolean))).map(t=>`${t}:${e.year}`)}function we(e,t){return e.sourceProvider&&t.has(e.sourceProvider)?t.get(e.sourceProvider):e.sourceProvider?t.size+1:t.size}function Te(e,t=ee.map(e=>e.id)){let n=new Map(t.map((e,t)=>[e,t])),r=e.map((e,t)=>({movie:e,index:t})).sort((e,t)=>we(e.movie,n)-we(t.movie,n)||e.index-t.index),i=new Set,a=new Set,o=[];for(let{movie:e}of r){if(e.sourceUrl&&a.has(e.sourceUrl))continue;let t=M(e);if(!t.some(e=>i.has(e))){o.push(e),e.sourceUrl&&a.add(e.sourceUrl);for(let e of t)i.add(e)}}return o}function Ee(e,t){let n=t.trim().toLocaleLowerCase();return n?[e.title,e.originalTitle??``,e.synopsis,e.genres.join(` `),e.cast.join(` `),e.creators?.join(` `)??``,e.director??``].join(` `).toLocaleLowerCase().includes(n):!1}var De=/(?:\s*[-–—|]\s*|\s+)(?:tập|tap|episode|ep\.?)\s*\d+(?:\s*\/\s*\d+)?(?:\s*(?:vietsub|thuyết\s*minh|thuyet\s*minh|lồng\s*tiếng|long\s*tieng|engsub|phụ\s*đề|phu\s*de|\[[^\]]+\]))*\s*$/iu;function Oe(e){let t=e.replace(/\s+/g,` `).trim();return t.replace(De,``).trim()||t}var N=t(),ke={myList:[],likedTitles:[],episodeSort:{},trackedTitles:[],newEpisodes:[],progress:[],subtitlePreferences:{fontSize:32,positionX:50,positionY:78,fontColor:`#ffffff`,backgroundColor:`rgba(0,0,0,0.75)`,fontFamily:`default`,captionsOn:!1,updatedAt:``}},P=[{label:`Home`,href:`/netflix`},{label:`Series`,href:`/netflix#netflix-originals`},{label:`Films`,href:`/netflix#movie-night`},{label:`New & Popular`,href:`/netflix#top-10`},{label:`My List`,href:`/netflix#my-list`},{label:`Browse by language`,href:`/netflix#footer`}],Ae=5*6e4;function je(e){return e?`/netflix/search?q=${encodeURIComponent(e)}`:`/netflix/search`}function Me(e){return e.sourceUrl?e.mediaType!==`movie`||(e.episodes?.length??0)>0:!1}function Ne(e){return e.resumePositionSeconds!==void 0}function Pe(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.round((Date.now()-t)/6e4);if(n<1)return`Just now`;if(n<60)return`${n} minute${n===1?``:`s`} ago`;let r=Math.round(n/60);if(r<24)return`${r} hour${r===1?``:`s`} ago`;let i=Math.round(r/24);return`${i} day${i===1?``:`s`} ago`}function Fe(){let e=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let t=document.activeElement,n=()=>Array.from(e.current?.querySelectorAll(`button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)??[]).filter(e=>!e.hasAttribute(`disabled`)),r=window.requestAnimationFrame(()=>n()[0]?.focus()),i=t=>{if(t.key!==`Tab`)return;let r=n();if(!r.length)return;let i=r[0],a=r[r.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),a.focus()):(!t.shiftKey&&document.activeElement===a||document.activeElement&&!e.current?.contains(document.activeElement))&&(t.preventDefault(),i.focus())};return document.addEventListener(`keydown`,i),()=>{window.cancelAnimationFrame(r),document.removeEventListener(`keydown`,i),t?.isConnected&&t.focus()}},[]),e}function Ie({featured:e,rows:t,initialImportedTitles:n,initialProviders:r,initialProfiles:i,initialActiveProfile:a,initialProfileLibrary:o,initialSearchOpen:s=!1,initialSearchQuery:c=``}){let[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(!1),[ee,te]=(0,A.useState)(!1),[h,ne]=(0,A.useState)(s),[re,g]=(0,A.useState)(!1),[_,v]=(0,A.useState)(!1),[ie,y]=(0,A.useState)(!1),[ae,b]=(0,A.useState)(!1),[oe,x]=(0,A.useState)(r),[S,C]=(0,A.useState)(n),[w,se]=(0,A.useState)(i),[T,ce]=(0,A.useState)(a),[le,ue]=(0,A.useState)(o),[de,E]=(0,A.useState)(``),[O,pe]=(0,A.useState)(c),[me,he]=(0,A.useState)([]),[ge,_e]=(0,A.useState)(``),[ve,ye]=(0,A.useState)(`idle`),[be,xe]=(0,A.useState)(``),[Se,Ce]=(0,A.useState)(null),[k,j]=(0,A.useState)(null),[M,we]=(0,A.useState)(null),[De,Oe]=(0,A.useState)(!1),[P,Pe]=(0,A.useState)(new Set(o.myList)),[Fe,Ie]=(0,A.useState)(new Set(o.likedTitles)),[Re,ze]=(0,A.useState)(new Set(o.trackedTitles??[])),[F,I]=(0,A.useState)(o.episodeSort??{}),He=(0,A.useRef)(null),R=(0,A.useRef)(s),Ge=(0,A.useRef)(c),z=(0,A.useRef)({version:0,controller:null}),B=(0,A.useRef)(a.id),Ke=(0,A.useRef)(r),qe=(0,A.useRef)(0),Je=(0,A.useRef)(0),V=(0,A.useRef)(0),Ye=(0,A.useRef)(Promise.resolve()),H=(0,A.useRef)(!1),Qe=(0,A.useCallback)(e=>{B.current!==e&&(B.current=e,qe.current+=1,V.current+=1,H.current=!1,z.current.version+=1,z.current.controller?.abort(),z.current.controller=null,Ke.current=[],x([]),C([]),ue(ke),Pe(new Set),Ie(new Set),ze(new Set),j(null),we(null),E(``))},[]),$e=(0,A.useCallback)(()=>{z.current.version+=1,z.current.controller?.abort(),z.current.controller=null},[]),et=(0,A.useCallback)(()=>{$e(),we(null)},[$e]);(0,A.useEffect)(()=>()=>{$e()},[$e]),(0,A.useEffect)(()=>{Ke.current=oe},[oe]);let tt=(0,A.useCallback)((e,t,n)=>{let r=e?je(t):`/netflix`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==r&&(n===`push`?window.history.pushState(null,``,r):window.history.replaceState(null,``,r))},[]),U=(0,A.useCallback)(e=>{let t=R.current;if(R.current=e,ne(e),e){t||tt(!0,Ge.current,`push`);return}Ge.current=``,pe(``),t&&tt(!1,``,`push`)},[tt]),nt=(0,A.useCallback)(e=>{Ge.current=e,pe(e),R.current&&tt(!0,e,`replace`)},[tt]),rt=(0,A.useMemo)(()=>{let n=[e,...S,...t.flatMap(e=>e.items)];return Array.from(new Map(n.map(e=>[e.id,e])).values())},[e,S,t]),W=(0,A.useMemo)(()=>{let e=new Map(le.progress.map(e=>[e.titleId,e]));return rt.map(t=>{let n=e.get(t.id);return!n||n.completed||n.positionSeconds<1?{...t,progress:void 0,resumeSeason:void 0,resumeEpisode:void 0,resumePositionSeconds:void 0,resumeDurationSeconds:void 0,resumeUpdatedAt:void 0}:{...t,progress:n.durationSeconds>0?Math.min(100,n.positionSeconds/n.durationSeconds*100):0,resumeSeason:n.seasonNumber,resumeEpisode:n.episodeNumber,resumePositionSeconds:n.positionSeconds,resumeDurationSeconds:n.durationSeconds,resumeUpdatedAt:n.updatedAt}})},[rt,le.progress]),G=(0,A.useMemo)(()=>new Map(W.map(e=>[e.id,e])),[W]),it=(0,A.useMemo)(()=>{let e=O.trim();return e?W.filter(t=>Ee(t,e)):[]},[W,O]),at=O.trim(),ot=(0,A.useMemo)(()=>oe.map(e=>e.id),[oe]),st=ot.join(`,`),ct=at.length>=2&&ge===at?me:[],lt=at.length<2?`idle`:ge===at?ve:`loading`,ut=ge===at?be:``,dt=Te([...it,...ct],ot),ft=(0,A.useMemo)(()=>W.filter(e=>P.has(e.id)),[P,W]),pt=(0,A.useMemo)(()=>{let e=new Map(le.progress.map(e=>[e.titleId,e]));return W.filter(t=>{let n=e.get(t.id);return!!(n&&!n.completed&&n.positionSeconds>=1&&(n.durationSeconds<=0||n.positionSeconds/n.durationSeconds<.95))}).sort((t,n)=>{let r=e.get(t.id)?.updatedAt??``;return(e.get(n.id)?.updatedAt??``).localeCompare(r)})},[le.progress,W]),K=(0,A.useMemo)(()=>le.newEpisodes??[],[le.newEpisodes]),mt=(0,A.useMemo)(()=>K.filter(e=>!e.seen).length,[K]),ht=(0,A.useMemo)(()=>{let e=new Map;for(let t of K){let n=e.get(t.titleId);(!n||t.seasonNumber>n.seasonNumber||t.seasonNumber===n.seasonNumber&&t.episodeNumber>n.episodeNumber)&&e.set(t.titleId,t)}return e},[K]),gt=(0,A.useMemo)(()=>Array.from(ht.keys()).flatMap(e=>{let t=G.get(e);return t?[t]:[]}),[ht,G]);(0,A.useEffect)(()=>{let e=()=>u(window.scrollY>24);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),(0,A.useEffect)(()=>{let e=()=>{let e=window.location.pathname.replace(/\/+$/,``)===`/netflix/search`,t=e?new URLSearchParams(window.location.search).get(`q`)??``:``;R.current=e,Ge.current=t,ne(e),pe(t)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,A.useEffect)(()=>{h&&(window.scrollTo(0,0),He.current?.focus())},[h]),(0,A.useEffect)(()=>{let e=O.trim();if(!h||e.length<2)return;let t=new AbortController,n=window.setTimeout(()=>{_e(e),he([]),ye(`loading`),xe(``);let n=new URLSearchParams({q:e,profileId:T.id});fetch(`/api/netflix/search?${n}`,{cache:`no-store`,signal:t.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Provider search failed.`);he(t.titles??[]),ye(`ready`),t.failedProviders?.length&&xe(`Some providers could not be searched: ${t.failedProviders.join(`, `)}.`)}).catch(e=>{t.signal.aborted||(ye(`error`),xe(e instanceof Error?e.message:`Provider search failed.`))})},350);return()=>{window.clearTimeout(n),t.abort()}},[T.id,st,h,O]),(0,A.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(M?et():k?j(null):ae?b(!1):ie?y(!1):h&&O?nt(``):h?U(!1):(g(!1),v(!1),f(!1),m(!1),te(!1)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[ie,et,ae,M,h,O,k,U,nt]);let _t=(0,A.useCallback)(async e=>{let t=++qe.current,n=await fetch(`/api/netflix/library?profileId=${encodeURIComponent(e)}`,{cache:`no-store`});if(!n.ok)return;let r=await n.json();B.current!==e||t!==qe.current||(H.current||(Ke.current=r.providers,x(r.providers)),C(r.titles))},[]),vt=(0,A.useCallback)(async e=>{let t=T.id,n=++V.current;qe.current+=1,H.current=!0;let r=Ke.current,i=new Map(r.map(e=>[e.id,e])),a=e.flatMap(e=>{let t=i.get(e);return t?[t]:[]}),o=new Set(e),s=[...a,...r.filter(({id:e})=>!o.has(e))].map((e,t)=>({...e,priority:t}));Ke.current=s,x(s),E(`Saving source priority…`);try{let r={},i=!1,a=Ye.current.catch(()=>void 0).then(async()=>{let n=await fetch(`/api/netflix/providers/order`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providerIds:e,profileId:t})});r=await n.json(),i=n.ok});if(Ye.current=a,await a,!i||!r.providers)throw Error(r.error||`Source priority could not be saved.`);if(B.current!==t||V.current!==n)return;qe.current+=1,H.current=!1,Ke.current=r.providers,x(r.providers),E(`Source priority saved.`)}catch(e){if(B.current!==t||V.current!==n)return;H.current=!1,Ke.current=r,x(r),E(e instanceof Error?e.message:`Source priority could not be saved.`);try{await _t(t)}catch{}}},[T.id,_t]),yt=(0,A.useCallback)(async e=>{let t=T.id,n=W.find(t=>t.id===e.id||e.sourceUrl&&t.sourceUrl===e.sourceUrl);if(n||!e.sourceProvider||!e.sourceUrl){U(!1),j(n??e);return}Ce(e.id),xe(``);try{let n=await fetch(`/api/netflix/movies/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:e.sourceUrl,mode:`stream`,profileId:t})}),r=await n.json();if(!n.ok||!r.title)throw Error(r.error||`Movie details could not be loaded.`);if(B.current!==t)return;C(e=>[r.title,...e.filter(e=>e.id!==r.title.id&&e.sourceUrl!==r.title.sourceUrl)]),U(!1),j(r.title)}catch(e){xe(e instanceof Error?e.message:`Movie details could not be loaded.`)}finally{Ce(null)}},[T.id,W,U]);(0,A.useEffect)(()=>{let e=T.id,t=window.setTimeout(()=>void _t(e),0);return()=>window.clearTimeout(t)},[T.id,_t]),(0,A.useEffect)(()=>{if(!S.some(e=>e.downloadStatus===`queued`||e.downloadStatus===`downloading`))return;let e=T.id,t=window.setInterval(()=>void _t(e),3e3);return()=>window.clearInterval(t)},[T.id,S,_t]),(0,A.useEffect)(()=>{if(!k&&!M&&!ie)return;let e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow,i=e.style.overscrollBehavior,a=t.style.overscrollBehavior,o=t.style.position,s=t.style.top,c=t.style.left,l=t.style.right,u=t.style.width,d=window.scrollX,f=window.scrollY;return e.style.overflow=`hidden`,t.style.overflow=`hidden`,e.style.overscrollBehavior=`none`,t.style.overscrollBehavior=`none`,t.style.position=`fixed`,t.style.top=`${-f}px`,t.style.left=`${-d}px`,t.style.right=`0`,t.style.width=`100%`,()=>{e.style.overflow=n,t.style.overflow=r,e.style.overscrollBehavior=i,t.style.overscrollBehavior=a,t.style.position=o,t.style.top=s,t.style.left=c,t.style.right=l,t.style.width=u,window.scrollTo(d,f)}},[ie,M,k]);let q=(0,A.useCallback)(e=>{ue({...e,trackedTitles:e.trackedTitles??[],newEpisodes:e.newEpisodes??[]}),Pe(new Set(e.myList)),Ie(new Set(e.likedTitles)),ze(new Set(e.trackedTitles??[])),I(e.episodeSort??{})},[]),J=(0,A.useCallback)(async e=>{let t=await fetch(`/api/netflix/profiles/${encodeURIComponent(e)}/library`,{cache:`no-store`});if(!t.ok)throw Error(`Profile library could not be loaded.`);let n=await t.json();B.current===e&&q(n)},[q]),bt=(0,A.useCallback)(async e=>{let t=++Je.current,n=await fetch(`/api/netflix/profiles/${encodeURIComponent(e.id)}/select`,{method:`POST`});if(!n.ok)return;let r=await n.json();t===Je.current&&(Qe(r.activeProfile.id),ce(r.activeProfile),q(r.library),m(!1),j(null),$e(),we(null))},[q,Qe,$e]),Y=(0,A.useCallback)(async(e,t)=>{let n=T.id!==t.id;n&&Qe(t.id),se(e),ce(t),n&&await J(t.id)},[T.id,Qe,J]),xt=e=>{let t=T.id,n=!P.has(e.id);Pe(t=>{let r=new Set(t);return n?r.add(e.id):r.delete(e.id),r}),fetch(`/api/netflix/profiles/${encodeURIComponent(t)}/library`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,inMyList:n})}).then(async e=>{if(!e.ok)throw Error();B.current===t&&q(await e.json())}).catch(()=>void J(t))},X=e=>{let t=T.id,n=!Fe.has(e.id);Ie(t=>{let r=new Set(t);return n?r.add(e.id):r.delete(e.id),r}),fetch(`/api/netflix/profiles/${encodeURIComponent(t)}/library`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,liked:n})}).then(async e=>{if(!e.ok)throw Error();B.current===t&&q(await e.json())}).catch(()=>void J(t))},St=(e,t)=>{let n=T.id;I(n=>{let r={...n};return t===`asc`?delete r[e.id]:r[e.id]=t,r}),fetch(`/api/netflix/profiles/${encodeURIComponent(n)}/library`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,episodeSort:t})}).then(async e=>{if(!e.ok)throw Error();B.current===n&&q(await e.json())}).catch(()=>void J(n))},Z=e=>{let t=T.id,n=!Re.has(e.id);ze(t=>{let r=new Set(t);return n?r.add(e.id):r.delete(e.id),r}),fetch(`/api/netflix/profiles/${encodeURIComponent(t)}/library`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,tracked:n})}).then(async e=>{if(!e.ok)throw Error();B.current===t&&q(await e.json())}).catch(()=>void J(t))},Ct=(0,A.useCallback)(e=>{let t=T.id;fetch(`/api/netflix/new-episodes`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...e,profileId:t})}).then(async e=>{if(!e.ok)throw Error();B.current===t&&q(await e.json())}).catch(()=>void J(t))},[T.id,q,J]);(0,A.useEffect)(()=>{let e=T.id,t=window.setInterval(()=>void J(e).catch(()=>void 0),Ae);return()=>window.clearInterval(t)},[T.id,J]);let wt=(e,t)=>{if($e(),e.sourceProvider&&!e.playbackPath&&!e.canStream){j(e);return}let n=t??e.resumeEpisode,r=e.episodes?.find(e=>e.episode===n)||(e.episode?.episode===n?e.episode:void 0)||(n?{season:e.resumeSeason??e.episode?.season??1,episode:n,title:`Episode ${n}`,duration:e.resumeDurationSeconds?`${Math.max(1,Math.round(e.resumeDurationSeconds/60))}m`:`45m`}:e.episode||e.episodes?.[0]),i=t===void 0||t===e.resumeEpisode;j(null),we(r?{...e,episode:r,resumePositionSeconds:i?e.resumePositionSeconds:void 0,resumeDurationSeconds:i?e.resumeDurationSeconds:void 0}:e)},Tt=(0,A.useCallback)(async e=>{let t=z.current;t.version+=1;let n=t.version;t.controller?.abort();let r=new AbortController;t.controller=r;try{let t=await fetch(`/api/netflix/titles/${encodeURIComponent(e)}?profileId=${encodeURIComponent(T.id)}`,{cache:`no-store`,signal:r.signal}),i=await t.json();if(!t.ok||!i.title)throw Error(i.error||`The requested movie was not found.`);if(r.signal.aborted||n!==z.current.version)return;let a=i.title;if(a.sourceProvider&&!a.playbackPath&&!a.canStream)throw Error(`The requested movie is not available to stream.`);a.sourceProvider&&C(e=>[a,...e.filter(e=>e.id!==a.id)]);let o=a.resumeEpisode??a.episode?.episode,s=a.episodes?.find(e=>e.episode===o)||(a.episode?.episode===o?a.episode:void 0)||(o?{season:a.resumeSeason??a.episode?.season??1,episode:o,title:`Episode ${o}`,duration:a.resumeDurationSeconds?`${Math.max(1,Math.round(a.resumeDurationSeconds/60))}m`:`45m`}:a.episode||a.episodes?.[0]);j(null),we(s?{...a,episode:s}:a)}catch(e){if(r.signal.aborted||n!==z.current.version)return;throw e}finally{z.current.controller===r&&(z.current.controller=null)}},[T.id]),Et=(0,A.useCallback)(e=>{ue(t=>({...t,progress:[e,...t.progress.filter(t=>t.titleId!==e.titleId)]}))},[]);return(0,N.jsxs)(`main`,{className:`site-shell`,children:[(0,N.jsx)(Le,{isScrolled:l,mobileMenuOpen:d,setMobileMenuOpen:f,searchOpen:h,setSearchOpen:U,searchQuery:O,setSearchQuery:nt,searchInputRef:He,profileOpen:p,setProfileOpen:m,notificationsOpen:ee,setNotificationsOpen:te,newEpisodeAlerts:K,unseenNotificationCount:mt,onNotificationsOpened:()=>Ct({action:`mark-seen`}),onPlayNewEpisode:e=>{let t=G.get(e.titleId);t&&(Ct({action:`dismiss`,titleId:e.titleId}),wt(t,e.episodeNumber))},sourcesOpen:re,setSourcesOpen:g,downloadsOpen:_,setDownloadsOpen:v,downloads:S.map(e=>G.get(e.id)??e),onPlay:e=>{v(!1),wt(e)},providers:oe,syncMessage:de,onReorderProviders:vt,onSync:async e=>{let t=T.id;x(t=>t.map(t=>t.id===e?{...t,syncStatus:`syncing`,lastError:null}:t)),E(`Syncing provider homepage…`);let n=await fetch(`/api/netflix/providers/${e}/sync?profileId=${encodeURIComponent(t)}`,{method:`POST`}),r=await n.json();B.current===t&&(E(n.ok?`${r.count??0} titles synced to SQLite.`:r.error||`Provider sync failed.`),await _t(t))},onAddMovie:()=>{g(!1),v(!1),y(!0)},profiles:w,activeProfile:T,onSelectProfile:bt,onManageProfiles:()=>{m(!1),b(!0)}}),h?(0,N.jsx)(Ue,{query:O,results:dt,providerStatus:lt,error:ut,resolvingTitleId:Se,onSelect:e=>void yt(e)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Be,{title:G.get(e.id)??e,previewPaused:De,setPreviewPaused:Oe,onPlay:()=>wt(G.get(e.id)??e),onMoreInfo:()=>j(G.get(e.id)??e)}),(0,N.jsxs)(`section`,{className:`catalog`,"aria-label":`Netflix catalog`,children:[S.length>0&&(0,N.jsx)(Ve,{row:{id:`provider-library`,title:`Your Provider Library`,kind:`standard`,items:S.map(e=>G.get(e.id)??e)},rowIndex:-2,myList:P,likedTitles:Fe,onSelect:j,onPlay:wt,onToggleMyList:xt,onToggleLike:X}),gt.length>0&&(0,N.jsx)(Ve,{row:{id:`new-episodes`,title:`New Episode`,kind:`standard`,items:gt},rowIndex:-4,myList:P,likedTitles:Fe,newEpisodeAlertsByTitle:ht,playOnCardClick:!0,onSelect:j,onPlay:(e,t)=>{let n=ht.get(e.id);Ct({action:`dismiss`,titleId:e.id}),wt(e,t??n?.episodeNumber)},onToggleMyList:xt,onToggleLike:X}),pt.length>0&&(0,N.jsx)(Ve,{row:{id:`continue-watching`,title:`Continue Watching for ${T.name}`,kind:`continue-watching`,items:pt},rowIndex:-3,myList:P,likedTitles:Fe,onSelect:j,onPlay:wt,onToggleMyList:xt,onToggleLike:X}),(0,N.jsx)(`div`,{className:`my-list-anchor`,id:`my-list`,children:ft.length>0?(0,N.jsx)(Ve,{row:{id:`my-list-row`,title:`My List`,kind:`standard`,items:ft},rowIndex:-1,myList:P,likedTitles:Fe,onSelect:j,onPlay:wt,onToggleMyList:xt,onToggleLike:X}):(0,N.jsxs)(`div`,{className:`my-list-empty`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:(0,N.jsx)(fe,{})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{children:`Your list is ready for something great`}),(0,N.jsx)(`p`,{children:`Use the plus button on any title to save it here for later.`})]})]})}),t.map((e,t)=>(0,N.jsx)(Ve,{row:{...e,items:e.items.map(e=>G.get(e.id)??e)},rowIndex:t,myList:P,likedTitles:Fe,onSelect:j,onPlay:wt,onToggleMyList:xt,onToggleLike:X},e.id))]}),(0,N.jsx)(Ze,{})]}),k&&(0,N.jsx)(We,{title:k,isInMyList:P.has(k.id),isLiked:Fe.has(k.id),canTrack:Ne(k)&&Me(k),isTracked:Re.has(k.id),episodeSort:F[k.id]??`asc`,onClose:()=>j(null),onPlay:e=>wt(k,e),onToggleMyList:()=>xt(k),onToggleLike:()=>X(k),onToggleTracking:()=>Z(k),onEpisodeSortChange:e=>St(k,e)}),M&&(0,N.jsx)(Xe,{title:M,profileId:T.id,subtitlePreferences:le.subtitlePreferences,episodeSort:F[M.id]??`asc`,onProgressChange:Et,onSubtitlePreferencesChange:e=>ue(t=>({...t,subtitlePreferences:e})),onSwitchTitle:Tt,onEpisodeSortChange:e=>St(M,e),onClose:et},M.id),ae&&(0,N.jsx)(D,{profiles:w,activeProfile:T,onClose:()=>b(!1),onProfilesChanged:Y}),ie&&(0,N.jsx)(L,{profileId:T.id,onClose:()=>y(!1),onImported:async()=>{y(!1),E(`Title and episode metadata added to your library.`),await _t(T.id)}})]})}function Le({isScrolled:e,mobileMenuOpen:t,setMobileMenuOpen:n,searchOpen:r,setSearchOpen:i,searchQuery:a,setSearchQuery:o,searchInputRef:s,profileOpen:c,setProfileOpen:l,notificationsOpen:u,setNotificationsOpen:d,newEpisodeAlerts:f,unseenNotificationCount:p,onNotificationsOpened:m,onPlayNewEpisode:ee,sourcesOpen:te,setSourcesOpen:h,downloadsOpen:re,setDownloadsOpen:_,downloads:v,onPlay:ie,providers:ae,syncMessage:oe,onReorderProviders:x,onSync:S,onAddMovie:C,profiles:w,activeProfile:se,onSelectProfile:T,onManageProfiles:le}){let[ue,D]=(0,A.useState)(!1);return(0,N.jsxs)(`header`,{className:`top-nav${e?` top-nav--solid`:``}${r?` top-nav--search`:``}`,children:[(0,N.jsxs)(`div`,{className:`nav-start`,children:[(0,N.jsx)(`button`,{className:`icon-button mobile-menu-button`,"aria-label":t?`Close navigation`:`Open navigation`,onClick:()=>{D(!1),n(!t)},children:t?(0,N.jsx)(de,{}):(0,N.jsx)(xe,{})}),(0,N.jsx)(`a`,{className:`netflix-wordmark`,href:`/netflix`,"aria-label":`Netflix home`,children:`NETFLIX`}),(0,N.jsx)(`nav`,{className:`primary-nav${t?` primary-nav--open`:``}`,"aria-label":`Primary navigation`,children:P.map((e,t)=>(0,N.jsx)(`a`,{className:t===0?`active`:``,href:e.href,onClick:()=>n(!1),children:e.label},e.label))})]}),(0,N.jsxs)(`div`,{className:`nav-end`,children:[(0,N.jsx)(ce,{id:`netflix-access-popover`,wrapClassName:`nav-popover-wrap`,buttonClassName:`icon-button access-button`,popoverClassName:`netflix-access-popover`,open:ue,onOpenChange:e=>{D(e),h(!1),_(!1),l(!1),d(!1),i(!1)}}),(0,N.jsxs)(`div`,{className:`nav-popover-wrap`,children:[(0,N.jsx)(`button`,{className:`icon-button source-button`,"aria-label":`Movie sources`,"aria-expanded":te,onClick:()=>{D(!1),h(!te),_(!1),l(!1),d(!1),i(!1)},children:(0,N.jsx)(ne,{})}),te&&(0,N.jsx)(Re,{providers:ae,message:oe,onReorder:x,onSync:S,onAddMovie:C})]}),(0,N.jsxs)(`div`,{className:`nav-popover-wrap`,children:[(0,N.jsxs)(`button`,{className:`icon-button download-button`,"aria-label":`Downloads`,"aria-expanded":re,onClick:()=>{D(!1),_(!re),h(!1),l(!1),d(!1),i(!1)},children:[(0,N.jsx)(y,{}),v.some(e=>e.downloadStatus===`queued`||e.downloadStatus===`downloading`)&&(0,N.jsx)(`span`,{className:`download-badge`,"aria-hidden":`true`,children:v.filter(e=>e.downloadStatus===`queued`||e.downloadStatus===`downloading`).length})]}),re&&(0,N.jsx)(ze,{titles:v,onPlay:ie})]}),(0,N.jsxs)(`div`,{className:`search-box${r?` search-box--open`:``}`,children:[(0,N.jsx)(`button`,{className:`icon-button search-trigger`,"aria-label":r?`Focus search`:`Search`,onClick:()=>{D(!1),h(!1),_(!1),l(!1),d(!1),r?s.current?.focus():i(!0)},children:(0,N.jsx)(E,{})}),(0,N.jsx)(`input`,{ref:s,tabIndex:r?0:-1,"aria-label":`Search for titles, people, and genres`,placeholder:`Titles, people, genres`,value:a,onChange:e=>o(e.target.value)}),r&&(0,N.jsx)(`button`,{className:`search-clear`,"aria-label":a?`Clear search`:`Close search`,onClick:()=>{a?o(``):i(!1)},children:(0,N.jsx)(de,{})})]}),(0,N.jsxs)(`div`,{className:`nav-popover-wrap`,children:[(0,N.jsxs)(`button`,{className:`icon-button notification-button`,"aria-label":p?`Notifications, ${p} unread`:`Notifications`,"aria-expanded":u,onClick:()=>{D(!1),h(!1),_(!1);let e=!u;d(e),e&&p&&m(),l(!1)},children:[(0,N.jsx)(g,{}),p>0&&(0,N.jsx)(`span`,{className:`notification-badge`,"aria-hidden":`true`,children:p>9?`9+`:p})]}),u&&(0,N.jsx)(F,{alerts:f,onSelectAlert:e=>{d(!1),ee(e)}})]}),(0,N.jsxs)(`div`,{className:`nav-popover-wrap`,children:[(0,N.jsxs)(`button`,{className:`profile-trigger`,"aria-label":`Open profile menu`,"aria-expanded":c,onClick:()=>{D(!1),h(!1),_(!1),l(!c),d(!1)},children:[(0,N.jsxs)(`span`,{className:`profile-avatar`,"aria-hidden":`true`,style:{backgroundColor:se.avatarColor},children:[(0,N.jsx)(`span`,{}),(0,N.jsx)(`span`,{}),(0,N.jsx)(`span`,{})]}),(0,N.jsx)(b,{className:c?`rotate`:``})]}),c&&(0,N.jsx)(I,{profiles:w,activeProfile:se,onSelectProfile:T,onManageProfiles:le})]})]})]})}function Re({providers:e,message:t,onReorder:n,onSync:r,onAddMovie:i}){let[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(null),[l,u]=(0,A.useState)(``),d=(0,A.useRef)(0),f=(0,A.useRef)(null),p=(0,A.useRef)(null),m=(0,A.useRef)(null),ee=(0,A.useRef)([]),te=new Map(e.map(e=>[e.id,e])),h=a??e.map(e=>e.id),re=new Set(h),g=[...h.flatMap(e=>{let t=te.get(e);return t?[t]:[]}),...e.filter(({id:e})=>!re.has(e))],_=(0,A.useRef)(g),v=(0,A.useRef)(null),ie=(0,A.useRef)(new Map),y=e=>{_.current=e,o(e.map(e=>e.id))},ae=(e,t)=>{let n=_.current,r=n.findIndex(t=>t.id===e);if(r<0)return n;let i=Math.max(0,Math.min(n.length-1,t));if(i===r)return n;let a=[...n],[o]=a.splice(r,1);return a.splice(i,0,o),y(a),a},b=(e,t)=>{let r=e.findIndex(e=>e.id===t.id);u(`${t.name} is now priority ${r+1} of ${e.length}.`);let i=++d.current;n(e.map(e=>e.id)).catch(()=>void 0).finally(()=>{i===d.current&&o(null)})},oe=(e,t)=>{let n=_.current.filter(t=>t.id!==e),r=n.findIndex(e=>{let n=ie.current.get(e.id)?.getBoundingClientRect();return!!(n&&t<n.top+n.height/2)});r<0&&(r=n.length);let i=_.current.find(t=>t.id===e);if(!i)return;let a=[...n];a.splice(r,0,i),y(a)};return(0,N.jsxs)(`div`,{className:`nav-popover sources-popover`,children:[(0,N.jsx)(`div`,{className:`popover-caret`}),(0,N.jsxs)(`div`,{className:`sources-heading`,children:[(0,N.jsx)(`span`,{children:(0,N.jsx)(ne,{})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`b`,{children:`Content sources`}),(0,N.jsx)(`small`,{children:`Drag, or use the grip with your keyboard`})]})]}),(0,N.jsx)(`p`,{id:`source-priority-instructions`,className:`visually-hidden`,children:`Press Space or Enter to lift a source, use Arrow Up, Arrow Down, Home, or End to move it, then press Space or Enter again to save. Press Escape to cancel.`}),(0,N.jsx)(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,children:l}),(0,N.jsx)(`div`,{className:`provider-list`,ref:v,role:`list`,"aria-label":`Source priority`,onPointerMove:e=>{let t=f.current;!t||p.current!==e.pointerId||!e.currentTarget.hasPointerCapture(e.pointerId)||oe(t,e.clientY)},onPointerUp:t=>{let n=f.current;if(!n||p.current!==t.pointerId)return;let r=_.current.find(e=>e.id===n),i=_.current;f.current=null,p.current=null,c(null),t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),r&&i.some((t,n)=>t.id!==e[n]?.id)?b(i,r):o(null)},onPointerCancel:t=>{p.current===t.pointerId&&(f.current=null,p.current=null,c(null),_.current=e,o(null),t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId))},onLostPointerCapture:t=>{p.current===t.pointerId&&(f.current=null,p.current=null,c(null),_.current=e,o(null))},children:g.map((t,n)=>(0,N.jsxs)(`article`,{className:s===t.id?`provider-row provider-row--dragging`:`provider-row`,ref:e=>{e?ie.current.set(t.id,e):ie.current.delete(t.id)},role:`listitem`,children:[(0,N.jsx)(`button`,{className:`provider-drag-handle`,type:`button`,"aria-describedby":`source-priority-instructions`,"aria-keyshortcuts":`Space Enter ArrowUp ArrowDown Home End Escape`,"aria-label":`${s===t.id?`Drop`:`Move`} ${t.name}, priority ${n+1} of ${g.length}`,"aria-pressed":s===t.id,title:`Drag ${t.name}, or press Space and use arrow keys`,onKeyDown:r=>{let i=r.key===` `||r.key===`Enter`,a=m.current===t.id;if(i){if(r.preventDefault(),_.current=g,a){m.current=null,c(null);let e=_.current,r=ee.current;e.some((e,t)=>e.id!==r[t])?b(e,t):(o(null),u(`${t.name} stayed at priority ${n+1}.`))}else m.current=t.id,ee.current=g.map(e=>e.id),o(ee.current),c(t.id),u(`${t.name} lifted. Use arrow keys to move it, then press Space or Enter to save.`);return}if(r.key===`Escape`&&a){r.preventDefault(),m.current=null,_.current=e,c(null),o(null),u(`${t.name} priority change canceled.`);return}let s=r.key===`ArrowUp`?n-1:r.key===`ArrowDown`?n+1:r.key===`Home`?0:r.key===`End`?g.length-1:null;if(s===null)return;r.preventDefault(),_.current=g;let l=_.current,d=ae(t.id,s);if(d!==l)if(a){let e=d.findIndex(e=>e.id===t.id);u(`${t.name} moved to priority ${e+1} of ${d.length}.`)}else b(d,t)},onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let n=v.current;n&&(n.setPointerCapture(e.pointerId),_.current=g,m.current=null,f.current=t.id,p.current=e.pointerId,c(t.id))},children:(0,N.jsx)(ve,{"aria-hidden":`true`})}),(0,N.jsx)(`span`,{className:`provider-mark`,children:t.name.slice(0,1).toUpperCase()}),(0,N.jsxs)(`span`,{className:`provider-copy`,children:[(0,N.jsx)(`b`,{children:t.name}),(0,N.jsx)(`a`,{href:t.baseUrl,target:`_blank`,rel:`noreferrer`,children:new URL(t.baseUrl).hostname}),(0,N.jsxs)(`small`,{children:[`Priority `,n+1,` ·`,` `,t.lastError||(t.lastSyncedAt?`Synced ${new Date(t.lastSyncedAt).toLocaleString()}`:`Not synced yet`)]})]}),(0,N.jsx)(`button`,{className:`provider-sync`,"aria-label":`Sync ${t.name}`,title:`Sync ${t.name}`,disabled:t.syncStatus===`syncing`,onClick:()=>void r(t.id),children:t.syncStatus===`syncing`?(0,N.jsx)(T,{className:`spin`}):(0,N.jsx)(x,{})})]},t.id))}),t&&(0,N.jsx)(`p`,{className:`source-message`,role:`status`,children:t}),(0,N.jsxs)(`button`,{className:`add-movie-button`,onClick:i,children:[(0,N.jsx)(fe,{}),` Add movie from link`]})]})}function ze({titles:e,onPlay:t}){let n=e.filter(e=>e.sourceProvider&&e.downloadStatus&&e.downloadStatus!==`metadata`).sort((e,t)=>{let n=new Set([`queued`,`downloading`]);return Number(n.has(t.downloadStatus??``))-Number(n.has(e.downloadStatus??``))}),r=n.filter(e=>e.downloadStatus===`queued`||e.downloadStatus===`downloading`).length;return(0,N.jsxs)(`div`,{className:`nav-popover downloads-popover`,children:[(0,N.jsx)(`div`,{className:`popover-caret`}),(0,N.jsxs)(`div`,{className:`downloads-heading`,children:[(0,N.jsx)(`span`,{children:(0,N.jsx)(y,{})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`b`,{children:`Downloads`}),(0,N.jsx)(`small`,{children:r>0?`${r} ${r===1?`movie`:`movies`} downloading`:n.length>0?`All downloads are up to date`:`No movies added yet`})]})]}),n.length>0?(0,N.jsx)(`div`,{className:`download-list`,"aria-live":`polite`,children:n.map(e=>{let n=Math.min(100,Math.max(0,e.downloadProgress??0)),r=e.downloadStatus===`queued`||e.downloadStatus===`downloading`,i=e.downloadStatus===`ready`?`Ready to play`:e.downloadStatus===`failed`?`Download failed`:e.downloadStatus===`queued`?`Waiting to download`:`Downloading — ${n}%`;return(0,N.jsxs)(`article`,{className:`download-item download-item--${e.downloadStatus}`,children:[(0,N.jsx)(`button`,{type:`button`,className:`download-thumb`,"aria-label":`Play ${e.title}`,onClick:()=>t(e),style:{backgroundImage:`linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2)), url("${e.backdropImage}")`},children:(0,N.jsx)(`span`,{className:`download-thumb-play`,"aria-hidden":`true`,children:(0,N.jsx)(S,{fill:`currentColor`})})}),(0,N.jsxs)(`div`,{className:`download-copy`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`b`,{children:e.title}),(0,N.jsx)(`span`,{className:`download-status-icon`,"aria-hidden":`true`,children:e.downloadStatus===`ready`?(0,N.jsx)(O,{}):e.downloadStatus===`failed`?(0,N.jsx)(de,{}):(0,N.jsx)(T,{className:r?`spin`:``})})]}),(0,N.jsx)(`small`,{children:i}),(0,N.jsx)(`div`,{className:`download-progress`,role:`progressbar`,"aria-label":`${e.title} download progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,children:(0,N.jsx)(`span`,{style:{width:`${n}%`}})}),e.downloadError&&(0,N.jsx)(`em`,{title:e.downloadError,children:e.downloadError})]})]},e.id)})}):(0,N.jsxs)(`div`,{className:`downloads-empty`,children:[(0,N.jsx)(y,{}),(0,N.jsx)(`b`,{children:`Your downloads will appear here`}),(0,N.jsx)(`small`,{children:`Add a movie from the Sources menu to get started.`})]})]})}function F({alerts:e,onSelectAlert:t}){return e.length?(0,N.jsxs)(`div`,{className:`nav-popover notification-popover`,children:[(0,N.jsx)(`div`,{className:`popover-caret`}),e.map(e=>(0,N.jsxs)(`button`,{type:`button`,className:`notification-item${e.seen?``:` is-unread`}`,onClick:()=>t(e),children:[(0,N.jsx)(`span`,{className:`notification-thumb`,style:e.artwork?{backgroundImage:`linear-gradient(140deg, transparent, rgba(0,0,0,.72)), url("${e.artwork}")`}:void 0}),(0,N.jsxs)(`span`,{children:[(0,N.jsxs)(`b`,{children:[`New episode: `,e.titleName]}),(0,N.jsxs)(`small`,{children:[`S`,e.seasonNumber,` · E`,e.episodeNumber,e.episodeTitle?` — ${e.episodeTitle}`:``]}),(0,N.jsx)(`em`,{children:Pe(e.discoveredAt)})]})]},`${e.titleId}-${e.seasonNumber}-${e.episodeNumber}`))]}):(0,N.jsxs)(`div`,{className:`nav-popover notification-popover`,children:[(0,N.jsx)(`div`,{className:`popover-caret`}),(0,N.jsx)(`p`,{className:`notification-empty`,children:`No new episodes yet. Tracked shows are checked every hour.`})]})}function I({profiles:e,activeProfile:t,onSelectProfile:n,onManageProfiles:r}){return(0,N.jsxs)(`div`,{className:`nav-popover profile-popover`,children:[(0,N.jsx)(`div`,{className:`popover-caret`}),e.map(e=>(0,N.jsxs)(`button`,{type:`button`,className:`profile-option`,"aria-current":e.id===t.id?`true`:void 0,onClick:()=>void n(e),children:[(0,N.jsx)(`span`,{className:`mini-avatar`,style:{backgroundColor:e.avatarColor},children:e.name.slice(0,1).toUpperCase()}),(0,N.jsx)(`span`,{children:e.name}),e.id===t.id&&(0,N.jsx)(O,{className:`profile-active-check`,"aria-label":`Active profile`})]},e.id)),(0,N.jsxs)(`button`,{type:`button`,onClick:r,children:[(0,N.jsx)(C,{}),`Manage profile`]}),(0,N.jsxs)(`a`,{href:`#account`,children:[(0,N.jsx)(Ce,{}),`Account`]}),(0,N.jsxs)(`a`,{href:`#help`,children:[(0,N.jsx)(u,{}),`Help Center`]}),(0,N.jsxs)(`a`,{className:`profile-signout`,href:`#signout`,children:[(0,N.jsx)(be,{}),`Sign out of Netflix`]})]})}function L({profileId:e,onClose:t,onImported:n}){let r=Fe(),[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(!1),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(``);return(0,N.jsx)(`div`,{className:`modal-backdrop add-movie-backdrop`,onMouseDown:t,children:(0,N.jsxs)(`article`,{ref:r,className:`add-movie-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`add-movie-title`,onMouseDown:e=>e.stopPropagation(),children:[(0,N.jsx)(`button`,{className:`modal-close`,"aria-label":`Close`,onClick:t,children:(0,N.jsx)(de,{})}),(0,N.jsx)(`span`,{className:`add-movie-icon`,children:(0,N.jsx)(v,{})}),(0,N.jsx)(`h2`,{id:`add-movie-title`,children:`Add a movie`}),(0,N.jsx)(`p`,{children:`Paste a supported movie page. Metadata is stored in SQLite and the video can stream directly from its provider.`}),(0,N.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),l(!0),d(``);try{let t=await fetch(`/api/netflix/movies/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:i,mode:o?`download`:`stream`,profileId:e})}),r=await t.json();if(!t.ok)throw Error(r.error||`Movie import failed.`);await n()}catch(e){d(e instanceof Error?e.message:`Movie import failed.`),l(!1)}},children:[(0,N.jsx)(`label`,{htmlFor:`movie-url`,children:`Movie link`}),(0,N.jsx)(`input`,{id:`movie-url`,type:`url`,required:!0,autoFocus:!0,placeholder:`https://phimhdcss.com/linh-hao-truy-sat-22642`,value:i,onChange:e=>a(e.target.value)}),(0,N.jsx)(`small`,{children:`Supported: phimhdcss.com, phimhdcss.net, and fsharetv.com`}),(0,N.jsxs)(`label`,{className:`offline-option`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.currentTarget.checked)}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`b`,{children:`Save an offline copy`}),(0,N.jsx)(`small`,{children:`Optional. Downloads the media and subtitles into the local data folder.`})]})]}),u&&(0,N.jsx)(`p`,{className:`form-error`,role:`alert`,children:u}),(0,N.jsxs)(`div`,{className:`add-movie-actions`,children:[(0,N.jsx)(`button`,{type:`button`,className:`button button--secondary`,onClick:t,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,className:`button button--primary`,disabled:c,children:[c?(0,N.jsx)(T,{className:`spin`}):o?(0,N.jsx)(y,{}):(0,N.jsx)(S,{fill:`currentColor`}),c?`Fetching movie…`:o?`Add & download`:`Add & stream`]})]})]})]})})}function Be({title:e,previewPaused:t,setPreviewPaused:n,onPlay:r,onMoreInfo:i}){let a={"--hero-image":`url("${e.backdropImage}")`,"--hero-accent":e.accentColor};return(0,N.jsxs)(`section`,{className:`hero${t?` hero--paused`:``}`,id:`top`,style:a,children:[(0,N.jsx)(`div`,{className:`hero-backdrop`}),(0,N.jsx)(`div`,{className:`hero-vignette`}),(0,N.jsxs)(`div`,{className:`hero-content`,children:[(0,N.jsxs)(`p`,{className:`netflix-series`,children:[(0,N.jsx)(`span`,{children:`N`}),` SERIES`]}),e.logoImage?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`h1`,{className:`visually-hidden`,children:e.title}),(0,N.jsx)(`img`,{className:`hero-title-logo`,src:e.logoImage,alt:``,"aria-hidden":`true`})]}):(0,N.jsx)(`h1`,{children:e.title}),(0,N.jsxs)(`p`,{className:`hero-rank`,children:[(0,N.jsxs)(`span`,{children:[`TOP`,(0,N.jsx)(`br`,{}),`10`]}),`#`,e.rank??1,` in TV Shows Today`]}),(0,N.jsx)(`p`,{className:`hero-description`,children:e.synopsis}),(0,N.jsxs)(`div`,{className:`hero-actions`,children:[(0,N.jsxs)(`button`,{className:`button button--primary`,onClick:r,children:[(0,N.jsx)(S,{fill:`currentColor`}),` Play`]}),(0,N.jsxs)(`button`,{className:`button button--secondary`,onClick:i,children:[(0,N.jsx)(ye,{}),` More Info`]})]})]}),(0,N.jsxs)(`div`,{className:`hero-side-controls`,children:[(0,N.jsx)(`button`,{className:`round-button`,"aria-label":t?`Resume preview motion`:`Pause preview motion`,onClick:()=>n(!t),children:t?(0,N.jsx)(S,{fill:`currentColor`}):(0,N.jsx)(ue,{fill:`currentColor`})}),(0,N.jsx)(`span`,{className:`maturity-badge`,children:e.maturityRating})]}),(0,N.jsx)(`div`,{className:`hero-scroll-cue`,children:(0,N.jsx)(b,{})})]})}function Ve({row:e,rowIndex:t,myList:n,likedTitles:r,newEpisodeAlertsByTitle:i,playOnCardClick:o=!1,onSelect:s,onPlay:c,onToggleMyList:l,onToggleLike:u}){let d=(0,A.useRef)(null),f=e=>{let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`;d.current?.scrollBy({left:e*d.current.clientWidth*.82,behavior:t})};return(0,N.jsxs)(`section`,{className:`title-row title-row--${e.kind}`,id:t===0?`new-popular`:e.id,"aria-labelledby":`${e.id}-heading`,children:[(0,N.jsxs)(`div`,{className:`row-heading`,children:[(0,N.jsx)(`h2`,{id:`${e.id}-heading`,children:e.title}),(0,N.jsxs)(`button`,{className:`explore-link`,onClick:()=>d.current?.scrollTo({left:d.current.scrollWidth,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),children:[`Explore All `,(0,N.jsx)(w,{})]})]}),(0,N.jsxs)(`div`,{className:`rail-shell`,children:[(0,N.jsx)(`button`,{className:`rail-control rail-control--left`,"aria-label":`Scroll ${e.title} left`,onClick:()=>f(-1),children:(0,N.jsx)(a,{})}),(0,N.jsx)(`div`,{className:`title-rail`,ref:d,children:e.items.map((t,a)=>(0,N.jsx)(He,{title:t,index:a,kind:e.kind,isInMyList:n.has(t.id),isLiked:r.has(t.id),newEpisodeAlert:i?.get(t.id),playOnCardClick:o,onSelect:()=>s(t),onPlay:()=>c(t),onPlayEpisode:e=>c(t,e),onToggleMyList:()=>l(t),onToggleLike:()=>u(t)},`${e.id}-${t.id}`))}),(0,N.jsx)(`button`,{className:`rail-control rail-control--right`,"aria-label":`Scroll ${e.title} right`,onClick:()=>f(1),children:(0,N.jsx)(w,{})})]})]})}function He({title:e,index:t,kind:n,isInMyList:r,isLiked:i,newEpisodeAlert:a,playOnCardClick:o,onSelect:s,onPlay:c,onPlayEpisode:l,onToggleMyList:u,onToggleLike:d}){let f=n===`ranked`,p=n===`originals`,m=n===`continue-watching`,ee=p||f?e.posterImage:e.backdropImage,te=Math.min(100,Math.max(0,e.progress??0)),h=m||o?c:s,ne=a&&o?`Play ${e.title}, Season ${a.seasonNumber} Episode ${a.episodeNumber}`:m?`Resume ${e.title}`:`Open details for ${e.title}${a?`, new episode Season ${a.seasonNumber} Episode ${a.episodeNumber}`:``}`;return(0,N.jsxs)(`div`,{className:`title-card${f?` title-card--ranked`:``}${p?` title-card--portrait`:``}`,tabIndex:0,role:`button`,"aria-label":ne,onClick:h,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),h())},children:[f&&(0,N.jsx)(`span`,{className:`rank-number`,"aria-hidden":`true`,children:e.rank??t+1}),(0,N.jsxs)(`div`,{className:`card-visual`,children:[(0,N.jsx)(`img`,{src:ee,alt:``,loading:`lazy`}),(0,N.jsx)(`div`,{className:`card-image-shade`}),e.isOriginal&&(0,N.jsxs)(`span`,{className:`card-n`,children:[`N`,(0,N.jsx)(`small`,{children:e.mediaType===`movie`?`FILM`:`SERIES`})]}),e.isNew&&!a&&(0,N.jsx)(`span`,{className:`new-season`,children:`New`}),a&&(0,N.jsxs)(`span`,{className:`new-episode-label`,"aria-label":`New episode: Season ${a.seasonNumber}, Episode ${a.episodeNumber}${a.episodeTitle?`, ${a.episodeTitle}`:``}`,children:[(0,N.jsxs)(`strong`,{children:[`S`,a.seasonNumber,` · E`,a.episodeNumber]}),a.episodeTitle&&(0,N.jsxs)(`small`,{children:[`— `,a.episodeTitle]})]}),(0,N.jsx)(`span`,{className:`card-title-fallback`,children:e.title})]}),n===`continue-watching`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`resume-checkpoint`,children:e.resumeEpisode?`E${e.resumeEpisode} · ${V(e.resumePositionSeconds??0)}`:V(e.resumePositionSeconds??0)}),(0,N.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-label":`${e.title} watch progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":te,children:(0,N.jsx)(`span`,{style:{width:`${te}%`}})})]}),(0,N.jsxs)(`div`,{className:`card-details`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`card-controls`,children:[(0,N.jsx)(`button`,{"aria-label":`Play ${e.title}`,onClick:c,children:(0,N.jsx)(S,{fill:`currentColor`})}),(0,N.jsx)(`button`,{"aria-label":r?`Remove from My List`:`Add to My List`,onClick:u,children:r?(0,N.jsx)(O,{}):(0,N.jsx)(fe,{})}),(0,N.jsx)(`button`,{className:i?`is-active`:``,"aria-label":i?`Remove rating`:`I like this`,"aria-pressed":i,onClick:d,children:(0,N.jsx)(k,{fill:i?`currentColor`:`none`})}),(0,N.jsx)(`button`,{className:`card-more-button`,"aria-label":`More information about ${e.title}`,onClick:s,children:(0,N.jsx)(b,{})})]}),(0,N.jsxs)(`div`,{className:`card-meta`,children:[(0,N.jsxs)(`strong`,{children:[e.match,`% Match`]}),(0,N.jsx)(`span`,{className:`mini-maturity`,children:e.maturityRating}),(0,N.jsx)(`span`,{children:e.duration}),e.isHD&&(0,N.jsx)(`span`,{className:`quality-badge`,children:`HD`})]}),(0,N.jsx)(`p`,{children:e.genres.slice(0,3).join(` • `)}),e.episodes?.length?(0,N.jsx)(`div`,{className:`card-episode-strip`,"aria-label":`${e.title} episodes`,children:e.episodes.map(t=>(0,N.jsxs)(`button`,{type:`button`,"aria-label":`Play ${t.title}`,title:t.title,onClick:()=>l(t.episode),children:[(0,N.jsx)(`img`,{src:t.image||e.backdropImage,alt:``,loading:`lazy`}),(0,N.jsx)(`span`,{children:t.episode})]},t.id||t.episode))}):null]})]})}function Ue({query:e,results:t,providerStatus:n,error:r,resolvingTitleId:i,onSelect:a}){let o=!!e.trim(),s=n===`loading`,c=t.find(e=>e.id===i);return(0,N.jsxs)(`section`,{className:`netflix-search-page`,"aria-label":o?`Search results for ${e}`:`Search titles`,children:[(0,N.jsx)(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,children:o?c?`Loading “${c.title}” from its provider…`:s?`Searching your library and all providers for “${e}”…`:t.length?`${t.length} titles related to “${e}”`:`We couldn't find “${e}”`:`Enter a movie, series, person, or genre to search.`}),r&&(0,N.jsx)(`p`,{className:`netflix-search-notice`,role:`alert`,children:r}),o?t.length?(0,N.jsx)(`div`,{className:`netflix-search-grid`,children:t.map(e=>(0,N.jsxs)(`button`,{className:`netflix-search-card`,"aria-label":`${e.title} · ${d(e.sourceProvider)}`,disabled:!!i,onClick:()=>a(e),children:[(0,N.jsxs)(`span`,{className:`netflix-search-artwork`,children:[(0,N.jsx)(`img`,{src:e.backdropImage,alt:``}),i===e.id&&(0,N.jsx)(T,{className:`netflix-search-loader spin`})]}),(0,N.jsx)(`span`,{className:`netflix-search-title`,title:e.title,children:e.title})]},`${e.sourceProvider??`catalog`}:${e.id}`))}):s?(0,N.jsxs)(`div`,{className:`empty-search`,children:[(0,N.jsx)(T,{className:`spin`}),(0,N.jsx)(`h2`,{children:`Searching all providers`}),(0,N.jsx)(`p`,{children:`Results follow the source priority in the sources menu.`})]}):(0,N.jsxs)(`div`,{className:`empty-search`,children:[(0,N.jsx)(E,{}),(0,N.jsx)(`h2`,{children:`No matches found`}),(0,N.jsx)(`p`,{children:`Try a title, actor, director, or genre.`})]}):(0,N.jsxs)(`div`,{className:`empty-search`,children:[(0,N.jsx)(E,{}),(0,N.jsx)(`h2`,{children:`Find something to watch`}),(0,N.jsx)(`p`,{children:`Search by movie, series, actor, director, or genre.`})]})]})}function We({title:e,isInMyList:t,isLiked:n,canTrack:r,isTracked:i,episodeSort:a,onClose:o,onPlay:s,onToggleMyList:c,onToggleLike:l,onToggleTracking:u,onEpisodeSortChange:f}){let p=Fe(),m=(0,A.useMemo)(()=>{let t=[...e.episodes?.length?e.episodes:e.episode?[e.episode]:[]].sort((e,t)=>e.season-t.season||e.episode-t.episode);return a===`desc`?t.reverse():t},[a,e.episode,e.episodes]);return(0,N.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,onMouseDown:o,children:(0,N.jsxs)(`article`,{ref:p,className:`details-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`${e.title} details`,onMouseDown:e=>e.stopPropagation(),children:[(0,N.jsx)(`button`,{className:`modal-close`,"aria-label":`Close`,onClick:o,children:(0,N.jsx)(de,{})}),(0,N.jsx)(`div`,{className:`modal-hero`,style:{"--modal-image":`url("${e.backdropImage}")`},children:(0,N.jsxs)(`div`,{className:`modal-hero-content`,children:[(0,N.jsxs)(`p`,{className:`netflix-series`,children:[(0,N.jsx)(`span`,{children:`N`}),` `,e.mediaType===`movie`?`FILM`:`SERIES`]}),(0,N.jsx)(`h2`,{children:e.title}),(0,N.jsxs)(`div`,{className:`modal-actions`,children:[(0,N.jsxs)(`button`,{className:`button button--primary`,onClick:()=>s(),disabled:!!(e.sourceProvider&&!e.playbackPath&&!e.canStream),children:[(0,N.jsx)(S,{fill:`currentColor`}),e.sourceProvider&&!e.playbackPath&&!e.canStream?`Metadata only`:e.sourceProvider&&e.downloadStatus!==`ready`?`Stream now`:e.resumePositionSeconds?`Resume at ${V(e.resumePositionSeconds)}`:`Play`]}),(0,N.jsx)(`button`,{className:`round-button`,"aria-label":t?`Remove from My List`:`Add to My List`,onClick:c,children:t?(0,N.jsx)(O,{}):(0,N.jsx)(fe,{})}),(0,N.jsx)(`button`,{className:`round-button${n?` is-active`:``}`,"aria-label":n?`Remove rating`:`I like this`,"aria-pressed":n,onClick:l,children:(0,N.jsx)(k,{fill:n?`currentColor`:`none`})}),r&&(0,N.jsx)(`button`,{className:`round-button track-button${i?` is-active`:``}`,"aria-label":i?`Stop tracking new episodes`:`Track new episodes`,"aria-pressed":i,title:i?`Tracking new episodes every hour`:`Track new episodes`,onClick:u,children:i?(0,N.jsx)(he,{}):(0,N.jsx)(g,{})})]})]})}),(0,N.jsxs)(`div`,{className:`modal-body`,children:[(0,N.jsxs)(`div`,{className:`modal-main-copy`,children:[e.sourceProvider&&(0,N.jsxs)(`div`,{className:`download-state download-state--${e.downloadStatus}`,children:[e.downloadStatus===`ready`?(0,N.jsx)(O,{}):e.downloadStatus===`metadata`?(0,N.jsx)(v,{}):(0,N.jsx)(y,{}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`b`,{children:e.downloadStatus===`ready`?`Ready to play locally`:e.downloadStatus===`failed`?`Offline download failed · Streaming available`:e.downloadStatus===`metadata`?e.canStream?`Ready to stream`:`Metadata synced`:`Streaming available · Downloading offline — ${e.downloadProgress??0}%`}),(0,N.jsx)(`small`,{children:e.downloadError||`Source: ${d(e.sourceProvider)} · Metadata stored in SQLite`})]})]}),(0,N.jsxs)(`div`,{className:`modal-meta`,children:[(0,N.jsxs)(`strong`,{children:[e.match,`% Match`]}),(0,N.jsx)(`span`,{children:e.year}),(0,N.jsx)(`span`,{children:e.duration}),(0,N.jsx)(`span`,{className:`quality-badge`,children:`HD`}),e.hasAudioDescription&&(0,N.jsx)(`span`,{className:`quality-badge`,children:`AD`})]}),(0,N.jsx)(`span`,{className:`modal-maturity`,children:e.maturityRating}),(0,N.jsx)(`p`,{className:`modal-synopsis`,children:e.synopsis})]}),(0,N.jsxs)(`dl`,{className:`modal-facts`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{children:`Cast:`}),(0,N.jsx)(`dd`,{children:e.cast.slice(0,4).join(`, `)})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{children:`Genres:`}),(0,N.jsx)(`dd`,{children:e.genres.join(`, `)})]}),e.creators?.length?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{children:`Creators:`}),(0,N.jsx)(`dd`,{children:e.creators.join(`, `)})]}):null]})]}),m.length>0&&(0,N.jsxs)(`div`,{className:`episode-panel`,children:[(0,N.jsxs)(`header`,{className:`episode-panel-header`,children:[(0,N.jsx)(`h3`,{children:`Episodes`}),(0,N.jsxs)(`div`,{className:`episode-panel-tools`,children:[(0,N.jsxs)(`span`,{children:[`Season `,Math.min(...m.map(e=>e.season)),` `,`· `,m.length,` episodes`]}),(0,N.jsxs)(`button`,{className:`episode-sort-button`,type:`button`,"aria-label":a===`asc`?`Sort episodes newest first`:`Sort episodes oldest first`,title:a===`asc`?`Sorted oldest first`:`Sorted newest first`,onClick:()=>f(a===`asc`?`desc`:`asc`),children:[a===`asc`?(0,N.jsx)(pe,{}):(0,N.jsx)(me,{}),(0,N.jsx)(`span`,{children:a===`asc`?`Oldest`:`Newest`})]})]})]}),(0,N.jsx)(`div`,{className:`episode-card-list`,children:m.map(t=>(0,N.jsxs)(`button`,{className:`episode-card`,"aria-label":`Play ${t.title}`,onClick:()=>s(t.episode),children:[(0,N.jsx)(`span`,{className:`episode-number`,children:t.episode}),(0,N.jsx)(`span`,{className:`episode-image`,style:{backgroundImage:`linear-gradient(90deg, transparent, rgba(0,0,0,.25)), url("${t.image||e.backdropImage}")`},children:(0,N.jsx)(S,{fill:`currentColor`})}),(0,N.jsxs)(`span`,{className:`episode-copy`,children:[(0,N.jsx)(`b`,{children:t.title}),(0,N.jsx)(`small`,{children:t.duration}),(0,N.jsx)(`em`,{children:t.synopsis||e.tagline||e.synopsis})]})]},t.id||t.episode))})]})]})})}var R=4140,Ge=`home-atom:subtitle-preferences`,z={x:50,y:78},B={label:`English`,language:`en`,src:`demo`};function Ke(e){return{x:Math.max(7,Math.min(93,e.x)),y:Math.max(10,Math.min(86,e.y))}}function qe(e,t,n){let r=Math.min(49,Math.max(7,(n.width/2+12)/t.width*100)),i=Math.min(49,Math.max(10,(n.height/2+12)/t.height*100));return{x:Math.max(r,Math.min(100-r,e.x)),y:Math.max(i,Math.min(86,100-i,e.y))}}function Je(e){return Array.from(e.activeCues??[]).flatMap(e=>(`text`in e&&typeof e.text==`string`?e.text:``).replace(/<br\s*\/?>/gi,`
|
|
2
|
+
`).replace(/<[^>]*>/g,``).split(/\r?\n/).map(e=>e.trim()).filter(Boolean))}function V(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}function Ye(e){let t=e?.match(/(\d+)\s*h/i)?.[1],n=e?.match(/(\d+)\s*(?:m|ph(?:út)?)/i)?.[1];return!t&&!n?R:(Number(t??0)*60+Number(n??0))*60}function Xe({title:e,profileId:t,subtitlePreferences:n,episodeSort:i,onProgressChange:a,onSubtitlePreferencesChange:u,onSwitchTitle:d,onEpisodeSortChange:ee,onClose:ne}){let g=Fe(),v=(0,A.useRef)(null),y=(0,A.useRef)(null),b=(0,A.useRef)(0),x=(0,A.useRef)(null),C=(0,A.useRef)(null),w=(0,A.useRef)(null),E=(0,A.useRef)(null),D=(0,A.useRef)(null),fe=(0,A.useRef)(null),he=(0,A.useRef)(null),ve=(0,A.useRef)(!1),ye=(0,A.useRef)(null),be=(0,A.useRef)(!0),xe=(0,A.useRef)(null),k=(0,A.useRef)(!1),j=(0,A.useRef)(new Set),M=(0,A.useRef)(0),we=(0,A.useRef)(()=>{}),[Te]=(0,A.useState)(_),[Ee,De]=(0,A.useState)(e.episodes??[]),[ke,P]=(0,A.useState)(e.subtitles??[]),Ae=Oe(e.title),je=Ee[0]?.episode,Me=e.episode?.episode||je||1,Ne=Ee.find(e=>e.episode===Me)||e.episode,Pe=!!(e.playbackPath&&(!je||Me===je)),Ie=!!(e.sourceProvider&&e.canStream&&!Pe),Le=e.resumeEpisode===void 0||e.resumeEpisode===Me?Math.max(0,e.resumePositionSeconds??0):0,Re=e.resumeDurationSeconds&&e.resumeDurationSeconds>0?e.resumeDurationSeconds:Ye(Ne?.duration),ze=Re>0?Le/Re*100:0,[F,I]=(0,A.useState)(!1),L=(0,A.useRef)(!1),[Be,Ve]=(0,A.useState)(!1),[He,Ue]=(0,A.useState)(1),We=(0,A.useRef)(1),[R,Xe]=(0,A.useState)(n.captionsOn),[Ze,H]=(0,A.useState)(!1),[Qe,$e]=(0,A.useState)(0),[et,tt]=(0,A.useState)([]),[U,nt]=(0,A.useState)(n.fontSize),[rt,W]=(0,A.useState)({x:n.positionX,y:n.positionY}),[G,it]=(0,A.useState)(n.fontColor),[at,ot]=(0,A.useState)(n.backgroundColor),[st,ct]=(0,A.useState)(n.fontFamily),lt=(0,A.useRef)({fontSize:n.fontSize,positionX:n.positionX,positionY:n.positionY,fontColor:n.fontColor,backgroundColor:n.backgroundColor,fontFamily:n.fontFamily,captionsOn:n.captionsOn}),[ut,dt]=(0,A.useState)(!0),[ft,pt]=(0,A.useState)(!1),[K,mt]=(0,A.useState)(!1),[ht,gt]=(0,A.useState)([]),[_t,vt]=(0,A.useState)(null),[yt,q]=(0,A.useState)(!1),[J,bt]=(0,A.useState)(null),[Y,xt]=(0,A.useState)(Me),[X,St]=(0,A.useState)(Re),[Z,Ct]=(0,A.useState)(Le),[wt,Tt]=(0,A.useState)(Math.min(100,ze+4)),[Et,Dt]=(0,A.useState)(1),[Ot,kt]=(0,A.useState)(!1),[At,jt]=(0,A.useState)(``),[Mt,Nt]=(0,A.useState)(Ie?`Connecting to provider…`:``),[Pt,Ft]=(0,A.useState)(Ie),[Q,It]=(0,A.useState)(Pe&&e.playbackPath?{path:e.playbackPath,kind:e.playbackKind===`hls`?`hls`:`file`}:null),Lt=(0,A.useRef)(Q),[Rt,zt]=(0,A.useState)(!1),[Bt,Vt]=(0,A.useState)(null),[$,Ht]=(0,A.useState)(null),[Ut,Wt]=(0,A.useState)(null),[Gt,Kt]=(0,A.useState)(!1),[qt,Jt]=(0,A.useState)(!1),[Yt,Xt]=(0,A.useState)(!1),[Zt,Qt]=(0,A.useState)(!1),$t=(0,A.useRef)(null),en=(0,A.useRef)(null);(0,A.useRef)(null);let tn=(0,A.useRef)(!1),nn=(0,A.useRef)(``),rn=!!(e.playbackPath||e.sourceProvider&&e.canStream),an=!rn||Q?.kind===`embed`,on=Math.max(8,(e.episode?.episode??1)+2),sn=(0,A.useMemo)(()=>Ee.length?Ee.map(t=>({season:t.season,number:t.episode,title:t.title,duration:t.duration,synopsis:t.synopsis||e.synopsis,image:t.image||e.backdropImage,subtitles:t.subtitles||[]})):Array.from({length:on},(t,n)=>{let r=n+1,i=r===e.episode?.episode;return{season:e.episode?.season??1,number:r,title:i?e.episode.title:`Episode ${r}`,duration:i?e.episode.duration:`${46+r*7%15}m`,synopsis:r===Y?e.synopsis:e.tagline??e.synopsis,image:e.backdropImage,subtitles:[]}}),[Y,on,Ee,e.backdropImage,e.episode,e.synopsis,e.tagline]),cn=(0,A.useMemo)(()=>i===`desc`?[...sn].reverse():sn,[i,sn]),ln=X>0?Z/X*100:0,un=sn.find(e=>e.number===Y)??sn[0],dn=sn.findIndex(e=>e.number===Y),fn=dn>=0&&dn<sn.length-1,pn=un?.season??Ne?.season??1,mn=ht.find(e=>e.id===_t),hn=un?.subtitles.length?un.subtitles:ke,gn=hn.length>0?hn:rn?[]:[B],_n=Math.min(Qe,Math.max(0,gn.length-1)),vn=gn.length>0,yn={"--player-progress":`${ln}%`,"--player-buffered":`${Math.max(ln,wt)}%`},bn=(0,A.useMemo)(()=>{let t=e.synopsis.split(/[.!?]/).map(e=>e.trim()).find(Boolean)??e.synopsis,n=t.length>42?`${t.slice(0,41).trimEnd()}…`:t;return[`– ${e.tagline??un?.title??e.title}`,`– ${n}`]},[un?.title,e.synopsis,e.tagline,e.title]),xn=rn?et:bn,Sn=(0,A.useRef)({seasonNumber:pn,episodeNumber:Y,positionSeconds:Z,durationSeconds:X});(0,A.useEffect)(()=>{Sn.current={seasonNumber:pn,episodeNumber:Y,positionSeconds:Z,durationSeconds:X}},[Y,Z,X,pn]);let Cn=(0,A.useCallback)((n={},r=!1)=>{let i={...Sn.current,...n};if(i.positionSeconds<1&&!i.completed)return;let o=[i.seasonNumber,i.episodeNumber,Math.round(i.positionSeconds*10),Math.round(i.durationSeconds*10),!!i.completed].join(`:`);if(nn.current===o)return;nn.current=o;let s=!!i.completed||i.durationSeconds>0&&i.positionSeconds/i.durationSeconds>=.95,c={titleId:e.id,seasonNumber:i.seasonNumber,episodeNumber:i.episodeNumber,positionSeconds:i.positionSeconds,durationSeconds:i.durationSeconds,completed:s,updatedAt:new Date().toISOString()};a(c),fetch(`/api/netflix/progress`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({profileId:t,...c}),keepalive:r}).then(async e=>{if(!e.ok)throw Error();a(await e.json())}).catch(()=>{r||jt(`Watch position could not be saved`)})},[a,t,e.id]);(0,A.useEffect)(()=>{let e=window.setInterval(()=>Cn(),5e3),t=()=>{document.visibilityState===`hidden`&&Cn({},!0)},n=()=>Cn({},!0);return document.addEventListener(`visibilitychange`,t),window.addEventListener(`beforeunload`,n),()=>{window.clearInterval(e),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`beforeunload`,n),Cn({},!0)}},[Cn]),(0,A.useEffect)(()=>{let n=new AbortController;return fetch(`/api/netflix/markers?titleId=${encodeURIComponent(e.id)}&profileId=${encodeURIComponent(t)}`,{cache:`no-store`,signal:n.signal}).then(async e=>{if(!e.ok)return;let t=await e.json();if(!n.signal.aborted)for(let e of t.markers??[])e.markerType===`intro`?Ht(e.timeSeconds):e.markerType===`outro`&&Wt(e.timeSeconds)}).catch(()=>{}),()=>n.abort()},[e.id,t]),(0,A.useEffect)(()=>($!==null&&Z>=0&&Z<=$&&!F?(Yt||Xt(!0),en.current!==null&&window.clearTimeout(en.current),en.current=window.setTimeout(()=>{Xt(!1),en.current=null},8e3)):Yt&&(Z>($??0)||F)&&Xt(!1),Ut!==null&&Z>=Ut&&X>0&&!F&&fn?Zt||Qt(!0):Zt&&(Z<(Ut??1/0)||F)&&Qt(!1),()=>{en.current!==null&&window.clearTimeout(en.current)}),[Z,$,Ut,F,Yt,Zt,X,fn]),(0,A.useEffect)(()=>{if(!Gt)return;let e=e=>{e.target instanceof Node&&!$t.current?.contains(e.target)&&Kt(!1)},t=e=>{e.key===`Escape`&&Kt(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Gt]),(0,A.useEffect)(()=>{let n=!!(e.playbackPath&&(!je||Y===je));if(!e.sourceProvider||!e.canStream||n)return;let r=new AbortController,i=new URLSearchParams({profileId:t});return e.episodes?.length&&i.set(`episode`,String(Y)),J?.id&&i.set(`server`,J.id),fetch(`/api/netflix/stream/${encodeURIComponent(e.id)}?${i}`,{cache:`no-store`,signal:r.signal}).then(async e=>{let t=await e.json();if(!e.ok||!t.path||!t.kind)throw Error(t.error||`The provider stream is unavailable.`);if(t.episodeMetadata){let e={...t.episodeMetadata,subtitles:t.subtitles??t.episodeMetadata.subtitles};De(t=>[...t.some(t=>t.id===e.id||t.episode===e.episode)?t.map(t=>t.id===e.id||t.episode===e.episode?e:t):[...t,e]].sort((e,t)=>e.episode-t.episode))}else Array.isArray(t.subtitles)&&P(t.subtitles);let n=Array.isArray(t.servers)?t.servers.filter(e=>typeof e?.id==`string`&&e.id.length>0&&typeof e.label==`string`&&e.label.length>0):[],r=t.server??t.selectedServerId,i=n.find(e=>e.id===r)??n.find(e=>e.id===J?.id)??n.find(e=>e.is4K||/(?:^|\s)4k(?:\s|$)/i.test(e.label))??n[0];gt(n),vt(i?.id??null),n.length||q(!1),It({path:t.path,kind:t.kind}),Nt(``),Ft(!1)}).catch(e=>{r.signal.aborted||(Nt(e instanceof Error?e.message:`The provider stream is unavailable.`),Ft(!1),I(!0))}),()=>r.abort()},[Y,je,e.canStream,e.episodes,e.id,e.playbackPath,e.sourceProvider,t,J]),(0,A.useEffect)(()=>{Lt.current=Q;let e=v.current;if(!e||!Q||Q.kind===`embed`)return;let t=!1,n=()=>{};return Q.kind===`hls`&&!e.canPlayType(`application/vnd.apple.mpegurl`)?r(async()=>{let{default:e}=await import(`./hls-CgexCc5Z.js`);return{default:e}},[]).then(({default:e})=>{if(t||!v.current||!e.isSupported())return;let r=new e;r.loadSource(Q.path),r.attachMedia(v.current),r.on(e.Events.MANIFEST_PARSED,()=>{t||(L.current?v.current?.pause():v.current?.play().catch(()=>I(!0)))}),r.on(e.Events.ERROR,(e,n)=>{n.fatal&&!t&&(Nt(`The provider stream stopped unexpectedly.`),I(!0))}),n=()=>r.destroy()}):(e.src=Q.path,L.current?e.pause():e.play().catch(()=>I(!0))),()=>{t=!0,n(),e.removeAttribute(`src`),e.load()}},[Q]),(0,A.useEffect)(()=>{L.current=F;let e=v.current;!e||!Lt.current||(F?e.pause():e.play().catch(()=>I(!0)))},[F]),(0,A.useEffect)(()=>{let e=v.current;e&&(e.playbackRate=Et)},[Et]),(0,A.useEffect)(()=>{let e=v.current;He>0&&(We.current=He),e&&(e.volume=He)},[Q,He]),(0,A.useEffect)(()=>{let e=v.current;if(!e){tt([]);return}let t=Array.from(e.textTracks),n=t[_n],r=()=>{tt(R&&n?Je(n):[])};for(let[e,n]of t.entries())n.mode=R&&e===_n?`hidden`:`disabled`;return n?.addEventListener(`cuechange`,r),r(),()=>{n?.removeEventListener(`cuechange`,r)}},[Y,R,Q,_n,hn.length]),(0,A.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{try{window.localStorage.getItem(Ge)&&window.localStorage.removeItem(Ge)}catch{}});return()=>window.cancelAnimationFrame(e)},[]),(0,A.useEffect)(()=>{if(!ut)return;if(be.current){be.current=!1;return}let e={fontSize:U,positionX:rt.x,positionY:rt.y,fontColor:G,backgroundColor:at,fontFamily:st,captionsOn:R},n=lt.current,r={};if(e.fontSize!==n.fontSize&&(r.fontSize=e.fontSize),(e.positionX!==n.positionX||e.positionY!==n.positionY)&&(r.positionX=e.positionX,r.positionY=e.positionY),e.fontColor!==n.fontColor&&(r.fontColor=e.fontColor),e.backgroundColor!==n.backgroundColor&&(r.backgroundColor=e.backgroundColor),e.fontFamily!==n.fontFamily&&(r.fontFamily=e.fontFamily),e.captionsOn!==n.captionsOn&&(r.captionsOn=e.captionsOn),Object.keys(r).length)return ye.current!==null&&window.clearTimeout(ye.current),ye.current=window.setTimeout(()=>{ye.current=null,lt.current=e,fetch(`/api/netflix/subtitle-preferences`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({profileId:t,...r})}).then(async e=>{e.ok&&u(await e.json())}).catch(()=>{})},600),()=>{ye.current!==null&&window.clearTimeout(ye.current)}},[t,U,rt,G,at,st,R,ut,u]),(0,A.useEffect)(()=>{if(!yt)return;let e=e=>{e.target instanceof Node&&!D.current?.contains(e.target)&&q(!1)},t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),q(!1),D.current?.querySelector(`.player-server-trigger`)?.focus())};return document.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t,!0)}},[yt]),(0,A.useEffect)(()=>{if(!Ze)return;let e=e=>{e.target instanceof Node&&!E.current?.contains(e.target)&&H(!1)},t=e=>{e.key===`Escape`&&H(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Ze]),(0,A.useEffect)(()=>{if(!R||!xn.length)return;let e=()=>{let e=g.current?.getBoundingClientRect(),t=fe.current?.getBoundingClientRect();!e||!t||W(n=>{let r=qe(n,e,t);return r.x===n.x&&r.y===n.y?n:r})},t=window.requestAnimationFrame(e);return window.addEventListener(`resize`,e),document.addEventListener(`fullscreenchange`,e),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,e),document.removeEventListener(`fullscreenchange`,e)}},[R,g,U,xn]),(0,A.useEffect)(()=>{if(!an||F)return;let e=window.setInterval(()=>{Ct(e=>{let t=e+.5,n=Math.min(t,X);return Sn.current.positionSeconds=n,n})},500);return()=>window.clearInterval(e)},[X,F,an]),(0,A.useEffect)(()=>{if(!an||F||X<=0||Z<X)return;Cn({positionSeconds:X,completed:!0});let e=window.requestAnimationFrame(()=>I(!0));return()=>window.cancelAnimationFrame(e)},[Z,X,F,Cn,an]),(0,A.useEffect)(()=>{let e=()=>kt(document.fullscreenElement===g.current);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[g]),(0,A.useEffect)(()=>()=>{C.current&&window.clearTimeout(C.current)},[]);let wn=(0,A.useCallback)(()=>{zt(!1),w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>zt(!0),5e3)},[]);(0,A.useEffect)(()=>{if(Q?.kind===`embed`||F||K||yt||Ze||ft||Gt||qt){w.current&&window.clearTimeout(w.current);let e=window.requestAnimationFrame(()=>zt(!1));return()=>window.cancelAnimationFrame(e)}let e=window.requestAnimationFrame(wn),t=g.current;if(!t)return()=>window.cancelAnimationFrame(e);let n=[`mousemove`,`mousedown`,`keydown`,`touchstart`,`scroll`];for(let e of n)t.addEventListener(e,wn);return()=>{window.cancelAnimationFrame(e);for(let e of n)t.removeEventListener(e,wn);w.current&&window.clearTimeout(w.current)}},[qt,K,Gt,Q?.kind,F,g,wn,yt,ft,Ze]);let Tn=e=>{let t=Math.max(0,Math.min(X,e));v.current&&(v.current.currentTime=t),Sn.current.positionSeconds=t,Ct(t)},En=(0,A.useCallback)(()=>{let e=y.current;if(!e||e.readyState<HTMLMediaElement.HAVE_METADATA)return;let t=b.current,n=Number.isFinite(e.duration)&&e.duration>0?Math.max(0,e.duration-.05):t;try{e.currentTime=Math.min(t,n)}catch{}},[]),Dn=e=>{b.current=e,x.current===null&&(x.current=window.requestAnimationFrame(()=>{x.current=null,En()}))},On=e=>{let t=Math.max(0,Math.min(X,e));Dn(t),Vt({position:X>0?t/X*100:0,time:t})},kn=(e,t)=>{let n=t.getBoundingClientRect(),r=n.width>0?Math.max(0,Math.min(1,(e-n.left)/n.width)):0;On(r*X)};(0,A.useEffect)(()=>{let e=y.current;if(!e||!Q||Q.kind===`embed`)return;let t=!1,n=()=>{};return Q.kind===`hls`&&!e.canPlayType(`application/vnd.apple.mpegurl`)?r(async()=>{let{default:e}=await import(`./hls-CgexCc5Z.js`);return{default:e}},[]).then(({default:e})=>{if(t||!y.current||!e.isSupported())return;let r=new e;r.loadSource(Q.path),r.attachMedia(y.current),r.on(e.Events.MANIFEST_PARSED,()=>{t||En()}),n=()=>r.destroy()}):(e.src=Q.path,e.load()),()=>{t=!0,n(),x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null),e.removeAttribute(`src`),e.load()}},[Q,En]);let An=()=>{let e=v.current;if(e){e.paused?e.play():e.pause();return}I(e=>(L.current=!e,!e))},jn=e=>{!e&&He<=0&&Ue(We.current||1),Ve(e)},Mn=(e,t=!1)=>{let n=e.currentTime;Number.isFinite(e.duration)&&e.duration>0&&(Sn.current.durationSeconds=e.duration,St(e.duration),t&&!tn.current&&Le>0&&(n=Math.min(Le,Math.max(0,e.duration-.1)),e.currentTime=n,tn.current=!0),e.buffered.length&&Tt(e.buffered.end(e.buffered.length-1)/e.duration*100)),Number.isFinite(n)&&(Sn.current.positionSeconds=n,Ct(n))},Nn=()=>{let e=[1,1.25,1.5,.75],t=e.indexOf(Et);Dt(e[(t+1)%e.length])},Pn=async()=>{try{document.fullscreenElement===g.current?await document.exitFullscreen():await g.current?.requestFullscreen()}catch{jt(`Fullscreen is unavailable in this window`)}},Fn=()=>{C.current&&window.clearTimeout(C.current),jt(`Thanks — the playback issue was reported`),C.current=window.setTimeout(()=>jt(``),2600)},In=n=>{let r=Z;n===`intro`?Ht(r):Wt(r),Kt(!1),jt(n===`intro`?`Intro end set at ${V(r)}`:`Outro start set at ${V(r)}`),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>jt(``),2600),fetch(`/api/netflix/markers`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,markerType:n,timeSeconds:r,profileId:t})}).catch(()=>{jt(`Marker could not be saved`)})},Ln=n=>{n===`intro`?Ht(null):Wt(null),Kt(!1),jt(n===`intro`?`Intro marker removed`:`Outro marker removed`),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>jt(``),2600),fetch(`/api/netflix/markers`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({titleId:e.id,markerType:n,profileId:t})}).catch(()=>{jt(`Marker could not be removed`)})},Rn=e=>{let t=he.current,n=g.current?.getBoundingClientRect();!t||t.pointerId!==e.pointerId||!n||W(qe({x:(e.clientX-t.offsetX-n.left)/n.width*100,y:(e.clientY-t.offsetY-n.top)/n.height*100},n,e.currentTarget.getBoundingClientRect()))},zn=e=>{if(e.button!==0)return;let t=g.current?.getBoundingClientRect();t&&(e.preventDefault(),e.stopPropagation(),he.current={pointerId:e.pointerId,offsetX:e.clientX-(t.left+rt.x/100*t.width),offsetY:e.clientY-(t.top+rt.y/100*t.height)},e.currentTarget.setPointerCapture(e.pointerId),pt(!0),L.current?ve.current=!1:(ve.current=!0,L.current=!0,I(!0)))},Bn=e=>{he.current?.pointerId===e.pointerId&&(Rn(e),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),he.current=null,pt(!1),ve.current&&(ve.current=!1,L.current=!1,I(!1)))},Vn=e=>{let t={ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0},ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1}}[e.key];if(!t)return;e.preventDefault();let n=e.shiftKey?5:1,r=g.current?.getBoundingClientRect(),i=e.currentTarget.getBoundingClientRect();W(e=>{let a={x:e.x+t.x*n,y:e.y+t.y*n};return r?qe(a,r,i):Ke(a)})},Hn=e=>{if(e===null){Xe(!1),tt([]);return}$e(e),Xe(!0)},Un=e=>{q(!1),Jt(!1),mt(!1),H(!1),!(e.id===_t&&!Pt)&&(It(null),Nt(`Loading ${e.label}…`),Ft(!0),bt(t=>({id:e.id,nonce:(t?.nonce??0)+1})))},Wn=t=>{if(mt(!1),q(!1),H(!1),t===Y)return;Cn();let n=sn.find(e=>e.number===t),r=!!(e.playbackPath&&(!je||t===je));xt(t),tn.current=!0,nn.current=``,Ct(0),Tt(0);let i=Ye(n?.duration);Sn.current={seasonNumber:n?.season??1,episodeNumber:t,positionSeconds:0,durationSeconds:i},St(i),L.current=!1,I(!1),!n?.subtitles.length&&!e.subtitles?.length&&Xe(!1),r&&e.playbackPath?(It({path:e.playbackPath,kind:e.playbackKind===`hls`?`hls`:`file`}),Nt(``),Ft(!1)):e.sourceProvider&&e.canStream&&(It(null),Nt(`Loading ${n?.title||`Episode ${t}`}…`),Ft(!0))},Gn=()=>{let e=sn[dn+1];e&&Wn(e.number)};(0,A.useEffect)(()=>{xe.current={sessionId:Te,profileId:t,titleId:e.id,title:Ae,artwork:un?.image||e.backdropImage,seasonNumber:pn,episodeNumber:Y,episodeTitle:un?.title||`Episode ${Y}`,episodes:sn.map(e=>({season:e.season,number:e.number,title:e.title})),currentTime:Z,duration:X,paused:F,muted:Be,volume:He,subtitles:{available:vn,captionsOn:R,fontSize:U,fontColor:G,backgroundColor:at},machineName:ie(),deviceType:re(),updatedAt:Date.now()}});let Kn=(0,A.useCallback)(()=>{if(k.current)return;let e=xe.current;if(!e)return;let t=new AbortController;j.current.add(t),fetch(`/api/netflix/activity`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({activity:{...e,updatedAt:Date.now()}}),cache:`no-store`,signal:t.signal}).catch(()=>{}).finally(()=>{j.current.delete(t)})},[]);return(0,A.useEffect)(()=>{we.current=e=>{switch(e.type){case`set-paused`:{let t=v.current;L.current=e.paused,I(e.paused),t&&(e.paused?t.pause():t.play().catch(()=>I(!0)));break}case`seek-relative`:Tn(Sn.current.positionSeconds+e.seconds);break;case`seek-to`:Tn(e.seconds);break;case`set-muted`:jn(e.muted);break;case`set-volume`:{let t=Math.max(0,Math.min(1,e.volume));t>0&&(We.current=t),Ue(t),Ve(t<=0);break}case`next-episode`:Gn();break;case`select-episode`:Wn(e.episodeNumber);break;case`switch-title`:d(e.titleId).catch(()=>{jt(`Movie could not be switched`)});break;case`switch-track`:case`switch-playlist`:break;case`set-captions`:Xe(e.enabled&&vn),e.enabled||tt([]);break;case`set-subtitle-font-size`:nt(Math.max(18,Math.min(64,e.fontSize)));break;case`set-subtitle-font-color`:it(e.color);break;case`set-subtitle-background`:ot(e.background);break;case`reset-subtitle-position`:W(z);break}window.requestAnimationFrame(Kn)}}),(0,A.useEffect)(()=>{k.current=!1,M.current=0;let e=!1,n=null,r=new AbortController,i=()=>{if(!k.current){k.current=!0;for(let e of j.current)e.abort();j.current.clear(),r.abort(),fetch(`/api/netflix/activity`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:Te,profileId:t}),cache:`no-store`,keepalive:!0}).catch(()=>{})}},a=async()=>{if(!(e||k.current||r.signal.aborted)){try{let e=M.current,n=await fetch(`/api/netflix/activity/${encodeURIComponent(Te)}/commands?after=${encodeURIComponent(e)}&profileId=${encodeURIComponent(t)}`,{cache:`no-store`,signal:r.signal});if(n.ok){let t=await n.json();if(typeof t==`object`&&t&&!Array.isArray(t)){let n=t,r=Array.isArray(n.commands)?n.commands:[],i=new Set,a=[];for(let t of r){if(typeof t!=`object`||!t||Array.isArray(t))continue;let n=t,r=n.id;if(typeof r!=`number`||!Number.isSafeInteger(r)||r<=e||i.has(r)||n.sessionId!==Te)continue;let o={kind:`command`,sessionId:Te,command:n.command};!h(o)||o.kind!==`command`||(i.add(r),a.push({id:r,command:o.command}))}a.sort((e,t)=>e.id-t.id);for(let e of a)we.current(e.command);let o=n.cursor,s=a.length>0?a[a.length-1].id:e;typeof o==`number`&&Number.isSafeInteger(o)&&o>=s?M.current=o:a.length&&(M.current=s)}}}catch{}!e&&!k.current&&!r.signal.aborted&&(n=window.setTimeout(()=>void a(),Math.min(500,ae)))}};window.addEventListener(`pagehide`,i),Kn();let o=window.setInterval(Kn,ae);return a(),()=>{e=!0,window.clearInterval(o),n!==null&&window.clearTimeout(n),window.removeEventListener(`pagehide`,i),i()}},[Te,t,Kn]),(0,A.useEffect)(()=>{Kn()},[Y,R,X,vn,Be,F,at,G,U,He,Kn]),(0,N.jsxs)(`section`,{ref:g,className:`player${F?` player--paused`:``}${rn?` player--local`:``}${Rt?` player--idle`:``}`,role:`dialog`,"aria-modal":`true`,"aria-label":`Playing ${Ae}`,style:{"--player-image":`url("${e.backdropImage}")`},children:[Q?.kind===`embed`?(0,N.jsx)(`iframe`,{className:`player-embed`,src:Q.path,title:`${Ae} provider player`,allow:`autoplay; encrypted-media; fullscreen; picture-in-picture`,allowFullScreen:!0,referrerPolicy:`origin`,sandbox:`allow-forms allow-presentation allow-same-origin allow-scripts`}):rn?(0,N.jsx)(`video`,{ref:v,className:`player-video`,autoPlay:!0,playsInline:!0,muted:Be,poster:e.backdropImage,onClick:An,onLoadedMetadata:e=>Mn(e.currentTarget,!0),onProgress:e=>Mn(e.currentTarget),onTimeUpdate:e=>Mn(e.currentTarget),onPlay:()=>{L.current=!1,I(!1)},onPause:()=>{L.current=!0,I(!0),Cn()},onEnded:()=>{let e=v.current,t=e&&Number.isFinite(e.duration)?e.duration:X;Ct(t),Cn({positionSeconds:t,durationSeconds:t||X,completed:!0}),L.current=!0,I(!0)},onError:()=>{Nt(`The browser could not play this provider stream.`),L.current=!0,I(!0)},children:hn.map(e=>(0,N.jsx)(`track`,{kind:`subtitles`,src:e.src,srcLang:e.language,label:e.label},`${Y}-${e.language}-${e.src}`))}):null,Mt&&(0,N.jsxs)(`div`,{className:`player-stream-status${Pt?``:` player-stream-status--error`}`,role:`status`,children:[Pt&&(0,N.jsx)(T,{className:`spin`}),(0,N.jsx)(`span`,{children:Mt})]}),(0,N.jsx)(`div`,{className:`player-cinematic-bars`}),(0,N.jsx)(`div`,{className:`player-noise`}),(0,N.jsxs)(`header`,{className:`player-topbar`,children:[(0,N.jsxs)(`div`,{className:`player-topbar-start`,children:[(0,N.jsx)(`button`,{className:`player-icon-button player-back`,onClick:()=>{Cn(),ne()},"aria-label":`Exit player`,children:(0,N.jsx)(c,{})}),Q?.kind===`embed`&&(0,N.jsxs)(`div`,{className:`player-embed-program`,children:[(0,N.jsx)(`strong`,{children:Ae}),(0,N.jsxs)(`span`,{children:[`Episode `,Y]})]})]}),(0,N.jsxs)(`div`,{className:`player-topbar-actions`,children:[ht.length>0&&(0,N.jsxs)(`div`,{className:`player-server-control`,ref:D,children:[(0,N.jsx)(`button`,{className:`player-icon-button player-server-trigger${yt?` is-active`:``}`,type:`button`,"aria-label":mn?`Change server, currently ${mn.label}`:`Change server`,"aria-haspopup":`listbox`,"aria-expanded":yt,onClick:()=>{let e=!yt;Jt(!1),mt(!1),H(!1),q(e)},children:(0,N.jsx)(Se,{})}),yt&&(0,N.jsxs)(`div`,{className:`player-server-menu`,children:[(0,N.jsx)(`h2`,{children:`Servers`}),(0,N.jsx)(`div`,{className:`player-server-options`,role:`listbox`,"aria-label":`Servers`,children:ht.map(e=>{let t=e.id===_t;return(0,N.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>Un(e),children:[(0,N.jsx)(Se,{"aria-hidden":`true`}),(0,N.jsx)(`span`,{children:e.label}),t&&(0,N.jsx)(O,{"aria-hidden":`true`})]},e.id)})})]})]}),Q?.kind===`embed`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{className:`player-icon-button player-topbar-episodes${K?` is-active`:``}`,type:`button`,"aria-label":K?`Hide episodes`:`Show episodes`,"aria-expanded":K,onClick:()=>{Jt(!1),q(!1),H(!1),mt(e=>!e)},children:(0,N.jsx)(s,{})}),(0,N.jsx)(`button`,{className:`player-icon-button player-topbar-next`,type:`button`,"aria-label":`Next episode`,onClick:Gn,disabled:!fn,children:(0,N.jsx)(p,{})})]}),(0,N.jsx)(ce,{id:`player-access-popover`,wrapClassName:`player-popover-wrap`,buttonClassName:`player-icon-button player-access`,popoverClassName:`player-access-popover`,open:qt,onOpenChange:e=>{e&&(q(!1),mt(!1),H(!1)),Jt(e)}}),(0,N.jsx)(`button`,{className:`player-icon-button player-report`,onClick:Fn,"aria-label":`Report a problem`,children:(0,N.jsx)(ge,{})})]})]}),Q?.kind!==`embed`&&R&&xn.length>0&&(0,N.jsx)(`div`,{ref:fe,className:`player-subtitles${ft?` player-subtitles--dragging`:``}`,style:{"--player-subtitle-font-size":`${U}px`,"--player-subtitle-color":G,"--player-subtitle-bg":at,"--player-subtitle-font-family":st==="default"?void 0:st,left:`${rt.x}%`,top:`${rt.y}%`},role:`group`,"aria-label":`Draggable subtitles`,"aria-live":`polite`,tabIndex:0,onClick:e=>e.stopPropagation(),onKeyDown:Vn,onPointerDown:zn,onPointerMove:Rn,onPointerUp:Bn,onPointerCancel:Bn,children:xn.map((e,t)=>(0,N.jsx)(`span`,{children:e},`${t}-${e}`))}),K&&(0,N.jsxs)(`aside`,{className:`player-episodes${Q?.kind===`embed`?` player-episodes--embed`:``}`,"aria-label":`Episodes`,children:[(0,N.jsxs)(`header`,{className:`player-episodes-header`,children:[(0,N.jsx)(`h2`,{children:e.mediaType===`limited-series`?`Limited Series`:`Season ${pn}`}),(0,N.jsxs)(`button`,{className:`episode-sort-button`,type:`button`,"aria-label":i===`asc`?`Sort episodes newest first`:`Sort episodes oldest first`,title:i===`asc`?`Sorted oldest first`:`Sorted newest first`,onClick:()=>ee(i===`asc`?`desc`:`asc`),children:[i===`asc`?(0,N.jsx)(pe,{}):(0,N.jsx)(me,{}),(0,N.jsx)(`span`,{children:i===`asc`?`Oldest`:`Newest`})]})]}),(0,N.jsx)(`div`,{className:`player-episode-list`,children:cn.map(e=>{let t=e.number===Y;return(0,N.jsxs)(`button`,{className:`player-episode${t?` player-episode--active`:``}`,"aria-label":`${e.number}. ${e.title}, ${e.duration}`,"aria-current":t?`true`:void 0,onClick:()=>Wn(e.number),children:[(0,N.jsxs)(`span`,{className:`player-episode-heading`,children:[(0,N.jsx)(`span`,{children:e.number}),(0,N.jsx)(`strong`,{children:e.title}),(0,N.jsx)(`i`,{"aria-hidden":`true`})]}),t&&(0,N.jsxs)(`span`,{className:`player-episode-details`,children:[(0,N.jsx)(`span`,{className:`player-episode-thumbnail`,style:{backgroundImage:`linear-gradient(rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.48)), url("${e.image}")`},children:(0,N.jsxs)(`span`,{className:`player-now-playing`,children:[(0,N.jsxs)(`span`,{className:`player-playing-bars`,"aria-hidden":`true`,children:[(0,N.jsx)(`i`,{}),(0,N.jsx)(`i`,{}),(0,N.jsx)(`i`,{}),(0,N.jsx)(`i`,{})]}),`Now playing`]})}),(0,N.jsx)(`span`,{className:`player-episode-synopsis`,children:e.synopsis})]})]},e.number)})})]}),Q?.kind!==`embed`&&F&&!Mt&&(0,N.jsx)(`button`,{className:`big-play`,onClick:An,"aria-label":`Resume`,children:(0,N.jsx)(S,{fill:`currentColor`})}),At&&(0,N.jsx)(`div`,{className:`player-notice`,role:`status`,children:At}),Q?.kind!==`embed`&&(0,N.jsxs)(`div`,{className:`player-bottom${K?` player-bottom--drawer-open`:``}`,children:[!K&&(0,N.jsxs)(`div`,{className:`player-timeline-row`,children:[(0,N.jsxs)(`div`,{className:`player-timeline-wrap${Bt?` player-timeline-wrap--previewing`:``}`,style:{"--seek-preview-position":`${Bt?.position??0}%`},onPointerEnter:e=>kn(e.clientX,e.currentTarget),onPointerMove:e=>kn(e.clientX,e.currentTarget),onPointerLeave:()=>Vt(null),children:[(0,N.jsxs)(`div`,{className:`player-seek-preview`,"aria-hidden":`true`,children:[Q?(0,N.jsx)(`video`,{ref:y,className:`player-seek-preview-frame`,muted:!0,playsInline:!0,preload:`metadata`,poster:un?.image||e.backdropImage,onLoadedMetadata:En,onSeeked:e=>e.currentTarget.pause()}):(0,N.jsx)(N.Fragment,{children:(0,N.jsx)(`img`,{src:un?.image||e.backdropImage,alt:``,draggable:!1})}),(0,N.jsx)(`time`,{children:V(Bt?.time??Z)})]}),(0,N.jsx)(`input`,{className:`player-timeline`,type:`range`,min:0,max:X||1,step:.1,value:Math.min(Z,X||1),style:yn,onFocus:e=>On(Number(e.currentTarget.value)),onBlur:()=>Vt(null),onInput:e=>On(Number(e.currentTarget.value)),onChange:e=>Tn(Number(e.currentTarget.value)),"aria-label":`Seek`,"aria-valuetext":`${V(Z)} of ${V(X)}`}),$!==null&&X>0&&(0,N.jsx)(`div`,{className:`player-timeline-marker player-timeline-marker--intro`,style:{left:`${$/X*100}%`},"aria-label":`Intro end at ${V($)}`}),Ut!==null&&X>0&&(0,N.jsx)(`div`,{className:`player-timeline-marker player-timeline-marker--outro`,style:{left:`${Ut/X*100}%`},"aria-label":`Outro start at ${V(Ut)}`}),F&&!Mt&&(0,N.jsxs)(`div`,{ref:$t,className:`player-marker-control`,style:{left:`${ln}%`},onPointerEnter:e=>{e.stopPropagation(),Vt(null)},onPointerMove:e=>e.stopPropagation(),onPointerLeave:e=>e.stopPropagation(),children:[(0,N.jsx)(`button`,{className:`player-marker-trigger`,"aria-label":`Timeline marker settings`,"aria-expanded":Gt,onClick:e=>{e.stopPropagation(),Kt(e=>!e)},children:(0,N.jsx)(Ce,{})}),Gt&&(0,N.jsxs)(`div`,{className:`player-marker-menu`,role:`menu`,"aria-label":`Set timeline marker`,children:[(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>In(`intro`),children:[(0,N.jsx)(le,{}),(0,N.jsx)(`span`,{children:`Set as Intro`}),$!==null&&(0,N.jsx)(`small`,{children:V($)})]}),(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>In(`outro`),children:[(0,N.jsx)(p,{}),(0,N.jsx)(`span`,{children:`Set as Outro`}),Ut!==null&&(0,N.jsx)(`small`,{children:V(Ut)})]}),$!==null&&(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`player-marker-menu-remove`,onClick:()=>Ln(`intro`),children:[(0,N.jsx)(de,{}),(0,N.jsx)(`span`,{children:`Remove Intro`}),(0,N.jsx)(`small`,{children:V($)})]}),Ut!==null&&(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`player-marker-menu-remove`,onClick:()=>Ln(`outro`),children:[(0,N.jsx)(de,{}),(0,N.jsx)(`span`,{children:`Remove Outro`}),(0,N.jsx)(`small`,{children:V(Ut)})]})]})]})]}),(0,N.jsx)(`time`,{children:V(X-Z)})]}),(0,N.jsxs)(`div`,{className:`player-controls`,children:[(0,N.jsxs)(`div`,{className:`player-controls-left`,children:[(0,N.jsx)(`button`,{className:`player-control-button`,onClick:An,"aria-label":F?`Play`:`Pause`,children:F?(0,N.jsx)(S,{fill:`currentColor`}):(0,N.jsx)(ue,{fill:`currentColor`})}),(0,N.jsxs)(`button`,{className:`player-control-button player-ten-second`,"aria-label":`Rewind 10 seconds`,onClick:()=>Tn(Z-10),children:[(0,N.jsx)(o,{}),(0,N.jsx)(`span`,{children:`10`})]}),(0,N.jsxs)(`button`,{className:`player-control-button player-ten-second`,"aria-label":`Forward 10 seconds`,onClick:()=>Tn(Z+10),children:[(0,N.jsx)(l,{}),(0,N.jsx)(`span`,{children:`10`})]}),(0,N.jsx)(`button`,{className:`player-control-button`,"aria-label":Be?`Unmute`:`Mute`,"aria-pressed":Be,onClick:()=>jn(!Be),children:Be?(0,N.jsx)(se,{}):(0,N.jsx)(oe,{})})]}),(0,N.jsxs)(`div`,{className:`player-program`,children:[(0,N.jsx)(`strong`,{children:Ae}),(0,N.jsxs)(`span`,{children:[`Season `,pn,`\xA0\xA0 Episode `,Y]})]}),(0,N.jsxs)(`div`,{className:`player-controls-right`,children:[(0,N.jsx)(`button`,{className:`player-control-button`,"aria-label":`Next episode`,onClick:Gn,disabled:!fn,children:(0,N.jsx)(p,{})}),(0,N.jsx)(`button`,{className:`player-control-button player-episodes-trigger${K?` is-active`:``}`,type:`button`,"aria-label":K?`Hide episodes`:`Show episodes`,"aria-expanded":K,onClick:()=>{Jt(!1),q(!1),H(!1),mt(e=>!e)},children:(0,N.jsx)(s,{})}),(0,N.jsxs)(`div`,{className:`player-subtitle-control`,ref:E,children:[Ze&&(0,N.jsxs)(`div`,{className:`player-subtitle-menu`,role:`dialog`,"aria-label":`Subtitles`,children:[(0,N.jsx)(`h2`,{children:`Subtitles`}),(0,N.jsxs)(`div`,{className:`player-subtitle-options`,role:`listbox`,"aria-label":`Subtitle language`,children:[(0,N.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!R,onClick:()=>Hn(null),children:[(0,N.jsx)(`span`,{className:`player-subtitle-check`,"aria-hidden":`true`,children:!R&&(0,N.jsx)(O,{})}),(0,N.jsx)(`span`,{children:`Off`})]}),gn.map((e,t)=>{let n=R&&t===_n;return(0,N.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>Hn(t),children:[(0,N.jsx)(`span`,{className:`player-subtitle-check`,"aria-hidden":`true`,children:n&&(0,N.jsx)(O,{})}),(0,N.jsx)(`span`,{children:e.label})]},`${e.language}-${e.src}`)})]}),(0,N.jsxs)(`div`,{className:`player-subtitle-settings`,children:[(0,N.jsxs)(`div`,{className:`player-subtitle-setting-heading`,children:[(0,N.jsx)(`label`,{htmlFor:`player-subtitle-font-size`,children:`Font size`}),(0,N.jsxs)(`output`,{htmlFor:`player-subtitle-font-size`,children:[U,`px`]})]}),(0,N.jsxs)(`div`,{className:`player-subtitle-size-control`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`A`}),(0,N.jsx)(`input`,{id:`player-subtitle-font-size`,type:`range`,min:18,max:64,step:2,value:U,"aria-label":`Subtitle font size`,onChange:e=>nt(Number(e.currentTarget.value))}),(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`A`})]}),(0,N.jsxs)(`div`,{className:`player-subtitle-position-setting`,children:[(0,N.jsx)(`p`,{children:`Drag subtitles on screen to move them.`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>W(z),children:`Reset position`})]}),(0,N.jsxs)(`div`,{className:`player-subtitle-color-setting`,children:[(0,N.jsx)(`label`,{htmlFor:`player-subtitle-font-color`,children:`Font color`}),(0,N.jsx)(`input`,{id:`player-subtitle-font-color`,type:`color`,value:G,onChange:e=>it(e.currentTarget.value)})]}),(0,N.jsxs)(`div`,{className:`player-subtitle-color-setting`,children:[(0,N.jsx)(`label`,{htmlFor:`player-subtitle-bg-color`,children:`Background`}),(0,N.jsxs)(`select`,{id:`player-subtitle-bg-color`,value:at,onChange:e=>ot(e.currentTarget.value),children:[(0,N.jsx)(`option`,{value:`transparent`,children:`None`}),(0,N.jsx)(`option`,{value:`rgba(0,0,0,0.75)`,children:`Dark`}),(0,N.jsx)(`option`,{value:`rgba(0,0,0,0.5)`,children:`Semi-dark`}),(0,N.jsx)(`option`,{value:`rgba(0,0,0,0.3)`,children:`Light`}),(0,N.jsx)(`option`,{value:`rgba(0,0,0,1)`,children:`Solid black`})]})]})]})]}),(0,N.jsx)(`button`,{className:`player-control-button player-subtitle-trigger${R?` is-active`:``}`,"aria-label":vn?`Subtitles`:`Subtitles unavailable`,"aria-haspopup":`dialog`,"aria-expanded":Ze,"aria-pressed":R,disabled:!vn,onClick:()=>{mt(!1),q(!1),H(e=>!e)},children:(0,N.jsx)(te,{})})]}),(0,N.jsxs)(`button`,{className:`player-control-button player-speed`,"aria-label":`Change playback speed, currently ${Et}x`,onClick:Nn,children:[(0,N.jsx)(_e,{}),Et!==1&&(0,N.jsxs)(`span`,{children:[Et,`×`]})]}),(0,N.jsx)(`button`,{className:`player-control-button`,"aria-label":Ot?`Exit fullscreen`:`Enter fullscreen`,onClick:()=>void Pn(),children:Ot?(0,N.jsx)(f,{}):(0,N.jsx)(m,{})})]})]})]}),Q?.kind!==`embed`&&Yt&&!F&&(0,N.jsx)(`button`,{className:`player-skip-intro`,onClick:()=>{$!==null&&Tn($),Xt(!1)},children:`Skip Intro`}),Q?.kind!==`embed`&&Zt&&!F&&fn&&(0,N.jsxs)(`button`,{className:`player-next-episode-prompt`,onClick:()=>{Qt(!1),Gn()},children:[(0,N.jsx)(S,{fill:`currentColor`}),`Next Episode`]})]})}function Ze(){return(0,N.jsxs)(`footer`,{className:`site-footer`,id:`footer`,children:[(0,N.jsxs)(`div`,{className:`social-links`,"aria-label":`Social media`,children:[(0,N.jsx)(`a`,{href:`#facebook`,"aria-label":`Facebook`,children:`f`}),(0,N.jsx)(`a`,{href:`#instagram`,"aria-label":`Instagram`,children:`◎`}),(0,N.jsx)(`a`,{href:`#twitter`,"aria-label":`X`,children:`𝕏`}),(0,N.jsx)(`a`,{href:`#youtube`,"aria-label":`YouTube`,children:`▶`})]}),(0,N.jsx)(`div`,{className:`footer-links`,children:[`Audio Description`,`Help Center`,`Gift Cards`,`Media Center`,`Investor Relations`,`Jobs`,`Terms of Use`,`Privacy`,`Legal Notices`,`Cookie Preferences`,`Corporate Information`,`Contact Us`].map(e=>(0,N.jsx)(`a`,{href:`#${H(e)}`,children:e},e))}),(0,N.jsx)(`span`,{className:`service-code`,children:`Service Code`}),(0,N.jsx)(`p`,{children:`© 1997–2026 Netflix Clone. Built for demonstration purposes.`})]})}function H(e){return e.toLowerCase().replace(/&/g,`and`).replace(/ /g,`-`)}export{Ie as NetflixBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chevron-left-Dn3noAqV.js";var t=e(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),n=e(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),r=e(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),i=e(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]);function a(){if(typeof navigator>`u`)return`unknown`;let e=navigator.userAgent;return/android/i.test(e)?/Mobile/i.test(e)?`phone`:`tablet`:/iPad/i.test(e)||/Macintosh/i.test(e)&&`ontouchend`in document?`tablet`:/iPhone|iPod/i.test(e)?`phone`:/Macintosh|Mac OS X/i.test(e)||/CrOS/i.test(e)?`laptop`:/Windows/i.test(e)||/Linux/i.test(e)?`desktop`:`unknown`}function o(){if(typeof navigator>`u`)return`Unknown`;let e=navigator.userAgent;if(/android/i.test(e)){let t=e.match(/;\s*([^;)]+)\s+Build\//);return t?t[1].trim():`Android`}return/iPad/i.test(e)||/Macintosh/i.test(e)&&`ontouchend`in document?`iPad`:/iPhone/i.test(e)?`iPhone`:/iPod/i.test(e)?`iPod`:/Windows/i.test(e)?`Windows PC`:/Macintosh|Mac OS X/i.test(e)?`Mac`:/CrOS/i.test(e)?`Chromebook`:/Linux/i.test(e)?`Linux PC`:`Unknown`}var s=1e3,c=0;function l(){let e=globalThis.crypto;return typeof e?.randomUUID==`function`?e.randomUUID():(c+=1,[`playback`,Date.now().toString(36),c.toString(36),Math.random().toString(36).slice(2)].join(`-`))}function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){return typeof e==`string`&&e.trim().length>0}function f(e){return typeof e==`number`&&Number.isFinite(e)}function p(e){return f(e)&&e>=0}function m(e){return Number.isInteger(e)&&typeof e==`number`&&e>0}function h(e){return f(e)&&e>=0&&e<=1}function g(e){return u(e)&&m(e.season)&&m(e.number)&&d(e.title)}function _(e){return u(e)&&typeof e.available==`boolean`&&typeof e.captionsOn==`boolean`&&f(e.fontSize)&&e.fontSize>=18&&e.fontSize<=64&&d(e.fontColor)&&d(e.backgroundColor)}function v(e){return u(e)&&d(e.sessionId)&&d(e.profileId)&&d(e.titleId)&&d(e.title)&&d(e.artwork)&&p(e.currentTime)&&p(e.duration)&&typeof e.paused==`boolean`&&typeof e.muted==`boolean`&&h(e.volume)&&p(e.updatedAt)?e.service===`spotify`?d(e.artist)&&d(e.album)&&(e.provider===void 0||d(e.provider)):(e.service===void 0||e.service===`netflix`)&&m(e.seasonNumber)&&m(e.episodeNumber)&&d(e.episodeTitle)&&Array.isArray(e.episodes)&&e.episodes.every(g)&&_(e.subtitles):!1}function y(e){if(!u(e)||typeof e.type!=`string`)return!1;switch(e.type){case`set-paused`:return typeof e.paused==`boolean`;case`seek-relative`:return f(e.seconds);case`seek-to`:return p(e.seconds);case`set-muted`:return typeof e.muted==`boolean`;case`set-volume`:return h(e.volume);case`previous-track`:case`next-track`:case`next-episode`:case`reset-subtitle-position`:return!0;case`select-episode`:return m(e.episodeNumber);case`switch-track`:return d(e.trackId);case`switch-playlist`:return d(e.playlistId);case`switch-title`:return d(e.titleId);case`set-captions`:return typeof e.enabled==`boolean`;case`set-subtitle-font-size`:return f(e.fontSize)&&e.fontSize>=18&&e.fontSize<=64;case`set-subtitle-font-color`:return d(e.color);case`set-subtitle-background`:return d(e.background);default:return!1}}function b(e){if(!u(e)||typeof e.kind!=`string`)return!1;switch(e.kind){case`announce`:return v(e.activity);case`command`:return d(e.sessionId)&&y(e.command);default:return!1}}function x(e){try{return b(e)}catch{return!1}}export{x as a,n as c,a as i,t as l,l as n,i as o,o as r,r as s,s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,r}from"./framework-BQUlGUOV.js";import{n as i}from"./chevron-left-Dn3noAqV.js";import{_ as a,a as o,d as s,f as c,i as l,m as u,o as d,p as f,r as p,s as m,t as h,v as g}from"./manage-profiles-modal-CWi3qgd4.js";var _=i(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),v=i(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),y=i(`heart`,[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]),b=i(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),x=i(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),S=i(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),C=i(`skip-back`,[[`path`,{d:`M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`15892j`}],[`path`,{d:`M3 20V4`,key:`1ptbpl`}]]),w=i(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),T=i(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),E=i(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),D=e(r(),1),O=e(n(),1),k=t();function A({profiles:e,activeProfile:t,onSelectProfile:n,onProfilesChanged:r}){let i=(0,D.useRef)(null),o=(0,D.useRef)(null),s=(0,D.useRef)(null),l=(0,D.useId)(),[u,d]=(0,D.useState)(!1),[f,p]=(0,D.useState)(!1),[m,_]=(0,D.useState)(null),[v,y]=(0,D.useState)(``);(0,D.useEffect)(()=>{if(!u)return;let e=window.requestAnimationFrame(()=>{s.current?.querySelector(`[role="menuitemradio"]:not(:disabled), [role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!i.current?.contains(e.target)&&d(!1)},n=e=>{e.key===`Escape`&&(e.preventDefault(),d(!1),o.current?.focus())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[u]);let b=e=>{e.relatedTarget instanceof Node&&i.current?.contains(e.relatedTarget)||d(!1)},x=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=Array.from(s.current?.querySelectorAll(`[role="menuitemradio"]:not(:disabled), [role="menuitem"]`)??[]);if(!t.length)return;e.preventDefault();let n=t.findIndex(e=>e===document.activeElement),r=0;e.key===`End`?r=t.length-1:e.key===`ArrowUp`?r=n<=0?t.length-1:Math.max(0,n-1):e.key===`ArrowDown`&&(r=n<0||n===t.length-1?0:n+1),t[r]?.focus()},S=async e=>{if(!m){if(e.id===t.id){d(!1),o.current?.focus();return}y(``),_(e.id);try{await n(e),d(!1),o.current?.focus()}catch{y(`Profile could not be selected. Please try again.`)}finally{_(null)}}};return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`store-profile-menu`,ref:i,onBlur:b,children:[(0,k.jsxs)(`button`,{className:`store-profile-trigger`,ref:o,type:`button`,"aria-label":`Profile: ${t.name}. Open profile menu`,"aria-haspopup":`menu`,"aria-expanded":u,"aria-controls":u?l:void 0,onClick:()=>{y(``),d(e=>!e)},onKeyDown:e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),y(``),d(!0))},children:[(0,k.jsxs)(`span`,{className:`store-profile-avatar`,"aria-hidden":`true`,style:{backgroundColor:t.avatarColor},children:[(0,k.jsx)(`span`,{}),(0,k.jsx)(`span`,{}),(0,k.jsx)(`span`,{})]}),(0,k.jsx)(a,{className:`store-profile-chevron${u?` store-profile-chevron--open`:``}`,"aria-hidden":`true`})]}),u&&(0,k.jsxs)(`div`,{className:`store-profile-popover`,id:l,ref:s,role:`menu`,"aria-label":`Choose a Netflix profile`,"aria-busy":m!==null,onKeyDown:x,children:[(0,k.jsx)(`span`,{className:`store-profile-caret`,"aria-hidden":`true`}),(0,k.jsx)(`div`,{className:`store-profile-options`,children:e.map(e=>{let n=e.id===t.id,r=e.id===m;return(0,k.jsxs)(`button`,{className:`store-profile-option`,type:`button`,role:`menuitemradio`,"aria-checked":n,disabled:m!==null,onClick:()=>void S(e),children:[(0,k.jsx)(`span`,{className:`store-profile-mini-avatar`,style:{backgroundColor:e.avatarColor},"aria-hidden":`true`,children:e.name.slice(0,1).toUpperCase()}),(0,k.jsxs)(`span`,{className:`store-profile-name`,children:[e.name,r?` — switching…`:``]}),n&&(0,k.jsx)(g,{className:`store-profile-active-check`,"aria-hidden":`true`})]},e.id)})}),(0,k.jsxs)(`button`,{className:`store-profile-manage`,type:`button`,role:`menuitem`,onClick:()=>{d(!1),p(!0)},children:[(0,k.jsx)(c,{"aria-hidden":`true`}),(0,k.jsx)(`span`,{children:`Manage profile`})]}),v&&(0,k.jsx)(`p`,{className:`store-profile-error`,role:`alert`,children:v})]})]}),f&&(0,O.createPortal)((0,k.jsx)(h,{profiles:[...e],activeProfile:t,onClose:()=>{p(!1),window.requestAnimationFrame(()=>o.current?.focus())},onProfilesChanged:r}),document.body)]})}function j({type:e}){switch(e){case`phone`:return(0,k.jsx)(w,{"aria-hidden":`true`});case`tablet`:return(0,k.jsx)(E,{"aria-hidden":`true`});case`laptop`:return(0,k.jsx)(b,{"aria-hidden":`true`});default:return(0,k.jsx)(x,{"aria-hidden":`true`})}}function M(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}function N({activity:e,tabLabel:t,searchOpen:n,onSearchToggle:r,onCommand:i}){let[a,c]=(0,D.useState)(null),u=Math.max(1,Math.round(e.duration)),p=Math.max(0,Math.min(u,Math.round(a??e.currentTime))),h=e.duration>0?Math.max(0,Math.min(100,p/e.duration*100)):0,g=Math.round(e.volume*100),_=t=>{let n=Math.max(0,Math.min(e.duration,Math.round(t)));c(null),i({type:`seek-to`,seconds:n})};return(0,k.jsxs)(`article`,{className:`activity-card activity-card--spotify`,"aria-label":`${e.title} playback in ${t}`,style:{"--activity-artwork":`url("${e.artwork}")`},children:[(0,k.jsxs)(`div`,{className:`activity-card__art`,children:[(0,k.jsxs)(`div`,{className:`activity-card__source`,children:[(0,k.jsxs)(`span`,{className:`activity-spotify-mark`,"aria-label":`Spotify`,children:[(0,k.jsx)(`i`,{}),(0,k.jsx)(`i`,{}),(0,k.jsx)(`i`,{})]}),(0,k.jsxs)(`span`,{className:`activity-live`,children:[(0,k.jsx)(`i`,{"aria-hidden":`true`}),(0,k.jsx)(j,{type:e.deviceType}),t]})]}),(0,k.jsxs)(`div`,{className:`activity-card__copy`,children:[(0,k.jsx)(`span`,{children:`Now listening`}),(0,k.jsx)(`h3`,{children:e.title}),(0,k.jsxs)(`p`,{children:[e.artist,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),e.album]})]})]}),(0,k.jsxs)(`div`,{className:`activity-card__remote`,children:[(0,k.jsx)(`input`,{className:`activity-progress`,type:`range`,min:0,max:u,step:1,value:p,disabled:e.duration<=0,"aria-label":`${e.title} progress`,"aria-valuetext":`${M(p)} of ${M(e.duration)}`,title:`Seek ${e.title}`,style:{"--activity-progress":`${h}%`},onChange:e=>c(Number(e.currentTarget.value)),onPointerUp:e=>_(Number(e.currentTarget.value)),onPointerCancel:()=>c(null),onKeyUp:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Home`||e.key===`End`||e.key===`PageUp`||e.key===`PageDown`)&&_(Number(e.currentTarget.value))},onBlur:e=>{a!==null&&_(Number(e.currentTarget.value))}}),(0,k.jsxs)(`div`,{className:`activity-time`,children:[(0,k.jsx)(`time`,{children:M(p)}),(0,k.jsx)(`span`,{children:M(e.duration)})]}),(0,k.jsxs)(`div`,{className:`activity-controls activity-controls--spotify`,role:`group`,"aria-label":`Controls for ${e.title} by ${e.artist}`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>i({type:`previous-track`}),"aria-label":`Previous track before ${e.title}`,children:(0,k.jsx)(C,{fill:`currentColor`})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i({type:`set-paused`,paused:!e.paused}),"aria-label":`${e.paused?`Play`:`Pause`} ${e.title}`,children:e.paused?(0,k.jsx)(s,{fill:`currentColor`}):(0,k.jsx)(f,{fill:`currentColor`})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i({type:`next-track`}),"aria-label":`Next track after ${e.title}`,children:(0,k.jsx)(d,{fill:`currentColor`})}),(0,k.jsxs)(`div`,{className:`activity-volume`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>i({type:`set-muted`,muted:!e.muted}),"aria-label":`${e.muted?`Unmute`:`Mute`} ${e.title}`,"aria-pressed":e.muted,children:e.muted?(0,k.jsx)(l,{}):(0,k.jsx)(o,{})}),(0,k.jsx)(`input`,{type:`range`,min:0,max:100,step:1,value:g,style:{"--activity-volume":`${g}%`},onChange:e=>i({type:`set-volume`,volume:Number(e.currentTarget.value)/100}),"aria-label":`Volume for ${e.title}`,"aria-valuetext":e.muted?`Muted, level ${g}%`:`${g}%`})]}),(0,k.jsx)(`button`,{className:n?`is-active`:``,type:`button`,onClick:r,"aria-label":`Switch ${e.title} to another track`,"aria-expanded":n,"aria-controls":`activity-tracks-${e.sessionId}`,children:(0,k.jsx)(m,{})})]})]})]})}var P={chromaticWeather:{from:`#3659f7`,to:`#ed5b98`,accent:`#d9f8ff`,glyph:`✦`},stillFrames:{from:`#d16b5d`,to:`#4a1f35`,accent:`#ffe4c7`,glyph:`◌`},parallelStreets:{from:`#121c3d`,to:`#af2f78`,accent:`#65e4ff`,glyph:`//`},blueHour:{from:`#204b78`,to:`#9b6db2`,accent:`#d9edff`,glyph:`◐`},orbiting:{from:`#322063`,to:`#e34f86`,accent:`#f5d5ff`,glyph:`◎`},smallHours:{from:`#b66a35`,to:`#2b483b`,accent:`#ffe3a8`,glyph:`☕`},lowTide:{from:`#22676c`,to:`#102e46`,accent:`#b7f5df`,glyph:`≈`},dreamingMono:{from:`#3c3d42`,to:`#8e718f`,accent:`#f2ebd9`,glyph:`◇`},liked:{from:`#3f2db8`,to:`#8ed8c8`,accent:`#ffffff`,glyph:`♥`},coding:{from:`#083d35`,to:`#151d28`,accent:`#53f2b0`,glyph:`</>`},nightDrive:{from:`#15152f`,to:`#7b205d`,accent:`#ff6cc7`,glyph:`☾`},coffeehouse:{from:`#9d5c3e`,to:`#2e2924`,accent:`#ffd59d`,glyph:`AM`},sundayReset:{from:`#d9846a`,to:`#687c67`,accent:`#fff0d2`,glyph:`SUN`},neonPulse:{from:`#4d1ec9`,to:`#e31f74`,accent:`#67f6da`,glyph:`N`},softPop:{from:`#e995b5`,to:`#8e70c9`,accent:`#fff1b8`,glyph:`POP`},deepFocus:{from:`#174d4b`,to:`#18233e`,accent:`#79d6bb`,glyph:`∞`},morningLight:{from:`#ee9b52`,to:`#f0cf78`,accent:`#4e3628`,glyph:`✺`}},F=[{id:`neon-skyline`,title:`Neon Skyline`,artist:`Luma Coast`,album:`Chromatic Weather`,durationSec:224,palette:P.chromaticWeather},{id:`open-windows`,title:`Open Windows`,artist:`Luma Coast`,album:`Chromatic Weather`,durationSec:197,palette:P.chromaticWeather},{id:`slow-motion`,title:`Slow Motion`,artist:`Arlo Vale`,album:`Still Frames`,durationSec:208,palette:P.stillFrames},{id:`paper-moons`,title:`Paper Moons`,artist:`Arlo Vale`,album:`Still Frames`,durationSec:186,palette:P.stillFrames},{id:`after-hours-drive`,title:`After Hours Drive`,artist:`Night Atlas`,album:`Parallel Streets`,durationSec:251,palette:P.parallelStreets},{id:`city-rain`,title:`City Rain`,artist:`Night Atlas`,album:`Parallel Streets`,durationSec:239,palette:P.parallelStreets},{id:`blue-hour`,title:`Blue Hour`,artist:`Mira Lane`,album:`Northbound`,durationSec:216,palette:P.blueHour},{id:`velvet-morning`,title:`Velvet Morning`,artist:`Mira Lane`,album:`Northbound`,durationSec:203,palette:P.blueHour},{id:`satellite-hearts`,title:`Satellite Hearts`,artist:`Nova Bloom`,album:`Orbiting`,durationSec:232,palette:P.orbiting},{id:`signal-fires`,title:`Signal Fires`,artist:`Nova Bloom`,album:`Orbiting`,durationSec:245,palette:P.orbiting},{id:`coffee-stains`,title:`Coffee Stains`,artist:`The Daylights`,album:`Small Hours`,durationSec:194,palette:P.smallHours},{id:`golden-lines`,title:`Golden Lines`,artist:`The Daylights`,album:`Small Hours`,durationSec:211,palette:P.smallHours},{id:`quiet-current`,title:`Quiet Current`,artist:`Elio Pines`,album:`Low Tide Letters`,durationSec:263,palette:P.lowTide},{id:`tides-in-reverse`,title:`Tides in Reverse`,artist:`Elio Pines`,album:`Low Tide Letters`,durationSec:228,palette:P.lowTide},{id:`soft-static`,title:`Soft Static`,artist:`Static Garden`,album:`Dreaming in Mono`,durationSec:274,palette:P.dreamingMono},{id:`midnight-orchard`,title:`Midnight Orchard`,artist:`Static Garden`,album:`Dreaming in Mono`,durationSec:257,palette:P.dreamingMono}],I=[{id:`daily-mix-one`,title:`Daily Mix 01`,description:`Luma Coast, Nova Bloom, Mira Lane and more`,curator:`Spotify Atom`,trackIds:[`neon-skyline`,`satellite-hearts`,`blue-hour`,`open-windows`,`signal-fires`],palette:P.chromaticWeather},{id:`daily-mix-two`,title:`Daily Mix 02`,description:`Night Atlas, Static Garden, Elio Pines and more`,curator:`Spotify Atom`,trackIds:[`after-hours-drive`,`soft-static`,`city-rain`,`quiet-current`,`midnight-orchard`],palette:P.parallelStreets},{id:`daily-mix-three`,title:`Daily Mix 03`,description:`Arlo Vale, The Daylights, Mira Lane and more`,curator:`Spotify Atom`,trackIds:[`slow-motion`,`coffee-stains`,`velvet-morning`,`paper-moons`,`golden-lines`],palette:P.stillFrames},{id:`discover-weekly`,title:`Discover Weekly`,description:`A fresh collection picked for your week`,curator:`Spotify Atom`,trackIds:[`tides-in-reverse`,`signal-fires`,`open-windows`,`midnight-orchard`,`golden-lines`],palette:P.orbiting},{id:`coding-mode`,title:`Coding Mode`,description:`Steady electronic focus without the distractions`,curator:`Spotify Atom`,trackIds:[`soft-static`,`quiet-current`,`midnight-orchard`,`tides-in-reverse`,`city-rain`],palette:P.coding},{id:`night-drive`,title:`Night Drive`,description:`Glowing synths for roads after dark`,curator:`Spotify Atom`,trackIds:[`after-hours-drive`,`neon-skyline`,`city-rain`,`satellite-hearts`,`signal-fires`],palette:P.nightDrive},{id:`coffeehouse`,title:`Coffeehouse`,description:`Warm voices, soft strings, unhurried mornings`,curator:`Spotify Atom`,trackIds:[`coffee-stains`,`slow-motion`,`paper-moons`,`velvet-morning`,`golden-lines`],palette:P.coffeehouse},{id:`sunday-reset`,title:`Sunday Reset`,description:`Easy songs for a slower kind of day`,curator:`Spotify Atom`,trackIds:[`velvet-morning`,`open-windows`,`coffee-stains`,`quiet-current`,`paper-moons`],palette:P.sundayReset},{id:`neon-pulse`,title:`Neon Pulse`,description:`Electric color and late-night momentum`,curator:`Atom Editorial`,trackIds:[`neon-skyline`,`satellite-hearts`,`after-hours-drive`,`signal-fires`,`soft-static`],palette:P.neonPulse},{id:`soft-pop`,title:`Soft Pop`,description:`Bright hooks with all the edges smoothed out`,curator:`Atom Editorial`,trackIds:[`blue-hour`,`open-windows`,`slow-motion`,`satellite-hearts`,`golden-lines`],palette:P.softPop},{id:`acoustic-mornings`,title:`Acoustic Mornings`,description:`A gentle start in wood, wire, and sunlight`,curator:`Atom Editorial`,trackIds:[`velvet-morning`,`coffee-stains`,`paper-moons`,`golden-lines`,`tides-in-reverse`],palette:P.morningLight},{id:`deep-focus`,title:`Deep Focus`,description:`Ambient textures for long stretches of concentration`,curator:`Atom Editorial`,trackIds:[`quiet-current`,`soft-static`,`midnight-orchard`,`city-rain`,`tides-in-reverse`],palette:P.deepFocus},{id:`slow-sundays`,title:`Slow Sundays`,description:`Stay in, breathe out, let the afternoon drift`,curator:`For your mood`,trackIds:[`slow-motion`,`paper-moons`,`coffee-stains`,`quiet-current`,`velvet-morning`],palette:P.sundayReset},{id:`city-after-dark`,title:`City After Dark`,description:`Streetlights, reflections, and midnight motion`,curator:`For your mood`,trackIds:[`city-rain`,`after-hours-drive`,`neon-skyline`,`soft-static`,`signal-fires`],palette:P.nightDrive},{id:`morning-light`,title:`Morning Light`,description:`Optimistic songs for opening the curtains`,curator:`For your mood`,trackIds:[`velvet-morning`,`golden-lines`,`open-windows`,`blue-hour`,`coffee-stains`],palette:P.morningLight},{id:`headphones-on`,title:`Headphones On`,description:`Detailed production made for getting lost in`,curator:`For your mood`,trackIds:[`satellite-hearts`,`midnight-orchard`,`tides-in-reverse`,`blue-hour`,`soft-static`],palette:P.dreamingMono}],L=[{id:`made-for-you`,title:`Made for you`,description:`Personal mixes shaped around your listening`,playlistIds:[`daily-mix-one`,`daily-mix-two`,`daily-mix-three`,`discover-weekly`]},{id:`recently-played`,title:`Recently played`,playlistIds:[`coding-mode`,`night-drive`,`coffeehouse`,`sunday-reset`]},{id:`popular-playlists`,title:`Popular playlists`,playlistIds:[`neon-pulse`,`soft-pop`,`acoustic-mornings`,`deep-focus`]},{id:`mood-mixes`,title:`Mood mixes`,description:`Pick a soundtrack that meets you where you are`,playlistIds:[`slow-sundays`,`city-after-dark`,`morning-light`,`headphones-on`]}],R=[{id:`liked-songs`,title:`Liked Songs`,subtitle:`Playlist · 16 songs`,kind:`collection`,palette:P.liked,pinned:!0},{id:`library-coding-mode`,title:`Coding Mode`,subtitle:`Playlist · Spotify Atom`,kind:`playlist`,palette:P.coding,playlistId:`coding-mode`,pinned:!0},{id:`library-night-drive`,title:`Night Drive`,subtitle:`Playlist · Spotify Atom`,kind:`playlist`,palette:P.nightDrive,playlistId:`night-drive`},{id:`library-sunday-reset`,title:`Sunday Reset`,subtitle:`Playlist · Spotify Atom`,kind:`playlist`,palette:P.sundayReset,playlistId:`sunday-reset`},{id:`library-luma-coast`,title:`Luma Coast`,subtitle:`Artist`,kind:`artist`,palette:P.chromaticWeather},{id:`library-blue-hour`,title:`Northbound`,subtitle:`Album · Mira Lane`,kind:`album`,palette:P.blueHour},{id:`library-deep-focus`,title:`Deep Focus`,subtitle:`Playlist · Atom Editorial`,kind:`playlist`,palette:P.deepFocus,playlistId:`deep-focus`},{id:`library-nova-bloom`,title:`Nova Bloom`,subtitle:`Artist`,kind:`artist`,palette:P.orbiting}];function z(e){return e.kind===`track`?`track:${e.track.id}`:`playlist:${e.playlist.id}`}function B({activity:e,onClose:t,onSelectTrack:n,onSelectPlaylist:r}){let i=(0,D.useRef)(null),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(F),[l,d]=(0,D.useState)(I.map(e=>({...e,trackCount:e.totalTracks??e.trackIds.length}))),[f,h]=(0,D.useState)([]),[g,_]=(0,D.useState)(!0),[v,y]=(0,D.useState)(``),[b,x]=(0,D.useState)(null),S=a.trim().toLocaleLowerCase(),C=`activity-tracks-${e.sessionId}`,w=(0,D.useMemo)(()=>{let t=S?[...s.map(e=>({kind:`track`,track:e})),...l.map(e=>({kind:`playlist`,playlist:e}))]:f,n=new Set;return t.filter(t=>{if(t.kind===`track`&&t.track.id===e.titleId||S&&!(t.kind===`track`?[t.track.title,t.track.artist,t.track.album,t.track.provider]:[t.playlist.title,t.playlist.description,t.playlist.curator,t.playlist.provider]).filter(Boolean).some(e=>e?.toLocaleLowerCase().includes(S)))return!1;let r=z(t);return n.has(r)?!1:(n.add(r),!0)}).slice(0,S?void 0:10)},[e.titleId,S,l,f,s]),T=(0,D.useMemo)(()=>I.map(e=>({...e,trackCount:e.totalTracks??e.trackIds.length})),[]);(0,D.useEffect)(()=>{let e=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus(),()=>{e?.isConnected&&e.focus()}},[]),(0,D.useEffect)(()=>{let t=new AbortController,n=`profileId=${encodeURIComponent(e.profileId)}`;return Promise.all([fetch(`/api/spotify/recently-played?${n}`,{cache:`no-store`,signal:t.signal}),fetch(`/api/spotify/tracks?${n}`,{cache:`no-store`,signal:t.signal}),fetch(`/api/spotify/playlists?${n}`,{cache:`no-store`,signal:t.signal})]).then(async([e,t,n])=>{let r=await e.json(),i=await t.json(),a=await n.json();if(!e.ok||!t.ok||!n.ok)throw Error(r.error||i.error||a.error||`Recently played music could not be loaded.`);let o=Array.isArray(i.tracks)?i.tracks:[],s=new Set(o.map(e=>e.id));c([...o,...F.filter(e=>!s.has(e.id))]);let l=Array.isArray(a.playlists)?a.playlists.map(e=>({id:e.id,title:e.title,description:e.description,curator:e.curator,trackCount:e.totalTracks??e.trackIds?.length??0,imageUrl:e.imageUrl,palette:e.palette,provider:e.provider})):[],u=new Set(l.map(e=>e.id));d([...l,...T.filter(e=>!u.has(e.id))]),h(Array.isArray(r.items)?r.items.slice(0,10):[])}).catch(e=>{t.signal.aborted||y(e instanceof Error?e.message:`Recently played music could not be loaded.`)}).finally(()=>{t.signal.aborted||_(!1)}),()=>t.abort()},[e.profileId,T]);let E=async e=>{let i=z(e);x(i),y(``);try{e.kind===`track`?await n(e.track):await r(e.playlist),t()}catch(e){y(e instanceof Error?e.message:`The music could not be switched.`),x(null)}};return(0,O.createPortal)((0,k.jsx)(`div`,{className:`activity-movie-search-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&t()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),t())},children:(0,k.jsxs)(`div`,{className:`activity-movie-search activity-track-search`,id:C,role:`dialog`,"aria-label":`Search another track for ${e.title}`,children:[(0,k.jsxs)(`div`,{className:`activity-movie-search__header`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{children:`Switch music`}),(0,k.jsxs)(`span`,{className:`activity-movie-search__now`,children:[`Now playing: `,e.title]})]}),(0,k.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close track search`,children:(0,k.jsx)(p,{})})]}),(0,k.jsxs)(`div`,{className:`activity-movie-search__field`,children:[(0,k.jsx)(m,{"aria-hidden":`true`}),(0,k.jsx)(`input`,{ref:i,type:`search`,value:a,onChange:e=>o(e.currentTarget.value),placeholder:`Search songs, artists, albums, and playlists`,"aria-label":`Search another track for ${e.title}`,autoComplete:`off`}),a&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(``),i.current?.focus()},"aria-label":`Clear track search`,children:(0,k.jsx)(p,{})})]}),(0,k.jsx)(`div`,{className:`activity-movie-search__heading`,children:(0,k.jsx)(`strong`,{children:S?`Search results`:`Recently played`})}),(0,k.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:b?`Switching from ${e.title}…`:g?`Loading recently played music…`:`${w.length} ${S?`search`:`recent`} ${w.length===1?`result`:`results`}.`}),v&&(0,k.jsx)(`p`,{className:`activity-movie-search__notice`,role:`alert`,children:v}),g?(0,k.jsxs)(`div`,{className:`activity-movie-search__empty`,children:[(0,k.jsx)(u,{className:`spin`,"aria-hidden":`true`}),(0,k.jsx)(`span`,{children:`Loading recently played music…`})]}):w.length?(0,k.jsx)(`div`,{className:`activity-movie-search__results`,"aria-label":S?`Music search results`:`Recently played`,children:w.map(e=>{let t=z(e),n=e.kind===`track`?e.track:e.playlist;return(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void E(e),disabled:b!==null,"aria-label":e.kind===`track`?`Switch to ${e.track.title} by ${e.track.artist}`:`Switch to playlist ${e.playlist.title}`,children:[(0,k.jsxs)(`span`,{className:`activity-movie-search__art activity-track-search__art`,style:n.imageUrl?{backgroundImage:`url(${JSON.stringify(n.imageUrl)})`}:n.palette?{backgroundImage:`linear-gradient(135deg, ${n.palette.from}, ${n.palette.to})`,color:n.palette.accent}:void 0,children:[!n.imageUrl&&(0,k.jsx)(`span`,{"aria-hidden":`true`,children:n.palette?.glyph??(e.kind===`playlist`?`☷`:`♫`)}),b===t&&(0,k.jsx)(u,{className:`spin`,"aria-hidden":`true`})]}),(0,k.jsxs)(`span`,{className:`activity-movie-search__copy`,children:[(0,k.jsx)(`strong`,{children:n.title}),(0,k.jsx)(`small`,{children:e.kind===`track`?(0,k.jsxs)(k.Fragment,{children:[e.track.artist,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),e.track.album]}):(0,k.jsxs)(k.Fragment,{children:[`Playlist`,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),e.playlist.curator,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),e.playlist.trackCount,` `,e.playlist.trackCount===1?`song`:`songs`]})})]})]},t)})}):(0,k.jsxs)(`div`,{className:`activity-movie-search__empty`,children:[(0,k.jsx)(m,{"aria-hidden":`true`}),(0,k.jsx)(`span`,{children:S?`No music found for “${a.trim()}”.`:`No recently played songs or playlists yet.`})]})]})}),document.body)}export{v as _,I as a,A as c,w as d,C as f,y as g,b as h,L as i,E as l,x as m,P as n,F as o,S as p,R as r,N as s,B as t,T as u,_ as v};
|
package/dist/client/_next/static/chunks/{step-forward-CV8I5pPb.js → provider-registry-CWHfJn3B.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./chevron-left-Dn3noAqV.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),r=e(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),i=e(`list-video`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M10 12H3`,key:`1ulcyk`}],[`path`,{d:`M10 19H3`,key:`108z41`}],[`path`,{d:`M15 12.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z`,key:`ms4nik`}]]),a=e(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),o=e(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),s=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),c=e(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),l=e(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]);export{a,
|
|
1
|
+
import{n as e}from"./chevron-left-Dn3noAqV.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),r=e(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),i=e(`list-video`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M10 12H3`,key:`1ulcyk`}],[`path`,{d:`M10 19H3`,key:`108z41`}],[`path`,{d:`M15 12.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z`,key:`ms4nik`}]]),a=e(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),o=e(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),s=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),c=e(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),l=e(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),u=[{id:`phimhdcss`,name:`PhimHDC`,baseUrl:`https://phimhdcss.com/`,hosts:[`phimhdcss.com`,`www.phimhdcss.com`,`phimhdcss.net`,`www.phimhdcss.net`],accentColor:`#7a171d`},{id:`fsharetv`,name:`FshareTV`,baseUrl:`https://fsharetv.com/`,hosts:[`fsharetv.com`,`www.fsharetv.com`],accentColor:`#235b76`},{id:`hh3d`,name:`HH3D`,baseUrl:`https://hh3d.com/`,hosts:[`hh3d.com`,`www.hh3d.com`],accentColor:`#d97706`},{id:`hhpanda`,name:`HHPanda`,baseUrl:`https://hhpanda.st/`,hosts:[`hhpanda.st`,`www.hhpanda.st`],accentColor:`#e11d48`}];function d(e){return u.find(t=>t.id===e)}function f(e,t=`Netflix library`){return d(e)?.name??t}export{s as a,i as c,t as d,c as i,r as l,f as n,o,l as r,a as s,u as t,n as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n}from"./framework-BQUlGUOV.js";import{n as r,t as i}from"./chevron-left-Dn3noAqV.js";import{_ as a,a as o,c as s,f as c,g as l,i as u,n as d,o as f,p,r as ee,s as te,t as ne,u as m,v as re}from"./playback-activity-track-switcher-BzvHiv7c.js";import{a as h,c as ie,i as g,l as ae,n as _,o as v,r as oe,s as se,t as ce}from"./playback-activity-66FeikYZ.js";import{a as le,c as ue,d as y,g as de,h as fe,i as pe,l as me,m as b,n as he,o as ge,p as x,r as S,s as C,u as _e,v as ve}from"./manage-profiles-modal-CWi3qgd4.js";import{t as ye}from"./house-DQz6VeTk.js";var be=r(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),xe=r(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),w=r(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Se=r(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ce=r(`library`,[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]),we=r(`list-music`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M11 19H3`,key:`zflm78`}],[`path`,{d:`M21 16V5`,key:`yxg4q8`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),Te=r(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Ee=r(`monitor-speaker`,[[`path`,{d:`M5.5 20H8`,key:`1k40s5`}],[`path`,{d:`M17 9h.01`,key:`1j24nn`}],[`rect`,{width:`10`,height:`16`,x:`12`,y:`4`,rx:`2`,key:`ixliua`}],[`path`,{d:`M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4`,key:`1mp6e1`}],[`circle`,{cx:`17`,cy:`15`,r:`1`,key:`tqvash`}]]),De=r(`repeat-2`,[[`path`,{d:`m2 9 3-3 3 3`,key:`1ltn5i`}],[`path`,{d:`M13 18H7a2 2 0 0 1-2-2V6`,key:`1r6tfw`}],[`path`,{d:`m22 15-3 3-3-3`,key:`4rnwn2`}],[`path`,{d:`M11 6h6a2 2 0 0 1 2 2v10`,key:`2f72bc`}]]),T=r(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),E=e(n(),1),D=t();function O({palette:e,title:t,className:n=``,imageUrl:r,rounded:i=!1}){let a={"--cover-from":e.from,"--cover-to":e.to,"--cover-accent":e.accent,backgroundImage:r?`url(${JSON.stringify(r)})`:void 0};return(0,D.jsxs)(`div`,{"aria-label":`${t} cover`,className:`coverArt ${r?`coverArtHasImage`:``} ${i?`coverArtRound`:``} ${n}`,role:`img`,style:a,children:[(0,D.jsx)(`span`,{className:`coverOrb coverOrbOne`}),(0,D.jsx)(`span`,{className:`coverOrb coverOrbTwo`}),(0,D.jsx)(`span`,{className:`coverLine`}),(0,D.jsx)(`span`,{className:`coverGlyph`,"aria-hidden":`true`,children:e.glyph}),(0,D.jsx)(`span`,{className:`coverNoise`})]})}function Oe(e){return e.replace(/[<>&"']/g,e=>{switch(e){case`<`:return`<`;case`>`:return`>`;case`&`:return`&`;case`"`:return`"`;default:return`'`}})}function ke(e){if(e.imageUrl)return e.imageUrl;let t=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 540">`,`<defs>`,`<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">`,`<stop stop-color="${Oe(e.palette.from)}"/>`,`<stop offset="1" stop-color="${Oe(e.palette.to)}"/>`,`</linearGradient>`,`</defs>`,`<rect width="960" height="540" fill="url(#g)"/>`,`<circle cx="760" cy="95" r="250" fill="${Oe(e.palette.accent)}" opacity=".18"/>`,`<circle cx="190" cy="485" r="225" fill="#000" opacity=".2"/>`,`<text x="480" y="315" fill="${Oe(e.palette.accent)}" font-family="Arial,sans-serif" font-size="150" font-weight="700" text-anchor="middle">${Oe(e.palette.glyph)}</text>`,`</svg>`].join(``);return`data:image/svg+xml,${encodeURIComponent(t)}`}function Ae(e,t){return{service:`spotify`,sessionId:t.id,profileId:t.profileId,titleId:e.track.id,title:e.track.title||`Untitled track`,artist:e.track.artist||`Unknown artist`,album:e.track.album||`Unknown album`,provider:e.track.provider||`Spotify Atom`,artwork:ke(e.track),currentTime:Math.max(0,e.currentTime),duration:Math.max(0,e.duration),paused:!e.isPlaying,muted:e.volume<=0,volume:Math.max(0,Math.min(1,e.volume/100)),machineName:oe(),deviceType:g(),updatedAt:Date.now()}}function je(e){let t=(0,E.useRef)(e),n=(0,E.useRef)(null),r=(0,E.useMemo)(()=>e.active&&e.profileId?{id:_(),profileId:e.profileId}:null,[e.active,e.profileId]);(0,E.useEffect)(()=>{t.current=e},[e]),(0,E.useEffect)(()=>{if(!r)return;let e=!1,i=0,a=null,o=new Set,s=new AbortController,c=()=>{let n=t.current;if(e||!n.active||n.profileId!==r.profileId)return;let i=new AbortController;o.add(i),fetch(`/api/netflix/activity`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({activity:Ae(n,r)}),cache:`no-store`,signal:i.signal}).catch(()=>{}).finally(()=>{o.delete(i)})};n.current=c;let l=e=>{let n=t.current;switch(e.type){case`set-paused`:n.onSetPaused(e.paused);break;case`seek-relative`:n.onSeek(n.currentTime+e.seconds);break;case`seek-to`:n.onSeek(e.seconds);break;case`set-muted`:n.onSetMuted(e.muted);break;case`set-volume`:n.onSetVolume(e.volume);break;case`previous-track`:n.onPrevious();break;case`next-track`:n.onNext();break;case`switch-track`:n.onSelectTrack(e.trackId);break;case`switch-playlist`:n.onSelectPlaylist(e.playlistId);break;case`next-episode`:case`select-episode`:case`switch-title`:case`set-captions`:case`set-subtitle-font-size`:case`set-subtitle-font-color`:case`set-subtitle-background`:case`reset-subtitle-position`:break}window.requestAnimationFrame(c)},u=async()=>{if(!(e||s.signal.aborted)){try{let e=await fetch(`/api/netflix/activity/${encodeURIComponent(r.id)}/commands?after=${encodeURIComponent(i)}&profileId=${encodeURIComponent(r.profileId)}`,{cache:`no-store`,signal:s.signal});if(e.ok){let t=await e.json();if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,n=Array.isArray(e.commands)?e.commands:[];for(let e of n){if(typeof e!=`object`||!e||Array.isArray(e))continue;let t=e;if(typeof t.id!=`number`||!Number.isSafeInteger(t.id)||t.id<=i||t.sessionId!==r.id)continue;let n={kind:`command`,sessionId:r.id,command:t.command};!h(n)||n.kind!==`command`||(l(n.command),i=t.id)}typeof e.cursor==`number`&&Number.isSafeInteger(e.cursor)&&e.cursor>=i&&(i=e.cursor)}}}catch{}!e&&!s.signal.aborted&&(a=window.setTimeout(()=>void u(),Math.min(500,ce)))}},d=()=>{if(!e){e=!0,s.abort();for(let e of o)e.abort();o.clear(),fetch(`/api/netflix/activity`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:r.id,profileId:r.profileId}),cache:`no-store`,keepalive:!0}).catch(()=>{})}};window.addEventListener(`pagehide`,d),c();let f=window.setInterval(c,ce);return u(),()=>{window.clearInterval(f),a!==null&&window.clearTimeout(a),window.removeEventListener(`pagehide`,d),n.current===c&&(n.current=null),d()}},[r]),(0,E.useEffect)(()=>{n.current?.()},[e.track.id,e.currentTime,e.duration,e.isPlaying,e.volume])}function Me(e){return e.kind===`track`?`track:${e.track.id}`:`playlist:${e.playlist.id}`}var Ne=[{id:`zing-mp3`,name:`Zing MP3`,homeUrl:`https://zingmp3.vn/`,lastSyncedAt:null,itemCount:0,syncStatus:`idle`,error:null},{id:`tiktok`,name:`TikTok`,homeUrl:`https://www.tiktok.com/`,lastSyncedAt:null,itemCount:0,syncStatus:`idle`,error:null},{id:`youtube`,name:`YouTube`,homeUrl:`https://www.youtube.com/`,lastSyncedAt:null,itemCount:0,syncStatus:`idle`,error:null},{id:`nhac-cua-tui`,name:`NhacCuaTui`,homeUrl:`https://www.nhaccuatui.com/`,lastSyncedAt:null,itemCount:0,syncStatus:`idle`,error:null}];async function k(e,t){let n=t?.method?.toUpperCase()??`GET`,r=await fetch(e,{cache:`no-store`,...t,headers:{Accept:`application/json`,...n!==`GET`&&n!==`HEAD`?{"X-Spotify-Atom-Request":`1`}:{},...t?.headers}}),i=await r.json().catch(()=>null);if(!r.ok){let e=i?.error||i?.message||`Request failed with status ${r.status}`;throw Error(e)}if(!i)throw Error(`The server returned an empty response.`);return i}function A(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}profileId=${encodeURIComponent(t)}`:e}function Pe(e){let t=e.provider.toLowerCase(),n=d.chromaticWeather;return t.includes(`zing`)?n=d.neonPulse:t.includes(`tiktok`)?n=d.parallelStreets:t.includes(`youtube`)?n=d.stillFrames:t.includes(`nhac`)&&(n=d.blueHour),{...e,durationSec:Number.isFinite(e.durationSec)?e.durationSec:0,imageUrl:e.imageUrl??void 0,palette:n}}function Fe(e){let t=e.totalTracks>0&&e.availableTracks>=e.totalTracks;return{id:e.id,title:e.title,description:t?e.description:`${e.availableTracks} of ${e.totalTracks} songs ready`,curator:e.curator,trackIds:e.trackIds,palette:d.stillFrames,imageUrl:e.imageUrl??void 0,provider:e.provider,sourceUrl:e.sourceUrl,totalTracks:e.totalTracks,availableTracks:e.availableTracks}}function Ie(e){if(e===null||!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r>=10||n===0?r.toFixed(0):r.toFixed(1)} ${t[n]}`}function Le(e){if(e.status===`completed`)return 100;let t=e.totalBytes!==null&&e.totalBytes>0?e.bytesDownloaded/e.totalBytes*100:0;return Math.round(Math.min(100,Math.max(0,Math.max(e.progress||0,t))))}function Re(e){switch(e){case`queued`:return`Queued`;case`fetching`:return`Fetching details`;case`downloading`:return`Downloading`;case`completed`:return`Ready to play`;case`failed`:return`Download failed`}}function ze(e){if(!e)return`Not synced yet`;let t=new Date(e);return Number.isNaN(t.getTime())?`Previously synced`:`Synced ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}`}function Be(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function Ve(e){let t=Number.isFinite(e)?Math.max(0,e):0;return`${Math.floor(t/60)}:${Math.floor(t%60).toString().padStart(2,`0`)}`}function He(){return(0,D.jsxs)(`span`,{className:`spotifyMark`,"aria-hidden":`true`,children:[(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{})]})}function j({autoFocus:e=!1,buttonRef:t,label:n,children:r,className:i=``,pressed:a,expanded:o,controls:s,hasPopup:c,onClick:l}){return(0,D.jsx)(`button`,{"aria-controls":s,"aria-expanded":o,"aria-haspopup":c,"aria-label":n,"aria-pressed":a,autoFocus:e,className:`iconButton ${a?`isActive`:``} ${i}`,onClick:l,ref:t,title:n,type:`button`,children:r})}function M({playing:e,label:t,size:n=`normal`,onClick:r}){return(0,D.jsx)(`button`,{"aria-label":t,className:`playButton playButton-${n}`,onClick:r,type:`button`,children:e?(0,D.jsx)(x,{fill:`currentColor`}):(0,D.jsx)(y,{fill:`currentColor`})})}function Ue({item:e,active:t,onSelect:n}){return(0,D.jsxs)(`button`,{className:`libraryRow ${t?`libraryRowActive`:``}`,onClick:n,type:`button`,children:[(0,D.jsx)(O,{className:`libraryCover`,imageUrl:e.imageUrl,palette:e.palette,rounded:e.kind===`artist`,title:e.title}),(0,D.jsxs)(`span`,{className:`libraryRowText`,children:[(0,D.jsx)(`span`,{className:`libraryRowTitle`,children:e.title}),(0,D.jsxs)(`span`,{className:`libraryRowMeta`,children:[e.pinned?(0,D.jsx)(p,{"aria-hidden":`true`,fill:`currentColor`,size:12}):null,e.subtitle]})]}),(0,D.jsx)(Se,{"aria-hidden":`true`,className:`libraryRowMore`,size:19})]})}function We({playlist:e,active:t,playing:n,onPlay:r}){return(0,D.jsxs)(`article`,{className:`playlistCard ${t?`playlistCardActive`:``}`,children:[(0,D.jsxs)(`div`,{className:`playlistCardArt`,children:[(0,D.jsx)(O,{imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsx)(M,{label:`${n&&t?`Pause`:`Play`} ${e.title}`,onClick:e=>{e.stopPropagation(),r()},playing:n&&t}),t&&n?(0,D.jsxs)(`span`,{className:`playingBadge`,children:[(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{})]}):null]}),(0,D.jsxs)(`button`,{className:`cardCopy`,onClick:r,type:`button`,children:[(0,D.jsx)(`span`,{className:`playlistCardTitle`,children:e.title}),(0,D.jsx)(`span`,{className:`playlistCardDescription`,children:e.description})]})]})}function Ge({track:e,active:t,playing:n,liked:r,onSelect:i,onLike:a}){return(0,D.jsxs)(`div`,{className:`trackResult ${t?`trackResultActive`:``}`,children:[(0,D.jsxs)(`button`,{"aria-label":`${n&&t?`Pause`:`Play`} ${e.title}`,className:`trackResultMain`,onClick:i,type:`button`,children:[(0,D.jsxs)(`span`,{className:`trackResultArtWrap`,children:[(0,D.jsx)(O,{className:`trackResultArt`,imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsx)(`span`,{className:`trackResultPlay`,children:n&&t?(0,D.jsx)(x,{fill:`currentColor`,size:18}):(0,D.jsx)(y,{fill:`currentColor`,size:18})})]}),(0,D.jsxs)(`span`,{className:`trackResultCopy`,children:[(0,D.jsx)(`span`,{className:`trackResultTitle`,children:e.title}),(0,D.jsx)(`span`,{children:e.artist})]})]}),(0,D.jsx)(`span`,{className:`trackResultAlbum`,children:e.album}),(0,D.jsx)(j,{className:`trackResultLike`,label:`${r?`Remove`:`Add`} ${e.title} ${r?`from`:`to`} Liked Songs`,onClick:a,pressed:r,children:(0,D.jsx)(l,{fill:r?`currentColor`:`none`,size:18})}),(0,D.jsx)(`span`,{className:`trackResultDuration`,children:Ve(e.durationSec)}),(0,D.jsx)(j,{label:`More options for ${e.title}`,children:(0,D.jsx)(Se,{size:19})})]})}function Ke({providers:e,syncingProviderIds:t,providerError:n,musicUrl:r,addMusicError:i,addingMusic:o,onClose:s,onMusicUrlChange:c,onAddMusic:l,onSync:u}){return(0,D.jsxs)(`div`,{"aria-label":`Music sources`,className:`headerPopover sourcePopover`,id:`source-popover`,role:`dialog`,children:[(0,D.jsxs)(`div`,{className:`popoverHeader`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`popoverEyebrow`,children:`YOUR MUSIC`}),(0,D.jsx)(`h2`,{children:`Sources`})]}),(0,D.jsx)(j,{label:`Close music sources`,onClick:s,children:(0,D.jsx)(S,{size:18})})]}),n?(0,D.jsxs)(`div`,{className:`popoverError`,role:`alert`,children:[(0,D.jsx)(a,{size:16}),(0,D.jsx)(`span`,{children:n})]}):null,(0,D.jsx)(`div`,{className:`providerList`,children:e.map(e=>{let n=t.has(e.id)||e.syncStatus.toLowerCase()===`syncing`;return(0,D.jsxs)(`article`,{className:`providerRow`,children:[(0,D.jsx)(`span`,{className:`providerMark providerMark--${e.id}`,"aria-hidden":`true`,children:e.name.slice(0,1).toUpperCase()}),(0,D.jsxs)(`div`,{className:`providerCopy`,children:[(0,D.jsxs)(`a`,{href:e.homeUrl,rel:`noreferrer`,target:`_blank`,children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsx)(fe,{size:13})]}),(0,D.jsxs)(`span`,{children:[ze(e.lastSyncedAt),` · `,e.itemCount,` `,e.itemCount===1?`item`:`items`]}),e.error?(0,D.jsx)(`span`,{className:`providerError`,children:e.error}):null]}),(0,D.jsxs)(`button`,{"aria-label":`Sync ${e.name}`,className:`syncProviderButton`,disabled:n,onClick:()=>u(e),type:`button`,children:[n?(0,D.jsx)(b,{"aria-hidden":`true`,className:`spin`,size:17}):(0,D.jsx)(ue,{"aria-hidden":`true`,size:17}),(0,D.jsx)(`span`,{children:n?`Syncing`:`Sync`})]})]},e.id)})}),(0,D.jsxs)(`form`,{className:`addMusicForm`,onSubmit:l,children:[(0,D.jsxs)(`div`,{className:`addMusicHeading`,children:[(0,D.jsx)(`span`,{className:`addMusicIcon`,children:(0,D.jsx)(v,{size:17})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:`Add music`}),(0,D.jsx)(`span`,{children:`Paste a song or YouTube playlist link.`})]})]}),(0,D.jsx)(`label`,{htmlFor:`music-source-url`,children:`Music link`}),(0,D.jsxs)(`div`,{className:`musicUrlControl`,children:[(0,D.jsx)(`input`,{autoComplete:`url`,id:`music-source-url`,onChange:e=>c(e.target.value),placeholder:`Paste a Zing MP3, TikTok, YouTube, or NCT link`,required:!0,type:`url`,value:r}),(0,D.jsxs)(`button`,{disabled:o||!r.trim(),type:`submit`,children:[o?(0,D.jsx)(b,{"aria-hidden":`true`,className:`spin`,size:17}):(0,D.jsx)(_e,{"aria-hidden":`true`,size:17}),(0,D.jsx)(`span`,{children:o?`Adding`:`Add`})]})]}),i?(0,D.jsx)(`span`,{className:`fieldError`,role:`alert`,children:i}):null]})]})}function qe({downloads:e,error:t,currentTrackId:n,isPlaying:r,onClose:i,onPlay:o}){let s=e.filter(e=>e.status!==`completed`&&e.status!==`failed`).length;return(0,D.jsxs)(`div`,{"aria-label":`Music downloads`,className:`headerPopover downloadsPopover`,id:`downloads-popover`,role:`dialog`,children:[(0,D.jsxs)(`div`,{className:`popoverHeader`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`popoverEyebrow`,children:`OFFLINE MUSIC`}),(0,D.jsx)(`h2`,{children:`Downloads`})]}),(0,D.jsxs)(`div`,{className:`downloadHeaderActions`,children:[s?(0,D.jsxs)(`span`,{className:`activeDownloadCount`,children:[(0,D.jsx)(b,{"aria-hidden":`true`,className:`spin`,size:13}),s,` active`]}):null,(0,D.jsx)(j,{label:`Close downloads`,onClick:i,children:(0,D.jsx)(S,{size:18})})]})]}),t?(0,D.jsxs)(`div`,{className:`popoverError`,role:`alert`,children:[(0,D.jsx)(a,{size:16}),(0,D.jsx)(`span`,{children:t})]}):null,(0,D.jsx)(`div`,{"aria-live":`polite`,className:`downloadList`,children:e.length?e.map(e=>{let t=e.track?Pe(e.track):null,i=e.status===`completed`&&!!t?.audioUrl&&!!e.track,s=t?.id===n,c=Le(e),l=Ie(e.bytesDownloaded),u=Ie(e.totalBytes);return(0,D.jsxs)(`article`,{className:`downloadRow ${e.status===`failed`?`downloadRowFailed`:``}`,children:[(0,D.jsxs)(`button`,{"aria-label":i?`${s&&r?`Pause`:`Play`} ${t?.title}`:`Music is not ready to play`,className:`downloadArtworkButton ${i?`downloadArtworkPlayable`:``} ${s?`downloadArtworkActive`:``}`,disabled:!i,onClick:()=>e.track&&o(e.track),type:`button`,children:[(0,D.jsx)(O,{className:`downloadArtwork`,imageUrl:t?.imageUrl,palette:t?.palette??d.deepFocus,title:t?.title??`Preparing music`}),(0,D.jsx)(`span`,{className:`downloadPlayOverlay`,"aria-hidden":`true`,children:s&&r?(0,D.jsx)(x,{fill:`currentColor`,size:20}):i?(0,D.jsx)(y,{fill:`currentColor`,size:20}):e.status===`failed`?(0,D.jsx)(a,{size:18}):(0,D.jsx)(b,{className:`spin`,size:18})})]}),(0,D.jsxs)(`div`,{className:`downloadCopy`,children:[(0,D.jsxs)(`div`,{className:`downloadTitleRow`,children:[(0,D.jsx)(`strong`,{children:t?.title??Be(e.sourceUrl)}),e.status===`completed`?(0,D.jsx)(be,{"aria-label":`Download complete`,className:`downloadCompleteIcon`,size:16}):null]}),(0,D.jsx)(`span`,{children:t?.artist??(e.status===`fetching`?`Reading song information`:Re(e.status))}),(0,D.jsxs)(`div`,{className:`downloadProgressMeta`,children:[(0,D.jsx)(`span`,{children:Re(e.status)}),(0,D.jsxs)(`span`,{children:[l,l&&u?` / ${u}`:``,!l&&e.status!==`failed`?`${c}%`:``]})]}),(0,D.jsx)(`span`,{"aria-label":`${c}% downloaded`,className:`downloadProgressTrack`,role:`progressbar`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":c,children:(0,D.jsx)(`span`,{style:{width:`${c}%`}})}),e.error?(0,D.jsx)(`span`,{className:`downloadError`,children:e.error}):null]})]},e.id)}):(0,D.jsxs)(`div`,{className:`emptyDownloads`,children:[(0,D.jsx)(`span`,{children:(0,D.jsx)(se,{size:23})}),(0,D.jsx)(`strong`,{children:`No downloads yet`}),(0,D.jsx)(`p`,{children:`Add a song or playlist from Sources and its progress will appear here.`})]})})]})}function Je({initialProfiles:e=[],initialActiveProfile:t=null}){let[n,r]=(0,E.useState)(`home`),[a,c]=(0,E.useState)(f[0].id),[u,d]=(0,E.useState)(o[0].id),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(0),[_,v]=(0,E.useState)(74),[oe,ce]=(0,E.useState)(74),[le,ue]=(0,E.useState)(!1),[fe,pe]=(0,E.useState)(!1),[b,ge]=(0,E.useState)(``),[be,xe]=(0,E.useState)(``),[w,Se]=(0,E.useState)(`all`),[Ee,De]=(0,E.useState)(!0),[T,Oe]=(0,E.useState)(()=>new Set([`neon-skyline`,`blue-hour`,`satellite-hearts`])),[Ae,Ie]=(0,E.useState)([]),[Le,Re]=(0,E.useState)([]),[ze,Be]=(0,E.useState)([]),[Ve,M]=(0,E.useState)(Ne),[We,Ge]=(0,E.useState)([]),[Je,Ze]=(0,E.useState)(``),[tt,nt]=(0,E.useState)(``),[N,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(!1),[rt,L]=(0,E.useState)(!1),[R,it]=(0,E.useState)(!1),[at,ot]=(0,E.useState)(!1),[st,ct]=(0,E.useState)(``),[lt,ut]=(0,E.useState)(e),[z,dt]=(0,E.useState)(t),[ft,pt]=(0,E.useState)(!1),[mt,ht]=(0,E.useState)(``),[gt,_t]=(0,E.useState)(``),[vt,yt]=(0,E.useState)(!1),[bt,xt]=(0,E.useState)(()=>new Set),[St,Ct]=(0,E.useState)(null),wt=(0,E.useRef)(null),Tt=(0,E.useRef)(null),Et=(0,E.useRef)(null),Dt=(0,E.useRef)(null),Ot=(0,E.useRef)(null),B=(0,E.useRef)(h),kt=(0,E.useRef)(null),At=(0,E.useRef)(null),jt=(0,E.useRef)(``),Mt=(0,E.useRef)(0),Nt=(0,E.useRef)(!1),V=(0,E.useRef)(t?.id??null),H=(0,E.useMemo)(()=>{let e=new Set(Ae.map(e=>e.id));return[...Ae,...f.filter(t=>!e.has(t.id))]},[Ae]),U=(0,E.useMemo)(()=>{let e=new Set(Le.map(e=>e.id));return[...Le,...o.filter(t=>!e.has(t.id))]},[Le]),W=H.find(e=>e.id===a)??f[0],Pt=U.find(e=>e.id===u)??o[0],G=(0,E.useMemo)(()=>{let e=Pt.trackIds.map(e=>H.find(t=>t.id===e)).filter(e=>!!e);return e.length?e:H},[H,Pt.trackIds]),Ft=(0,E.useMemo)(()=>{let e=G.findIndex(e=>e.id===W.id);return e<0?G:[...G.slice(e+1),...G.slice(0,e)]},[W.id,G]),K=St?.trackId===W.id&&St.duration>0?St.duration:W.durationSec,It=We.filter(e=>e.status!==`completed`&&e.status!==`failed`).length,q=(0,E.useCallback)(e=>{ct(e),At.current&&clearTimeout(At.current),At.current=setTimeout(()=>ct(``),2400)},[]),Lt=(0,E.useCallback)(()=>{L(!1),window.requestAnimationFrame(()=>Et.current?.focus())},[]),Rt=(0,E.useCallback)(()=>{ot(!1),it(!1),window.requestAnimationFrame(()=>Dt.current?.focus())},[]),J=(0,E.useCallback)(e=>{let t=V.current;if(!t)return;let n=Date.now(),r=Me(e);Be(t=>[{...e,playedAt:n},...t.filter(e=>Me(e)!==r)].slice(0,10)),k(A(`/api/spotify/recently-played`,t),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({item:e,profileId:t})}).catch(()=>{})},[]),zt=(0,E.useCallback)(e=>{if(V.current===e)return;V.current=e;let t=Tt.current;t&&(t.pause(),t.removeAttribute(`src`),delete t.dataset.trackId,t.load()),jt.current=``,m(!1),pt(!1),it(!1),ot(!1),g(0),B.current=0,Ct(null),c(f[0].id),d(o[0].id),Ie([]),Re([]),Be([]),M(Ne),Ge([]),Ze(``),nt(``),xt(new Set),yt(!1),_t(``)},[]),Bt=(0,E.useCallback)(async e=>{let t=Mt.current;try{let n=await k(`/api/netflix/profiles`,{signal:e});if(Nt.current||t!==Mt.current)return;let r=Array.isArray(n.profiles)?n.profiles:[],i=n.activeProfile&&r.some(e=>e.id===n.activeProfile?.id)?n.activeProfile:r[0]??null;zt(i?.id??null),ut(r),dt(i)}catch{}},[zt]),Vt=(0,E.useCallback)(async e=>{Nt.current=!0,Mt.current+=1;try{let t=await k(`/api/netflix/profiles/${encodeURIComponent(e.id)}/select`,{method:`POST`});Mt.current+=1;let n=t.activeProfile??e;zt(n.id),dt(n)}finally{Nt.current=!1}},[zt]),Ht=(0,E.useCallback)(async(e,t)=>{Mt.current+=1,zt(t.id),ut(e),dt(t)},[zt]),Ut=(0,E.useCallback)(async e=>{let t=e??null;try{let n=await k(A(`/api/spotify/providers`,e));if(V.current!==t)return;M(n.providers.length?n.providers:Ne),Ze(``)}catch(e){if(V.current!==t)return;Ze(e instanceof Error?e.message:`Could not load music sources.`)}},[]),Wt=(0,E.useCallback)(async e=>{let t=e??null;try{let n=await k(A(`/api/spotify/downloads`,e));if(V.current!==t)return;Ge([...n.downloads].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())),nt(``)}catch(e){if(V.current!==t)return;nt(e instanceof Error?e.message:`Could not load downloads.`)}},[]),Gt=(0,E.useCallback)(async e=>{let t=e??null;try{let n=await k(A(`/api/spotify/tracks`,e));if(V.current!==t)return;Ie(n.tracks.map(Pe))}catch{}},[]),Kt=(0,E.useCallback)(async e=>{let t=e??null;try{let n=await k(A(`/api/spotify/playlists`,e));if(V.current!==t)return;Re(n.playlists.map(Fe))}catch{}},[]),qt=(0,E.useCallback)(async e=>{let t=e??null;try{let n=await k(A(`/api/spotify/recently-played`,e));if(V.current!==t)return;Be(Array.isArray(n.items)?n.items.slice(0,10):[])}catch{}},[]);(0,E.useEffect)(()=>{let e=z?.id,t=window.setTimeout(()=>{Ut(e),Wt(e),Gt(e),Kt(e),qt(e)},0),n=window.setInterval(()=>{Wt(e)},1600),r=window.setInterval(()=>{Gt(e),Kt(e),qt(e)},3e3),i=window.setInterval(()=>{Ut(e)},6e3);return()=>{window.clearTimeout(t),window.clearInterval(n),window.clearInterval(r),window.clearInterval(i)}},[z?.id,Wt,Ut,qt,Kt,Gt]),(0,E.useEffect)(()=>{let n=new AbortController,r=()=>void Bt(n.signal),i=()=>{document.visibilityState===`visible`&&r()},a=window.setInterval(r,3e3);if(window.addEventListener(`focus`,r),document.addEventListener(`visibilitychange`,i),!e.length||!t){let e=window.requestAnimationFrame(r);return()=>{n.abort(),window.cancelAnimationFrame(e),window.clearInterval(a),window.removeEventListener(`focus`,r),document.removeEventListener(`visibilitychange`,i)}}return()=>{n.abort(),window.clearInterval(a),window.removeEventListener(`focus`,r),document.removeEventListener(`visibilitychange`,i)}},[t,e.length,Bt]);let Y=(0,E.useCallback)((e,t)=>{let n=Tt.current;if(!(!n||!e.audioUrl)){if((n.dataset.trackId!==e.id||n.getAttribute(`src`)!==e.audioUrl)&&(n.src=e.audioUrl,n.dataset.trackId=e.id,jt.current=``,n.load()),!t){n.pause();return}n.play().catch(()=>{m(!1),q(`This downloaded track could not be played.`)})}},[q]),Jt=(0,E.useCallback)((e,t=!0)=>{if(e.id===a&&t){let t=!p;m(t),t&&(pt(!0),J({kind:`track`,track:e})),Y(e,t);return}c(e.id),B.current=0,g(0),m(t),t&&(pt(!0),J({kind:`track`,track:e})),Y(e,t)},[a,p,J,Y]),Yt=(0,E.useCallback)(e=>{let t=H.find(t=>t.id===e.trackIds[0]);if(!t){q(`${e.title} has no playable songs yet`);return}let n=e.id===u,r=e.trackIds.includes(a),i=!(n&&r&&p);pt(!0),d(e.id),i&&J({kind:`playlist`,playlist:{id:e.id,title:e.title,description:e.description,curator:e.curator,trackCount:e.totalTracks??e.trackIds.length,imageUrl:e.imageUrl,palette:e.palette,provider:e.provider}}),n&&r?m(e=>!e):(c(t.id),B.current=0,g(0),m(!0))},[H,u,a,p,J,q]),X=(0,E.useCallback)(()=>{G.length&&(c(e=>{let t=G.findIndex(t=>t.id===e),n=t>=0?(t+1)%G.length:0;if(le&&G.length>1)do n=Math.floor(Math.random()*G.length);while(n===t);return G[n]?.id??e}),B.current=0,g(0))},[G,le]),Z=(0,E.useCallback)(e=>{let t=Math.max(0,Math.min(e,K||e));B.current=t,g(t);let n=Tt.current;W.audioUrl&&n?.dataset.trackId===W.id&&(n.currentTime=t)},[W.audioUrl,W.id,K]),Xt=(0,E.useCallback)(()=>{if(B.current>4){Z(0);return}G.length&&(c(e=>{let t=G.findIndex(t=>t.id===e),n=(Math.max(0,t)-1+G.length)%G.length;return G[n]?.id??e}),B.current=0,g(0))},[Z,G]);(0,E.useEffect)(()=>{if(!p||W.audioUrl)return;let e=window.setInterval(()=>{g(e=>{if(e+1>=W.durationSec)return B.current=W.durationSec,window.setTimeout(()=>{fe?(B.current=0,g(0)):X()},0),W.durationSec;let t=e+1;return B.current=t,t})},1e3);return()=>window.clearInterval(e)},[W.audioUrl,W.durationSec,X,p,fe]),(0,E.useEffect)(()=>{let e=Tt.current;e&&(e.volume=_/100)},[_]),(0,E.useEffect)(()=>{let e=Tt.current;if(e){if(!W.audioUrl){e.dataset.trackId&&(e.pause(),e.removeAttribute(`src`),delete e.dataset.trackId,e.load());return}(e.dataset.trackId!==W.id||e.getAttribute(`src`)!==W.audioUrl)&&(e.src=W.audioUrl,e.dataset.trackId=W.id,jt.current=``,e.load()),p&&e.paused?e.play().catch(()=>{m(!1),q(`This downloaded track could not be played.`)}):!p&&!e.paused&&e.pause()}},[W.audioUrl,W.id,p,q]);let Zt=(0,E.useCallback)(()=>{let e=!p;m(e),e&&pt(!0),Y(W,e)},[W,p,Y]),Qt=(0,E.useCallback)(e=>{m(!e),Y(W,!e)},[W,Y]),$t=(0,E.useCallback)(e=>{v(t=>e?(t>0&&ce(t),0):t>0?t:oe||74)},[oe]),en=(0,E.useCallback)(e=>{let t=Math.max(0,Math.min(100,Math.round(e*100)));v(t),t>0&&ce(t)},[]),tn=(0,E.useCallback)(e=>{let t=H.find(t=>t.id===e);t&&(c(t.id),B.current=0,g(0),m(!0),pt(!0),J({kind:`track`,track:t}),Y(t,!0))},[H,J,Y]),nn=(0,E.useCallback)(e=>{let t=U.find(t=>t.id===e);t&&Yt(t)},[U,Yt]);je({active:ft,profileId:z?.id??``,track:W,currentTime:h,duration:K,isPlaying:p,volume:_,onSetPaused:Qt,onSeek:Z,onSetMuted:$t,onSetVolume:en,onPrevious:Xt,onNext:X,onSelectTrack:tn,onSelectPlaylist:nn});let rn=(0,E.useCallback)(e=>{switch(e.type){case`set-paused`:Qt(e.paused);break;case`seek-relative`:Z(B.current+e.seconds);break;case`seek-to`:Z(e.seconds);break;case`set-muted`:$t(e.muted);break;case`set-volume`:en(e.volume);break;case`previous-track`:Xt();break;case`next-track`:X();break;case`switch-track`:tn(e.trackId);break;case`switch-playlist`:nn(e.playlistId);break;case`next-episode`:case`select-episode`:case`switch-title`:case`set-captions`:case`set-subtitle-font-size`:case`set-subtitle-font-color`:case`set-subtitle-background`:case`reset-subtitle-position`:break}},[X,Xt,Z,nn,tn,$t,Qt,en]);(0,E.useEffect)(()=>{let e=e=>{let t=e.target,n=t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`)e.preventDefault(),r(`search`),window.requestAnimationFrame(()=>wt.current?.focus());else if(e.key===`Escape`){if(R){Rt();return}let e=N||F||rt;P(!1),I(!1),rt?Lt():L(!1),!e&&b&&ge(``)}else e.code===`Space`&&!n&&(e.preventDefault(),Zt())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Lt,Rt,F,R,b,rt,N,Zt]),(0,E.useEffect)(()=>{if(!R)return;let e=window.requestAnimationFrame(()=>Ot.current?.focus());return()=>window.cancelAnimationFrame(e)},[R]),(0,E.useEffect)(()=>{if(!N&&!F)return;let e=e=>{e.target instanceof Node&&!kt.current?.contains(e.target)&&(P(!1),I(!1))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[F,N]),(0,E.useEffect)(()=>()=>{At.current&&clearTimeout(At.current)},[]);let an=(0,E.useMemo)(()=>{let e=Le.map(e=>{let t=e.totalTracks??e.trackIds.length,n=e.availableTracks??e.trackIds.length;return{id:`library-${e.id}`,title:e.title,subtitle:n>=t?`Playlist · ${t} ${t===1?`song`:`songs`}`:`Playlist · ${n} of ${t} ready`,kind:`playlist`,palette:e.palette,imageUrl:e.imageUrl,playlistId:e.id}});return[ee[0],...e,...ee.slice(1)]},[Le]),on=(0,E.useMemo)(()=>{let e=be.trim().toLowerCase(),t=an.filter(t=>{let n=w===`all`||t.kind===w||w===`playlist`&&t.kind===`collection`,r=!e||`${t.title} ${t.subtitle}`.toLowerCase().includes(e);return n&&r});return Ee?t:[...t].reverse()},[an,w,Ee,be]),Q=b.trim().toLowerCase(),sn=(0,E.useMemo)(()=>Q?H.filter(e=>`${e.title} ${e.artist} ${e.album}`.toLowerCase().includes(Q)):[],[H,Q]),cn=(0,E.useMemo)(()=>Q?U.filter(e=>`${e.title} ${e.description}`.toLowerCase().includes(Q)):[],[U,Q]),ln=(0,E.useMemo)(()=>ze.map(e=>{if(e.kind===`track`){let t=H.find(t=>t.id===e.track.id);return t?{kind:`track`,track:t}:null}let t=U.find(t=>t.id===e.playlist.id);return t?{kind:`playlist`,playlist:t}:null}).filter(e=>e!==null).slice(0,10),[U,H,ze]),un=e=>{Oe(t=>{let n=new Set(t),r=H.find(t=>t.id===e);return n.has(e)?(n.delete(e),q(`Removed ${r?.title??`track`} from Liked Songs`)):(n.add(e),q(`Added ${r?.title??`track`} to Liked Songs`)),n})},dn=e=>{if(e.playlistId){let t=U.find(t=>t.id===e.playlistId);if(t){Yt(t),q(`Playing ${t.title}`);return}}if(e.id===`liked-songs`){Jt(H.find(e=>T.has(e.id))??f[0]),q(`Playing Liked Songs`);return}let t=H.find(t=>`${t.artist} ${t.album}`.includes(e.title));t&&(Jt(t),q(`Playing ${e.title}`))},fn=async e=>{let t=z?.id??null;xt(t=>new Set(t).add(e.id)),M(t=>t.map(t=>t.id===e.id?{...t,syncStatus:`syncing`,error:null}:t));try{let n=await k(A(`/api/spotify/providers/${encodeURIComponent(e.id)}/sync`,t),{method:`POST`});if(V.current!==t)return;M(t=>t.map(t=>t.id===e.id?n.provider:t)),Ze(``),q(`${e.name} is synced`),Gt(t)}catch(n){if(V.current!==t)return;let r=n instanceof Error?n.message:`Could not sync ${e.name}.`;M(t=>t.map(t=>t.id===e.id?{...t,syncStatus:`failed`,error:r}:t)),q(`Could not sync ${e.name}`)}finally{V.current===t&&xt(t=>{let n=new Set(t);return n.delete(e.id),n})}},pn=async e=>{e.preventDefault();let t=z?.id??null,n=mt.trim();_t(``);try{let e=new URL(n);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw Error(`Enter a valid http or https music link.`)}catch{_t(`Enter a valid music link.`);return}yt(!0);try{let e=await k(`/api/spotify/music`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:n,profileId:t})});if(V.current!==t)return;if(e.download){let t=e.download;Ge(e=>[t,...e.filter(e=>e.id!==t.id)])}if(e.playlist){let t=Fe(e.playlist);Re(e=>[t,...e.filter(e=>e.id!==t.id)])}if(!e.download&&!e.playlist)throw Error(`The server did not create a download or playlist.`);ht(``),P(!1),I(!0),q(e.playlist?`${e.playlist.title} added to Your Library`:`Music added to downloads`),Wt(t),Kt(t),Gt(t)}catch(e){if(V.current!==t)return;_t(e instanceof Error?e.message:`Could not add this music link.`)}finally{V.current===t&&yt(!1)}},mn=e=>{let t=Pe(e);Ie(e=>[t,...e.filter(e=>e.id!==t.id)]),Jt(t)},$=e=>{r(e),P(!1),I(!1),e===`search`&&window.requestAnimationFrame(()=>wt.current?.focus())},hn=K>0?Math.min(100,h/K*100):0,gn={"--range-progress":`${hn}%`},_n={"--range-progress":`${_}%`},vn={service:`spotify`,sessionId:`mobile-now-playing`,profileId:z?.id??`local-profile`,titleId:W.id,title:W.title,artist:W.artist,album:W.album,provider:W.provider??`Spotify Atom`,artwork:ke(W),currentTime:h,duration:K,paused:!p,muted:_<=0,volume:_/100,deviceType:`phone`,updatedAt:0};return(0,D.jsxs)(`div`,{className:`spotifyApp`,children:[(0,D.jsxs)(`aside`,{className:`sidebar`,children:[(0,D.jsxs)(`div`,{className:`sidebarTop`,children:[(0,D.jsxs)(`button`,{className:`brand`,onClick:()=>$(`home`),type:`button`,children:[(0,D.jsx)(He,{}),(0,D.jsx)(`span`,{children:`Spotify`})]}),(0,D.jsxs)(`div`,{className:`sidebarPrimaryNav`,children:[(0,D.jsxs)(`button`,{className:n===`home`?`sidebarNavActive`:``,onClick:()=>$(`home`),type:`button`,children:[(0,D.jsx)(ye,{fill:n===`home`?`currentColor`:`none`,size:24}),`Home`]}),(0,D.jsxs)(`button`,{className:n===`search`?`sidebarNavActive`:``,onClick:()=>$(`search`),type:`button`,children:[(0,D.jsx)(C,{size:24}),`Search`]})]})]}),(0,D.jsxs)(`section`,{className:`libraryPanel`,children:[(0,D.jsxs)(`div`,{className:`libraryHeader`,children:[(0,D.jsxs)(`button`,{onClick:()=>$(`library`),type:`button`,children:[(0,D.jsx)(Ce,{size:23}),(0,D.jsx)(`span`,{children:`Your Library`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(j,{label:`Create playlist or folder`,onClick:()=>q(`Your new playlist is ready to name`),children:(0,D.jsx)(_e,{size:20})}),(0,D.jsx)(j,{label:`Expand your library`,onClick:()=>$(`library`),children:(0,D.jsx)(re,{size:20})})]})]}),(0,D.jsx)(`div`,{className:`filterChips`,"aria-label":`Library filters`,children:[`all`,`playlist`,`artist`,`album`].map(e=>(0,D.jsx)(`button`,{className:w===e?`chipActive`:``,onClick:()=>Se(e),type:`button`,children:e===`all`?`All`:e===`playlist`?`Playlists`:`${e[0].toUpperCase()}${e.slice(1)}s`},e))}),(0,D.jsxs)(`div`,{className:`libraryTools`,children:[(0,D.jsxs)(`label`,{children:[(0,D.jsx)(C,{"aria-hidden":`true`,size:17}),(0,D.jsx)(`input`,{"aria-label":`Search in Your Library`,onChange:e=>xe(e.target.value),placeholder:`Search in Your Library`,value:be}),be?(0,D.jsx)(`button`,{"aria-label":`Clear library search`,onClick:()=>xe(``),type:`button`,children:(0,D.jsx)(S,{size:15})}):null]}),(0,D.jsxs)(`button`,{className:`recentsButton`,onClick:()=>De(e=>!e),type:`button`,children:[Ee?`Recents`:`Oldest`,(0,D.jsx)(we,{size:17})]})]}),(0,D.jsxs)(`div`,{className:`libraryList`,children:[on.map(e=>(0,D.jsx)(Ue,{active:!!(e.playlistId&&e.playlistId===u),item:e,onSelect:()=>dn(e)},e.id)),on.length?null:(0,D.jsxs)(`div`,{className:`emptyLibrary`,children:[(0,D.jsx)(C,{size:24}),(0,D.jsx)(`strong`,{children:`No matches found`}),(0,D.jsx)(`span`,{children:`Try another search or filter.`})]})]})]})]}),(0,D.jsxs)(`main`,{className:`mainPanel`,children:[(0,D.jsxs)(`header`,{className:`topBar`,children:[(0,D.jsxs)(`div`,{className:`historyButtons`,children:[(0,D.jsx)(j,{label:`Go back`,onClick:()=>$(`home`),children:(0,D.jsx)(i,{size:25})}),(0,D.jsx)(j,{label:`Go forward`,children:(0,D.jsx)(de,{size:25})})]}),(0,D.jsxs)(`div`,{className:`globalSearch ${n===`search`?`searchEmphasis`:``}`,children:[(0,D.jsx)(C,{"aria-hidden":`true`,size:21}),(0,D.jsx)(`input`,{onChange:e=>{ge(e.target.value),e.target.value&&r(`search`)},onFocus:()=>r(`search`),placeholder:`What do you want to play?`,ref:wt,value:b}),b?(0,D.jsx)(`button`,{"aria-label":`Clear search`,className:`clearSearch`,onClick:()=>ge(``),type:`button`,children:(0,D.jsx)(S,{size:18})}):(0,D.jsx)(`kbd`,{children:`⌘ K`})]}),(0,D.jsxs)(`div`,{className:`topActions`,ref:kt,children:[(0,D.jsx)(`button`,{className:`explorePremium`,onClick:()=>q(`Premium looks good on you`),type:`button`,children:`Explore Premium`}),(0,D.jsxs)(`button`,{className:`installButton`,onClick:()=>q(`Spotify is ready in your browser`),type:`button`,children:[(0,D.jsx)(se,{size:16}),`Install App`]}),(0,D.jsx)(he,{id:`spotify-access-popover`,wrapClassName:`headerPopoverWrap`,buttonClassName:`iconButton accessActionButton`,popoverClassName:`spotify-access-popover`,icon:(0,D.jsx)(me,{size:19}),onOpenChange:e=>{e&&(P(!1),I(!1),L(!1))}}),(0,D.jsxs)(`div`,{className:`headerPopoverWrap`,children:[(0,D.jsx)(j,{className:`sourceActionButton`,controls:`source-popover`,expanded:N,hasPopup:`dialog`,label:`Music sources`,onClick:()=>{let e=!N;P(e),I(!1),L(!1),e&&Ut(z?.id)},children:(0,D.jsx)(ie,{size:19})}),N?(0,D.jsx)(Ke,{addMusicError:gt,addingMusic:vt,musicUrl:mt,onAddMusic:pn,onClose:()=>P(!1),onMusicUrlChange:e=>{ht(e),gt&&_t(``)},onSync:e=>{fn(e)},providerError:Je,providers:Ve,syncingProviderIds:bt}):null]}),(0,D.jsxs)(`div`,{className:`headerPopoverWrap`,children:[(0,D.jsxs)(j,{className:`downloadsActionButton`,controls:`downloads-popover`,expanded:F,hasPopup:`dialog`,label:It?`Downloads, ${It} active`:`Downloads`,onClick:()=>{let e=!F;I(e),P(!1),L(!1),e&&(Wt(z?.id),Gt(z?.id))},children:[(0,D.jsx)(se,{size:19}),It?(0,D.jsx)(`span`,{className:`downloadActionBadge`,"aria-hidden":`true`,children:It>9?`9+`:It}):null]}),F?(0,D.jsx)(qe,{currentTrackId:a,downloads:We,error:tt,isPlaying:p,onClose:()=>I(!1),onPlay:mn}):null]}),(0,D.jsx)(j,{label:`What’s New`,onClick:()=>{P(!1),I(!1)},children:(0,D.jsx)(ae,{size:19})}),z?(0,D.jsx)(`div`,{className:`sharedProfileAction`,onFocus:()=>{P(!1),I(!1)},onPointerDown:()=>{P(!1),I(!1)},children:(0,D.jsx)(s,{profiles:lt,activeProfile:z,onSelectProfile:Vt,onProfilesChanged:Ht})}):null]})]}),(0,D.jsxs)(`div`,{className:`mainScroll`,children:[n===`home`?(0,D.jsx)(Ye,{currentPlaylistId:u,isPlaying:p,onPlayPlaylist:Yt,onShowSearch:()=>$(`search`)}):null,n===`search`?(0,D.jsx)(Xe,{currentPlaylistId:u,currentTrackId:a,isPlaying:p,likedTracks:T,matchingPlaylists:cn,matchingTracks:sn,normalizedQuery:Q,onLike:un,onPlayPlaylist:Yt,onSelectTrack:Jt,query:b,recentItems:ln,setQuery:ge}):null,n===`library`?(0,D.jsx)(Qe,{availableTracks:H,currentPlaylistId:u,currentTrackId:a,filteredLibrary:on,isPlaying:p,likedTracks:T,onOpenItem:dn,onSelectTrack:Jt}):null,(0,D.jsxs)(`footer`,{className:`contentFooter`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:`Spotify Atom`}),(0,D.jsx)(`span`,{children:`A Next.js listening experience.`})]}),(0,D.jsx)(`span`,{children:`Fictional artists and demo content`})]})]}),rt?(0,D.jsx)($e,{currentTrack:W,onClose:Lt,onSelectTrack:Jt,playlistTitle:Pt.title,tracks:Ft}):null]}),(0,D.jsx)(`audio`,{"aria-hidden":`true`,className:`audioEngine`,onEnded:e=>{fe?(e.currentTarget.currentTime=0,e.currentTarget.play().catch(()=>{m(!1),q(`This downloaded track could not be replayed.`)})):X()},onError:e=>{let t=e.currentTarget.dataset.trackId;t&&t===W.id&&jt.current!==t&&(jt.current=t,m(!1),q(`The downloaded audio file is unavailable.`))},onLoadedMetadata:e=>{let t=e.currentTarget.duration;Number.isFinite(t)&&t>0&&Ct({trackId:e.currentTarget.dataset.trackId??W.id,duration:t})},onTimeUpdate:e=>{if(e.currentTarget.dataset.trackId===W.id){let t=e.currentTarget.currentTime;B.current=t,g(t)}},preload:`metadata`,ref:Tt}),(0,D.jsx)(et,{currentTrack:W,duration:K,elapsed:h,isPlaying:p,liked:T.has(W.id),onLike:()=>un(W.id),onNext:X,onPrevious:Xt,onSeek:Z,onTogglePlay:Zt,onToggleQueue:()=>{L(e=>!e),P(!1),I(!1)},onVolumeChange:e=>{v(e),e>0&&ce(e)},progressStyle:gn,queueButtonRef:Et,queueOpen:rt,repeat:fe,setRepeat:pe,setShuffle:ue,shuffle:le,showToast:q,volume:_,volumeStyle:_n,toggleMute:()=>{_>0?(ce(_),v(0)):v(oe||74)}}),(0,D.jsxs)(`div`,{className:`mobilePlayer`,children:[(0,D.jsx)(`span`,{className:`mobilePlayerProgress`,style:{width:`${hn}%`}}),(0,D.jsx)(O,{className:`mobilePlayerArt`,imageUrl:W.imageUrl,palette:W.palette,title:W.title}),(0,D.jsxs)(`button`,{className:`mobilePlayerCopy`,onClick:()=>q(`${W.title} · ${W.artist}`),type:`button`,children:[(0,D.jsx)(`strong`,{children:W.title}),(0,D.jsx)(`span`,{children:W.artist})]}),(0,D.jsx)(j,{label:`${T.has(W.id)?`Remove from`:`Add to`} Liked Songs`,onClick:()=>un(W.id),pressed:T.has(W.id),children:(0,D.jsx)(l,{fill:T.has(W.id)?`currentColor`:`none`,size:21})}),(0,D.jsx)(j,{className:`mobilePlayToggle`,label:p?`Pause`:`Play`,onClick:Zt,children:p?(0,D.jsx)(x,{fill:`currentColor`,size:25}):(0,D.jsx)(y,{fill:`currentColor`,size:25})}),(0,D.jsx)(j,{buttonRef:Dt,className:`mobileExpandToggle`,controls:`mobile-expanded-player`,expanded:R,hasPopup:`dialog`,label:`Expand player`,onClick:()=>{it(!0),P(!1),I(!1)},children:(0,D.jsx)(Te,{size:21})})]}),R?(0,D.jsx)(`div`,{className:`mobileExpandedPlayerBackdrop`,onClick:Rt,children:(0,D.jsxs)(`section`,{"aria-label":`Now playing ${W.title}`,"aria-modal":`true`,className:`mobileExpandedPlayer`,id:`mobile-expanded-player`,onClick:e=>e.stopPropagation(),role:`dialog`,children:[(0,D.jsxs)(`header`,{className:`mobileExpandedPlayerHeader`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{children:`Spotify activity`}),(0,D.jsx)(`h2`,{children:`Now playing`})]}),(0,D.jsx)(j,{autoFocus:!0,buttonRef:Ot,label:`Close expanded player`,onClick:Rt,children:(0,D.jsx)(S,{size:20})})]}),(0,D.jsx)(te,{activity:vn,onCommand:rn,onSearchToggle:()=>ot(e=>!e),searchOpen:at,tabLabel:`This device`})]})}):null,at?(0,D.jsx)(ne,{activity:vn,onClose:()=>ot(!1),onSelectPlaylist:async e=>{nn(e.id)},onSelectTrack:async e=>{tn(e.id)}}):null,(0,D.jsxs)(`nav`,{className:`mobileNav`,"aria-label":`Main navigation`,children:[(0,D.jsxs)(`button`,{className:n===`home`?`mobileNavActive`:``,onClick:()=>$(`home`),type:`button`,children:[(0,D.jsx)(ye,{fill:n===`home`?`currentColor`:`none`,size:24}),(0,D.jsx)(`span`,{children:`Home`})]}),(0,D.jsxs)(`button`,{className:n===`search`?`mobileNavActive`:``,onClick:()=>$(`search`),type:`button`,children:[(0,D.jsx)(C,{size:24}),(0,D.jsx)(`span`,{children:`Search`})]}),(0,D.jsxs)(`button`,{className:n===`library`?`mobileNavActive`:``,onClick:()=>$(`library`),type:`button`,children:[(0,D.jsx)(Ce,{size:24}),(0,D.jsx)(`span`,{children:`Your Library`})]})]}),(0,D.jsxs)(`div`,{"aria-atomic":`true`,"aria-live":`polite`,className:`toast ${st?`toastVisible`:``}`,children:[(0,D.jsx)(ve,{size:18}),st]})]})}function Ye({currentPlaylistId:e,isPlaying:t,onPlayPlaylist:n,onShowSearch:r}){let i=o.find(e=>e.id===`discover-weekly`)??o[0],a=o.slice(4,10);return(0,D.jsxs)(`div`,{className:`homeView`,children:[(0,D.jsxs)(`section`,{className:`hero`,children:[(0,D.jsx)(`div`,{className:`heroGlow`}),(0,D.jsxs)(`div`,{className:`heroCopy`,children:[(0,D.jsxs)(`span`,{className:`heroEyebrow`,children:[(0,D.jsx)(m,{size:15}),`MADE FOR YOU`]}),(0,D.jsx)(`h1`,{children:`Soundtrack your every move.`}),(0,D.jsx)(`p`,{children:`New discoveries, old favorites, and the right music for right now.`}),(0,D.jsxs)(`div`,{className:`heroActions`,children:[(0,D.jsxs)(`button`,{className:`primaryButton`,onClick:()=>n(i),type:`button`,children:[e===i.id&&t?(0,D.jsx)(x,{fill:`currentColor`,size:19}):(0,D.jsx)(y,{fill:`currentColor`,size:19}),e===i.id&&t?`Pause your mix`:`Play your mix`]}),(0,D.jsxs)(`button`,{className:`secondaryButton`,onClick:r,type:`button`,children:[(0,D.jsx)(w,{size:19}),`Explore music`]})]})]}),(0,D.jsxs)(`div`,{className:`heroArt`,"aria-hidden":`true`,children:[(0,D.jsx)(O,{className:`heroCover heroCoverBack`,palette:o[1].palette,title:o[1].title}),(0,D.jsx)(O,{className:`heroCover heroCoverMiddle`,palette:o[3].palette,title:o[3].title}),(0,D.jsx)(O,{className:`heroCover heroCoverFront`,palette:o[0].palette,title:o[0].title})]})]}),(0,D.jsxs)(`section`,{className:`quickSection`,children:[(0,D.jsx)(`div`,{className:`sectionTitleRow compactTitleRow`,children:(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`sectionEyebrow`,children:`PICK UP WHERE YOU LEFT OFF`}),(0,D.jsx)(`h2`,{children:`Good evening`})]})}),(0,D.jsx)(`div`,{className:`quickGrid`,children:a.map(r=>{let i=r.id===e;return(0,D.jsxs)(`button`,{className:`quickTile ${i?`quickTileActive`:``}`,onClick:()=>n(r),type:`button`,children:[(0,D.jsx)(O,{className:`quickTileArt`,palette:r.palette,title:r.title}),(0,D.jsx)(`strong`,{children:r.title}),(0,D.jsx)(`span`,{className:`quickTilePlay`,"aria-hidden":`true`,children:i&&t?(0,D.jsx)(x,{fill:`currentColor`,size:19}):(0,D.jsx)(y,{fill:`currentColor`,size:19})})]},r.id)})})]}),u.map(r=>{let i=r.playlistIds.map(e=>o.find(t=>t.id===e)).filter(e=>!!e);return(0,D.jsxs)(`section`,{className:`shelfSection`,children:[(0,D.jsxs)(`div`,{className:`sectionTitleRow`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:r.title}),r.description?(0,D.jsx)(`p`,{children:r.description}):null]}),(0,D.jsx)(`button`,{type:`button`,children:`Show all`})]}),(0,D.jsx)(`div`,{className:`playlistGrid`,children:i.map(r=>(0,D.jsx)(We,{active:r.id===e,onPlay:()=>n(r),playing:t,playlist:r},r.id))})]},r.id)})]})}function Xe({currentPlaylistId:e,currentTrackId:t,isPlaying:n,likedTracks:r,matchingPlaylists:i,matchingTracks:a,normalizedQuery:o,onLike:s,onPlayPlaylist:c,onSelectTrack:l,query:u,recentItems:d,setQuery:f}){return(0,D.jsxs)(`div`,{className:`searchView`,children:[(0,D.jsxs)(`div`,{className:`pageHeading`,children:[(0,D.jsx)(`span`,{className:`sectionEyebrow`,children:`FIND YOUR NEXT FAVORITE`}),(0,D.jsx)(`h1`,{children:`Search`}),(0,D.jsx)(`p`,{children:`Artists, songs, albums, playlists, and everything in between.`})]}),(0,D.jsxs)(`label`,{className:`mobileSearchInput`,children:[(0,D.jsx)(C,{size:21}),(0,D.jsx)(`input`,{onChange:e=>f(e.target.value),placeholder:`What do you want to play?`,value:u}),u?(0,D.jsx)(`button`,{"aria-label":`Clear search`,onClick:()=>f(``),type:`button`,children:(0,D.jsx)(S,{size:19})}):null]}),o?(0,D.jsx)(`div`,{className:`searchResults`,children:a.length||i.length?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`section`,{className:`topResultSection`,children:[(0,D.jsx)(`div`,{className:`sectionTitleRow`,children:(0,D.jsx)(`h2`,{children:`Top result`})}),(0,D.jsxs)(`div`,{className:`topResultLayout`,children:[a[0]?(0,D.jsxs)(`button`,{className:`topResultCard`,onClick:()=>l(a[0]),type:`button`,children:[(0,D.jsx)(O,{className:`topResultArt`,imageUrl:a[0].imageUrl,palette:a[0].palette,title:a[0].title}),(0,D.jsx)(`strong`,{children:a[0].title}),(0,D.jsxs)(`span`,{children:[`Song · `,(0,D.jsx)(`b`,{children:a[0].artist})]}),(0,D.jsx)(`span`,{className:`topResultPlay`,children:t===a[0].id&&n?(0,D.jsx)(x,{fill:`currentColor`,size:26}):(0,D.jsx)(y,{fill:`currentColor`,size:26})})]}):i[0]?(0,D.jsxs)(`button`,{className:`topResultCard`,onClick:()=>c(i[0]),type:`button`,children:[(0,D.jsx)(O,{className:`topResultArt`,imageUrl:i[0].imageUrl,palette:i[0].palette,title:i[0].title}),(0,D.jsx)(`strong`,{children:i[0].title}),(0,D.jsxs)(`span`,{children:[`Playlist · `,i[0].curator]}),(0,D.jsx)(`span`,{className:`topResultPlay`,children:(0,D.jsx)(y,{fill:`currentColor`,size:26})})]}):null,(0,D.jsxs)(`div`,{className:`songResults`,children:[(0,D.jsx)(`div`,{className:`sectionTitleRow`,children:(0,D.jsx)(`h2`,{children:`Songs`})}),a.slice(0,4).map(e=>(0,D.jsx)(Ge,{active:e.id===t,liked:r.has(e.id),onLike:()=>s(e.id),onSelect:()=>l(e),playing:n,track:e},e.id))]})]})]}),i.length?(0,D.jsxs)(`section`,{className:`shelfSection searchPlaylistSection`,children:[(0,D.jsx)(`div`,{className:`sectionTitleRow`,children:(0,D.jsx)(`h2`,{children:`Playlists`})}),(0,D.jsx)(`div`,{className:`playlistGrid`,children:i.slice(0,5).map(e=>(0,D.jsx)(We,{active:!1,onPlay:()=>c(e),playing:n,playlist:e},e.id))})]}):null]}):(0,D.jsxs)(`div`,{className:`noResults`,children:[(0,D.jsx)(`span`,{children:(0,D.jsx)(C,{size:28})}),(0,D.jsxs)(`h2`,{children:[`No results found for “`,u,`”`]}),(0,D.jsx)(`p`,{children:`Check the spelling or try fewer words.`})]})}):(0,D.jsxs)(`section`,{"aria-labelledby":`search-recent-heading`,className:`searchRecentSection`,children:[(0,D.jsx)(`div`,{className:`sectionTitleRow`,children:(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{id:`search-recent-heading`,children:`Recently played`}),(0,D.jsx)(`p`,{children:`Your latest songs and playlists.`})]})}),d.length?(0,D.jsx)(`div`,{className:`recentSearchGrid`,children:d.map(r=>(0,D.jsx)(Ze,{active:r.kind===`track`?r.track.id===t:r.playlist.id===e,item:r,onPlay:()=>{r.kind===`track`?l(r.track):c(r.playlist)},playing:n},r.kind===`track`?`track:${r.track.id}`:`playlist:${r.playlist.id}`))}):(0,D.jsxs)(`div`,{className:`searchRecentEmpty`,role:`status`,children:[(0,D.jsx)(xe,{"aria-hidden":`true`,size:27}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:`Nothing played yet`}),(0,D.jsx)(`p`,{children:`Play a song or playlist and it will appear here.`})]})]})]})]})}function Ze({active:e,item:t,onPlay:n,playing:r}){let i=t.kind===`track`?t.track:t.playlist,a=e&&r;return(0,D.jsxs)(`button`,{"aria-label":`${a?`Pause`:`Play`} ${i.title}`,className:`recentSearchCard ${e?`recentSearchCardActive`:``}`,onClick:n,type:`button`,children:[(0,D.jsxs)(`span`,{className:`recentSearchArt`,children:[(0,D.jsx)(O,{imageUrl:i.imageUrl,palette:i.palette,title:i.title}),(0,D.jsx)(`span`,{className:`recentSearchPlay`,"aria-hidden":`true`,children:a?(0,D.jsx)(x,{fill:`currentColor`,size:20}):(0,D.jsx)(y,{fill:`currentColor`,size:20})})]}),(0,D.jsxs)(`span`,{className:`recentSearchCopy`,children:[(0,D.jsx)(`strong`,{children:i.title}),(0,D.jsx)(`span`,{children:t.kind===`track`?`Song · ${t.track.artist}`:`Playlist · ${t.playlist.curator}`})]})]})}function Qe({availableTracks:e,currentPlaylistId:t,currentTrackId:n,filteredLibrary:r,isPlaying:i,likedTracks:a,onOpenItem:o,onSelectTrack:s}){let c=e.filter(e=>a.has(e.id));return(0,D.jsxs)(`div`,{className:`fullLibraryView`,children:[(0,D.jsxs)(`div`,{className:`pageHeading libraryPageHeading`,children:[(0,D.jsx)(`span`,{className:`sectionEyebrow`,children:`SAVED FOR LATER`}),(0,D.jsx)(`h1`,{children:`Your Library`}),(0,D.jsx)(`p`,{children:`Playlists, artists, albums, and the songs you never skip.`})]}),(0,D.jsxs)(`section`,{className:`libraryCollectionGrid`,children:[(0,D.jsxs)(`button`,{className:`likedCollection`,onClick:()=>c[0]&&s(c[0]),type:`button`,children:[(0,D.jsx)(`span`,{className:`likedTrackNames`,children:c.slice(0,3).map(e=>(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`b`,{children:e.title}),` `,(0,D.jsxs)(`span`,{children:[`· `,e.artist]})]},e.id))}),(0,D.jsx)(`strong`,{children:`Liked Songs`}),(0,D.jsxs)(`span`,{children:[c.length,` songs`]}),(0,D.jsx)(`span`,{className:`likedCollectionPlay`,children:c.some(e=>e.id===n)&&i?(0,D.jsx)(x,{fill:`currentColor`,size:24}):(0,D.jsx)(y,{fill:`currentColor`,size:24})})]}),r.filter(e=>e.id!==`liked-songs`).slice(0,5).map(e=>(0,D.jsxs)(`button`,{className:`libraryCollectionCard ${e.playlistId===t?`libraryCollectionActive`:``}`,onClick:()=>o(e),type:`button`,children:[(0,D.jsx)(O,{className:`libraryCollectionArt`,imageUrl:e.imageUrl,palette:e.palette,rounded:e.kind===`artist`,title:e.title}),(0,D.jsx)(`strong`,{children:e.title}),(0,D.jsx)(`span`,{children:e.subtitle})]},e.id))]}),(0,D.jsxs)(`section`,{className:`shelfSection likedTracksSection`,children:[(0,D.jsxs)(`div`,{className:`sectionTitleRow`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:`Your liked songs`}),(0,D.jsx)(`p`,{children:`The tracks at the heart of your library.`})]}),(0,D.jsx)(xe,{size:20})]}),(0,D.jsx)(`div`,{className:`likedTracksTable`,children:c.map((e,t)=>(0,D.jsxs)(`button`,{className:e.id===n?`likedTrackActive`:``,onClick:()=>s(e),type:`button`,children:[(0,D.jsx)(`span`,{className:`likedTrackNumber`,children:e.id===n&&i?(0,D.jsxs)(`span`,{className:`miniEqualizer`,children:[(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{})]}):t+1}),(0,D.jsx)(O,{className:`likedTrackArt`,imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsxs)(`span`,{className:`likedTrackCopy`,children:[(0,D.jsx)(`strong`,{children:e.title}),(0,D.jsx)(`span`,{children:e.artist})]}),(0,D.jsx)(`span`,{className:`likedTrackAlbum`,children:e.album}),(0,D.jsx)(l,{"aria-hidden":`true`,fill:`currentColor`,size:17}),(0,D.jsx)(`span`,{children:Ve(e.durationSec)})]},e.id))})]})]})}function $e({currentTrack:e,onClose:t,onSelectTrack:n,playlistTitle:r,tracks:i}){return(0,D.jsxs)(`aside`,{"aria-labelledby":`queue-heading`,className:`queuePanel`,id:`queue-panel`,role:`dialog`,children:[(0,D.jsxs)(`header`,{className:`queueHeader`,children:[(0,D.jsx)(`h2`,{id:`queue-heading`,children:`Queue`}),(0,D.jsx)(j,{autoFocus:!0,label:`Close queue`,onClick:t,children:(0,D.jsx)(S,{size:20})})]}),(0,D.jsxs)(`div`,{className:`queueScroll`,children:[(0,D.jsxs)(`section`,{"aria-labelledby":`queue-now-playing`,children:[(0,D.jsx)(`h3`,{id:`queue-now-playing`,children:`Now playing`}),(0,D.jsxs)(`div`,{className:`queueTrack queueTrackCurrent`,children:[(0,D.jsx)(O,{className:`queueTrackArt`,imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsxs)(`span`,{className:`queueTrackCopy`,children:[(0,D.jsx)(`strong`,{children:e.title}),(0,D.jsx)(`span`,{children:e.artist})]})]})]}),(0,D.jsxs)(`section`,{className:`queueNext`,"aria-labelledby":`queue-next-heading`,children:[(0,D.jsxs)(`h3`,{id:`queue-next-heading`,children:[`Next from: `,r]}),i.length?(0,D.jsx)(`div`,{className:`queueTrackList`,children:i.map(e=>(0,D.jsxs)(`button`,{className:`queueTrack`,onClick:()=>n(e),type:`button`,children:[(0,D.jsx)(O,{className:`queueTrackArt`,imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsxs)(`span`,{className:`queueTrackCopy`,children:[(0,D.jsx)(`strong`,{children:e.title}),(0,D.jsx)(`span`,{children:e.artist})]})]},e.id))}):(0,D.jsx)(`p`,{className:`queueEmpty`,children:`There are no more songs in this queue.`})]})]})]})}function et({currentTrack:e,duration:t,elapsed:n,isPlaying:r,liked:i,onLike:a,onNext:o,onPrevious:s,onSeek:u,onTogglePlay:d,onToggleQueue:f,onVolumeChange:p,progressStyle:ee,queueButtonRef:te,queueOpen:ne,repeat:m,setRepeat:re,setShuffle:h,shuffle:ie,showToast:g,toggleMute:ae,volume:_,volumeStyle:v}){return(0,D.jsxs)(`footer`,{className:`desktopPlayer`,children:[(0,D.jsxs)(`div`,{className:`playerTrack`,children:[(0,D.jsx)(O,{className:`playerCover`,imageUrl:e.imageUrl,palette:e.palette,title:e.title}),(0,D.jsxs)(`div`,{className:`playerTrackCopy`,children:[(0,D.jsx)(`strong`,{children:e.title}),(0,D.jsx)(`span`,{children:e.artist})]}),(0,D.jsx)(j,{label:`${i?`Remove from`:`Add to`} Liked Songs`,onClick:a,pressed:i,children:(0,D.jsx)(l,{fill:i?`currentColor`:`none`,size:19})}),(0,D.jsx)(j,{label:`Open Now Playing view`,onClick:()=>g(`Now Playing view is already in focus`),children:(0,D.jsx)(Te,{size:17})})]}),(0,D.jsxs)(`div`,{className:`playerCenter`,children:[(0,D.jsxs)(`div`,{className:`transportControls`,children:[(0,D.jsx)(j,{label:`Turn shuffle ${ie?`off`:`on`}`,onClick:()=>h(!ie),pressed:ie,children:(0,D.jsx)(T,{size:18})}),(0,D.jsx)(j,{label:`Previous`,onClick:s,children:(0,D.jsx)(c,{fill:`currentColor`,size:19})}),(0,D.jsx)(M,{label:r?`Pause`:`Play`,onClick:d,playing:r,size:`small`}),(0,D.jsx)(j,{label:`Next`,onClick:o,children:(0,D.jsx)(ge,{fill:`currentColor`,size:19})}),(0,D.jsx)(j,{label:`Turn repeat ${m?`off`:`on`}`,onClick:()=>re(!m),pressed:m,children:(0,D.jsx)(De,{size:18})})]}),(0,D.jsxs)(`div`,{className:`progressRow`,children:[(0,D.jsx)(`span`,{children:Ve(n)}),(0,D.jsx)(`input`,{"aria-label":`Seek playback position`,className:`range`,max:t,min:0,onChange:e=>u(Number(e.target.value)),onKeyDown:e=>{e.key===`Home`?u(0):e.key===`End`&&u(t)},style:ee,type:`range`,value:Math.min(n,t)}),(0,D.jsx)(`span`,{children:Ve(t)})]})]}),(0,D.jsxs)(`div`,{className:`playerTools`,children:[(0,D.jsx)(j,{label:`Now Playing view`,children:(0,D.jsx)(we,{size:18})}),(0,D.jsx)(j,{className:`playerQueueButton`,controls:`queue-panel`,expanded:ne,hasPopup:`dialog`,label:`Queue`,onClick:f,pressed:ne,buttonRef:te,children:(0,D.jsx)(we,{size:18})}),(0,D.jsx)(j,{label:`Connect to a device`,onClick:()=>g(`Listening on this web browser`),children:(0,D.jsx)(Ee,{size:18})}),(0,D.jsx)(j,{label:_===0?`Unmute`:`Mute`,onClick:ae,children:_===0?(0,D.jsx)(pe,{size:20}):(0,D.jsx)(le,{size:20})}),(0,D.jsx)(`input`,{"aria-label":`Volume`,className:`range volumeRange`,max:100,min:0,onChange:e=>p(Number(e.target.value)),style:v,type:`range`,value:_}),(0,D.jsx)(j,{label:`Full screen`,children:(0,D.jsx)(Te,{size:17})})]})]})}export{Je as SpotifyApp};
|