"use strict";(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[286],{63744:(t,e,a)=>{a.r(e),a.d(e,{default:()=>m});vari=a(42755),s=a(88231),o=a(33795),n=a(78423),r=a(22583),l=a(64491),d=a(19755);functionc(t){returnfunction(t){if(Array.isArray(t))returnp(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)returnp(t,e);vara=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)returnArray.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))returnp(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.")}()}functionp(t,e){(null==e||e>t.length)&&(e=t.length);for(vara=0,i=newArray(e);a<e;a++)i[a]=t[a];returni}constm={props:["accountId"],components:{drawer:i.default,sidebar:s.default,intersect:n.default,"dm-placeholder":o.default,"profile-card":r.default,message:l.default},data:function(){return{isLoaded:!1,profile:void0,conversationProfile:void0,isIntersecting:!1,config:window.App.config,hideAvatars:!0,hideTimestamps:!1,largerText:!1,autoRefresh:!1,mutedNotifications:!1,blocked:!1,loaded:!1,page:"read",pages:["browse","add","read"],threads:[],thread:!1,threadIndex:!1,replyText:"",composeUsername:"",uploading:!1,uploadProgress:null,min_id:null,max_id:null,loadingMessages:!1,showLoadMore:!0,showReplyLong:!1,showReplyTooLong:!1,showPrivacyWarning:!0}},mounted:function(){vart=this;this.profile=window._sharedData.user,this.isLoaded=!0;vare=this;axios.get("/api/v1/accounts/"+this.accountId).then((function(e){t.conversationProfile=e.data})),axios.get("/api/direct/thread",{params:{pid:e.accountId}}).then((function(a){e.loaded=!0;vari=a.data;t.thread=i,t.threads=[i],t.threadIndex=0;vars=i.messages.map((function(t){returnt.id}));t.max_id=Math.max.apply(Math,c(s)),t.min_id=Math.min.apply(Math,c(s)),t.mutedNotifications=i.muted,t.markAsRead()}));vara=localStorage.getItem("px_dm_options");a&&(a=JSON.parse(a),this.hideAvatars=a.hideAvatars,this.hideTimestamps=a.hideTimestamps,this.largerText=a.largerText)},computed:{showDMPrivacyWarning:{get:function(){returnthis.$store.state.showDMPrivacyWarning},set:function(t){window.localStorage.removeItem("pf_m2s.dmwarncounter"),this.$store.commit("setShowDMPrivacyWarning",t)}}},watch:{mutedNotifications:function(t){t?axios.post("/api/direct/mute",{id:this.accountId}).then((function(t){})):axios.post("/api/direct/unmute",{id:this.accountId}).then((function(t){})),this.mutedNotifications=t},hideAvatars:function(t){this.hideAvatars=t,this.updateOptions()},hideTimestamps:function(t){this.hideTimestamps=t,this.updateOptions()},largerText:function(t){this.largerText=t,this.updateOptions()},replyText:function(t){returnt.length<500&&(this.showReplyLong=!1,this.showReplyTooLong=!1),t.length>500?(this.showReplyLong=!1,void(this.showReplyTooLong=!0)):t.length>450?(this.showReplyTooLong=!1,void(this.showReplyLong=!0)):void0}},methods:{sendMessage:function(){vart=this,e=this,a=this.replyText;axios.post("/api/direct/create",{to_id:this.threads[this.threadIndex].id,message:a,type:e.isEmoji(a)&&a.length<10?"emoji":"text"}).then((function(a){vari=a.data;e.threads[e.threadIndex].messages.unshift(i);vars=e.threads[e.threadIndex].messages.map((function(t){returnt.id}));t.max_id=Math.max.apply(Math,c(s)),t.min_id=Math.min.apply(Math,c(s))})).catch((function(t){403==t.response.status&&(e.blocked=!0,swal("Profile Unavailable","You cannot message this profile at this time.","error"))})),this.replyText=""},truncate:function(t){return_.truncate(t)},deleteMessage:function(t){vare=this;window.confirm("Are you sure you want to delete this message?")&&axios.delete("/api/direct/message",{params:{id:this.thread.messages[t].reportId}}).then((function(a){e.thread.messages.splice(t,1)}))},reportMessage:function(){this.closeCtxMenu();vart="/i/report?type=post