(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[33],{98379:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>n});i(82364);functiono(t){returnfunction(t){if(Array.isArray(t))returns(t)}(t)||function(t){if("undefined"!=typeofSymbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])returnArray.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeoft)returns(t,e);vari=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)returnArray.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))returns(t,e)}(t)||function(){thrownewTypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}functions(t,e){(null==e||e>t.length)&&(e=t.length);for(vari=0,o=newArray(e);i<e;i++)o[i]=t[i];returno}constn={props:["collection-id","collection-title","collection-description","collection-visibility","profile-id","profile-username"],components:{intersect:i(78423).default},data:function(){return{collection:{},config:window.App.config,loaded:!1,posts:[],ids:[],user:!1,owner:!1,title:this.collectionTitle,description:this.collectionDescription,visibility:this.collectionVisibility,photoId:"",postsList:[],loadingPostList:!1,addingPostToCollection:!1,markedForDeletion:[],canLoadMore:!1,isIntersecting:!1,page:1}},beforeMount:function(){this.fetchCollection()},methods:{enterIntersect:function(){this.isIntersecting||(this.isIntersecting=!0,this.page++,this.fetchItems())},statusUrl:function(t){return"/i/web/post/"+t.id},fetchCollection:function(){vart=this;axios.get("/api/local/collection/"+this.collectionId).then((function(e){t.collection=e.data,t.collection.post_count>9&&(t.canLoadMore=!0),t.fetchCurrentUser()}))},fetchCurrentUser:function(){vart=this;1==document.querySelectorAll("body")[0].classList.contains("loggedIn")?axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(e){t.user=e.data,t.owner=t.user.id==t.profileId,window._sharedData.curUser=e.data,window.App.util.navatar(),t.fetchItems()})):this.fetchItems()},fetchItems:function(){vart=this;axios.get("/api/local/collection/items/"+this.collectionId,{params:{page:this.page}}).then((function(e){vari;if(0==e.data.length)returnconsole.log("no items found"),t.loaded=!0,t.isIntersecting=!1,void(t.canLoadMore=!1);vars=e.data.filter((function(e){return-1==t.ids.indexOf(e.id)}));(i=t.posts).push.apply(i,o(s)),t.ids=t.posts.map((function(t){returnt.id})),t.loaded=!0,t.isIntersecting=!1,0==s.length&&(t.canLoadMore=!1)}))},previewUrl:function(t){returnt&&t.sensitive?"/storage/no-preview.png?v="+(newDate).getTime():t.media_attachments[0].url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");"},addToCollection:function(){vart=this;this.loadingPostList=!0,0==this.postsList.length?axios.get("/api/pixelfed/v1/accounts/"+this.profileId+"/statuses",{params:{min_id:1,limit:24}}).then((function(e){t.postsList=e.data.filter((function(e){return-1==t.ids.indexOf(e.id)})).splice(0,9),t.loadingPostList=!1,t.$refs.addPhotoModal.show()})).catch((function(e){t.loadingPostList=!1,swal("An Error Occured","We cannot process your request at this time, please try again later.","error")})):(this.$refs.addPhotoModal.show(),this.loadingPostList=!1)},pushId:function(){vart=this,e=this.config.uploader.max_collection_length,i=this;if(this.posts.length>=e)swal("Error","You can only add "+e+" posts per collection","error");else{vars=this.photoId,n=window.location.origin,a=s.split("/");if(s.slice(0,n.length)!==n&&(swal("Invalid URL","You can only add posts from this instance","error"),this.photoId=""),!s.includes("/i/web/post/")&&!s.includes("/p/"))returnswal("Invalid URL","Invalid URL","error"),void(this.photoId="");varl=a[a.length-1].split("?")[0];axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:l}).then((function(t){vare;(e=i.ids).push.apply(e,o(l)),i.posts.push(t.data),i.collection.post_count++,i.id=""})).catch((function(e){