"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[5269],{65269:function(e,t,l){l.r(t),l.d(t,{default:function(){return _}});l(18111),l(22489);var i=l(20641);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"),u=(0,i.g2)("NoItems"),p=(0,i.g2)("Collections"),y=(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)),onAddToQueue:t[1]||(t[1]=t=>e.$emit("add-to-queue",t)),onDelete:t[2]||(t[2]=t=>e.$emit("delete",t)),onPlay:t[3]||(t[3]=t=>e.$emit("play",t)),onPlayWithOpts:t[4]||(t[4]=t=>e.$emit("play-with-opts",t)),onPlaylistMove:d.playlistMove,onRemoveFromPlaylist:t[5]||(t[5]=t=>e.$emit("remove-from-playlist",t)),onSelect:t[6]||(t[6]=t=>{e.selectedResult=t,e.$emit("select",t)}),onSelectCollection:d.selectCollection,onView:t[7]||(t[7]=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)(p,{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)(y,{key:1,results:d.mediaItems,sources:{jellyfin:!0},filter:e.filter,"selected-result":e.selectedResult,onAddToPlaylist:t[8]||(t[8]=t=>e.$emit("add-to-playlist",t)),onAddToQueue:t[9]||(t[9]=t=>e.$emit("add-to-queue",t)),onDownload:t[10]||(t[10]=t=>e.$emit("download",t)),onPlay:t[11]||(t[11]=t=>e.$emit("play",t)),onPlayWithOpts:t[12]||(t[12]=t=>e.$emit("play-with-opts",t)),onRemoveFromPlaylist:t[13]||(t[13]=t=>e.$emit("remove-from-playlist",t)),onSelect:d.selectItem,onView:t[14]||(t[14]=t=>e.$emit("view",t))},null,8,["results","filter","selected-result","onSelect"])):(0,i.Q3)("",!0)])):((0,i.uX)(),(0,i.Wv)(u,{key:2,"with-shadow":!1},{default:(0,i.k6)(()=>[...t[15]||(t[15]=[(0,i.eW)(" No media found. ",-1)])]),_:1}))])}l(74423),l(61701);var a=l(72654),d=l(81350),r=l(82012),m=l(41873),u=l(73072),p=l(20388),y={mixins:[r["default"]],emits:["add-to-playlist","add-to-queue","delete","download","play","play-with-opts","remove-from-playlist","select","select-collection","view"],components:{Collections:a["default"],Loading:d.A,Music:m["default"],NoItems:u.A,Results:p.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()}},h=l(66262);const f=(0,h.A)(y,[["render",c],["__scopeId","data-v-32cf02fc"]]);var _=f}}]);
//# sourceMappingURL=5269.d59309e8.js.map