(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[4822],{13574:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>r});vara=i(24786),s=i(91584),o=(i(77333),i(74692));functionn(t){returnfunction(t){if(Array.isArray(t))returnl(t)}(t)||function(t){if("undefined"!=typeofSymbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])returnArray.from(t)}(t)||function(t,e){if(t){if("string"==typeoft)returnl(t,e);vari={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?l(t,e):void0}}(t)||function(){thrownewTypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}functionl(t,e){(null==e||e>t.length)&&(e=t.length);for(vari=0,a=Array(e);i<e;i++)a[i]=t[i];returna}constr={components:{VueCropper:s.default,VueTimeago:a.default},props:["profile-id"],data:function(){return{loaded:!1,config:window.App.config,mimes:["image/jpeg","image/png","video/mp4"],page:"landing",pages:["landing","crop","edit","confirm","error","uploading","createPoll"],uploading:!1,uploadProgress:0,cropper:{aspectRatio:9/16,viewMode:3,zoomable:!0,zoom:null},mediaUrl:null,mediaId:null,mediaType:null,stories:[],lightboxMedia:!1,duration:10,canReply:!0,canReact:!0,poll:{question:null,options:[]},pollQuestion:null,pollOptions:[],canPostPoll:!1,max_duration:15}},watch:{duration:function(t){"video"==this.mediaType&&(this.$refs.previewVideo.currentTime=t,this.$refs.previewVideo.play())},pollQuestion:function(t){t.length<6&&(this.canPostPoll=!1)},pollOptions:function(t){this.pollOptions.filter((function(t){returnt.length>=2})).length>=2?this.canPostPoll=!0:this.canPostPoll=!1}},mounted:function(){vart=this;o("body").addClass("bg-black"),this.mediaWatcher(),setTimeout((function(){axios.get("/api/web/stories/v1/profile/"+t.profileId).then((function(e){e.data.length&&(t.stories=e.data[0].nodes.map((function(t){returnt.showViewers=!1,t.viewers=[],t}))),t.loaded=!0}))}),400)},methods:{upload:function(){o('.file-input[name="media"]').trigger("click")},mediaWatcher:function(){vart=this;o(document).on("change","#pf-dz",(function(e){t.triggerUpload()}))},triggerUpload:function(){vart=this;t.uploading=!0;vare=document.querySelector("#pf-dz");t.page="uploading",Array.prototype.forEach.call(e.files,(function(e,i){if(t.media&&t.media.length+i>=t.config.uploader.album_limit)returnswal("Error","You can only upload "+t.config.uploader.album_limit+" photos per album","error"),t.uploading=!1,void(t.page=2);vara=e.type;if(-1==o.inArray(a,t.mimes))returnswal("Invalid File Type","The file you are trying to add is not a valid mime type. Please upload a "+t.mimes+" only.","error"),t.uploading=!1,void(t.page="error");vars=newFormData;s.append("file",e);varn={onUploadProgress:function(e){vari=Math.floor(100*e.loaded/e.total);t.uploadProgress=i}};e.value=null,axios.post("/api/web/stories/v1/add",s,n).then((function(e){t.uploadProgress=100,t.uploading=!1,t.mediaUrl=e.data.media_url,t.mediaId=e.data.media_id,t.mediaType=e.data.media_type,t.page="video"===e.data.media_type?"preview":"crop",e.data.hasOwnProperty("media_duration")&&(t.max_duration=e.data.media_duration)})).catch((function(i){t.uploading=!1,e.value=null;vara=i.response.data.message?i.response.data.message:i.response.data.error?i.response.data.error:"Something went wrong.";swal("Oops!",a,"warning"),t.page="error"})),t.uploadProgress=0})),document.querySelector("#pf-dz").value=""},expiresTimestamp:function(t){return(t=newDate(1e3*t)).toDateString()+" "+t.toLocaleTimeString()},edit:function(){this.page="edit"},showLightbox:function(t){this.lightboxMedia={url:t.src},this.$refs.lightboxModal.show()},deleteStory:function(t,e){vari=this;1==window.confirm("Are you sure you want to delete this Story?")&&axios.delete("/api/web/stories/v1/delete/"+t.id).then((function(t){i.stories.splice(e,1),0==i.stories.length&&(window.location.href="/i/stories/new")}))},navigateTo:function(){vart=