"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[2519],{2519:function(e,n,s){s.r(n),s.d(n,{default:function(){return T}});var i=s(641),t=s(33);const a={class:"media-youtube-channel"},l={key:1,class:"channel"},r={class:"header"},o={class:"banner"},c=["src"],d={class:"row info-container"},u={class:"info"},h={class:"row"},b={class:"title-container"},g=["href"],p={class:"image"},m=["src"],k=["href"],y={class:"actions"},w=["title"],f={key:0,class:"subscribers"},v={key:0,class:"row description-container"},_={class:"description-toggle"},C=["title"];function L(e,n,s,L,E,P){const x=(0,i.g2)("Loading"),S=(0,i.g2)("Results");return(0,i.uX)(),(0,i.CE)("div",a,[P.isLoading?((0,i.uX)(),(0,i.Wv)(x,{key:0})):E.channel?((0,i.uX)(),(0,i.CE)("div",l,[(0,i.Lk)("div",r,[(0,i.Lk)("div",o,[E.banner?.length?((0,i.uX)(),(0,i.CE)("img",{key:0,src:E.channel.banner,onError:n[0]||(n[0]=(...e)=>P.onBannerError&&P.onBannerError(...e))},null,40,c)):(0,i.Q3)("",!0)]),(0,i.Lk)("div",d,[(0,i.Lk)("div",u,[(0,i.Lk)("div",h,[(0,i.Lk)("div",b,[E.image?.length?((0,i.uX)(),(0,i.CE)("a",{key:0,href:E.channel.url,target:"_blank",rel:"noopener noreferrer"},[(0,i.Lk)("div",p,[(0,i.Lk)("img",{src:E.image,onError:n[1]||(n[1]=(...e)=>P.onImageError&&P.onImageError(...e))},null,40,m)])],8,g)):(0,i.Q3)("",!0),(0,i.Lk)("a",{class:"title",href:E.channel.url,target:"_blank",rel:"noopener noreferrer"},(0,t.v_)(E.channel?.name),9,k)]),(0,i.Lk)("div",y,[(0,i.Lk)("button",{title:E.subscribed?"Unsubscribe":"Subscribe",onClick:n[2]||(n[2]=(...e)=>P.toggleSubscription&&P.toggleSubscription(...e))},(0,t.v_)(E.subscribed?"Unsubscribe":"Subscribe"),9,w),null!=E.channel.subscribers&&(E.channel.subscribers||0)>=0?((0,i.uX)(),(0,i.CE)("div",f,(0,t.v_)(e.formatNumber(E.channel.subscribers))+" subscribers ",1)):(0,i.Q3)("",!0)])])])])]),E.channel?.description?((0,i.uX)(),(0,i.CE)("div",v,[(0,i.Lk)("div",_,[(0,i.Lk)("button",{title:E.showDescription?"Hide description":"Show description",onClick:n[3]||(n[3]=e=>E.showDescription=!E.showDescription)},[(0,i.Lk)("i",{class:(0,t.C4)(["fas",{"fa-chevron-down":!E.showDescription,"fa-chevron-up":E.showDescription}])},null,2)],8,C)]),E.channel?.description?((0,i.uX)(),(0,i.CE)("div",{key:0,class:(0,t.C4)(["description",{hidden:!E.showDescription}])},(0,t.v_)(E.channel.description),3)):(0,i.Q3)("",!0)])):(0,i.Q3)("",!0),(0,i.bF)(S,{results:E.channel.items,filter:s.filter,"result-index-step":null,"selected-result":E.selectedResult,ref:"results",onAddToPlaylist:n[4]||(n[4]=n=>e.$emit("add-to-playlist",n)),onDownload:n[5]||(n[5]=n=>e.$emit("download",n)),onDownloadAudio:n[6]||(n[6]=n=>e.$emit("download-audio",n)),onOpenChannel:n[7]||(n[7]=n=>e.$emit("open-channel",n)),onPlay:n[8]||(n[8]=n=>e.$emit("play",n)),onPlayWithOpts:n[9]||(n[9]=n=>e.$emit("play-with-opts",n)),onScrollEnd:P.loadNextPage,onSelect:n[10]||(n[10]=e=>E.selectedResult=e),onView:n[11]||(n[11]=n=>e.$emit("view",n))},null,8,["results","filter","selected-result","onScrollEnd"])])):(0,i.Q3)("",!0)])}var E=s(9828),P=s(3149),x=s(2002),S={mixins:[x.A],emits:["add-to-playlist","download","download-audio","open-channel","play","play-with-opts","view"],components:{Loading:E.A,Results:P.A},props:{id:{type:String,required:!0},filter:{type:String,default:null},loading:{type:Boolean,default:!1}},data(){return{banner:null,channel:null,image:null,loading_:!1,loadingNextPage:!1,nextPageToken:null,renderedPageTokens:{},selectedResult:null,showDescription:!1,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=this.channel?.next_page_token,s=await this.request("youtube.get_channel",{id:this.id,page:n});n&&(this.renderedPageTokens[n]=!0),this.nextPageToken=s.next_page_token,this.image=s.image,this.banner=s.banner;const i=this.itemsByUrl||{};let t=s.items.filter((e=>!i[e.url])).map((e=>({type:"youtube",...e})));e||(t=this.channel.items.concat(t)),this.channel=s,this.channel.items=t},async loadNextPage(){if(this.nextPageToken&&!this.renderedPageTokens[this.nextPageToken]&&!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},onBannerError(){this.banner=null},onImageError(){this.image=null}},async mounted(){this.setUrlArgs({channel:this.id}),await this.loadChannel()},unmounted(){this.setUrlArgs({channel:null})}},D=s(6262);const A=(0,D.A)(S,[["render",L],["__scopeId","data-v-1dc82e96"]]);var T=A}}]);
//# sourceMappingURL=2519.d259b2bb.js.map