import{d as F,f as A,t as h,q as n,k as _,F as C,u as w,s as g}from"./preload-helper-DadE4qT2.chunk.mjs";import{m as r}from"./index-BCevi9E9.chunk.mjs";import{x as k,j as p,v as c,Q as v,a as N,y as S,q as B,C as u,R as m,A as x}from"./index-Dgdobvu3.chunk.mjs";import{P as M,u as P,s as I}from"./filters-Ck71oeb9.chunk.mjs";import{N as O}from"./NcActionButton-DykQxmXJ-KVA0ETt1.chunk.mjs";import{N as L}from"./NcEmptyContent-D03x2I6w.chunk.mjs";import{I as $,P as f,n as b,A as T,F as U,e as D,k as Y,o as E,D as R}from"./icons-CFZwNZD8.chunk.mjs";import{A as V}from"./ActionFavorite-7rTcVpSr.chunk.mjs";import{A as y}from"./AlbumForm-RjiiBLP7.chunk.mjs";import{N as j}from"./NcListItem-BommrKRB-nRPPDJuP.chunk.mjs";import{N as H}from"./NcUserBubble-VLY4hn5K-C859Jy5x.chunk.mjs";import{F as Q}from"./FetchCollectionsMixin-DcEv3N9Z.chunk.mjs";import{F as q}from"./FileComponent-A6f_Dtn9.chunk.mjs";import{F as z,a as J}from"./FilesSelectionMixin-1nnlfofj.chunk.mjs";import{H as G}from"./HeaderNavigation-DLWOytuO.chunk.mjs";import{F as K}from"./FetchFilesMixin-BGmLOce1.chunk.mjs";import{F as W}from"./FilesByMonthMixin-BLjMI05j.chunk.mjs";import"./index-D_vzF9fp.chunk.mjs";import"./PhotosFiltersInput-B33sPvuK.chunk.mjs";import"./NcSelect-DTniMiUS-DT0HbKa6.chunk.mjs";import"./useModelMigration-EhAWvqDD-Zhby4giX.chunk.mjs";import"./NcAvatar-D5nljVEA-Mn39wJHK.chunk.mjs";import"./NcDateTimePicker-BJgTfZNh.chunk.mjs";import"./useFormatDateTime-Dj6f4vk0.chunk.mjs";import"./NcDateTime-enXYuwj8-Db78ZihF.chunk.mjs";import"./collectionFetcher-D94WC1TK.chunk.mjs";import"./video-eu9Y2O-I.chunk.mjs";import"./createElementId-DhjFt1I9-B2HCdIOx.chunk.mjs";import"./NcTextField-CfZknuqx-CsSvGxmN.chunk.mjs";import"./index-x9vhq81Z.chunk.mjs";import"./NcSelectUsers-RyUVUaWQ-CTrr_2Z8.chunk.mjs";import"./FetchCollectionContentMixin-NK9nekKH.chunk.mjs";import"./AbortControllerMixin-Bb5X6Yae.chunk.mjs";import"./NcVNodes-BVNC6_P_.chunk.mjs";import"./NcCheckboxRadioSwitch-DAPHFb0L-ou8aC9jF.chunk.mjs";import"./fileFetcher-CFJaIlCO.chunk.mjs";import"./PhotoSearch-3PnBhHOR.chunk.mjs";const X=F({name:"AlbumPicker",components:{Plus:f,ImageMultipleOutline:$,NcButton:p,NcListItem:j,NcLoadingIcon:k,NcUserBubble:H,AlbumForm:y},filters:{toCoverUrl(e){return _(`/apps/photos/api/v1/preview/${e}?x=64&y=64`)}},mixins:[Q],data(){return{showAlbumCreationForm:!1}},computed:{albums(){return this.$store.getters.albums},sharedAlbums(){return this.$store.getters.sharedAlbums},allAlbums(){return[...Object.values(this.albums),...Object.values(this.sharedAlbums)]}},mounted(){this.fetchAlbumList()},methods:{async fetchAlbumList(){await this.fetchCollections(`/photos/${n()?.uid}/albums`,c),await this.fetchCollections(`/photos/${n()?.uid}/sharedalbums`,c)},albumCreatedHandler(){this.showAlbumCreationForm=!1,this.fetchAlbumList()},pickAlbum(e){this.$emit("album-picked",e)},isSharedAlbum(e){return e.path.match(/^\/photos\/.+\/sharedalbums\//)!==null},originalName(e){return this.isSharedAlbum(e)?e.basename.replace(new RegExp(`\\(${e.attributes.collaborators[0].id}\\)$`),""):e.basename},t:h,n:A}});var Z=function(){var e=this,t=e._self._c;return e._self._setupProxy,e.showAlbumCreationForm?t("AlbumForm",{attrs:{"display-back-button":!0,title:e.t("photos","New album")},on:{back:function(o){e.showAlbumCreationForm=!1},done:e.albumCreatedHandler}}):t("div",{staticClass:"album-picker"},[t("h2",[e._v(" "+e._s(e.t("photos","Add to Album"))+" "),e.loadingCollections?t("NcLoadingIcon",{staticClass:"loading-icon"}):e._e()],1),t("ul",{staticClass:"albums-container"},e._l(e.allAlbums,function(o){return t("NcListItem",{key:o.attributes.filename,staticClass:"album",attrs:{name:e.originalName(o),"aria-label":e.t("photos","Add selection to album {albumName}",{albumName:o.basename})},on:{click:function(s){return e.pickAlbum(o)}},scopedSlots:e._u([{key:"subname",fn:function(){return[e._v(" "+e._s(e.n("photos","%n item","%n photos and videos",o.attributes.nbItems))+" "),e.isSharedAlbum(o)?[e._v(" ⸱ "+e._s(e.t("photos","Shared by"))+" "),t("NcUserBubble",{attrs:{"display-name":o.attributes.collaborators[0].label,user:o.attributes.collaborators[0].id}})]:e._e()]},proxy:!0}],null,!0)},[t("template",{slot:"icon"},[o.attributes["last-photo"]!==-1?t("img",{staticClass:"album__image",attrs:{src:e._f("toCoverUrl")(o.attributes["last-photo"])}}):t("div",{staticClass:"album__image album__image--placeholder"},[t("ImageMultipleOutline",{attrs:{size:32}})],1)])],2)}),1),t("NcButton",{staticClass:"new-album-button",attrs:{"aria-label":e.t("photos","Create a new album."),variant:"tertiary"},on:{click:function(o){e.showAlbumCreationForm=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Plus")]},proxy:!0}],null,!1,1489515321)},[e._v(" "+e._s(e.t("photos","Create new album"))+" ")])],1)},ee=[],te=b(X,Z,ee,!1,null,"9619a86f");const oe=te.exports;async function d(e,t){await v.head(e);const o=document.createElement("a");o.download=t??"",o.href=e,o.click()}function se(e,t){const o=e.split("/").filter(Boolean),s=t.split("/").filter(Boolean);let i="";for(const[a,l]of o.entries()){if(a>=t.length||l!==s[a])break;i=`${i}${i===""?"":"/"}${l}`}return i}async function ie(e){let t;if(e.length===1)if(e[0].type===C.File){await d(e[0].encodedSource,e[0].displayname);return}else t=new URL(e[0].encodedSource),t.searchParams.append("accept","zip");else{t=new URL(e[0].encodedSource);let o=t.pathname;for(const i of e.slice(1))o=se(o,new URL(i.encodedSource).pathname);t.pathname=o;const s=e.map(i=>decodeURIComponent(i.encodedSource.slice(t.href.length+1)));t.searchParams.append("accept","zip"),t.searchParams.append("files",JSON.stringify(s))}t.pathname.at(-1)!=="/"&&(t.pathname=`${t.pathname}/`),await d(t.href)}const ae={name:"TimelineView",components:{DeleteOutline:R,PlusBoxMultipleOutline:E,DownloadOutline:Y,Close:D,Plus:f,FolderAlertOutline:U,NcEmptyContent:L,NcModal:B,NcActions:S,NcActionButton:O,NcButton:p,AlbumForm:y,AlbumPicker:oe,FilesListViewer:J,FileComponent:q,ActionFavorite:V,HeaderNavigation:G,PhotosSourceLocationsSettings:M,AlertCircleOutline:T},filters:{dateMonth(e){return r(e,"YYYYMM").format("MMMM")},dateYear(e){return r(e,"YYYYMM").format("YYYY")}},mixins:[K,z,W],beforeRouteLeave(e,t,o){this.appContent?.scrollTo(0,0),o(),Object.keys(this.selectedFilters).forEach(s=>{this.selectedFilters[s]=[]})},props:{onlyFavorites:{type:Boolean,default:!1},mimesType:{type:Array,default:()=>N},onThisDay:{type:Boolean,default:!1},rootTitle:{type:String,required:!0}},setup(){const e=x(),t=P(),{selectedFilters:o,filtersQuery:s}=I(t);return{isMobile:e,selectedFilters:o,filtersQuery:s}},data(){return{loadingCount:0,showAlbumCreationForm:!1,showAlbumPicker:!1,appContent:document.getElementById("app-content-vue"),showFilters:!1}},computed:{files(){return this.$store.state.files.files},createAlbumButtonLabel(){return Object.keys(this.selectedFilters).length>0?this.t("photos","Create new album from filters"):this.t("photos","Create new album")}},watch:{filtersQuery(){this.resetFetchFilesState(),this.getContent()}},mounted(){g(m,this.handleUserConfigChange)},destroyed(){w(m,this.handleUserConfigChange)},methods:{getContent(){this.fetchFiles({mimesType:this.mimesType,onThisDay:this.onThisDay,onlyFavorites:this.onlyFavorites,extraFilters:this.filtersQuery})},openViewer(e){window.OCA.Viewer.open({fileInfo:u(this.files[e]),list:Object.values(this.fileIdsByMonth).flat().map(t=>u(this.files[t]))})},openUploader(){},async addSelectionToAlbum(e){this.showAlbumPicker=!1,await this.$store.dispatch("addFilesToCollection",{collectionFileName:e.root+e.path,fileIdsToAdd:this.selectedFileIds})},async deleteSelection(){const e=this.selectedFileIds;this.onUncheckFiles(e),this.fetchedFileIds=this.fetchedFileIds.filter(t=>!e.includes(t)),await this.$store.dispatch("deleteFiles",e)},handleUserConfigChange({key:e}){e==="photosSourceFolders"&&this.resetFetchFilesState()},handleFormCreationDone({album:e}){this.showAlbumCreationForm=!1,this.$router.push(`/albums/${e.basename}`)},downloadSelectedFiles(){const e=this.selectedFileIds;this.onUncheckFiles(e),ie(e.map(t=>this.files[t]))},t:h}};var le=function(){var e=this,t=e._self._c;return e.errorFetchingFiles?t("div",{staticClass:"timeline__empty-content"},[e.errorFetchingFiles===404?t("NcEmptyContent",{attrs:{name:e.t("photos","One of the source folders does not exist")}},[t("FolderAlertOutline",{attrs:{slot:"icon"},slot:"icon"}),t("PhotosSourceLocationsSettings",{staticClass:"timeline__update_source_directory",attrs:{slot:"action"},slot:"action"})],1):t("NcEmptyContent",{attrs:{name:e.t("photos","An error occurred")}},[t("AlertCircleOutline",{attrs:{slot:"icon"},slot:"icon"})],1)],1):t("div",{staticClass:"timeline"},[t("HeaderNavigation",{key:"navigation",attrs:{loading:e.loadingCount>0,path:"/",title:e.rootTitle,"root-title":e.rootTitle},on:{refresh:e.resetFetchFilesState}},[t("div",{staticClass:"timeline__header__left"},[e.selectedFileIds.length===0?t("NcButton",{ref:"newAlbumButton",attrs:{"aria-label":e.createAlbumButtonLabel,"data-cy-header-action":"create-album"},on:{click:function(o){e.showAlbumCreationForm=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("PlusBoxMultipleOutline")]},proxy:!0}],null,!1,2448450972)},[e._v(" "+e._s(e.createAlbumButtonLabel)+" ")]):[t("NcButton",{attrs:{"close-after-click":!0,variant:"primary","aria-label":e.t("photos","Add to album"),"data-cy-header-action":"add-to-album"},on:{click:function(o){e.showAlbumPicker=!0}},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Plus")]},proxy:!0},e.isMobile?null:{key:"default",fn:function(){return[e._v(" "+e._s(e.t("photos","Add to album"))+" ")]},proxy:!0}],null,!0)}),e.selectedFileIds.length>0?t("NcButton",{attrs:{"aria-label":e.t("photos","Unselect all"),"data-cy-header-action":"unselect-all"},on:{click:e.resetSelection},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Close")]},proxy:!0},e.isMobile?null:{key:"default",fn:function(){return[e._v(" "+e._s(e.t("photos","Unselect all"))+" ")]},proxy:!0}],null,!0)}):e._e(),t("NcActions",{attrs:{"aria-label":e.t("photos","Open actions menu")}},[t("NcActionButton",{attrs:{"data-cy-header-action":"download-selection","close-after-click":!0,"aria-label":e.t("photos","Download selected files")},on:{click:e.downloadSelectedFiles},scopedSlots:e._u([{key:"icon",fn:function(){return[t("DownloadOutline")]},proxy:!0}])},[e._v(" "+e._s(e.t("photos","Download selected files"))+" ")]),t("ActionFavorite",{attrs:{"selected-file-ids":e.selectedFileIds}}),t("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":e.t("photos","Delete selection"),"data-cy-header-action":"delete-selection"},on:{click:e.deleteSelection},scopedSlots:e._u([{key:"icon",fn:function(){return[t("DeleteOutline")]},proxy:!0}])},[e._v(" "+e._s(e.t("photos","Delete selection"))+" ")])],1)]],2)]),t("FilesListViewer",{ref:"filesListViewer",staticClass:"timeline__file-list",attrs:{"container-element":e.appContent,"file-ids-by-section":e.fileIdsByMonth,sections:e.monthsList,loading:e.loadingFiles,"base-height":e.isMobile?120:200,"empty-message":e.t("photos","No photos or videos in here")},on:{"need-content":e.getContent},scopedSlots:e._u([{key:"default",fn:function({file:o,isHeader:s}){return[s?t("h2",{staticClass:"section-header",attrs:{id:`file-picker-section-header-${o.id}`}},[t("b",[e._v(e._s(e._f("dateMonth")(o.id)))]),e._v(" "+e._s(e._f("dateYear")(o.id))+" ")]):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}})]}}])}),e.showAlbumCreationForm?t("NcModal",{key:"albumCreationForm",attrs:{"label-id":"new-album-form","set-return-focus":e.$refs.newAlbumButton?.$el},on:{close:function(o){e.showAlbumCreationForm=!1}}},[t("h2",{staticClass:"timeline__heading"},[e._v(" "+e._s(e.t("photos","New album"))+" ")]),t("AlbumForm",{attrs:{"filters-value":e.selectedFilters},on:{done:e.handleFormCreationDone}})],1):e._e(),e.showAlbumPicker?t("NcModal",{key:"albumPicker",attrs:{"label-id":"album-picker"},on:{close:function(o){e.showAlbumPicker=!1}}},[t("AlbumPicker",{on:{"album-picked":e.addSelectionToAlbum}})],1):e._e()],1)},ne=[],re=b(ae,le,ne,!1,null,"0b7f1d5e");const qe=re.exports;export{qe as default}; //# sourceMappingURL=TimelineView-Bzb4Tj8Y.chunk.mjs.map