import{d as a,a as n,t as i,s as l}from"./dav-D-0Zsvk_.chunk.mjs";import{N as g}from"./NcEmptyContent-DEGDbAVb.chunk.mjs";import{N as c}from"./NcLoadingIcon-Ctb4dpAr.chunk.mjs";import{L as h}from"./video-B2Zidy_E.chunk.mjs";import{I as d,n as r}from"./icons-D6kGtfXC.chunk.mjs";import{A as o}from"./AbortControllerMixin-C4cpCLeS.chunk.mjs";import{l as u}from"./index-VDTWCae_.chunk.mjs";import"./index-CxUc7fso.chunk.mjs";const m=a({name:"TagCover",components:{RouterLink:h,ImageMultipleOutline:d},mixins:[o],props:{tag:{type:Object,required:!0}},data(){return{loadCover:!1,observer:null}},computed:{tags(){return this.$store.state.systemtags.tags},files(){return this.$store.state.files.files},coverUrl(){return this.loadCover?l(`/core/preview?fileId=${this.tag.attributes["reference-fileid"]}&x=512&y=512&forceIcon=0&a=1`):""},count(){return this.tag.attributes["files-assigned"]}},watch:{loadCover(){this.tag.attributes["files-assigned"]||this.$store.dispatch("fetchTagFiles",{id:this.tag.attributes.id,signal:this.abortController.signal})}},mounted(){this.observer=new IntersectionObserver(t=>{t[0].isIntersecting&&(this.loadCover=!0,this.observer?.disconnect())}),this.observer.observe(this.$el)},methods:{t:i,n}});var p=function(){var t=this,s=t._self._c;return t._self._setupProxy,s("RouterLink",{staticClass:"tag-cover",attrs:{to:`/tags/${t.tag.attributes["display-name"]}`}},[t.tag.attributes["files-assigned"]!==0?s("img",{staticClass:"tag-cover__image",attrs:{src:t.coverUrl}}):s("div",{staticClass:"tag-cover__image tag-cover__image--placeholder"},[s("ImageMultipleOutline",{attrs:{size:128}})],1),s("div",{staticClass:"tag-cover__details"},[s("div",{staticClass:"tag-cover__details__first-line"},[s("h3",{staticClass:"tag-cover__details__name"},[t._v(" "+t._s(t.t("recognize",t.tag.attributes["display-name"]))+" ")])]),s("div",{staticClass:"tag-cover__details__second-line"},[t._v(" "+t._s(t.n("photos","%n photo","%n photos",t.count))+" ")])])])},f=[],v=r(m,p,f,!1,null,"01249121");const _=v.exports,C=a({name:"TagsView",components:{TagCover:_,NcLoadingIcon:c,NcEmptyContent:g},mixins:[o],data(){return{error:null,loading:!1,showTags:!1}},computed:{files(){return this.$store.state.files.files},tags(){return this.$store.state.systemtags.tags},tagsNames(){return this.$store.state.systemtags.names},tagsList(){return Object.keys(this.tagsNames).map(t=>this.tags[this.tagsNames[t]]).filter(t=>t&&t.attributes.id)},popularTags(){return Object.keys(this.tagsNames).filter(t=>this.tags[this.tagsNames[t]].attributes["files-assigned"]>50).sort((t,s)=>this.tags[this.tagsNames[s]]["files-assigned"]-this.tags[this.tagsNames[t]]["files-assigned"]).slice(0,9).map(t=>this.tags[this.tagsNames[t]])}},async beforeMount(){await this.fetchRootContent()},methods:{async fetchRootContent(){window.OCA.Viewer.close(),this.error=null;try{this.tagsList.length||(this.loading=!0,await this.$store.dispatch("fetchAllTags",{signal:this.abortController.signal}))}catch(t){u.error("Failed to fetch tags",{error:t}),this.error=!0}finally{this.loading=!1}},t:i}});var b=function(){var t=this,s=t._self._c;return t._self._setupProxy,s("div",[t.error?s("NcEmptyContent",{attrs:{name:t.t("photos","An error occurred")}}):t._e(),!t.loading&&t.tagsList.length===0?s("NcEmptyContent",{attrs:{name:t.t("photos","No tags yet"),description:t.t("photos","Photos with tags will show up here")}}):t._e(),t.loading?s("NcLoadingIcon",{staticClass:"loader"}):s("div",{staticClass:"container"},[t.popularTags.length?s("h2",[t._v(" "+t._s(t.t("photos","Popular tags"))+" ")]):t._e(),s("div",{staticClass:"popular-tags"},t._l(t.popularTags,function(e){return s("TagCover",{key:e.attributes.id,attrs:{tag:e}})}),1),t.tagsList.length?s("h2",[t._v(" "+t._s(t.t("photos","All tags"))+" ")]):t._e(),s("div",{staticClass:"tags"},t._l(t.tagsList,function(e){return s("TagCover",{key:e.attributes.id,attrs:{tag:e}})}),1)])],1)},y=[],N=r(C,b,y,!1,null,"cb8dfce8");const A=N.exports;export{A as default};
//# sourceMappingURL=TagsView-DV0r_bHA.chunk.mjs.map
