@aigamo/hydrangean-diva 0.0.1-alpha.64 → 0.0.1-alpha.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@emotion/react/jsx-runtime"),a=require("react"),be=require("ajv"),n=require("mobx"),_=require("@aigamo/route-sphere"),N=require("lodash-es"),O=require("@aigamo/nostalgic-diva"),s=require("@elastic/eui"),p=require("mobx-react-lite"),d=require("@fluentui/react-icons"),R=require("ez-modal-react"),K=require("react-sortablejs"),W=require("@tanstack/react-router"),Y=81,H=new Map(Object.entries({Audio:"",Dailymotion:"https://www.dailymotion.com/favicon.ico",Niconico:"https://www.nicovideo.jp/favicon.ico",SoundCloud:"https://soundcloud.com/favicon.ico",Twitch:"https://www.twitch.tv/favicon.ico",Vimeo:"https://vimeo.com/favicon.ico",YouTube:"https://www.youtube.com/favicon.ico"})),ve=({components:t=[],children:e})=>o.jsx(o.Fragment,{children:t.reduceRight((r,l)=>o.jsx(l,{children:r}),e)}),$={playQueue:"PlayQueueStore",bottomBar:"BottomBarStore",playlistList:"PlaylistListStore",playlist:t=>`PlaylistStore/${t}`},ne=a.createContext(void 0),E=()=>a.useContext(ne),V=new be({coerceTypes:!0});function X(t,e){let r;if(r=V.getSchema(e),r===void 0&&(V.addSchema(t,e),r=V.getSchema(e)),r===void 0||r.schema!==t)throw new Error(`Invalid schema. Expected: '${JSON.stringify(t)}', but got '${JSON.stringify(r?.schema)}'.`);return r}var g=(t=>(t.Off="Off",t.All="All",t.One="One",t))(g||{}),ge=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,x=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ie(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&ge(e,r,i),i};const fe={type:"object",properties:{repeat:{type:"string",enum:Object.values(g),nullable:!0},shuffle:{type:"boolean",nullable:!0}}};class ie{constructor(e){this.bottomBar=e,n.makeObservable(this)}get state(){return{repeat:this.bottomBar.repeat,shuffle:this.bottomBar.shuffle}}set state(e){this.bottomBar.repeat=e.repeat??g.Off,this.bottomBar.shuffle=e.shuffle??!1}validateState(e){return X(fe,"BottomBarLocalStorageState")(e)}}x([n.computed.struct],ie.prototype,"state",1);class b{constructor(e,r){this.player=e,this.playQueue=r,n.makeObservable(this),this.localStorageState=new ie(this)}localStorageState;repeat=g.Off;shuffle=!1;get controller(){return this.player.controller}get playing(){return this.player.playing}get percent(){return this.player.percent}get canSeek(){return!this.playQueue.isEmpty&&this.controller.supports("setCurrentTime")}get currentItem(){return this.playQueue.currentItem}get canToggleRepeat(){return!0}get canToggleShuffle(){return!1}get canPlay(){return this.playQueue.canPlay&&this.controller.supports("play")}get canPause(){return this.playQueue.canPause&&this.controller.supports("pause")}get canPrevious(){return!this.playQueue.isEmpty}get canNext(){return this.playQueue.hasNextItem}get canSkipBack10(){return this.canSeek}get canSkipForward30(){return this.canSeek}get canRemoveFromPlayQueue(){return!this.playQueue.isEmpty}setPercent(e){this.player.setPercent(e)}setSeeking(e){this.player.setSeeking(e)}toggleRepeat(){switch(this.repeat){case g.Off:this.repeat=g.All;break;case g.All:this.repeat=g.One;break;case g.One:this.repeat=g.Off;break}}toggleShuffle(){this.shuffle=!this.shuffle}play(){return this.controller.play()}pause(){return this.controller.pause()}async previous(){if(this.playQueue.hasPreviousItem){const e=await this.controller.getCurrentTime();e===void 0||e<5?await this.playQueue.previous():await this.controller.setCurrentTime(0)}else await this.controller.setCurrentTime(0)}next(){return this.playQueue.next()}async skipBack10(){const e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e-10)}async skipForward30(){const e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e+30)}async removeFromPlayQueue(){this.currentItem!==void 0&&await this.playQueue.removeItems([this.currentItem])}}x([n.observable],b.prototype,"repeat",2);x([n.observable],b.prototype,"shuffle",2);x([n.computed],b.prototype,"controller",1);x([n.computed],b.prototype,"playing",1);x([n.computed],b.prototype,"percent",1);x([n.computed],b.prototype,"canSeek",1);x([n.computed],b.prototype,"currentItem",1);x([n.computed],b.prototype,"canToggleRepeat",1);x([n.computed],b.prototype,"canToggleShuffle",1);x([n.computed],b.prototype,"canPlay",1);x([n.computed],b.prototype,"canPause",1);x([n.computed],b.prototype,"canPrevious",1);x([n.computed],b.prototype,"canNext",1);x([n.computed],b.prototype,"canSkipBack10",1);x([n.computed],b.prototype,"canSkipForward30",1);x([n.computed],b.prototype,"canRemoveFromPlayQueue",1);x([n.action.bound],b.prototype,"setPercent",1);x([n.action.bound],b.prototype,"setSeeking",1);x([n.action.bound],b.prototype,"toggleRepeat",1);x([n.action.bound],b.prototype,"toggleShuffle",1);x([n.action.bound],b.prototype,"play",1);x([n.action.bound],b.prototype,"pause",1);x([n.action.bound],b.prototype,"previous",1);x([n.action.bound],b.prototype,"next",1);x([n.action.bound],b.prototype,"skipBack10",1);x([n.action.bound],b.prototype,"skipForward30",1);x([n.action.bound],b.prototype,"removeFromPlayQueue",1);const Z=a.createContext(void 0),A=()=>a.useContext(Z),le=a.createContext(void 0),ae=()=>a.useContext(le),Se=({children:t})=>{const e=ae(),r=A(),[l]=a.useState(()=>new b(e,r));return _.useLocalStorageState($.bottomBar,l.localStorageState),o.jsx(ne.Provider,{value:l,children:t})},ce=a.createContext(void 0),je=()=>a.useContext(ce);var Pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,F=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ce(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Pe(e,r,i),i};class B{constructor(e,r,l){this.player=e,this.playQueue=r,this.bottomBar=l,n.makeObservable(this)}interacted=!1;get controller(){return this.player.controller}get currentItem(){return this.playQueue.currentItem}interact(){this.interacted=!0}async onLoaded(){this.interacted&&await this.controller.play()}onPlay(){this.player.onPlay()}onPause(){this.player.onPause()}async onEnded(){switch(this.bottomBar.repeat){case g.One:await this.controller.setCurrentTime(0);break;case g.Off:case g.All:if(this.playQueue.isLastItem)switch(this.bottomBar.repeat){case g.Off:this.player.onEnded();break;case g.All:this.playQueue.hasMultipleItems?await this.playQueue.goToFirst():await this.controller.setCurrentTime(0);break}else await this.playQueue.next();break}}onTimeUpdate(e){this.player.onTimeUpdate(e)}onControllerChange(e){this.player.onControllerChange(e)}}F([n.observable],B.prototype,"interacted",2);F([n.computed],B.prototype,"controller",1);F([n.computed],B.prototype,"currentItem",1);F([n.action.bound],B.prototype,"interact",1);F([n.action.bound],B.prototype,"onLoaded",1);F([n.action.bound],B.prototype,"onPlay",1);F([n.action.bound],B.prototype,"onPause",1);F([n.action.bound],B.prototype,"onEnded",1);F([n.action.bound],B.prototype,"onTimeUpdate",1);F([n.action.bound],B.prototype,"onControllerChange",1);const Ee=({children:t})=>{const e=ae(),r=A(),l=E(),[i]=a.useState(()=>new B(e,r,l));return o.jsx(ce.Provider,{value:i,children:t})},ue={type:"object",properties:{url:{type:"string"},type:{type:"string"},videoId:{type:"string"},title:{type:"string"}},required:["url","type","videoId","title"]},Te={type:"object",properties:{version:{type:"string",nullable:!0},repeat:{type:"string",enum:Object.values(g),nullable:!0},shuffle:{type:"boolean",nullable:!0},items:{type:"array",nullable:!0,items:ue},currentIndex:{type:"integer",nullable:!0}}};var we=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,P=(t,e,r,l)=>{for(var i=l>1?void 0:l?ke(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&we(e,r,i),i};const S=class U{constructor(e,r){this.playQueue=e,this.dto=r,n.makeObservable(this),this.id=U.nextId++}static nextId=1;id;isSelected=!1;static fromDto(e,r){return new U(e,r)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return this.playQueue.currentItem===this}get index(){return this.playQueue.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playQueue.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playQueue.hasMultipleItems}clone(){return this.playQueue.createItemFromDto(this.dto)}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.setCurrentItem(this),Promise.resolve()}remove(){return this.playQueue.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.clone()])}playNext(){return this.playQueue.playNext([this.clone()])}addToPlayQueue(){return this.playQueue.addItems([this.clone()])}moveToTop(){this.playQueue.moveItem(this,0)}moveToBottom(){this.playQueue.moveItem(this,this.playQueue.items.length-1)}removeToTop(){return this.playQueue.removeItemsAbove(this)}removeOthers(){return this.playQueue.removeOtherItems(this)}};P([n.observable],S.prototype,"isSelected",2);P([n.computed],S.prototype,"isCurrent",1);P([n.computed],S.prototype,"index",1);P([n.computed],S.prototype,"isFirst",1);P([n.computed],S.prototype,"isLast",1);P([n.computed],S.prototype,"canMoveToTop",1);P([n.computed],S.prototype,"canMoveToBottom",1);P([n.computed],S.prototype,"canRemoveToTop",1);P([n.computed],S.prototype,"canRemoveOthers",1);P([n.action.bound],S.prototype,"unselect",1);P([n.action.bound],S.prototype,"select",1);P([n.action.bound],S.prototype,"toggleSelected",1);P([n.action.bound],S.prototype,"play",1);P([n.action.bound],S.prototype,"remove",1);P([n.action.bound],S.prototype,"playFirst",1);P([n.action.bound],S.prototype,"playNext",1);P([n.action.bound],S.prototype,"addToPlayQueue",1);P([n.action.bound],S.prototype,"moveToTop",1);P([n.action.bound],S.prototype,"moveToBottom",1);P([n.action.bound],S.prototype,"removeToTop",1);P([n.action.bound],S.prototype,"removeOthers",1);let Be=S;var Fe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,m=(t,e,r,l)=>{for(var i=l>1?void 0:l?Oe(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Fe(e,r,i),i};class de{constructor(e){this.playQueue=e,n.makeObservable(this)}get state(){return{version:"1.0",items:this.playQueue.items.map(e=>e.dto),currentIndex:this.playQueue.currentIndex}}set state(e){this.playQueue.items=e.items?.map(r=>this.playQueue.createItemFromDto(r))??[],this.playQueue.currentIndex=e.currentIndex}validateState(e){return X(Te,"PlayQueueDto")(e)}}m([n.computed.struct],de.prototype,"state",1);class h{localStorageState;items=[];currentId;constructor(){n.makeObservable(this),this.localStorageState=new de(this)}createItemFromDto(e){return Be.fromDto(this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get canClear(){return!this.isEmpty}get currentItem(){return this.items.find(e=>e.id===this.currentId)}get canPlay(){return this.currentItem!==void 0}get canPause(){return this.currentItem!==void 0}get hasMultipleItems(){return this.items.length>1}get currentIndex(){return this.currentId!==void 0?this.items.findIndex(e=>e.id===this.currentId):void 0}set currentIndex(e){this.currentId=e!==void 0?this.items.at(e)?.id:void 0}get hasPreviousItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex>0}get hasNextItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex<this.items.length-1}get isLastItem(){return this.currentIndex!==void 0&&this.currentIndex===this.items.length-1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}clear(){this.currentIndex=void 0,this.items=[]}unselectAll(){for(const e of this.items)e.unselect()}selectAll(){for(const e of this.items)e.select()}setCurrentItem(e){this.currentId=e?.id}setNextItems(e){this.currentIndex!==void 0&&this.items.splice(this.currentIndex+1,0,...e)}clearAndSetItems(e){this.clear(),this.setCurrentItem(e[0]),this.setNextItems(e)}async playNext(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.setNextItems(e)}async playSelectedItemsNext(){await this.playNext(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async addItems(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.items.push(...e)}async addSelectedItems(){await this.addItems(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async playFirst(e){if(this.isEmpty){this.clearAndSetItems(e);return}const{currentIndex:r}=this;r!==void 0&&(this.items.splice(r,0,...e),this.currentIndex=r)}moveItem(e,r){const l=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(r,0,l)}async goToFirst(){this.currentIndex!==void 0&&(this.currentIndex=0)}async removeItems(e){const{currentItem:r}=this;N.pull(this.items,...e.filter(c=>c!==r));const{currentIndex:l,isLastItem:i}=this;N.pull(this.items,e.find(c=>c===r)),this.currentItem!==r&&(i?await this.goToFirst():this.currentIndex=l)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){const r=e.id;return this.removeItems(this.items.filter(l=>l.id!==r))}async removeItemsAbove(e){const r=this.items.indexOf(e);return this.removeItems(this.items.filter((l,i)=>i<r))}async previous(){this.currentIndex!==void 0&&this.hasPreviousItem&&this.currentIndex--}async next(){this.currentIndex!==void 0&&this.hasNextItem&&this.currentIndex++}addItemFromDto(e){const r=this.createItemFromDto(e);return this.addItems([r])}}m([n.observable],h.prototype,"items",2);m([n.observable],h.prototype,"currentId",2);m([n.computed],h.prototype,"isEmpty",1);m([n.computed],h.prototype,"canClear",1);m([n.computed],h.prototype,"currentItem",1);m([n.computed],h.prototype,"canPlay",1);m([n.computed],h.prototype,"canPause",1);m([n.computed],h.prototype,"hasMultipleItems",1);m([n.computed],h.prototype,"currentIndex",1);m([n.computed],h.prototype,"hasPreviousItem",1);m([n.computed],h.prototype,"hasNextItem",1);m([n.computed],h.prototype,"isLastItem",1);m([n.computed],h.prototype,"selectedItems",1);m([n.computed],h.prototype,"allItemsSelected",1);m([n.computed],h.prototype,"hasSelectedItems",1);m([n.computed],h.prototype,"selectedItemsOrAllItems",1);m([n.computed],h.prototype,"canAddSelectedItems",1);m([n.computed],h.prototype,"canPlaySelectedItemsNext",1);m([n.computed],h.prototype,"canRemoveSelectedItems",1);m([n.action.bound],h.prototype,"setItems",1);m([n.action.bound],h.prototype,"clear",1);m([n.action.bound],h.prototype,"unselectAll",1);m([n.action.bound],h.prototype,"selectAll",1);m([n.action.bound],h.prototype,"setCurrentItem",1);m([n.action.bound],h.prototype,"setNextItems",1);m([n.action.bound],h.prototype,"clearAndSetItems",1);m([n.action.bound],h.prototype,"playNext",1);m([n.action.bound],h.prototype,"playSelectedItemsNext",1);m([n.action.bound],h.prototype,"addItems",1);m([n.action.bound],h.prototype,"addSelectedItems",1);m([n.action.bound],h.prototype,"playFirst",1);m([n.action.bound],h.prototype,"moveItem",1);m([n.action.bound],h.prototype,"goToFirst",1);m([n.action.bound],h.prototype,"removeItems",1);m([n.action.bound],h.prototype,"removeSelectedItems",1);m([n.action.bound],h.prototype,"removeOtherItems",1);m([n.action.bound],h.prototype,"removeItemsAbove",1);m([n.action.bound],h.prototype,"previous",1);m([n.action.bound],h.prototype,"next",1);m([n.action.bound],h.prototype,"addItemFromDto",1);const Re=({children:t})=>{const[e]=a.useState(()=>new h);_.useLocalStorageState($.playQueue,e.localStorageState);const r=O.useNostalgicDiva();return a.useEffect(()=>n.reaction(()=>e.currentItem,async(l,i)=>{l===void 0||i===void 0||l.type===i.type&&l.videoId===i.videoId&&await r.setCurrentTime(0)}),[e,r]),o.jsx(Z.Provider,{value:e,children:t})};var Ae=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,w=(t,e,r,l)=>{for(var i=l>1?void 0:l?Me(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Ae(e,r,i),i};class T{controller=O.nullPlayerController;playing=!1;percent=0;seeking=!1;constructor(){n.makeObservable(this)}setPlaying(e){this.playing=e}setPercent(e){this.percent=e}setSeeking(e){this.seeking=e}onControllerChange(e){this.controller=e}onPlay(){this.playing=!0}onPause(){this.playing=!1}onEnded(){this.playing=!1}onTimeUpdate({percent:e}){e!==void 0&&(this.seeking||(this.percent=e))}}w([n.observable],T.prototype,"controller",2);w([n.observable],T.prototype,"playing",2);w([n.observable],T.prototype,"percent",2);w([n.observable],T.prototype,"seeking",2);w([n.action.bound],T.prototype,"setPlaying",1);w([n.action.bound],T.prototype,"setPercent",1);w([n.action.bound],T.prototype,"setSeeking",1);w([n.action.bound],T.prototype,"onControllerChange",1);w([n.action.bound],T.prototype,"onPlay",1);w([n.action.bound],T.prototype,"onPause",1);w([n.action.bound],T.prototype,"onEnded",1);w([n.action.bound],T.prototype,"onTimeUpdate",1);const De=({children:t})=>{const[e]=a.useState(()=>new T);return o.jsx(le.Provider,{value:e,children:t})},ee=a.createContext(void 0),pe=()=>a.useContext(ee);var Qe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,q=(t,e,r,l)=>{for(var i=l>1?void 0:l?ze(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Qe(e,r,i),i};class M{constructor(e,r,l){this.playlistList=e,n.makeObservable(this),this.id=r,this.name=l}id;name;async rename(e){this.name=e}remove(){return this.playlistList.removeItem(this)}}q([n.observable],M.prototype,"id",2);q([n.observable],M.prototype,"name",2);q([n.action.bound],M.prototype,"rename",1);q([n.action.bound],M.prototype,"remove",1);var Le=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,z=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ne(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Le(e,r,i),i};class me{constructor(e){this.playlistList=e,n.makeObservable(this)}get state(){return{items:this.playlistList.items.map(e=>({id:e.id,name:e.name}))}}set state(e){this.playlistList.items=e.items?.map(r=>new M(this.playlistList,r.id,r.name))??[]}validateState(e){return!0}}z([n.computed.struct],me.prototype,"state",1);class L{localStorageState;items=[];constructor(){n.makeObservable(this),this.localStorageState=new me(this)}createItem(e){return new M(this,crypto.randomUUID(),e)}setItems(e){this.items=e}async addItem(e){this.items.push(e)}async removeItem(e){N.pull(this.items,e)}}z([n.observable],L.prototype,"items",2);z([n.action.bound],L.prototype,"setItems",1);z([n.action.bound],L.prototype,"addItem",1);z([n.action.bound],L.prototype,"removeItem",1);const _e=({children:t})=>{const[e]=a.useState(()=>new L);return _.useLocalStorageState($.playlistList,e.localStorageState),o.jsx(ee.Provider,{value:e,children:t})},He=({children:t,nostalgicDivaProps:e})=>o.jsx(O.NostalgicDivaProvider,{...e,children:o.jsx(ve,{components:[De,Re,Se,Ee,_e],children:t})}),G={width:400,height:225},$e=p.observer(({children:t})=>{const e=A();return o.jsxs(s.EuiPageTemplate,{panelled:!0,style:{minBlockSize:`max(460px, 100vh - ${Y}px)`},children:[t,!e.isEmpty&&o.jsx(s.EuiSpacer,{style:{blockSize:G.height}})]})}),qe=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:`Shuffle: ${t.shuffle?"On":"Off"}`,"aria-label":`Shuffle: ${t.shuffle?"On":"Off"}`,iconType:t.shuffle?d.ArrowShuffleFilled:d.ArrowShuffleOffFilled,size:"s",iconSize:"l",onClick:t.toggleShuffle,disabled:!t.canToggleShuffle})}),Ve=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Previous","aria-label":"Previous",iconType:d.PreviousFilled,size:"s",iconSize:"l",onClick:t.previous,disabled:!t.canPrevious})}),Ue=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Skip back 10 seconds","aria-label":"Skip back 10 seconds",iconType:d.SkipBack10Regular,size:"s",iconSize:"l",onClick:t.skipBack10,disabled:!t.canSkipBack10})}),Ge=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Pause","aria-label":"Pause",iconType:d.PauseFilled,size:"s",iconSize:"l",onClick:t.pause,disabled:!t.canPause})}),Je=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Play","aria-label":"Play",iconType:d.PlayFilled,size:"s",iconSize:"l",onClick:t.play,disabled:!t.canPlay})}),Ke=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Skip forward 30 seconds","aria-label":"Skip forward 30 seconds",iconType:d.SkipForward30Regular,size:"s",iconSize:"l",onClick:t.skipForward30,disabled:!t.canSkipForward30})}),We=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Next","aria-label":"Next",iconType:d.NextFilled,size:"s",iconSize:"l",onClick:t.next,disabled:!t.canNext})}),he={[g.Off]:d.ArrowRepeatAllOffFilled,[g.All]:d.ArrowRepeatAllFilled,[g.One]:d.ArrowRepeat1Filled},Ye=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:`Repeat: ${t.repeat===g.All?"All":t.repeat===g.One?"One":"Off"}`,"aria-label":`Repeat: ${t.repeat===g.All?"All":t.repeat===g.One?"One":"Off"}`,iconType:he[t.repeat],size:"s",iconSize:"l",onClick:t.toggleRepeat,disabled:!t.canToggleRepeat})}),Xe=p.observer(()=>{const t=E();return o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center",children:[o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(qe,{})}),o.jsx(Ve,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ue,{})}),t.playing?o.jsx(Ge,{}):o.jsx(Je,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ke,{})}),o.jsx(We,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ye,{})})]})}),Ze=a.memo(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,onClick:u})=>({name:i,icon:c,onClick:async v=>{e(),u(v)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Open in new tab",icon:o.jsx(s.EuiIcon,{type:d.OpenRegular}),onClick:async()=>{window.open(t.dto.url,"_blank")}}),r({name:"Copy link address",icon:o.jsx(s.EuiIcon,{type:""}),onClick:async()=>{await navigator.clipboard.writeText(t.dto.url)}}),r({name:"Copy link text",icon:o.jsx(s.EuiIcon,{type:""}),onClick:async()=>{await navigator.clipboard.writeText(t.dto.title)}})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),et=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonEmpty,{iconType:H.get(t.type),size:"s",onClick:l,children:t.title}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"upLeft",children:o.jsx(Ze,{item:t,closePopover:i})})}),tt=p.observer(()=>{const t=E();return o.jsx(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"flexStart",alignItems:"center",children:t.currentItem&&o.jsx(et,{item:t.currentItem})})}),ot=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Mute","aria-label":"Mute",iconType:d.Speaker2Regular,size:"s",iconSize:"l",disabled:!t.controller.supports("setMuted")})}),st=p.observer(({button:t,isOpen:e,closePopover:r})=>{const l=E(),[i,c]=a.useState("0"),u=O.useNostalgicDiva();a.useLayoutEffect(()=>{e&&u.getVolume().then(y=>{y!==void 0&&c(Math.floor(y*100).toString())})},[e,u]);const v=a.useCallback(async y=>{c(y.currentTarget.value),await u.setVolume(Number(y.currentTarget.value)/100)},[u]);return o.jsx(s.EuiPopover,{button:t,isOpen:e,closePopover:r,anchorPosition:"upRight",children:o.jsx(s.EuiFormRow,{children:o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center",children:[o.jsx(ot,{}),o.jsx(s.EuiRange,{min:0,max:100,step:1,value:i,onChange:v,css:{blockSize:32},disabled:!l.controller.supports("setVolume")})]})})})}),rt=p.observer(()=>{const t=E(),[e,r]=a.useState(!1),l=()=>r(!e);return o.jsx(st,{button:o.jsx(s.EuiButtonIcon,{title:"Volume","aria-label":"Volume",iconType:d.Speaker2Regular,size:"s",iconSize:"l",onClick:l,disabled:!t.controller.supports("getVolume")}),isOpen:e,closePopover:()=>r(!1)})}),nt=({onClickPlayQueueButton:t})=>o.jsx(s.EuiButtonIcon,{title:"Play queue","aria-label":"Play queue",iconType:d.NavigationPlayRegular,size:"s",iconSize:"l",onClick:t}),it=p.observer(({closePopover:t})=>{const e=E(),r=O.useNostalgicDiva(),[l,i]=a.useState(),c=a.useCallback(async()=>{await e.controller.getPlaybackRate().then(y=>i(y))},[e]),u=a.useCallback(({name:y,icon:k,onClick:D,disabled:Q,className:se})=>({name:y,icon:k,onClick:async()=>{t(),D()},disabled:Q,className:se}),[t]),v=a.useMemo(()=>[{id:0,items:[{name:"Speed",icon:o.jsx(s.EuiIcon,{type:d.TopSpeedRegular}),panel:1,onClick:c,disabled:!e.controller.supports("getPlaybackRate")},u({name:"Skip back 10 seconds",icon:o.jsx(s.EuiIcon,{type:d.SkipBack10Regular}),onClick:e.skipBack10,disabled:!e.canSkipBack10}),u({name:"Skip forward 30 seconds",icon:o.jsx(s.EuiIcon,{type:d.SkipForward30Regular}),onClick:e.skipForward30,disabled:!e.canSkipForward30}),u({name:`Shuffle: ${e.shuffle?"On":"Off"}`,icon:o.jsx(s.EuiIcon,{type:e.shuffle?d.ArrowShuffleFilled:d.ArrowShuffleOffFilled}),onClick:e.toggleShuffle,disabled:!e.canToggleShuffle,className:"eui-showFor--xs--flex"}),u({name:`Repeat: ${e.repeat===g.All?"All":e.repeat===g.One?"One":"Off"}`,icon:o.jsx(s.EuiIcon,{type:he[e.repeat]}),onClick:e.toggleRepeat,disabled:!e.canToggleRepeat,className:"eui-showFor--xs--flex"}),{isSeparator:!0},u({name:"Remove from play queue",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:e.removeFromPlayQueue,disabled:!e.canRemoveFromPlayQueue})]},{id:1,title:"Speed",items:[.25,.5,.75,1,1.25,1.5,1.75,2].map(y=>u({name:y.toString(),onClick:()=>r.setPlaybackRate(y),icon:y===l?"check":"empty",disabled:!e.controller.supports("setPlaybackRate")}))}],[e,u,c,r,l]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:v})}),lt=a.memo(({button:t,isOpen:e,closePopover:r})=>o.jsx(s.EuiPopover,{button:t,isOpen:e,closePopover:r,panelPaddingSize:"none",anchorPosition:"upRight",children:o.jsx(it,{closePopover:r})})),at=a.memo(()=>{const[t,e]=a.useState(!1),r=()=>e(!t);return o.jsx(lt,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",iconSize:"l",onClick:r}),isOpen:t,closePopover:()=>e(!1)})}),ct=a.memo(({onClickPlayQueueButton:t})=>o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"flexEnd",alignItems:"center",children:[o.jsx(rt,{}),t&&o.jsx(nt,{onClickPlayQueueButton:t}),o.jsx(at,{})]})),ut=p.observer(()=>{const t=E(),e=O.useNostalgicDiva(),r=a.useCallback(c=>{const u=Number(c.currentTarget.value)/100;t.setPercent(u)},[t]),l=a.useCallback(c=>{c.button===0&&t.setSeeking(!0)},[t]),i=a.useCallback(async c=>{if(c.button===0){const u=Number(c.currentTarget.value)/100;t.setSeeking(!1);const v=await e.getDuration();v!==void 0&&await e.setCurrentTime(v*u)}},[t,e]);return o.jsx(s.EuiRange,{min:0,max:100,step:1e-7,value:t.percent*100,onChange:r,onMouseDown:l,onMouseUp:i,fullWidth:!0,showRange:!0,css:{blockSize:32},disabled:!t.canSeek})}),dt=p.observer(({onClickPlayQueueButton:t})=>o.jsx(s.EuiBottomBar,{paddingSize:"s",children:o.jsxs(s.EuiFlexGroup,{direction:"column",gutterSize:"none",children:[o.jsx(s.EuiFlexItem,{children:o.jsx(ut,{})}),o.jsx(s.EuiFlexItem,{children:o.jsxs(s.EuiFlexGroup,{responsive:!1,children:[o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(tt,{})}),o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(Xe,{})}),o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(ct,{onClickPlayQueueButton:t})})]})})]})})),pt=p.observer(()=>{const t=je(),e=a.useMemo(()=>({onLoaded:t.onLoaded,onPlay:t.onPlay,onPause:t.onPause,onEnded:t.onEnded,onTimeUpdate:t.onTimeUpdate}),[t]);return a.useLayoutEffect(()=>(window.addEventListener("click",t.interact,{once:!0}),()=>{window.removeEventListener("click",t.interact)}),[t]),o.jsx("div",{css:{position:"fixed",right:0,bottom:Y,width:G.width,height:G.height,zIndex:998,backgroundColor:"rgb(39, 39, 39)",display:"flex",flexDirection:"column"},children:o.jsx("div",{css:{flexGrow:1,backgroundColor:"black"},children:t.currentItem&&o.jsx(O.NostalgicDiva,{src:t.currentItem.url,options:e,onControllerChange:t.onControllerChange})})})});function mt(t){return t!==null&&typeof t=="object"&&"title"in t&&typeof t.title=="string"}const ht=R.create(({remove:t,resolve:e})=>{const r=s.useGeneratedHtmlId({prefix:"modalForm"}),[l,i]=a.useState(""),[c,u]=a.useState(""),[v,y]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=url]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Add video"})}),o.jsx(s.EuiModalBody,{children:o.jsxs(s.EuiForm,{id:r,component:"form",onSubmit:async k=>{k.preventDefault();try{y(!0);const D=O.findVideoService(l);if(D===void 0)return;const Q=D.extractVideoId(l);if(Q===void 0)return;const re=await(await fetch(`https://noembed.com/embed?url=${encodeURIComponent(l)}`)).json();e({url:l,type:D.type,videoId:Q,title:c||(mt(re)?re.title:Q)}),t()}finally{y(!1)}},children:[o.jsx(s.EuiFormRow,{label:"URL",children:o.jsx(s.EuiFieldText,{name:"url",value:l,onChange:k=>i(k.target.value)})}),o.jsx(s.EuiFormRow,{label:"Title",children:o.jsx(s.EuiFieldText,{name:"title",value:c,onChange:k=>u(k.target.value)})})]})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:r,fill:!0,disabled:l.trim().length===0,isLoading:v,children:"Add video"})]})]})}),te=a.memo(({onFulfilled:t})=>{const e=()=>R.show(ht).then(t);return o.jsx(s.EuiButton,{onClick:e,iconType:d.AddRegular,color:"primary",children:"Add video"})}),yt=p.observer(({playQueue:t})=>o.jsx(s.EuiButton,{iconType:d.AddRegular,onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems,children:"Add to play queue"})),xt=p.observer(({playQueue:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v})=>({name:i,icon:c,disabled:u,onClick:async y=>{e(),v(y)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems}),r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems}),r({name:"Clear",icon:o.jsx(s.EuiIcon,{type:d.DeleteRegular}),onClick:t.clear,disabled:!t.canClear})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),bt=a.memo(({playQueue:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{display:"base",size:"m",iconType:d.MoreHorizontalFilled,onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"downLeft",children:o.jsx(xt,{playQueue:t,closePopover:i})})}),vt=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiFlexGroup,{alignItems:"center",gutterSize:"m",responsive:!1,style:{position:"sticky",top:48,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext,children:"Play next"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(yt,{playQueue:t})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DismissRegular,onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems,children:"Remove"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DeleteRegular,onClick:t.clear,disabled:!t.canClear,children:"Clear"})})]}),o.jsx(s.EuiShowFor,{sizes:["xs"],children:o.jsx(bt,{playQueue:t})}),o.jsx(s.EuiFlexItem,{grow:!0}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(te,{onFulfilled:t.addItemFromDto})})]})}),gt=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(o.Fragment,{children:[o.jsx(s.EuiTableHeaderMobile,{children:o.jsx(s.EuiFlexGroup,{responsive:!1,justifyContent:"spaceBetween",alignItems:"baseline",children:o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:r=>{r.target.checked?t.selectAll():t.unselectAll()}})})})}),o.jsxs(s.EuiTableHeader,{style:{position:"sticky",top:112,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsx(s.EuiTableHeaderCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:r=>{r.target.checked?t.selectAll():t.unselectAll()}})}),o.jsx(s.EuiTableHeaderCell,{width:24}),o.jsx(s.EuiTableHeaderCell,{children:"Title"}),o.jsx(s.EuiTableHeaderCell,{})]})]})}),It=p.observer(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v,className:y})=>({name:i,icon:c,disabled:u,onClick:async k=>{e(),v(k)},className:y}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play",icon:o.jsx(s.EuiIcon,{type:d.PlayRegular}),onClick:t.play,className:"eui-showFor--xs--flex"}),r({name:"Play first",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playFirst}),r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addToPlayQueue}),{isSeparator:!0},r({name:"Move to the top",icon:o.jsx(s.EuiIcon,{type:d.ArrowUploadRegular}),onClick:t.moveToTop,disabled:!t.canMoveToTop}),r({name:"Move to the bottom",icon:o.jsx(s.EuiIcon,{type:d.ArrowDownloadRegular}),onClick:t.moveToBottom,disabled:!t.canMoveToBottom}),{isSeparator:!0},r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.remove,className:"eui-showFor--xs--flex"}),r({name:"Remove to the top",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeToTop,disabled:!t.canRemoveToTop}),r({name:"Remove others",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeOthers,disabled:!t.canRemoveOthers})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),ft=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",color:"text",onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"leftCenter",children:o.jsx(It,{item:t,closePopover:i})})}),St=p.observer(({item:t})=>{const e=O.useNostalgicDiva();return o.jsxs(s.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:"right",children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiButton,{iconType:d.PlayRegular,size:"s",onClick:async()=>{t.isCurrent?await e.setCurrentTime(0):await t.play()},children:"Play"}),o.jsx(s.EuiButton,{iconType:d.DismissRegular,size:"s",onClick:t.remove,children:"Remove"})]}),o.jsx(ft,{item:t})]})}),jt=p.observer(({item:t})=>o.jsxs(s.EuiTableRow,{isSelected:t.isCurrent,hasSelection:!0,hasActions:!0,children:[o.jsx(s.EuiTableRowCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:t.id.toString(),checked:t.isSelected,onChange:t.toggleSelected})}),o.jsx(s.EuiTableRowCell,{textOnly:!1,children:o.jsx("img",{src:H.get(t.type),width:16,height:16,alt:t.type})}),o.jsx(s.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:"100%"},children:o.jsx(s.EuiLink,{href:t.url,target:"_blank",external:!0,children:t.title})}),o.jsx(St,{item:t})]})),Pt=p.observer(({playQueue:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(jt,{item:e},e.id))})),Ct=p.observer(({playQueue:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(gt,{playQueue:t}),o.jsx(Pt,{playQueue:t})]})),ye=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(vt,{playQueue:t}),o.jsx(s.EuiSpacer,{size:"l",style:{position:"sticky",top:88,zIndex:998,background:e.colors.backgroundBasePlain}}),t.isEmpty?o.jsx(s.EuiEmptyPrompt,{title:o.jsx("h2",{children:"We couldn't find any videos"}),body:o.jsx("p",{children:"Your video library doesn't contain any video content."}),actions:o.jsx(te,{onFulfilled:t.addItemFromDto})}):o.jsx(Ct,{playQueue:t})]})}),oe=({breadcrumbs:t,tabs:e,...r})=>{const l=W.useRouter();return o.jsx(s.EuiPageTemplate.Header,{...r,breadcrumbs:t?.map(({linkProps:i,...c})=>({...c,href:i===void 0?void 0:l.buildLocation(i).href,onClick:i===void 0?void 0:async u=>{u.preventDefault(),await l.navigate(i)}})),tabs:e?.map(({linkProps:i,...c})=>({...c,href:i===void 0?void 0:l.buildLocation(i).href,onClick:i===void 0?void 0:async u=>{u.preventDefault(),await l.navigate(i)}}))})},Et=()=>{const t=A();return o.jsxs(o.Fragment,{children:[o.jsx(oe,{pageTitle:"Play queue",rightSideItems:[]}),o.jsx(ye,{playQueue:t})]})},Tt=R.create(({remove:t,resolve:e,playlistListItem:r})=>{const[l,i]=a.useState(!1),c=a.useCallback(async()=>{try{i(!0),e(),t()}finally{i(!1)}},[e,t]);return o.jsx(s.EuiConfirmModal,{title:"Delete playlist permanently?",onCancel:t,onConfirm:c,cancelButtonText:"Cancel",confirmButtonText:"Delete",buttonColor:"danger",isLoading:l,children:o.jsxs("p",{children:["Are you sure you want to delete this playlist? If you delete '",r.name,"', you won't be able to recover it."]})})}),wt=p.observer(({playlist:t})=>o.jsx(s.EuiButton,{iconType:d.AddRegular,onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems,children:"Add to play queue"})),kt=p.observer(({playlist:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v})=>({name:i,icon:c,disabled:u,onClick:async y=>{e(),v(y)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems}),r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),Bt=a.memo(({playlist:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{display:"base",size:"m",iconType:d.MoreHorizontalFilled,onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"downLeft",children:o.jsx(kt,{playlist:t,closePopover:i})})}),Ft=p.observer(({playlist:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiFlexGroup,{alignItems:"center",gutterSize:"m",responsive:!1,style:{position:"sticky",top:48,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext,children:"Play next"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(wt,{playlist:t})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DismissRegular,onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems,children:"Remove"})})]}),o.jsx(s.EuiShowFor,{sizes:["xs"],children:o.jsx(Bt,{playlist:t})}),o.jsx(s.EuiFlexItem,{grow:!0}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(te,{onFulfilled:t.addItemFromDto})})]})}),Ot=p.observer(({playlist:t})=>o.jsxs(o.Fragment,{children:[o.jsx(s.EuiTableHeaderMobile,{children:o.jsx(s.EuiFlexGroup,{responsive:!1,justifyContent:"spaceBetween",alignItems:"baseline",children:o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:e=>{e.target.checked?t.selectAll():t.unselectAll()}})})})}),o.jsxs(s.EuiTableHeader,{children:[o.jsx(s.EuiTableHeaderCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:e=>{e.target.checked?t.selectAll():t.unselectAll()}})}),o.jsx(s.EuiTableHeaderCell,{width:24}),o.jsx(s.EuiTableHeaderCell,{children:"Title"}),o.jsx(s.EuiTableHeaderCell,{})]})]})),Rt=a.memo(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v,className:y})=>({name:i,icon:c,disabled:u,onClick:async k=>{e(),v(k)},className:y}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play",icon:o.jsx(s.EuiIcon,{type:d.PlayRegular}),onClick:t.play,className:"eui-showFor--xs--flex"}),r({name:"Play first",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playFirst}),r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addToPlayQueue}),{isSeparator:!0},r({name:"Move to the top",icon:o.jsx(s.EuiIcon,{type:d.ArrowUploadRegular}),onClick:t.moveToTop,disabled:!t.canMoveToTop}),r({name:"Move to the bottom",icon:o.jsx(s.EuiIcon,{type:d.ArrowDownloadRegular}),onClick:t.moveToBottom,disabled:!t.canMoveToBottom}),{isSeparator:!0},r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.remove,className:"eui-showFor--xs--flex"}),r({name:"Remove to the top",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeToTop,disabled:!t.canRemoveToTop}),r({name:"Remove others",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeOthers,disabled:!t.canRemoveOthers})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),At=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",color:"text",onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"leftCenter",children:o.jsx(Rt,{item:t,closePopover:i})})}),Mt=p.observer(({item:t})=>o.jsxs(s.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:"right",children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiButton,{iconType:d.PlayRegular,size:"s",onClick:t.play,children:"Play"}),o.jsx(s.EuiButton,{iconType:d.DismissRegular,size:"s",onClick:t.remove,children:"Remove"})]}),o.jsx(At,{item:t})]})),Dt=p.observer(({item:t})=>o.jsxs(s.EuiTableRow,{isSelected:t.isCurrent,hasSelection:!0,hasActions:!0,children:[o.jsx(s.EuiTableRowCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:t.id.toString(),checked:t.isSelected,onChange:t.toggleSelected})}),o.jsx(s.EuiTableRowCell,{textOnly:!1,children:o.jsx("img",{src:H.get(t.type),width:16,height:16,alt:t.type})}),o.jsx(s.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:"100%"},children:o.jsx(s.EuiLink,{href:t.url,target:"_blank",external:!0,children:t.title})}),o.jsx(Mt,{item:t})]})),Qt=p.observer(({playlist:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(Dt,{item:e},e.id))})),zt=p.observer(({playlist:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(Ot,{playlist:t}),o.jsx(Qt,{playlist:t})]})),Lt=p.observer(({playlist:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(Ft,{playlist:t}),o.jsx(s.EuiSpacer,{size:"l",style:{position:"sticky",top:88,zIndex:998,background:e.colors.backgroundBasePlain}}),t.isEmpty?o.jsx(o.Fragment,{}):o.jsx(zt,{playlist:t})]})}),Nt=R.create(({remove:t,resolve:e,playlistListItem:r})=>{const l=s.useGeneratedHtmlId({prefix:"modalForm"}),[i,c]=a.useState(r.name),[u,v]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=name]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Rename playlist"})}),o.jsx(s.EuiModalBody,{children:o.jsx(s.EuiForm,{id:l,component:"form",onSubmit:async y=>{y.preventDefault();try{v(!0),e(i),t()}finally{v(!1)}},children:o.jsx(s.EuiFormRow,{label:"Name",children:o.jsx(s.EuiFieldText,{name:"name",value:i,onChange:y=>c(y.target.value)})})})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:l,fill:!0,disabled:i.trim().length===0,isLoading:u,children:"Rename"})]})]})});var _t=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,C=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ht(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&_t(e,r,i),i};const j=class J{constructor(e,r,l){this.playQueue=e,this.playlist=r,this.dto=l,n.makeObservable(this),this.id=J.nextId++}static nextId=1;id;isSelected=!1;static fromDto(e,r,l){return new J(e,r,l)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return!1}get index(){return this.playlist.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playlist.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playlist.hasMultipleItems}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.clearAndSetItems([this.playQueue.createItemFromDto(this.dto)]),Promise.resolve()}remove(){return this.playlist.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.playQueue.createItemFromDto(this.dto)])}playNext(){return this.playQueue.playNext([this.playQueue.createItemFromDto(this.dto)])}addToPlayQueue(){return this.playQueue.addItems([this.playQueue.createItemFromDto(this.dto)])}moveToTop(){this.playlist.moveItem(this,0)}moveToBottom(){this.playlist.moveItem(this,this.playlist.items.length-1)}removeToTop(){return this.playlist.removeItemsAbove(this)}removeOthers(){return this.playlist.removeOtherItems(this)}};C([n.observable],j.prototype,"isSelected",2);C([n.computed],j.prototype,"isCurrent",1);C([n.computed],j.prototype,"index",1);C([n.computed],j.prototype,"isFirst",1);C([n.computed],j.prototype,"isLast",1);C([n.computed],j.prototype,"canMoveToTop",1);C([n.computed],j.prototype,"canMoveToBottom",1);C([n.computed],j.prototype,"canRemoveToTop",1);C([n.computed],j.prototype,"canRemoveOthers",1);C([n.action.bound],j.prototype,"unselect",1);C([n.action.bound],j.prototype,"select",1);C([n.action.bound],j.prototype,"toggleSelected",1);C([n.action.bound],j.prototype,"play",1);C([n.action.bound],j.prototype,"remove",1);C([n.action.bound],j.prototype,"playFirst",1);C([n.action.bound],j.prototype,"playNext",1);C([n.action.bound],j.prototype,"addToPlayQueue",1);C([n.action.bound],j.prototype,"moveToTop",1);C([n.action.bound],j.prototype,"moveToBottom",1);C([n.action.bound],j.prototype,"removeToTop",1);C([n.action.bound],j.prototype,"removeOthers",1);let $t=j;var qt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,I=(t,e,r,l)=>{for(var i=l>1?void 0:l?Vt(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&qt(e,r,i),i};const Ut={type:"object",properties:{version:{type:"string",nullable:!0},items:{type:"array",nullable:!0,items:ue}}};class xe{constructor(e){this.playlist=e,n.makeObservable(this)}get state(){return{version:"1.0",items:this.playlist.items.map(e=>e.dto)}}set state(e){this.playlist.items=e.items?.map(r=>this.playlist.createItemFromDto(r))??[]}validateState(e){return X(Ut,"PlaylistLocalStorageState")(e)}}I([n.computed.struct],xe.prototype,"state",1);class f{constructor(e){this.playQueue=e,n.makeObservable(this),this.localStorageState=new xe(this)}localStorageState;items=[];createItemFromDto(e){return $t.fromDto(this.playQueue,this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get hasMultipleItems(){return this.items.length>1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}unselectAll(){for(const e of this.items)e.unselect()}selectAll(){for(const e of this.items)e.select()}async playSelectedItemsNext(){await this.playQueue.playNext(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addSelectedItems(){await this.playQueue.addItems(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addItems(e){this.items.push(...e)}moveItem(e,r){const l=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(r,0,l)}async removeItems(e){N.pull(this.items,...e)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){const r=e.id;return this.removeItems(this.items.filter(l=>l.id!==r))}async removeItemsAbove(e){const r=this.items.indexOf(e);return this.removeItems(this.items.filter((l,i)=>i<r))}addItemFromDto(e){const r=this.createItemFromDto(e);return this.addItems([r])}playAll(){return this.playQueue.clearAndSetItems(this.items.map(e=>this.playQueue.createItemFromDto(e.dto))),Promise.resolve()}}I([n.observable],f.prototype,"items",2);I([n.computed],f.prototype,"isEmpty",1);I([n.computed],f.prototype,"hasMultipleItems",1);I([n.computed],f.prototype,"selectedItems",1);I([n.computed],f.prototype,"allItemsSelected",1);I([n.computed],f.prototype,"hasSelectedItems",1);I([n.computed],f.prototype,"selectedItemsOrAllItems",1);I([n.computed],f.prototype,"canAddSelectedItems",1);I([n.computed],f.prototype,"canPlaySelectedItemsNext",1);I([n.computed],f.prototype,"canRemoveSelectedItems",1);I([n.action.bound],f.prototype,"setItems",1);I([n.action.bound],f.prototype,"unselectAll",1);I([n.action.bound],f.prototype,"selectAll",1);I([n.action.bound],f.prototype,"playSelectedItemsNext",1);I([n.action.bound],f.prototype,"addSelectedItems",1);I([n.action.bound],f.prototype,"addItems",1);I([n.action.bound],f.prototype,"moveItem",1);I([n.action.bound],f.prototype,"removeItems",1);I([n.action.bound],f.prototype,"removeSelectedItems",1);I([n.action.bound],f.prototype,"removeOtherItems",1);I([n.action.bound],f.prototype,"removeItemsAbove",1);I([n.action.bound],f.prototype,"addItemFromDto",1);I([n.action.bound],f.prototype,"playAll",1);const Gt=({onClick:t})=>o.jsx(s.EuiButton,{onClick:t,iconType:d.PlayRegular,fill:!0,children:"Play all"}),Jt=({playlistListItem:t,onFulfilled:e})=>{const r=()=>R.show(Nt,{playlistListItem:t}).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.RenameRegular,children:"Rename"})},Kt=({playlistListItem:t,onFulfilled:e})=>{const r=()=>R.show(Tt,{playlistListItem:t}).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.DeleteRegular,children:"Delete"})},Wt=p.observer(({playlistListItem:t})=>{const e=$.playlist(t.id),r=A(),[l]=a.useState(()=>new f(r));_.useLocalStorageState(e,l.localStorageState);const i=W.useRouter(),c=a.useCallback(async v=>{await t.rename(v)},[t]),u=a.useCallback(async()=>{await i.navigate({to:"/playlists"}),window.localStorage.removeItem(e),await t.remove()},[t,i,e]);return o.jsxs(o.Fragment,{children:[o.jsx(oe,{pageTitle:t.name,breadcrumbs:[{text:"Playlists",linkProps:{to:"/playlists"}},{text:t.name}],rightSideItems:[o.jsx(Gt,{onClick:l.playAll}),o.jsx(Jt,{playlistListItem:t,onFulfilled:c}),o.jsx(Kt,{playlistListItem:t,onFulfilled:u})]}),o.jsx(Lt,{playlist:l})]})}),Yt=R.create(({remove:t,resolve:e})=>{const r=s.useGeneratedHtmlId({prefix:"modalForm"}),[l,i]=a.useState(""),[c,u]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=name]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Create playlist"})}),o.jsx(s.EuiModalBody,{children:o.jsx(s.EuiForm,{id:r,component:"form",onSubmit:async v=>{v.preventDefault();try{u(!0),e(l),t()}finally{u(!1)}},children:o.jsx(s.EuiFormRow,{label:"Name",children:o.jsx(s.EuiFieldText,{name:"name",value:l,onChange:v=>i(v.target.value)})})})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:r,fill:!0,disabled:l.trim().length===0,isLoading:c,children:"Create playlist"})]})]})}),Xt=({children:t,onFulfilled:e})=>{const r=()=>R.show(Yt).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.AddRegular,fill:!0,children:t})},Zt=({linkProps:t,...e})=>{const r=W.useRouter(),l=async i=>{i.preventDefault(),await r.navigate(t)};return o.jsx(s.EuiLink,{...e,href:r.buildLocation(t).href,onClick:l})},eo=p.observer(({playlistList:t})=>o.jsx(s.EuiTableHeader,{children:o.jsx(s.EuiTableHeaderCell,{children:"Name"})})),to=p.observer(({item:t})=>o.jsx(s.EuiTableRow,{children:o.jsx(s.EuiTableRowCell,{children:o.jsx(Zt,{linkProps:{to:"/playlists/$playlistId",params:{playlistId:t.id}},children:t.name})})},t.id)),oo=p.observer(({playlistList:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(to,{item:e},e.id))})),so=p.observer(({playlistList:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(eo,{playlistList:t}),o.jsx(oo,{playlistList:t})]})),ro=()=>o.jsx(oe,{pageTitle:"Playlists",breadcrumbs:[{text:"Playlists"}]}),no=p.observer(({playlistList:t})=>{const e=a.useCallback(async r=>{await t.addItem(t.createItem(r))},[t]);return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(Xt,{onFulfilled:e,children:"New playlist"}),o.jsx(s.EuiSpacer,{size:"l"}),o.jsx(so,{playlistList:t})]})}),io=a.memo(()=>{const t=pe();return o.jsxs(o.Fragment,{children:[o.jsx(ro,{}),o.jsx(no,{playlistList:t})]})});exports.BottomBar=dt;exports.HydrangeanDivaProvider=He;exports.MediaPlayerLayout=$e;exports.MiniPlayer=pt;exports.PlayQueueContext=Z;exports.PlayQueuePage=Et;exports.PlayQueueSection=ye;exports.PlaylistDetailsPage=Wt;exports.PlaylistListContext=ee;exports.PlaylistListPage=io;exports.RepeatMode=g;exports.bottomBarHeight=Y;exports.usePlayQueue=A;exports.usePlaylistList=pe;exports.videoServiceIcons=H;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@emotion/react/jsx-runtime"),a=require("react"),be=require("ajv"),n=require("mobx"),_=require("@aigamo/route-sphere"),L=require("lodash-es"),O=require("@aigamo/nostalgic-diva"),s=require("@elastic/eui"),p=require("mobx-react-lite"),d=require("@fluentui/react-icons"),R=require("ez-modal-react"),K=require("react-sortablejs"),W=require("@tanstack/react-router"),Y=81,H=new Map(Object.entries({Audio:"",Dailymotion:"https://www.dailymotion.com/favicon.ico",Niconico:"https://www.nicovideo.jp/favicon.ico",SoundCloud:"https://soundcloud.com/favicon.ico",Twitch:"https://www.twitch.tv/favicon.ico",Vimeo:"https://vimeo.com/favicon.ico",YouTube:"https://www.youtube.com/favicon.ico"})),ve=({components:t=[],children:e})=>o.jsx(o.Fragment,{children:t.reduceRight((r,l)=>o.jsx(l,{children:r}),e)}),$={playQueue:"PlayQueueStore",bottomBar:"BottomBarStore",playlistList:"PlaylistListStore",playlist:t=>`PlaylistStore/${t}`},ne=a.createContext(void 0),E=()=>a.useContext(ne),V=new be({coerceTypes:!0});function X(t,e){let r;if(r=V.getSchema(e),r===void 0&&(V.addSchema(t,e),r=V.getSchema(e)),r===void 0||r.schema!==t)throw new Error(`Invalid schema. Expected: '${JSON.stringify(t)}', but got '${JSON.stringify(r?.schema)}'.`);return r}var g=(t=>(t.Off="Off",t.All="All",t.One="One",t))(g||{}),ge=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,x=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ie(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&ge(e,r,i),i};const fe={type:"object",properties:{repeat:{type:"string",enum:Object.values(g),nullable:!0},shuffle:{type:"boolean",nullable:!0}}};class ie{constructor(e){this.bottomBar=e,n.makeObservable(this)}get state(){return{repeat:this.bottomBar.repeat,shuffle:this.bottomBar.shuffle}}set state(e){this.bottomBar.repeat=e.repeat??g.Off,this.bottomBar.shuffle=e.shuffle??!1}validateState(e){return X(fe,"BottomBarLocalStorageState")(e)}}x([n.computed.struct],ie.prototype,"state",1);class b{constructor(e,r){this.player=e,this.playQueue=r,n.makeObservable(this),this.localStorageState=new ie(this)}localStorageState;repeat=g.Off;shuffle=!1;get controller(){return this.player.controller}get playing(){return this.player.playing}get percent(){return this.player.percent}get canSeek(){return!this.playQueue.isEmpty&&this.controller.supports("setCurrentTime")}get currentItem(){return this.playQueue.currentItem}get canToggleRepeat(){return!0}get canToggleShuffle(){return!1}get canPlay(){return this.playQueue.canPlay&&this.controller.supports("play")}get canPause(){return this.playQueue.canPause&&this.controller.supports("pause")}get canPrevious(){return!this.playQueue.isEmpty}get canNext(){return this.playQueue.hasNextItem}get canSkipBack10(){return this.canSeek}get canSkipForward30(){return this.canSeek}get canRemoveFromPlayQueue(){return!this.playQueue.isEmpty}setPercent(e){this.player.setPercent(e)}setSeeking(e){this.player.setSeeking(e)}toggleRepeat(){switch(this.repeat){case g.Off:this.repeat=g.All;break;case g.All:this.repeat=g.One;break;case g.One:this.repeat=g.Off;break}}toggleShuffle(){this.shuffle=!this.shuffle}play(){return this.controller.play()}pause(){return this.controller.pause()}async previous(){if(this.playQueue.hasPreviousItem){const e=await this.controller.getCurrentTime();e===void 0||e<5?await this.playQueue.previous():await this.controller.setCurrentTime(0)}else await this.controller.setCurrentTime(0)}next(){return this.playQueue.next()}async skipBack10(){const e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e-10)}async skipForward30(){const e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e+30)}async removeFromPlayQueue(){this.currentItem!==void 0&&await this.playQueue.removeItems([this.currentItem])}}x([n.observable],b.prototype,"repeat",2);x([n.observable],b.prototype,"shuffle",2);x([n.computed],b.prototype,"controller",1);x([n.computed],b.prototype,"playing",1);x([n.computed],b.prototype,"percent",1);x([n.computed],b.prototype,"canSeek",1);x([n.computed],b.prototype,"currentItem",1);x([n.computed],b.prototype,"canToggleRepeat",1);x([n.computed],b.prototype,"canToggleShuffle",1);x([n.computed],b.prototype,"canPlay",1);x([n.computed],b.prototype,"canPause",1);x([n.computed],b.prototype,"canPrevious",1);x([n.computed],b.prototype,"canNext",1);x([n.computed],b.prototype,"canSkipBack10",1);x([n.computed],b.prototype,"canSkipForward30",1);x([n.computed],b.prototype,"canRemoveFromPlayQueue",1);x([n.action.bound],b.prototype,"setPercent",1);x([n.action.bound],b.prototype,"setSeeking",1);x([n.action.bound],b.prototype,"toggleRepeat",1);x([n.action.bound],b.prototype,"toggleShuffle",1);x([n.action.bound],b.prototype,"play",1);x([n.action.bound],b.prototype,"pause",1);x([n.action.bound],b.prototype,"previous",1);x([n.action.bound],b.prototype,"next",1);x([n.action.bound],b.prototype,"skipBack10",1);x([n.action.bound],b.prototype,"skipForward30",1);x([n.action.bound],b.prototype,"removeFromPlayQueue",1);const Z=a.createContext(void 0),A=()=>a.useContext(Z),le=a.createContext(void 0),ae=()=>a.useContext(le),Se=({children:t})=>{const e=ae(),r=A(),[l]=a.useState(()=>new b(e,r));return _.useLocalStorageState($.bottomBar,l.localStorageState),o.jsx(ne.Provider,{value:l,children:t})},ce=a.createContext(void 0),je=()=>a.useContext(ce);var Pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,F=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ce(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Pe(e,r,i),i};class B{constructor(e,r,l){this.player=e,this.playQueue=r,this.bottomBar=l,n.makeObservable(this)}interacted=!1;get controller(){return this.player.controller}get currentItem(){return this.playQueue.currentItem}interact(){this.interacted=!0}async onLoaded(){this.interacted&&await this.controller.play()}onPlay(){this.player.onPlay()}onPause(){this.player.onPause()}async onEnded(){switch(this.bottomBar.repeat){case g.One:await this.controller.setCurrentTime(0);break;case g.Off:case g.All:if(this.playQueue.isLastItem)switch(this.bottomBar.repeat){case g.Off:this.player.onEnded();break;case g.All:this.playQueue.hasMultipleItems?await this.playQueue.goToFirst():await this.controller.setCurrentTime(0);break}else await this.playQueue.next();break}}onTimeUpdate(e){this.player.onTimeUpdate(e)}onControllerChange(e){this.player.onControllerChange(e)}}F([n.observable],B.prototype,"interacted",2);F([n.computed],B.prototype,"controller",1);F([n.computed],B.prototype,"currentItem",1);F([n.action.bound],B.prototype,"interact",1);F([n.action.bound],B.prototype,"onLoaded",1);F([n.action.bound],B.prototype,"onPlay",1);F([n.action.bound],B.prototype,"onPause",1);F([n.action.bound],B.prototype,"onEnded",1);F([n.action.bound],B.prototype,"onTimeUpdate",1);F([n.action.bound],B.prototype,"onControllerChange",1);const Ee=({children:t})=>{const e=ae(),r=A(),l=E(),[i]=a.useState(()=>new B(e,r,l));return o.jsx(ce.Provider,{value:i,children:t})},ue={type:"object",properties:{url:{type:"string"},type:{type:"string"},videoId:{type:"string"},title:{type:"string"}},required:["url","type","videoId","title"]},Te={type:"object",properties:{version:{type:"string",nullable:!0},repeat:{type:"string",enum:Object.values(g),nullable:!0},shuffle:{type:"boolean",nullable:!0},items:{type:"array",nullable:!0,items:ue},currentIndex:{type:"integer",nullable:!0}}};var we=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,P=(t,e,r,l)=>{for(var i=l>1?void 0:l?ke(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&we(e,r,i),i};const S=class U{constructor(e,r){this.playQueue=e,this.dto=r,n.makeObservable(this),this.id=U.nextId++}static nextId=1;id;isSelected=!1;static fromDto(e,r){return new U(e,r)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return this.playQueue.currentItem===this}get index(){return this.playQueue.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playQueue.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playQueue.hasMultipleItems}clone(){return this.playQueue.createItemFromDto(this.dto)}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.setCurrentItem(this),Promise.resolve()}remove(){return this.playQueue.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.clone()])}playNext(){return this.playQueue.playNext([this.clone()])}addToPlayQueue(){return this.playQueue.addItems([this.clone()])}moveToTop(){this.playQueue.moveItem(this,0)}moveToBottom(){this.playQueue.moveItem(this,this.playQueue.items.length-1)}removeToTop(){return this.playQueue.removeItemsAbove(this)}removeOthers(){return this.playQueue.removeOtherItems(this)}};P([n.observable],S.prototype,"isSelected",2);P([n.computed],S.prototype,"isCurrent",1);P([n.computed],S.prototype,"index",1);P([n.computed],S.prototype,"isFirst",1);P([n.computed],S.prototype,"isLast",1);P([n.computed],S.prototype,"canMoveToTop",1);P([n.computed],S.prototype,"canMoveToBottom",1);P([n.computed],S.prototype,"canRemoveToTop",1);P([n.computed],S.prototype,"canRemoveOthers",1);P([n.action.bound],S.prototype,"unselect",1);P([n.action.bound],S.prototype,"select",1);P([n.action.bound],S.prototype,"toggleSelected",1);P([n.action.bound],S.prototype,"play",1);P([n.action.bound],S.prototype,"remove",1);P([n.action.bound],S.prototype,"playFirst",1);P([n.action.bound],S.prototype,"playNext",1);P([n.action.bound],S.prototype,"addToPlayQueue",1);P([n.action.bound],S.prototype,"moveToTop",1);P([n.action.bound],S.prototype,"moveToBottom",1);P([n.action.bound],S.prototype,"removeToTop",1);P([n.action.bound],S.prototype,"removeOthers",1);let Be=S;var Fe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,m=(t,e,r,l)=>{for(var i=l>1?void 0:l?Oe(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Fe(e,r,i),i};class de{constructor(e){this.playQueue=e,n.makeObservable(this)}get state(){return{version:"1.0",items:this.playQueue.items.map(e=>e.dto),currentIndex:this.playQueue.currentIndex}}set state(e){this.playQueue.items=e.items?.map(r=>this.playQueue.createItemFromDto(r))??[],this.playQueue.currentIndex=e.currentIndex}validateState(e){return X(Te,"PlayQueueDto")(e)}}m([n.computed.struct],de.prototype,"state",1);class h{localStorageState;items=[];currentId;constructor(){n.makeObservable(this),this.localStorageState=new de(this)}createItemFromDto(e){return Be.fromDto(this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get canClear(){return!this.isEmpty}get currentItem(){return this.items.find(e=>e.id===this.currentId)}get canPlay(){return this.currentItem!==void 0}get canPause(){return this.currentItem!==void 0}get hasMultipleItems(){return this.items.length>1}get currentIndex(){return this.currentId!==void 0?this.items.findIndex(e=>e.id===this.currentId):void 0}set currentIndex(e){this.currentId=e!==void 0?this.items.at(e)?.id:void 0}get hasPreviousItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex>0}get hasNextItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex<this.items.length-1}get isLastItem(){return this.currentIndex!==void 0&&this.currentIndex===this.items.length-1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}clear(){this.currentIndex=void 0,this.items=[]}unselectAll(){for(const e of this.items)e.unselect()}selectAll(){for(const e of this.items)e.select()}setCurrentItem(e){this.currentId=e?.id}setNextItems(e){this.currentIndex!==void 0&&this.items.splice(this.currentIndex+1,0,...e)}clearAndSetItems(e){this.clear(),this.setCurrentItem(e[0]),this.setNextItems(e)}async playNext(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.setNextItems(e)}async playSelectedItemsNext(){await this.playNext(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async addItems(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.items.push(...e)}async addSelectedItems(){await this.addItems(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async playFirst(e){if(this.isEmpty){this.clearAndSetItems(e);return}const{currentIndex:r}=this;r!==void 0&&(this.items.splice(r,0,...e),this.currentIndex=r)}moveItem(e,r){const l=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(r,0,l)}async goToFirst(){this.currentIndex!==void 0&&(this.currentIndex=0)}async removeItems(e){const{currentItem:r}=this;L.pull(this.items,...e.filter(c=>c!==r));const{currentIndex:l,isLastItem:i}=this;L.pull(this.items,e.find(c=>c===r)),this.currentItem!==r&&(i?await this.goToFirst():this.currentIndex=l)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){const r=e.id;return this.removeItems(this.items.filter(l=>l.id!==r))}async removeItemsAbove(e){const r=this.items.indexOf(e);return this.removeItems(this.items.filter((l,i)=>i<r))}async previous(){this.currentIndex!==void 0&&this.hasPreviousItem&&this.currentIndex--}async next(){this.currentIndex!==void 0&&this.hasNextItem&&this.currentIndex++}addItemFromDto(e){const r=this.createItemFromDto(e);return this.addItems([r])}}m([n.observable],h.prototype,"items",2);m([n.observable],h.prototype,"currentId",2);m([n.computed],h.prototype,"isEmpty",1);m([n.computed],h.prototype,"canClear",1);m([n.computed],h.prototype,"currentItem",1);m([n.computed],h.prototype,"canPlay",1);m([n.computed],h.prototype,"canPause",1);m([n.computed],h.prototype,"hasMultipleItems",1);m([n.computed],h.prototype,"currentIndex",1);m([n.computed],h.prototype,"hasPreviousItem",1);m([n.computed],h.prototype,"hasNextItem",1);m([n.computed],h.prototype,"isLastItem",1);m([n.computed],h.prototype,"selectedItems",1);m([n.computed],h.prototype,"allItemsSelected",1);m([n.computed],h.prototype,"hasSelectedItems",1);m([n.computed],h.prototype,"selectedItemsOrAllItems",1);m([n.computed],h.prototype,"canAddSelectedItems",1);m([n.computed],h.prototype,"canPlaySelectedItemsNext",1);m([n.computed],h.prototype,"canRemoveSelectedItems",1);m([n.action.bound],h.prototype,"setItems",1);m([n.action.bound],h.prototype,"clear",1);m([n.action.bound],h.prototype,"unselectAll",1);m([n.action.bound],h.prototype,"selectAll",1);m([n.action.bound],h.prototype,"setCurrentItem",1);m([n.action.bound],h.prototype,"setNextItems",1);m([n.action.bound],h.prototype,"clearAndSetItems",1);m([n.action.bound],h.prototype,"playNext",1);m([n.action.bound],h.prototype,"playSelectedItemsNext",1);m([n.action.bound],h.prototype,"addItems",1);m([n.action.bound],h.prototype,"addSelectedItems",1);m([n.action.bound],h.prototype,"playFirst",1);m([n.action.bound],h.prototype,"moveItem",1);m([n.action.bound],h.prototype,"goToFirst",1);m([n.action.bound],h.prototype,"removeItems",1);m([n.action.bound],h.prototype,"removeSelectedItems",1);m([n.action.bound],h.prototype,"removeOtherItems",1);m([n.action.bound],h.prototype,"removeItemsAbove",1);m([n.action.bound],h.prototype,"previous",1);m([n.action.bound],h.prototype,"next",1);m([n.action.bound],h.prototype,"addItemFromDto",1);const Re=({children:t})=>{const[e]=a.useState(()=>new h);_.useLocalStorageState($.playQueue,e.localStorageState);const r=O.useNostalgicDiva();return a.useEffect(()=>n.reaction(()=>e.currentItem,async(l,i)=>{l===void 0||i===void 0||l.type===i.type&&l.videoId===i.videoId&&await r.setCurrentTime(0)}),[e,r]),o.jsx(Z.Provider,{value:e,children:t})};var Ae=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,w=(t,e,r,l)=>{for(var i=l>1?void 0:l?Me(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Ae(e,r,i),i};class T{controller=O.nullPlayerController;playing=!1;percent=0;seeking=!1;constructor(){n.makeObservable(this)}setPlaying(e){this.playing=e}setPercent(e){this.percent=e}setSeeking(e){this.seeking=e}onControllerChange(e){this.controller=e}onPlay(){this.playing=!0}onPause(){this.playing=!1}onEnded(){this.playing=!1}onTimeUpdate({percent:e}){e!==void 0&&(this.seeking||(this.percent=e))}}w([n.observable],T.prototype,"controller",2);w([n.observable],T.prototype,"playing",2);w([n.observable],T.prototype,"percent",2);w([n.observable],T.prototype,"seeking",2);w([n.action.bound],T.prototype,"setPlaying",1);w([n.action.bound],T.prototype,"setPercent",1);w([n.action.bound],T.prototype,"setSeeking",1);w([n.action.bound],T.prototype,"onControllerChange",1);w([n.action.bound],T.prototype,"onPlay",1);w([n.action.bound],T.prototype,"onPause",1);w([n.action.bound],T.prototype,"onEnded",1);w([n.action.bound],T.prototype,"onTimeUpdate",1);const De=({children:t})=>{const[e]=a.useState(()=>new T);return o.jsx(le.Provider,{value:e,children:t})},ee=a.createContext(void 0),pe=()=>a.useContext(ee);var Qe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,q=(t,e,r,l)=>{for(var i=l>1?void 0:l?ze(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Qe(e,r,i),i};class M{constructor(e,r,l){this.playlistList=e,n.makeObservable(this),this.id=r,this.name=l}id;name;async rename(e){this.name=e}remove(){return this.playlistList.removeItem(this)}}q([n.observable],M.prototype,"id",2);q([n.observable],M.prototype,"name",2);q([n.action.bound],M.prototype,"rename",1);q([n.action.bound],M.prototype,"remove",1);var Ne=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,z=(t,e,r,l)=>{for(var i=l>1?void 0:l?Le(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&Ne(e,r,i),i};class me{constructor(e){this.playlistList=e,n.makeObservable(this)}get state(){return{items:this.playlistList.items.map(e=>({id:e.id,name:e.name}))}}set state(e){this.playlistList.items=e.items?.map(r=>new M(this.playlistList,r.id,r.name))??[]}validateState(e){return!0}}z([n.computed.struct],me.prototype,"state",1);class N{localStorageState;items=[];constructor(){n.makeObservable(this),this.localStorageState=new me(this)}createItem(e){return new M(this,crypto.randomUUID(),e)}setItems(e){this.items=e}async addItem(e){this.items.push(e)}async removeItem(e){L.pull(this.items,e)}}z([n.observable],N.prototype,"items",2);z([n.action.bound],N.prototype,"setItems",1);z([n.action.bound],N.prototype,"addItem",1);z([n.action.bound],N.prototype,"removeItem",1);const _e=({children:t})=>{const[e]=a.useState(()=>new N);return _.useLocalStorageState($.playlistList,e.localStorageState),o.jsx(ee.Provider,{value:e,children:t})},He=({children:t,nostalgicDivaProps:e})=>o.jsx(O.NostalgicDivaProvider,{...e,children:o.jsx(ve,{components:[De,Re,Se,Ee,_e],children:t})}),G={width:400,height:225},$e=p.observer(({children:t})=>{const e=A();return o.jsxs(s.EuiPageTemplate,{panelled:!0,style:{minBlockSize:`max(460px, 100vh - ${Y}px)`},children:[t,!e.isEmpty&&o.jsx(s.EuiSpacer,{style:{blockSize:G.height}})]})}),qe=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:`Shuffle: ${t.shuffle?"On":"Off"}`,"aria-label":`Shuffle: ${t.shuffle?"On":"Off"}`,iconType:t.shuffle?d.ArrowShuffleFilled:d.ArrowShuffleOffFilled,size:"s",iconSize:"l",onClick:t.toggleShuffle,disabled:!t.canToggleShuffle})}),Ve=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Previous","aria-label":"Previous",iconType:d.PreviousFilled,size:"s",iconSize:"l",onClick:t.previous,disabled:!t.canPrevious})}),Ue=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Skip back 10 seconds","aria-label":"Skip back 10 seconds",iconType:d.SkipBack10Regular,size:"s",iconSize:"l",onClick:t.skipBack10,disabled:!t.canSkipBack10})}),Ge=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Pause","aria-label":"Pause",iconType:d.PauseFilled,size:"s",iconSize:"l",onClick:t.pause,disabled:!t.canPause})}),Je=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Play","aria-label":"Play",iconType:d.PlayFilled,size:"s",iconSize:"l",onClick:t.play,disabled:!t.canPlay})}),Ke=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Skip forward 30 seconds","aria-label":"Skip forward 30 seconds",iconType:d.SkipForward30Regular,size:"s",iconSize:"l",onClick:t.skipForward30,disabled:!t.canSkipForward30})}),We=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Next","aria-label":"Next",iconType:d.NextFilled,size:"s",iconSize:"l",onClick:t.next,disabled:!t.canNext})}),he={[g.Off]:d.ArrowRepeatAllOffFilled,[g.All]:d.ArrowRepeatAllFilled,[g.One]:d.ArrowRepeat1Filled},Ye=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:`Repeat: ${t.repeat===g.All?"All":t.repeat===g.One?"One":"Off"}`,"aria-label":`Repeat: ${t.repeat===g.All?"All":t.repeat===g.One?"One":"Off"}`,iconType:he[t.repeat],size:"s",iconSize:"l",onClick:t.toggleRepeat,disabled:!t.canToggleRepeat})}),Xe=p.observer(()=>{const t=E();return o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center",children:[o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(qe,{})}),o.jsx(Ve,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ue,{})}),t.playing?o.jsx(Ge,{}):o.jsx(Je,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ke,{})}),o.jsx(We,{}),o.jsx(s.EuiHideFor,{sizes:["xs"],children:o.jsx(Ye,{})})]})}),Ze=a.memo(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,onClick:u})=>({name:i,icon:c,onClick:async v=>{e(),u(v)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Open in new tab",icon:o.jsx(s.EuiIcon,{type:d.OpenRegular}),onClick:async()=>{window.open(t.dto.url,"_blank")}}),r({name:"Copy link address",icon:o.jsx(s.EuiIcon,{type:""}),onClick:async()=>{await navigator.clipboard.writeText(t.dto.url)}}),r({name:"Copy link text",icon:o.jsx(s.EuiIcon,{type:""}),onClick:async()=>{await navigator.clipboard.writeText(t.dto.title)}})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),et=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonEmpty,{iconType:H.get(t.type),size:"s",onClick:l,children:t.title}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"upLeft",children:o.jsx(Ze,{item:t,closePopover:i})})}),tt=p.observer(()=>{const t=E();return o.jsx(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"flexStart",alignItems:"center",children:t.currentItem&&o.jsx(et,{item:t.currentItem})})}),ot=p.observer(()=>{const t=E();return o.jsx(s.EuiButtonIcon,{title:"Mute","aria-label":"Mute",iconType:d.Speaker2Regular,size:"s",iconSize:"l",disabled:!t.controller.supports("setMuted")})}),st=p.observer(({button:t,isOpen:e,closePopover:r})=>{const l=E(),[i,c]=a.useState("0"),u=O.useNostalgicDiva();a.useLayoutEffect(()=>{e&&u.getVolume().then(y=>{y!==void 0&&c(Math.floor(y*100).toString())})},[e,u]);const v=a.useCallback(async y=>{c(y.currentTarget.value),await u.setVolume(Number(y.currentTarget.value)/100)},[u]);return o.jsx(s.EuiPopover,{button:t,isOpen:e,closePopover:r,anchorPosition:"upRight",children:o.jsx(s.EuiFormRow,{children:o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center",children:[o.jsx(ot,{}),o.jsx(s.EuiRange,{min:0,max:100,step:1,value:i,onChange:v,css:{blockSize:32},disabled:!l.controller.supports("setVolume")})]})})})}),rt=p.observer(()=>{const t=E(),[e,r]=a.useState(!1),l=()=>r(!e);return o.jsx(st,{button:o.jsx(s.EuiButtonIcon,{title:"Volume","aria-label":"Volume",iconType:d.Speaker2Regular,size:"s",iconSize:"l",onClick:l,disabled:!t.controller.supports("getVolume")}),isOpen:e,closePopover:()=>r(!1)})}),nt=({onClickPlayQueueButton:t})=>o.jsx(s.EuiButtonIcon,{title:"Play queue","aria-label":"Play queue",iconType:d.NavigationPlayRegular,size:"s",iconSize:"l",onClick:t}),it=p.observer(({closePopover:t})=>{const e=E(),r=O.useNostalgicDiva(),[l,i]=a.useState(),c=a.useCallback(async()=>{await e.controller.getPlaybackRate().then(y=>i(y))},[e]),u=a.useCallback(({name:y,icon:k,onClick:D,disabled:Q,className:se})=>({name:y,icon:k,onClick:async()=>{t(),D()},disabled:Q,className:se}),[t]),v=a.useMemo(()=>[{id:0,items:[{name:"Speed",icon:o.jsx(s.EuiIcon,{type:d.TopSpeedRegular}),panel:1,onClick:c,disabled:!e.controller.supports("getPlaybackRate")},u({name:"Skip back 10 seconds",icon:o.jsx(s.EuiIcon,{type:d.SkipBack10Regular}),onClick:e.skipBack10,disabled:!e.canSkipBack10}),u({name:"Skip forward 30 seconds",icon:o.jsx(s.EuiIcon,{type:d.SkipForward30Regular}),onClick:e.skipForward30,disabled:!e.canSkipForward30}),u({name:`Shuffle: ${e.shuffle?"On":"Off"}`,icon:o.jsx(s.EuiIcon,{type:e.shuffle?d.ArrowShuffleFilled:d.ArrowShuffleOffFilled}),onClick:e.toggleShuffle,disabled:!e.canToggleShuffle,className:"eui-showFor--xs--flex"}),u({name:`Repeat: ${e.repeat===g.All?"All":e.repeat===g.One?"One":"Off"}`,icon:o.jsx(s.EuiIcon,{type:he[e.repeat]}),onClick:e.toggleRepeat,disabled:!e.canToggleRepeat,className:"eui-showFor--xs--flex"}),{isSeparator:!0},u({name:"Remove from play queue",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:e.removeFromPlayQueue,disabled:!e.canRemoveFromPlayQueue})]},{id:1,title:"Speed",items:[.25,.5,.75,1,1.25,1.5,1.75,2].map(y=>u({name:y.toString(),onClick:()=>r.setPlaybackRate(y),icon:y===l?"check":"empty",disabled:!e.controller.supports("setPlaybackRate")}))}],[e,u,c,r,l]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:v})}),lt=a.memo(({button:t,isOpen:e,closePopover:r})=>o.jsx(s.EuiPopover,{button:t,isOpen:e,closePopover:r,panelPaddingSize:"none",anchorPosition:"upRight",children:o.jsx(it,{closePopover:r})})),at=a.memo(()=>{const[t,e]=a.useState(!1),r=()=>e(!t);return o.jsx(lt,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",iconSize:"l",onClick:r}),isOpen:t,closePopover:()=>e(!1)})}),ct=a.memo(({onClickPlayQueueButton:t})=>o.jsxs(s.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"flexEnd",alignItems:"center",children:[o.jsx(rt,{}),t&&o.jsx(nt,{onClickPlayQueueButton:t}),o.jsx(at,{})]})),ut=p.observer(()=>{const t=E(),e=O.useNostalgicDiva(),r=a.useCallback(c=>{const u=Number(c.currentTarget.value)/100;t.setPercent(u)},[t]),l=a.useCallback(c=>{c.button===0&&t.setSeeking(!0)},[t]),i=a.useCallback(async c=>{if(c.button===0){const u=Number(c.currentTarget.value)/100;t.setSeeking(!1);const v=await e.getDuration();v!==void 0&&await e.setCurrentTime(v*u)}},[t,e]);return o.jsx(s.EuiRange,{min:0,max:100,step:1e-7,value:t.percent*100,onChange:r,onMouseDown:l,onMouseUp:i,fullWidth:!0,showRange:!0,css:{blockSize:32},disabled:!t.canSeek})}),dt=p.observer(({onClickPlayQueueButton:t})=>o.jsx(s.EuiBottomBar,{paddingSize:"s",children:o.jsxs(s.EuiFlexGroup,{direction:"column",gutterSize:"none",children:[o.jsx(s.EuiFlexItem,{children:o.jsx(ut,{})}),o.jsx(s.EuiFlexItem,{children:o.jsxs(s.EuiFlexGroup,{responsive:!1,children:[o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(tt,{})}),o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(Xe,{})}),o.jsx(s.EuiFlexItem,{css:{width:"calc(100% / 3)"},children:o.jsx(ct,{onClickPlayQueueButton:t})})]})})]})})),pt=p.observer(()=>{const t=je(),e=a.useMemo(()=>({onLoaded:t.onLoaded,onPlay:t.onPlay,onPause:t.onPause,onEnded:t.onEnded,onTimeUpdate:t.onTimeUpdate}),[t]);return a.useEffect(()=>n.reaction(()=>t.currentItem,t.interact),[t]),o.jsx("div",{css:{position:"fixed",right:0,bottom:Y,width:G.width,height:G.height,zIndex:998,backgroundColor:"rgb(39, 39, 39)",display:"flex",flexDirection:"column"},children:o.jsx("div",{css:{flexGrow:1,backgroundColor:"black"},children:t.currentItem&&o.jsx(O.NostalgicDiva,{src:t.currentItem.url,options:e,onControllerChange:t.onControllerChange})})})});function mt(t){return t!==null&&typeof t=="object"&&"title"in t&&typeof t.title=="string"}const ht=R.create(({remove:t,resolve:e})=>{const r=s.useGeneratedHtmlId({prefix:"modalForm"}),[l,i]=a.useState(""),[c,u]=a.useState(""),[v,y]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=url]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Add video"})}),o.jsx(s.EuiModalBody,{children:o.jsxs(s.EuiForm,{id:r,component:"form",onSubmit:async k=>{k.preventDefault();try{y(!0);const D=O.findVideoService(l);if(D===void 0)return;const Q=D.extractVideoId(l);if(Q===void 0)return;const re=await(await fetch(`https://noembed.com/embed?url=${encodeURIComponent(l)}`)).json();e({url:l,type:D.type,videoId:Q,title:c||(mt(re)?re.title:Q)}),t()}finally{y(!1)}},children:[o.jsx(s.EuiFormRow,{label:"URL",children:o.jsx(s.EuiFieldText,{name:"url",value:l,onChange:k=>i(k.target.value)})}),o.jsx(s.EuiFormRow,{label:"Title",children:o.jsx(s.EuiFieldText,{name:"title",value:c,onChange:k=>u(k.target.value)})})]})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:r,fill:!0,disabled:l.trim().length===0,isLoading:v,children:"Add video"})]})]})}),te=a.memo(({onFulfilled:t})=>{const e=()=>R.show(ht).then(t);return o.jsx(s.EuiButton,{onClick:e,iconType:d.AddRegular,color:"primary",children:"Add video"})}),yt=p.observer(({playQueue:t})=>o.jsx(s.EuiButton,{iconType:d.AddRegular,onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems,children:"Add to play queue"})),xt=p.observer(({playQueue:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v})=>({name:i,icon:c,disabled:u,onClick:async y=>{e(),v(y)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems}),r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems}),r({name:"Clear",icon:o.jsx(s.EuiIcon,{type:d.DeleteRegular}),onClick:t.clear,disabled:!t.canClear})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),bt=a.memo(({playQueue:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{display:"base",size:"m",iconType:d.MoreHorizontalFilled,onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"downLeft",children:o.jsx(xt,{playQueue:t,closePopover:i})})}),vt=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiFlexGroup,{alignItems:"center",gutterSize:"m",responsive:!1,style:{position:"sticky",top:48,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext,children:"Play next"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(yt,{playQueue:t})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DismissRegular,onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems,children:"Remove"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DeleteRegular,onClick:t.clear,disabled:!t.canClear,children:"Clear"})})]}),o.jsx(s.EuiShowFor,{sizes:["xs"],children:o.jsx(bt,{playQueue:t})}),o.jsx(s.EuiFlexItem,{grow:!0}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(te,{onFulfilled:t.addItemFromDto})})]})}),gt=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(o.Fragment,{children:[o.jsx(s.EuiTableHeaderMobile,{children:o.jsx(s.EuiFlexGroup,{responsive:!1,justifyContent:"spaceBetween",alignItems:"baseline",children:o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:r=>{r.target.checked?t.selectAll():t.unselectAll()}})})})}),o.jsxs(s.EuiTableHeader,{style:{position:"sticky",top:112,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsx(s.EuiTableHeaderCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:r=>{r.target.checked?t.selectAll():t.unselectAll()}})}),o.jsx(s.EuiTableHeaderCell,{width:24}),o.jsx(s.EuiTableHeaderCell,{children:"Title"}),o.jsx(s.EuiTableHeaderCell,{})]})]})}),It=p.observer(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v,className:y})=>({name:i,icon:c,disabled:u,onClick:async k=>{e(),v(k)},className:y}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play",icon:o.jsx(s.EuiIcon,{type:d.PlayRegular}),onClick:t.play,className:"eui-showFor--xs--flex"}),r({name:"Play first",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playFirst}),r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addToPlayQueue}),{isSeparator:!0},r({name:"Move to the top",icon:o.jsx(s.EuiIcon,{type:d.ArrowUploadRegular}),onClick:t.moveToTop,disabled:!t.canMoveToTop}),r({name:"Move to the bottom",icon:o.jsx(s.EuiIcon,{type:d.ArrowDownloadRegular}),onClick:t.moveToBottom,disabled:!t.canMoveToBottom}),{isSeparator:!0},r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.remove,className:"eui-showFor--xs--flex"}),r({name:"Remove to the top",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeToTop,disabled:!t.canRemoveToTop}),r({name:"Remove others",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeOthers,disabled:!t.canRemoveOthers})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),ft=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",color:"text",onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"leftCenter",children:o.jsx(It,{item:t,closePopover:i})})}),St=p.observer(({item:t})=>{const e=O.useNostalgicDiva();return o.jsxs(s.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:"right",children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiButton,{iconType:d.PlayRegular,size:"s",onClick:async()=>{t.isCurrent?await e.setCurrentTime(0):await t.play()},children:"Play"}),o.jsx(s.EuiButton,{iconType:d.DismissRegular,size:"s",onClick:t.remove,children:"Remove"})]}),o.jsx(ft,{item:t})]})}),jt=p.observer(({item:t})=>o.jsxs(s.EuiTableRow,{isSelected:t.isCurrent,hasSelection:!0,hasActions:!0,children:[o.jsx(s.EuiTableRowCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:t.id.toString(),checked:t.isSelected,onChange:t.toggleSelected})}),o.jsx(s.EuiTableRowCell,{textOnly:!1,children:o.jsx("img",{src:H.get(t.type),width:16,height:16,alt:t.type})}),o.jsx(s.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:"100%"},children:o.jsx(s.EuiLink,{href:t.url,target:"_blank",external:!0,children:t.title})}),o.jsx(St,{item:t})]})),Pt=p.observer(({playQueue:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(jt,{item:e},e.id))})),Ct=p.observer(({playQueue:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(gt,{playQueue:t}),o.jsx(Pt,{playQueue:t})]})),ye=p.observer(({playQueue:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(vt,{playQueue:t}),o.jsx(s.EuiSpacer,{size:"l",style:{position:"sticky",top:88,zIndex:998,background:e.colors.backgroundBasePlain}}),t.isEmpty?o.jsx(s.EuiEmptyPrompt,{title:o.jsx("h2",{children:"We couldn't find any videos"}),body:o.jsx("p",{children:"Your video library doesn't contain any video content."}),actions:o.jsx(te,{onFulfilled:t.addItemFromDto})}):o.jsx(Ct,{playQueue:t})]})}),oe=({breadcrumbs:t,tabs:e,...r})=>{const l=W.useRouter();return o.jsx(s.EuiPageTemplate.Header,{...r,breadcrumbs:t?.map(({linkProps:i,...c})=>({...c,href:i===void 0?void 0:l.buildLocation(i).href,onClick:i===void 0?void 0:async u=>{u.preventDefault(),await l.navigate(i)}})),tabs:e?.map(({linkProps:i,...c})=>({...c,href:i===void 0?void 0:l.buildLocation(i).href,onClick:i===void 0?void 0:async u=>{u.preventDefault(),await l.navigate(i)}}))})},Et=()=>{const t=A();return o.jsxs(o.Fragment,{children:[o.jsx(oe,{pageTitle:"Play queue",rightSideItems:[]}),o.jsx(ye,{playQueue:t})]})},Tt=R.create(({remove:t,resolve:e,playlistListItem:r})=>{const[l,i]=a.useState(!1),c=a.useCallback(async()=>{try{i(!0),e(),t()}finally{i(!1)}},[e,t]);return o.jsx(s.EuiConfirmModal,{title:"Delete playlist permanently?",onCancel:t,onConfirm:c,cancelButtonText:"Cancel",confirmButtonText:"Delete",buttonColor:"danger",isLoading:l,children:o.jsxs("p",{children:["Are you sure you want to delete this playlist? If you delete '",r.name,"', you won't be able to recover it."]})})}),wt=p.observer(({playlist:t})=>o.jsx(s.EuiButton,{iconType:d.AddRegular,onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems,children:"Add to play queue"})),kt=p.observer(({playlist:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v})=>({name:i,icon:c,disabled:u,onClick:async y=>{e(),v(y)}}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addSelectedItems,disabled:!t.canAddSelectedItems}),r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),Bt=a.memo(({playlist:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{display:"base",size:"m",iconType:d.MoreHorizontalFilled,onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"downLeft",children:o.jsx(kt,{playlist:t,closePopover:i})})}),Ft=p.observer(({playlist:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiFlexGroup,{alignItems:"center",gutterSize:"m",responsive:!1,style:{position:"sticky",top:48,zIndex:998,background:e.colors.backgroundBasePlain},children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{disabled:!t.canPlaySelectedItemsNext,onClick:t.playSelectedItemsNext,children:"Play next"})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(wt,{playlist:t})}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiButton,{iconType:d.DismissRegular,onClick:t.removeSelectedItems,disabled:!t.canRemoveSelectedItems,children:"Remove"})})]}),o.jsx(s.EuiShowFor,{sizes:["xs"],children:o.jsx(Bt,{playlist:t})}),o.jsx(s.EuiFlexItem,{grow:!0}),o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(te,{onFulfilled:t.addItemFromDto})})]})}),Ot=p.observer(({playlist:t})=>o.jsxs(o.Fragment,{children:[o.jsx(s.EuiTableHeaderMobile,{children:o.jsx(s.EuiFlexGroup,{responsive:!1,justifyContent:"spaceBetween",alignItems:"baseline",children:o.jsx(s.EuiFlexItem,{grow:!1,children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:e=>{e.target.checked?t.selectAll():t.unselectAll()}})})})}),o.jsxs(s.EuiTableHeader,{children:[o.jsx(s.EuiTableHeaderCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:"",checked:t.allItemsSelected,onChange:e=>{e.target.checked?t.selectAll():t.unselectAll()}})}),o.jsx(s.EuiTableHeaderCell,{width:24}),o.jsx(s.EuiTableHeaderCell,{children:"Title"}),o.jsx(s.EuiTableHeaderCell,{})]})]})),Rt=a.memo(({item:t,closePopover:e})=>{const r=a.useCallback(({name:i,icon:c,disabled:u,onClick:v,className:y})=>({name:i,icon:c,disabled:u,onClick:async k=>{e(),v(k)},className:y}),[e]),l=a.useMemo(()=>[{id:0,items:[r({name:"Play",icon:o.jsx(s.EuiIcon,{type:d.PlayRegular}),onClick:t.play,className:"eui-showFor--xs--flex"}),r({name:"Play first",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playFirst}),r({name:"Play next",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.playNext}),r({name:"Add to play queue",icon:o.jsx(s.EuiIcon,{type:d.AddRegular}),onClick:t.addToPlayQueue}),{isSeparator:!0},r({name:"Move to the top",icon:o.jsx(s.EuiIcon,{type:d.ArrowUploadRegular}),onClick:t.moveToTop,disabled:!t.canMoveToTop}),r({name:"Move to the bottom",icon:o.jsx(s.EuiIcon,{type:d.ArrowDownloadRegular}),onClick:t.moveToBottom,disabled:!t.canMoveToBottom}),{isSeparator:!0},r({name:"Remove",icon:o.jsx(s.EuiIcon,{type:d.DismissRegular}),onClick:t.remove,className:"eui-showFor--xs--flex"}),r({name:"Remove to the top",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeToTop,disabled:!t.canRemoveToTop}),r({name:"Remove others",icon:o.jsx(s.EuiIcon,{type:""}),onClick:t.removeOthers,disabled:!t.canRemoveOthers})]}],[r,t]);return o.jsx(s.EuiContextMenu,{initialPanelId:0,panels:l})}),At=a.memo(({item:t})=>{const[e,r]=a.useState(!1),l=a.useCallback(()=>r(!e),[e]),i=a.useCallback(()=>r(!1),[]);return o.jsx(s.EuiPopover,{button:o.jsx(s.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:d.MoreHorizontalFilled,size:"s",color:"text",onClick:l}),isOpen:e,closePopover:i,panelPaddingSize:"none",anchorPosition:"leftCenter",children:o.jsx(Rt,{item:t,closePopover:i})})}),Mt=p.observer(({item:t})=>o.jsxs(s.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:"right",children:[o.jsxs(s.EuiHideFor,{sizes:["xs"],children:[o.jsx(s.EuiButton,{iconType:d.PlayRegular,size:"s",onClick:t.play,children:"Play"}),o.jsx(s.EuiButton,{iconType:d.DismissRegular,size:"s",onClick:t.remove,children:"Remove"})]}),o.jsx(At,{item:t})]})),Dt=p.observer(({item:t})=>o.jsxs(s.EuiTableRow,{isSelected:t.isCurrent,hasSelection:!0,hasActions:!0,children:[o.jsx(s.EuiTableRowCellCheckbox,{children:o.jsx(s.EuiCheckbox,{id:t.id.toString(),checked:t.isSelected,onChange:t.toggleSelected})}),o.jsx(s.EuiTableRowCell,{textOnly:!1,children:o.jsx("img",{src:H.get(t.type),width:16,height:16,alt:t.type})}),o.jsx(s.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:"100%"},children:o.jsx(s.EuiLink,{href:t.url,target:"_blank",external:!0,children:t.title})}),o.jsx(Mt,{item:t})]})),Qt=p.observer(({playlist:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(Dt,{item:e},e.id))})),zt=p.observer(({playlist:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(Ot,{playlist:t}),o.jsx(Qt,{playlist:t})]})),Nt=p.observer(({playlist:t})=>{const{euiTheme:e}=s.useEuiTheme();return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(Ft,{playlist:t}),o.jsx(s.EuiSpacer,{size:"l",style:{position:"sticky",top:88,zIndex:998,background:e.colors.backgroundBasePlain}}),t.isEmpty?o.jsx(o.Fragment,{}):o.jsx(zt,{playlist:t})]})}),Lt=R.create(({remove:t,resolve:e,playlistListItem:r})=>{const l=s.useGeneratedHtmlId({prefix:"modalForm"}),[i,c]=a.useState(r.name),[u,v]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=name]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Rename playlist"})}),o.jsx(s.EuiModalBody,{children:o.jsx(s.EuiForm,{id:l,component:"form",onSubmit:async y=>{y.preventDefault();try{v(!0),e(i),t()}finally{v(!1)}},children:o.jsx(s.EuiFormRow,{label:"Name",children:o.jsx(s.EuiFieldText,{name:"name",value:i,onChange:y=>c(y.target.value)})})})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:l,fill:!0,disabled:i.trim().length===0,isLoading:u,children:"Rename"})]})]})});var _t=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,C=(t,e,r,l)=>{for(var i=l>1?void 0:l?Ht(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&_t(e,r,i),i};const j=class J{constructor(e,r,l){this.playQueue=e,this.playlist=r,this.dto=l,n.makeObservable(this),this.id=J.nextId++}static nextId=1;id;isSelected=!1;static fromDto(e,r,l){return new J(e,r,l)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return!1}get index(){return this.playlist.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playlist.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playlist.hasMultipleItems}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.clearAndSetItems([this.playQueue.createItemFromDto(this.dto)]),Promise.resolve()}remove(){return this.playlist.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.playQueue.createItemFromDto(this.dto)])}playNext(){return this.playQueue.playNext([this.playQueue.createItemFromDto(this.dto)])}addToPlayQueue(){return this.playQueue.addItems([this.playQueue.createItemFromDto(this.dto)])}moveToTop(){this.playlist.moveItem(this,0)}moveToBottom(){this.playlist.moveItem(this,this.playlist.items.length-1)}removeToTop(){return this.playlist.removeItemsAbove(this)}removeOthers(){return this.playlist.removeOtherItems(this)}};C([n.observable],j.prototype,"isSelected",2);C([n.computed],j.prototype,"isCurrent",1);C([n.computed],j.prototype,"index",1);C([n.computed],j.prototype,"isFirst",1);C([n.computed],j.prototype,"isLast",1);C([n.computed],j.prototype,"canMoveToTop",1);C([n.computed],j.prototype,"canMoveToBottom",1);C([n.computed],j.prototype,"canRemoveToTop",1);C([n.computed],j.prototype,"canRemoveOthers",1);C([n.action.bound],j.prototype,"unselect",1);C([n.action.bound],j.prototype,"select",1);C([n.action.bound],j.prototype,"toggleSelected",1);C([n.action.bound],j.prototype,"play",1);C([n.action.bound],j.prototype,"remove",1);C([n.action.bound],j.prototype,"playFirst",1);C([n.action.bound],j.prototype,"playNext",1);C([n.action.bound],j.prototype,"addToPlayQueue",1);C([n.action.bound],j.prototype,"moveToTop",1);C([n.action.bound],j.prototype,"moveToBottom",1);C([n.action.bound],j.prototype,"removeToTop",1);C([n.action.bound],j.prototype,"removeOthers",1);let $t=j;var qt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,I=(t,e,r,l)=>{for(var i=l>1?void 0:l?Vt(e,r):e,c=t.length-1,u;c>=0;c--)(u=t[c])&&(i=(l?u(e,r,i):u(i))||i);return l&&i&&qt(e,r,i),i};const Ut={type:"object",properties:{version:{type:"string",nullable:!0},items:{type:"array",nullable:!0,items:ue}}};class xe{constructor(e){this.playlist=e,n.makeObservable(this)}get state(){return{version:"1.0",items:this.playlist.items.map(e=>e.dto)}}set state(e){this.playlist.items=e.items?.map(r=>this.playlist.createItemFromDto(r))??[]}validateState(e){return X(Ut,"PlaylistLocalStorageState")(e)}}I([n.computed.struct],xe.prototype,"state",1);class f{constructor(e){this.playQueue=e,n.makeObservable(this),this.localStorageState=new xe(this)}localStorageState;items=[];createItemFromDto(e){return $t.fromDto(this.playQueue,this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get hasMultipleItems(){return this.items.length>1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}unselectAll(){for(const e of this.items)e.unselect()}selectAll(){for(const e of this.items)e.select()}async playSelectedItemsNext(){await this.playQueue.playNext(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addSelectedItems(){await this.playQueue.addItems(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addItems(e){this.items.push(...e)}moveItem(e,r){const l=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(r,0,l)}async removeItems(e){L.pull(this.items,...e)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){const r=e.id;return this.removeItems(this.items.filter(l=>l.id!==r))}async removeItemsAbove(e){const r=this.items.indexOf(e);return this.removeItems(this.items.filter((l,i)=>i<r))}addItemFromDto(e){const r=this.createItemFromDto(e);return this.addItems([r])}playAll(){return this.playQueue.clearAndSetItems(this.items.map(e=>this.playQueue.createItemFromDto(e.dto))),Promise.resolve()}}I([n.observable],f.prototype,"items",2);I([n.computed],f.prototype,"isEmpty",1);I([n.computed],f.prototype,"hasMultipleItems",1);I([n.computed],f.prototype,"selectedItems",1);I([n.computed],f.prototype,"allItemsSelected",1);I([n.computed],f.prototype,"hasSelectedItems",1);I([n.computed],f.prototype,"selectedItemsOrAllItems",1);I([n.computed],f.prototype,"canAddSelectedItems",1);I([n.computed],f.prototype,"canPlaySelectedItemsNext",1);I([n.computed],f.prototype,"canRemoveSelectedItems",1);I([n.action.bound],f.prototype,"setItems",1);I([n.action.bound],f.prototype,"unselectAll",1);I([n.action.bound],f.prototype,"selectAll",1);I([n.action.bound],f.prototype,"playSelectedItemsNext",1);I([n.action.bound],f.prototype,"addSelectedItems",1);I([n.action.bound],f.prototype,"addItems",1);I([n.action.bound],f.prototype,"moveItem",1);I([n.action.bound],f.prototype,"removeItems",1);I([n.action.bound],f.prototype,"removeSelectedItems",1);I([n.action.bound],f.prototype,"removeOtherItems",1);I([n.action.bound],f.prototype,"removeItemsAbove",1);I([n.action.bound],f.prototype,"addItemFromDto",1);I([n.action.bound],f.prototype,"playAll",1);const Gt=({onClick:t})=>o.jsx(s.EuiButton,{onClick:t,iconType:d.PlayRegular,fill:!0,children:"Play all"}),Jt=({playlistListItem:t,onFulfilled:e})=>{const r=()=>R.show(Lt,{playlistListItem:t}).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.RenameRegular,children:"Rename"})},Kt=({playlistListItem:t,onFulfilled:e})=>{const r=()=>R.show(Tt,{playlistListItem:t}).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.DeleteRegular,children:"Delete"})},Wt=p.observer(({playlistListItem:t})=>{const e=$.playlist(t.id),r=A(),[l]=a.useState(()=>new f(r));_.useLocalStorageState(e,l.localStorageState);const i=W.useRouter(),c=a.useCallback(async v=>{await t.rename(v)},[t]),u=a.useCallback(async()=>{await i.navigate({to:"/playlists"}),window.localStorage.removeItem(e),await t.remove()},[t,i,e]);return o.jsxs(o.Fragment,{children:[o.jsx(oe,{pageTitle:t.name,breadcrumbs:[{text:"Playlists",linkProps:{to:"/playlists"}},{text:t.name}],rightSideItems:[o.jsx(Gt,{onClick:l.playAll}),o.jsx(Jt,{playlistListItem:t,onFulfilled:c}),o.jsx(Kt,{playlistListItem:t,onFulfilled:u})]}),o.jsx(Nt,{playlist:l})]})}),Yt=R.create(({remove:t,resolve:e})=>{const r=s.useGeneratedHtmlId({prefix:"modalForm"}),[l,i]=a.useState(""),[c,u]=a.useState(!1);return o.jsxs(s.EuiModal,{onClose:t,initialFocus:"[name=name]",children:[o.jsx(s.EuiModalHeader,{children:o.jsx(s.EuiModalHeaderTitle,{children:"Create playlist"})}),o.jsx(s.EuiModalBody,{children:o.jsx(s.EuiForm,{id:r,component:"form",onSubmit:async v=>{v.preventDefault();try{u(!0),e(l),t()}finally{u(!1)}},children:o.jsx(s.EuiFormRow,{label:"Name",children:o.jsx(s.EuiFieldText,{name:"name",value:l,onChange:v=>i(v.target.value)})})})}),o.jsxs(s.EuiModalFooter,{children:[o.jsx(s.EuiButtonEmpty,{onClick:t,children:"Cancel"}),o.jsx(s.EuiButton,{type:"submit",form:r,fill:!0,disabled:l.trim().length===0,isLoading:c,children:"Create playlist"})]})]})}),Xt=({children:t,onFulfilled:e})=>{const r=()=>R.show(Yt).then(e);return o.jsx(s.EuiButton,{onClick:r,iconType:d.AddRegular,fill:!0,children:t})},Zt=({linkProps:t,...e})=>{const r=W.useRouter(),l=async i=>{i.preventDefault(),await r.navigate(t)};return o.jsx(s.EuiLink,{...e,href:r.buildLocation(t).href,onClick:l})},eo=p.observer(({playlistList:t})=>o.jsx(s.EuiTableHeader,{children:o.jsx(s.EuiTableHeaderCell,{children:"Name"})})),to=p.observer(({item:t})=>o.jsx(s.EuiTableRow,{children:o.jsx(s.EuiTableRowCell,{children:o.jsx(Zt,{linkProps:{to:"/playlists/$playlistId",params:{playlistId:t.id}},children:t.name})})},t.id)),oo=p.observer(({playlistList:t})=>o.jsx(K.ReactSortable,{tag:"tbody",list:t.items,setList:e=>t.setItems(e),children:t.items.map(e=>o.jsx(to,{item:e},e.id))})),so=p.observer(({playlistList:t})=>o.jsxs(s.EuiTable,{children:[o.jsx(eo,{playlistList:t}),o.jsx(oo,{playlistList:t})]})),ro=()=>o.jsx(oe,{pageTitle:"Playlists",breadcrumbs:[{text:"Playlists"}]}),no=p.observer(({playlistList:t})=>{const e=a.useCallback(async r=>{await t.addItem(t.createItem(r))},[t]);return o.jsxs(s.EuiPageTemplate.Section,{children:[o.jsx(Xt,{onFulfilled:e,children:"New playlist"}),o.jsx(s.EuiSpacer,{size:"l"}),o.jsx(so,{playlistList:t})]})}),io=a.memo(()=>{const t=pe();return o.jsxs(o.Fragment,{children:[o.jsx(ro,{}),o.jsx(no,{playlistList:t})]})});exports.BottomBar=dt;exports.HydrangeanDivaProvider=He;exports.MediaPlayerLayout=$e;exports.MiniPlayer=pt;exports.PlayQueueContext=Z;exports.PlayQueuePage=Et;exports.PlayQueueSection=ye;exports.PlaylistDetailsPage=Wt;exports.PlaylistListContext=ee;exports.PlaylistListPage=io;exports.RepeatMode=g;exports.bottomBarHeight=Y;exports.usePlayQueue=A;exports.usePlaylistList=pe;exports.videoServiceIcons=H;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|