"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[168],{168:function(e,n,s){s.r(n),s.d(n,{default:function(){return N}});var t=s(6252),i=s(3577);const l={class:"media-youtube-channel"},a={key:1,class:"channel"},r={class:"header"},c={class:"banner"},o=["src"],d={class:"row info-container"},u={class:"info"},h={class:"row"},b={class:"title-container"},g=["href"],p={class:"image"},y=["src"],m=["href"],_={class:"actions"},f=["title"],w={key:0,class:"subscribers"},k={key:0,class:"description"};function v(e,n,s,v,x,C){const S=(0,t.up)("Loading"),q=(0,t.up)("Results");return(0,t.wg)(),(0,t.iD)("div",l,[C.isLoading?((0,t.wg)(),(0,t.j4)(S,{key:0})):x.channel?((0,t.wg)(),(0,t.iD)("div",a,[(0,t._)("div",r,[(0,t._)("div",c,[x.channel?.banner?.length?((0,t.wg)(),(0,t.iD)("img",{key:0,src:x.channel.banner},null,8,o)):(0,t.kq)("",!0)]),(0,t._)("div",d,[(0,t._)("div",u,[(0,t._)("div",h,[(0,t._)("div",b,[x.channel?.image?.length?((0,t.wg)(),(0,t.iD)("a",{key:0,href:x.channel.url,target:"_blank",rel:"noopener noreferrer"},[(0,t._)("div",p,[(0,t._)("img",{src:x.channel.image},null,8,y)])],8,g)):(0,t.kq)("",!0),(0,t._)("a",{class:"title",href:x.channel.url,target:"_blank",rel:"noopener noreferrer"},(0,i.zw)(x.channel?.name),9,m)]),(0,t._)("div",_,[(0,t._)("button",{title:x.subscribed?"Unsubscribe":"Subscribe",onClick:n[0]||(n[0]=(...e)=>C.toggleSubscription&&C.toggleSubscription(...e))},(0,i.zw)(x.subscribed?"Unsubscribe":"Subscribe"),9,f),null!=x.channel.subscribers&&(x.channel.subscribers||0)>=0?((0,t.wg)(),(0,t.iD)("div",w,(0,i.zw)(e.formatNumber(x.channel.subscribers))+" subscribers ",1)):(0,t.kq)("",!0)])]),x.channel?.description?((0,t.wg)(),(0,t.iD)("div",k,(0,i.zw)(x.channel.description),1)):(0,t.kq)("",!0)])])]),(0,t.Wm)(q,{results:x.channel.items,filter:s.filter,"result-index-step":null,"selected-result":x.selectedResult,ref:"results",onAddToPlaylist:n[1]||(n[1]=n=>e.$emit("add-to-playlist",n)),onDownload:n[2]||(n[2]=n=>e.$emit("download",n)),onDownloadAudio:n[3]||(n[3]=n=>e.$emit("download-audio",n)),onOpenChannel:n[4]||(n[4]=n=>e.$emit("open-channel",n)),onPlay:n[5]||(n[5]=n=>e.$emit("play",n)),onPlayCache:n[6]||(n[6]=n=>e.$emit("play-cache",n)),onScrollEnd:C.loadNextPage,onSelect:n[7]||(n[7]=e=>x.selectedResult=e)},null,8,["results","filter","selected-result","onScrollEnd"])])):(0,t.kq)("",!0)])}var x=s(6791),C=s(2893),S=s(8637),q={mixins:[S.Z],emits:["add-to-playlist","download","download-audio","open-channel","play","play-cache"],components:{Loading:x.Z,Results:C.Z},props:{id:{type:String,required:!0},filter:{type:String,default:null},loading:{type:Boolean,default:!1}},data(){return{channel:null,loading_:!1,loadingNextPage:!1,selectedResult:null,subscribed:!1}},computed:{isLoading(){return this.loading||this.loading_},itemsByUrl(){return this.channel?.items.reduce(((e,n)=>(e[n.url]=n,e)),{})}},methods:{async loadChannel(){this.loading_=!0;try{await this.updateChannel(!0),this.subscribed=await this.request("youtube.is_subscribed",{channel_id:this.id})}finally{this.loading_=!1}},async updateChannel(e){const n=await this.request("youtube.get_channel",{id:this.id,next_page_token:this.channel?.next_page_token}),s=this.itemsByUrl||{};let t=n.items.filter((e=>!s[e.url])).map((e=>({type:"youtube",...e})));e||(t=this.channel.items.concat(t)),this.channel=n,this.channel.items=t},async loadNextPage(){if(this.channel?.next_page_token&&!this.loadingNextPage){this.loadingNextPage=!0;try{await this.timeout(500),await this.updateChannel()}finally{this.loadingNextPage=!1}}},async toggleSubscription(){const e=this.subscribed?"unsubscribe":"subscribe";await this.request(`youtube.${e}`,{channel_id:this.id}),this.subscribed=!this.subscribed}},async mounted(){this.setUrlArgs({channel:this.id}),await this.loadChannel()},unmounted(){this.setUrlArgs({channel:null})}},P=s(3744);const D=(0,P.Z)(q,[["render",v],["__scopeId","data-v-0f1311f3"]]);var N=D}}]);
//# sourceMappingURL=168.89125ddf.js.map