"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[6975],{6975:function(e,t,l){l.r(t),l.d(t,{default:function(){return _}});var i=l(641);const o={class:"videos index"},s={key:1,class:"wrapper music-wrapper"},n={key:3,class:"wrapper items-wrapper"};function c(e,t,l,c,a,d){const r=(0,i.g2)("Loading"),m=(0,i.g2)("Music"),p=(0,i.g2)("NoItems"),y=(0,i.g2)("Collections"),h=(0,i.g2)("Results");return(0,i.uX)(),(0,i.CE)("div",o,[e.isLoading?((0,i.uX)(),(0,i.Wv)(r,{key:0})):"music"===e.collection?.collection_type?((0,i.uX)(),(0,i.CE)("div",s,[(0,i.bF)(m,{collection:e.collection,filter:e.filter,loading:e.isLoading,path:e.path,onAddToPlaylist:t[0]||(t[0]=t=>e.$emit("add-to-playlist",t)),onDelete:t[1]||(t[1]=t=>e.$emit("delete",t)),onPlay:t[2]||(t[2]=t=>e.$emit("play",t)),onPlayWithOpts:t[3]||(t[3]=t=>e.$emit("play-with-opts",t)),onPlaylistMove:d.playlistMove,onRemoveFromPlaylist:t[4]||(t[4]=t=>e.$emit("remove-from-playlist",t)),onSelect:t[5]||(t[5]=t=>{e.selectedResult=t,e.$emit("select",t)}),onSelectCollection:d.selectCollection,onView:t[6]||(t[6]=t=>e.$emit("view",t))},null,8,["collection","filter","loading","path","onPlaylistMove","onSelectCollection"])])):e.items?.length?((0,i.uX)(),(0,i.CE)("div",n,[d.collections.length>0?((0,i.uX)(),(0,i.Wv)(y,{key:0,collection:e.collection,filter:e.filter,items:d.collections,loading:e.isLoading,"parent-id":e.collection?.id,onRefresh:d.refresh,onSelect:d.selectCollection},null,8,["collection","filter","items","loading","parent-id","onRefresh","onSelect"])):(0,i.Q3)("",!0),d.mediaItems.length>0?((0,i.uX)(),(0,i.Wv)(h,{key:1,results:d.mediaItems,sources:{jellyfin:!0},filter:e.filter,"selected-result":e.selectedResult,onAddToPlaylist:t[7]||(t[7]=t=>e.$emit("add-to-playlist",t)),onDownload:t[8]||(t[8]=t=>e.$emit("download",t)),onPlay:t[9]||(t[9]=t=>e.$emit("play",t)),onPlayWithOpts:t[10]||(t[10]=t=>e.$emit("play-with-opts",t)),onRemoveFromPlaylist:t[11]||(t[11]=t=>e.$emit("remove-from-playlist",t)),onSelect:d.selectItem,onView:t[12]||(t[12]=t=>e.$emit("view",t))},null,8,["results","filter","selected-result","onSelect"])):(0,i.Q3)("",!0)])):((0,i.uX)(),(0,i.Wv)(p,{key:2,"with-shadow":!1},{default:(0,i.k6)((()=>t[13]||(t[13]=[(0,i.eW)(" No media found. ")]))),_:1}))])}var a=l(8411),d=l(9828),r=l(2012),m=l(1433),p=l(6561),y=l(3149),h={mixins:[r["default"]],emits:["add-to-playlist","delete","download","play","play-with-opts","remove-from-playlist","select","select-collection","view"],components:{Collections:a["default"],Loading:d.A,Music:m["default"],NoItems:p.A,Results:y.A},computed:{collections(){return this.sortedItems?.filter((e=>["collection","playlist"].includes(e.item_type)))??[]},mediaItems(){const e=this.sortedItems?.filter((e=>!["collection","playlist"].includes(e.item_type)))??[];return!this.collection||this.collection.collection_type&&"books"!==this.collection.collection_type?e:e.sort(((e,t)=>{if(e.created_at&&t.created_at)return new Date(e.created_at)<new Date(t.created_at);if(e.created_at)return-1;if(t.created_at)return 1;let l=[e.name||e.title||"",t.name||t.title||""];return l[0].localeCompare(l[1])}))}},methods:{selectCollection(e){this.$emit("select-collection",{type:"homevideos",...e})},selectItem(e){const t=this.items[e];"book"===t.item_type&&t.embed_url?window.open(t.embed_url,"_blank"):this.selectedResult=e},async playlistMove(e){const{item:t,to:l}=e;this.loading_=!0;try{await this.request("media.jellyfin.playlist_move",{playlist_id:this.collection.id,item_id:t.playlist_item_id,to_pos:l}),await this.refresh()}finally{this.loading_=!1}},async init(){const e=this.getUrlArgs();let t=e?.collection;if(t){this.loading_=!0;try{t=await this.request("media.jellyfin.info",{item_id:t}),t&&this.selectCollection(t)}finally{this.loading_=!1}}},async refresh(){if("music"!==this.collection?.collection_type){this.loading_=!0;try{"tvshows"===this.collection?.collection_type?this.items=(await this.request("media.jellyfin.get_collections",{parent_id:this.collection.id})).map((e=>({...e,item_type:"collection"}))):this.items=this.collection?.id?await this.request("media.jellyfin.get_items",{parent_id:this.collection.id,limit:25e3}):(await this.request("media.jellyfin.get_collections")).map((e=>({...e,item_type:"collection"})))}finally{this.loading_=!1}}}},async mounted(){this.init(),await this.refresh()}},u=l(6262);const f=(0,u.A)(h,[["render",c],["__scopeId","data-v-19c9d0dd"]]);var _=f}}]);
//# sourceMappingURL=6975.ea0d851e.js.map