import{r as b,o as i,g as r,a as h,u as d,F as P,D as z,c as g,w as f,f as a,t as m,i as v,L as D,h as u,b as k}from"./app-DA7OTM4Q.js";import{u as L}from"./app-BT68AfZ-.js";import{T as C}from"./app-Zes_jb7S.js";import"./app-kBNY2ZLt.js";import{T as U}from"./app-BkWUIifj.js";const j=["value"],x={key:0,class:"label-group"},J=["onClick"],M=h("i",{class:"pi pi-remove"},null,-1),O=[M],E={key:1},F={key:0,class:"red"},H={key:0},R={key:1},Y={key:1,class:"grey"},q={key:2,class:"my-4"},G=h("span",{class:"disabled"},"|",-1),te={__name:"SSLCertsBox",props:["v-certs","v-cert","v-protocol","v-view-size","v-single-mode","v-description","v-domains","v-user-id"],emits:["update:modelValue"],setup(S,{emit:T}){const s=S,w=T,{certs:n,description:_}=(()=>{let e=s.vCerts;e==null&&(e=[]),s.vCert!=null&&(e.push(s.vCert),setTimeout(()=>c()));let t=s.vDescription;return(t==null||typeof t!="string")&&(t=""),{certs:b(e),description:b(t)}})();setTimeout(()=>c());const I=function(){return n.value.map(function(e){return e.id})},p=L(),$=function(e){p.confirm("确定删除此证书吗？证书数据仍然保留，只是当前网站不再使用此证书。",function(){n.value.$remove(e),c()})},B=function(){let e=[];if(s.vDomains!=null){if(typeof s.vDomains=="function"){let o=s.vDomains();o!=null&&typeof o=="object"&&o instanceof Array&&(e=o)}else typeof s.vDomains=="object"&&s.vDomains instanceof Array&&(e=s.vDomains);e.length>1e4&&(e=e.slice(0,1e4))}let t=n.value.map(function(o){return o.id}),l=s.vUserId;l==null&&(l=0),p.popup("/servers/certs/selectPopup?viewSize=&searchingDomains="+window.encodeURIComponent(e.join(","))+"&selectedCertIds="+t.join(",")+"&userId="+l,{width:"50em",height:"40em",callback:function(o){o.data.cert!=null&&n.value.push(o.data.cert),o.data.certs!=null&&n.value.$pushAll(o.data.certs),c()}})},N=function(){let e=s.vUserId;typeof e!="number"&&typeof e!="string"&&(e=0),p.popup("/servers/certs/uploadPopup?userId="+e,{height:"28em",callback:function(t){p.success("上传成功",function(){t.data.cert!=null&&n.value.push(t.data.cert),t.data.certs!=null&&n.value.$pushAll(t.data.certs),c()})}})},V=function(){let e=s.vUserId;typeof e!="number"&&typeof e!="string"&&(e=0),p.popup("/servers/certs/uploadBatchPopup?userId="+e,{height:"30em",callback:function(t){t.data.cert!=null&&n.value.push(t.data.cert),t.data.certs!=null&&n.value.$pushAll(t.data.certs),c()}})},A=function(e){return new Date(e*1e3).format("Y-m-d")},y=function(){return s.vSingleMode==null||!s.vSingleMode||n.value==null||n.value.length==0},c=()=>{w("update:modelValue",JSON.stringify(I()))};return(e,t)=>(i(),r("div",null,[h("input",{type:"hidden",name:"certIdsJSON",value:JSON.stringify(I())},null,8,j),d(n)!=null&&d(n).length>0?(i(),r("div",x,[(i(!0),r(P,null,z(d(n),(l,o)=>(i(),g(U,{outlined:""},{default:f(()=>[a(m(l.name)+" / "+m(l.dnsNames)+" / 有效至"+m(A(l.timeEndAt))+"   ",1),h("a",{href:"",title:"删除",onClick:v(K=>$(o),["prevent"])},O,8,J)]),_:2},1024))),256)),y()?(i(),g(D,{key:0})):u("",!0)])):(i(),r("div",E,[d(_).length==0?(i(),r("span",F,[a("选择或上传证书后"),e.vProtocol=="https"?(i(),r("span",H,"HTTPS")):u("",!0),e.vProtocol=="tls"?(i(),r("span",R,"TLS")):u("",!0),a("服务才能生效。")])):u("",!0),d(_).length>0?(i(),r("span",Y,m(d(_)),1)):u("",!0),y()?(i(),g(D,{key:2})):u("",!0)])),y()?(i(),r("div",q,[k(C,{secondary:"",size:"small",onClick:t[0]||(t[0]=v(l=>B(),["prevent"]))},{default:f(()=>[a("选择已有证书")]),_:1}),a("   "),G,a("   "),k(C,{secondary:"",size:"small",onClick:t[1]||(t[1]=v(l=>N(),["prevent"]))},{default:f(()=>[a("上传新证书")]),_:1}),a("   "),k(C,{secondary:"",size:"small",onClick:t[2]||(t[2]=v(l=>V(),["prevent"]))},{default:f(()=>[a("批量上传证书")]),_:1}),a("   ")])):u("",!0)]))}};export{te as _};
