import{f as n,t as i,V as c}from"./preload-helper-DadE4qT2.chunk.mjs";import{N as l}from"./NcActionButton-DykQxmXJ-KVA0ETt1.chunk.mjs";import{j as r,i as f,y as d,x as h,l as s,C as a}from"./index-Dgdobvu3.chunk.mjs";import{N as u}from"./NcEmptyContent-D03x2I6w.chunk.mjs";import{g as p,h as m,f as F,i as v,j as g,A as _,e as y,k as N,S as w,a as C,c as M,n as k}from"./icons-CFZwNZD8.chunk.mjs";import{F as S}from"./FaceMergeForm-BHfOqGG8.chunk.mjs";import{F as I}from"./FileComponent-A6f_Dtn9.chunk.mjs";import{F as A,a as $}from"./FilesSelectionMixin-1nnlfofj.chunk.mjs";import{F as x}from"./FaceCover-y62LmE3b.chunk.mjs";import{F as R}from"./FetchFilesMixin-BGmLOce1.chunk.mjs";import"./index-BCevi9E9.chunk.mjs";import"./createElementId-DhjFt1I9-B2HCdIOx.chunk.mjs";import"./NcCheckboxRadioSwitch-DAPHFb0L-ou8aC9jF.chunk.mjs";import"./useModelMigration-EhAWvqDD-Zhby4giX.chunk.mjs";import"./fileFetcher-CFJaIlCO.chunk.mjs";import"./AbortControllerMixin-Bb5X6Yae.chunk.mjs";import"./PhotoSearch-3PnBhHOR.chunk.mjs";const B={name:"FaceContent",components:{PencilOutline:M,Star:C,StarOutline:w,Download:N,Close:y,AlertCircleOutline:_,SendOutline:g,Merge:v,ArrowLeft:F,AccountBoxMultipleOutline:m,FaceMergeForm:S,FilesListViewer:$,FileComponent:I,NcLoadingIcon:h,NcEmptyContent:u,NcActions:d,NcActionButton:l,NcDialog:f,NcButton:r,AccountSwitchOutline:p},directives:{focus(e){c.nextTick(()=>e.focus())}},mixins:[x,R,A],props:{faceName:{type:String,default:"/"}},data(){return{showMoveModal:!1,showMergeModal:!1,showRenameModal:!1,loadingCount:0,appContent:document.getElementById("app-content-vue")}},computed:{files(){return this.$store.state.files.files},facesFiles(){return this.$store.state.faces.facesFiles},face(){return this.faces[this.faceName]},faceFileIds(){return this.facesFiles[this.faceName]||[]},shouldFavoriteSelection(){return this.selectedFileIds.some(e=>this.$store.state.files.files[e].attributes.favorite===0)}},watch:{face(){this.face&&this.fetchFaceContent(this.faceName)}},mounted(){this.fetchFaceContent(this.faceName)},methods:{openViewer(e){window.OCA.Viewer.open({fileInfo:a(this.files[e]),list:this.faceFileIds.map(t=>a(this.files[t]))})},async handleRemoveFilesFromFace(e){try{this.loadingCount++,await this.$store.dispatch("removeFilesFromFace",{faceName:this.faceName,fileIdsToRemove:e}),this.resetSelection()}catch(t){s.error(t)}finally{this.loadingCount--}},async handleDeleteFace(){try{this.loadingCount++,await this.$store.dispatch("deleteFace",{faceName:this.faceName}),this.$router.push("/faces")}catch(e){s.error(e)}finally{this.loadingCount--}},async handleRenameFace(e){try{this.loadingCount++,this.showRenameModal=!1;const t=this.faceName;await this.$store.dispatch("renameFace",{oldName:t,faceName:e}),this.$router.push({name:"facecontent",params:{faceName:e}})}catch(t){s.error(t)}finally{this.loadingCount--}},async handleMerge(e){try{this.loadingCount++,await this.$store.dispatch("moveFilesToFace",{oldFace:this.faceName,faceName:e,fileIdsToMove:this.facesFiles[this.faceName]}),await this.$store.dispatch("deleteFace",{faceName:this.faceName}),this.showMergeModal=!1,this.$router.push({name:"facecontent",params:{faceName:e}})}catch(t){s.error(t)}finally{this.loadingCount--}},async handleMove(e,t){try{this.loadingCount++,await this.$store.dispatch("moveFilesToFace",{oldFace:this.faceName,faceName:e,fileIdsToMove:t}),this.showMoveModal=!1}catch(o){s.error(o)}finally{this.loadingCount--}},async favoriteSelection(){try{this.loadingCount++,await this.$store.dispatch("toggleFavoriteForFiles",{fileIds:this.selectedFileIds,favoriteState:!0})}catch(e){s.error(e)}finally{this.loadingCount--}},async unFavoriteSelection(){try{this.loadingCount++,await this.$store.dispatch("toggleFavoriteForFiles",{fileIds:this.selectedFileIds,favoriteState:!1})}catch(e){s.error(e)}finally{this.loadingCount--}},async downloadSelection(){try{this.loadingCount++,await this.$store.dispatch("downloadFiles",this.selectedFileIds)}catch(e){s.error(e)}finally{this.loadingCount--}},t:i,n}};var O=function(){var e=this,t=e._self._c;return e.face===void 0&&!e.loadingFiles&&!e.loadingFaces?t("NcEmptyContent",{staticClass:"empty-content-with-illustration",scopedSlots:e._u([{key:"icon",fn:function(){return[t("AccountBoxMultipleOutline")]},proxy:!0}],null,!1,2861705255)},[e._v(" "+e._s(e.t("photos","This person could not be found"))+" ")]):e.errorFetchingFiles||e.errorFetchingFaces?t("NcEmptyContent",{scopedSlots:e._u([{key:"icon",fn:function(){return[t("AlertCircleOutline")]},proxy:!0}])},[e._v(" "+e._s(e.t("photos","An error occurred"))+" ")]):t("div",{staticClass:"face"},[t("div",{staticClass:"face__header"},[t("div",{staticClass:"face__header__left"},[t("NcActions",[t("NcActionButton",{on:{click:function(o){return e.$router.push("/faces/")}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("ArrowLeft")]},proxy:!0}])},[e._v(e._s(e.t("photos","Back"))+" ")])],1),t("div",{staticClass:"face__header__title"},[e.face!==void 0?t("h2",{staticClass:"face-name",class:{"hidden-visually":e.face.basename.match(/^[0-9]+$/)}},[e._v(" "+e._s(e.face.basename)+" ")]):e._e()]),e.loadingCount>0||e.loadingFaces?t("NcLoadingIcon"):e._e()],1),e.face!==void 0?t("div",{staticClass:"face__header__actions"},[t("NcActions",[t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Rename person")},on:{click:function(o){e.showRenameModal=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("PencilOutline")]},proxy:!0}],null,!1,347985790)},[e._v(" "+e._s(e.t("photos","Rename person"))+" ")])],1),t("NcActions",{attrs:{"force-menu":!0}},[Object.keys(e.faces).length>1?t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Merge with different person")},on:{click:function(o){e.showMergeModal=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Merge")]},proxy:!0}],null,!1,3117189691)},[e._v(" "+e._s(e.t("photos","Merge with different person"))+" ")]):e._e(),e.selectedFileIds.length?[t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Download selected files")},on:{click:e.downloadSelection}},[t("Download",{attrs:{slot:"icon"},slot:"icon"}),e._v(" "+e._s(e.t("photos","Download selected photos"))+" ")],1),e.shouldFavoriteSelection?t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Mark selection as favorite")},on:{click:e.favoriteSelection}},[t("StarOutline",{attrs:{slot:"icon"},slot:"icon"}),e._v(" "+e._s(e.t("photos","Favorite"))+" ")],1):t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Remove selection from favorites")},on:{click:e.unFavoriteSelection}},[t("Star",{attrs:{slot:"icon"},slot:"icon"}),e._v(" "+e._s(e.t("photos","Remove from favorites"))+" ")],1),t("NcActionButton",{attrs:{"close-after-click":!0},on:{click:function(o){e.showMoveModal=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("AccountSwitchOutline")]},proxy:!0}],null,!1,1476410576)},[e._v(" "+e._s(e.n("photos","Move photo to a different person","Move photos to a different person",e.selectedFileIds.length))+" ")]),t("NcActionButton",{attrs:{"close-after-click":!0},on:{click:function(o){return e.handleRemoveFilesFromFace(e.selectedFileIds)}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Close")]},proxy:!0}],null,!1,1051939733)},[e._v(" "+e._s(e.n("photos","Remove photo from person","Remove photos from person",e.selectedFileIds.length))+" ")])]:e._e(),t("NcActionButton",{attrs:{"close-after-click":!0},on:{click:e.handleDeleteFace},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Close")]},proxy:!0}],null,!1,1051939733)},[e._v(" "+e._s(e.t("photos","Remove person"))+" ")])],2)],1):e._e()]),e.face!==void 0?t("FilesListViewer",{staticClass:"face__photos",attrs:{"container-element":e.appContent,"file-ids":e.faceFileIds,loading:e.loadingFiles||e.loadingFaces},scopedSlots:e._u([{key:"default",fn:function({file:o}){return t("FileComponent",{attrs:{file:e.files[o.id],"allow-selection":!0,selected:e.selection[o.id]===!0},on:{click:e.openViewer,"select-toggled":e.onFileSelectToggle}})}}],null,!1,3208665420)}):e._e(),e.showRenameModal?t("NcDialog",{attrs:{name:e.t("photos","Rename person"),"close-on-click-outside":"",size:"small"},on:{closing:function(o){e.showRenameModal=!1}},scopedSlots:e._u([{key:"actions",fn:function(){return[t("NcButton",{attrs:{"aria-label":e.t("photos","Save."),variant:"primary",disabled:e.$refs.nameInput&&e.$refs.nameInput.value.trim()===""},on:{click:function(o){return e.handleRenameFace(e.$refs.nameInput.value)}},scopedSlots:e._u([{key:"icon",fn:function(){return[e.loadingCount?t("NcLoadingIcon"):t("SendOutline")]},proxy:!0}],null,!1,4093389955)},[e._v(" "+e._s(e.t("photos","Save"))+" ")])]},proxy:!0}],null,!1,1503261394)},[t("div",{staticClass:"rename-form"},[t("input",{directives:[{name:"focus",rawName:"v-focus"}],ref:"nameInput",attrs:{type:"text",name:"name",required:"",placeholder:e.t("photos","Name of this person")},domProps:{value:e.faceName},on:{keydown:function(o){return!o.type.indexOf("key")&&e._k(o.keyCode,"enter",13,o.key,"Enter")?null:e.handleRenameFace(e.$refs.nameInput.value)}}})])]):e._e(),e.showMergeModal?t("NcDialog",{attrs:{name:e.t("photos","Merge person"),"close-on-click-outside":"",size:"normal"},on:{closing:function(o){e.showMergeModal=!1}}},[t("FaceMergeForm",{attrs:{"first-face":e.faceName},on:{select:function(o){return e.handleMerge(o)}}})],1):e._e(),e.showMoveModal?t("NcDialog",{attrs:{name:e.t("photos","Move to different person"),"close-on-click-outside":"",size:"normal"},on:{closing:function(o){e.showMoveModal=!1}}},[t("FaceMergeForm",{attrs:{"first-face":e.faceName},on:{select:function(o){return e.handleMove(o,e.selectedFileIds)}}})],1):e._e()],1)},b=[],D=k(B,O,b,!1,null,"e7556087");const Z=D.exports;export{Z as default}; //# sourceMappingURL=FaceContent-5XRK_xd6.chunk.mjs.map