import{r as C,Y as $,g as M,E,D as P,j as g,a as o,c as p,b as e,d as i,m as f,x as S,v as L,w as k,z as x,_ as V,n as w,i as m,t as Y,S as H,e as N}from"./index-Cdy--wcE.js";import{d as v}from"./dayjs.min-B_4C5ugr.js";import{V as I}from"./vue-datepicker-BjpxqJk-.js";import{L as u}from"./localeText-DwvvmbTS.js";const R={key:0},U={class:"mb-3"},j={class:"position-relative"},A=["disabled"],B={class:"position-relative"},T=["disabled"],O=["disabled"],J={class:"form-check form-switch"},W={class:"form-check-label",for:"includeAttachment"},q=["disabled"],z={key:0},G={key:1},F={key:1},K={__name:"peerShareWithEmail",props:["dataCopy","selectedPeer"],async setup(s){let t,h;const _=s,b=C(!1);[t,h]=$(()=>M("/api/email/ready",{},c=>{b.value=c.status})),await t,h();const n=E({Receiver:"",Body:"",Subject:"",IncludeAttachment:!1,ConfigurationName:_.selectedPeer.configuration.Name,Peer:_.selectedPeer.id}),r=P(),l=C(!1),y=async()=>{l.value=!0,await x("/api/email/send",n,c=>{c.status?r.newMessage("Server","Email sent successfully!","success"):r.newMessage("Server",`Email sent failed! Reason: ${c.message}`,"danger"),l.value=!1})};return(c,a)=>{const D=g("RouterLink");return b.value?(o(),p("div",R,[e("h6",U,[i(u,{t:"Share with Email"})]),e("form",{class:"d-flex gap-3 flex-column",onSubmit:a[4]||(a[4]=d=>{d.preventDefault(),y()})},[e("div",null,[e("div",j,[a[5]||(a[5]=e("i",{class:"bi bi-person-circle",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),f(e("input",{type:"email",class:"form-control rounded-top-3 rounded-bottom-0",style:{"padding-left":"calc( 0.75rem + 24px )"},"onUpdate:modelValue":a[0]||(a[0]=d=>n.Receiver=d),disabled:l.value,placeholder:"Send to who?",required:"",id:"email_receiver","aria-describedby":"emailHelp"},null,8,A),[[S,n.Receiver]])]),e("div",B,[a[6]||(a[6]=e("i",{class:"bi bi-hash",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),f(e("input",{type:"text",class:"form-control rounded-0 border-top-0 border-bottom-0",style:{"padding-left":"calc( 0.75rem + 24px )"},placeholder:"Subject",disabled:l.value,"onUpdate:modelValue":a[1]||(a[1]=d=>n.Subject=d),id:"email_subject","aria-describedby":"emailHelp"},null,8,T),[[S,n.Subject]])]),f(e("textarea",{class:"form-control rounded-bottom-3 rounded-top-0","onUpdate:modelValue":a[2]||(a[2]=d=>n.Body=d),disabled:l.value,placeholder:"Body",style:{"min-height":"300px"}},null,8,O),[[S,n.Body]])]),e("div",J,[f(e("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":a[3]||(a[3]=d=>n.IncludeAttachment=d),role:"switch",id:"includeAttachment",checked:""},null,512),[[L,n.IncludeAttachment]]),e("label",W,[i(u,{t:"Include configuration file as an attachment"})])]),e("button",{disabled:l.value,class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-3"},[l.value?(o(),p("span",G,[a[8]||(a[8]=e("span",{class:"spinner-border spinner-border-sm me-2"},null,-1)),i(u,{t:"Sending..."})])):(o(),p("span",z,[a[7]||(a[7]=e("i",{class:"bi bi-send me-2"},null,-1)),i(u,{t:"Send"})]))],8,q)],32)])):(o(),p("div",F,[e("small",null,[i(u,{t:"SMTP is not configured, please navigate to "}),i(D,{to:"/settings"},{default:k(()=>[i(u,{t:"Settings"})]),_:1}),i(u,{t:" to finish setup"})])]))}}},Q={name:"peerShareLinkModal",props:{selectedPeer:Object},components:{PeerShareWithEmail:K,LocaleText:u,VueDatePicker:I},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:P()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.selectedPeer.ShareLink)).at(0)},watch:{"selectedPeer.ShareLink":{deep:!0,handler(s,t){t.length!==s.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.selectedPeer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,x("/api/sharePeer/create",{Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,ExpireDate:v().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},s=>{s.status?(this.selectedPeer.ShareLink=s.data,this.dataCopy=s.data.at(0)):this.store.newMessage("Server","Share link failed to create. Reason: "+s.message,"danger"),this.loading=!1})},updateLinkExpireDate(){x("/api/sharePeer/update",this.dataCopy,s=>{s.status?(this.dataCopy=s.data.at(0),this.selectedPeer.ShareLink=s.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+s.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=v().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(s){s?this.dataCopy.ExpireDate=v(s).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const s=this.store.getActiveCrossServer();return s?`${s.host}/${this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}`:window.location.origin+window.location.pathname+this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}}},X={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Z={class:"container d-flex h-100 w-100"},ee={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},te={class:"card rounded-3 shadow flex-grow-1"},se={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},ae={class:"mb-0"},ie={key:0,class:"card-body px-4 pb-4"},oe={key:0},ne={class:"mb-3 text-muted"},re=["disabled"],le={key:1},de={class:"d-flex gap-2 mb-4"},ce=["href"],ue={class:"d-flex flex-column gap-2 mb-3"},pe=["disabled"],me={class:"text-muted"};function he(s,t,h,_,b,n){const r=g("LocaleText"),l=g("VueDatePicker"),y=g("PeerShareWithEmail");return o(),p("div",X,[e("div",Z,[e("div",ee,[e("div",te,[e("div",se,[e("h4",ae,[i(r,{t:"Share Peer"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=c=>this.$emit("close"))})]),this.selectedPeer.ShareLink?(o(),p("div",ie,[this.dataCopy?(o(),p("div",le,[e("div",de,[t[4]||(t[4]=e("i",{class:"bi bi-link-45deg"},null,-1)),e("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},Y(n.getUrl),9,ce)]),e("div",ue,[e("small",null,[t[5]||(t[5]=e("i",{class:"bi bi-calendar me-2"},null,-1)),i(r,{t:"Expire At"})]),i(l,{is24:!0,"min-date":new Date,"model-value":this.dataCopy.ExpireDate,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","dark"])]),e("button",{onClick:t[2]||(t[2]=c=>this.stopSharing()),disabled:this.loading,class:"w-100 btn bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle rounded-3 shadow-sm"},[e("span",{class:w({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[6]||(t[6]=[e("i",{class:"bi bi-send-slash-fill me-2"},null,-1)]),2),this.loading?(o(),m(r,{key:0,t:"Stop Sharing..."})):(o(),m(r,{key:1,t:"Stop Sharing"}))],8,pe),t[8]||(t[8]=e("hr",null,null,-1)),(o(),m(H,null,{fallback:k(()=>[e("h6",me,[t[7]||(t[7]=e("span",{class:"spinner-border me-2 spinner-border-sm",role:"status"},null,-1)),i(r,{t:"Checking SMTP Configuration..."})])]),default:k(()=>[i(y,{selectedPeer:h.selectedPeer,dataCopy:b.dataCopy},null,8,["selectedPeer","dataCopy"])]),_:1}))])):(o(),p("div",oe,[e("h6",ne,[i(r,{t:"Currently the peer is not sharing"})]),e("button",{onClick:t[1]||(t[1]=c=>this.startSharing()),disabled:this.loading,class:"w-100 btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm"},[e("span",{class:w({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[3]||(t[3]=[e("i",{class:"bi bi-send-fill me-2"},null,-1)]),2),this.loading?(o(),m(r,{key:0,t:"Sharing..."})):(o(),m(r,{key:1,t:"Start Sharing"}))],8,re)]))])):N("",!0)])])])])}const ye=V(Q,[["render",he]]);export{ye as default};