import{d as a,a as n,t as i,_ as l}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";import{N as g}from"./NcEmptyContent-C3BLUUdi.chunk.mjs";import{f as c,l as h}from"./index-BMeBqg0T.chunk.mjs";import{L as d}from"./video-B-t_GSGv.chunk.mjs";import{j as u,n as r}from"./icons-VGG7keIQ.chunk.mjs";import{A as o}from"./AbortControllerMixin-KqbYNBDv.chunk.mjs";import"./index-XmYygNaN.chunk.mjs";import"./preload-helper-Dh9HmuEY.chunk.mjs";const m=a({name:"TagCover",components:{RouterLink:d,ImageMultipleOutline:u},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=[],_=r(m,p,f,!1,null,"4e0e61e1");const v=_.exports,C=a({name:"TagsView",components:{TagCover:v,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){h.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-B1bAj-t7.chunk.mjs.map
