import{c as e,s,r as a,v as l,x as r,e as t,B as o,z as n,K as u,y as v,R as c,Q as m,aY as i,T as p}from"./base-lib.js?v=1761009159";import{b as d,p as f,P as x,_ as y}from"./utils-lib.js?v=1761009159";import{H as _,I as h}from"./ssl.js?v=1761009159";import{u as b}from"./useStore11.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const g={class:"p-[16px]"},j={class:"flex flex-1 justify-start mt-[16px]"},D={class:"flex-1 mr-[2rem]"},R={class:"flex-1"},w=y(e({__name:"index",emits:["close"],setup(e,{expose:y,emit:w}){const{activeTabs:I,sslIsRefresh:V,testIsRefresh:k,encryptIsRefresh:T,otherIsRefresh:z}=s(b()),q=w,C=a(""),E=a(""),F=a(!1),H=a(!1),K=(e,s)=>{var a;if(s.preventDefault(),"key"===e?F.value=!1:H.value=!1,window.FileReader){const l=null==(a=s.dataTransfer)?void 0:a.files;if(l&&l.length>0){const s=l[0],a=new FileReader;a.onload=s=>{var a;(null==(a=s.target)?void 0:a.result)&&("key"===e?C.value=s.target.result:E.value=s.target.result)},a.onerror=()=>{d().error("请上传证书文件")},a.readAsText(s)}else d().error("无效的证书文件拖拽上传")}else d().error("当前浏览器版本不支持文件拖拽上传，请升级浏览器版本")},P={ssl:()=>V.value=!0,test:()=>k.value=!0,encrypt:()=>T.value=!0,other:()=>z.value=!0};return y({onConfirm:async()=>{var e;try{const s=await _({key:C.value,csr:E.value});d().request(s),s.status&&(q("close"),s.creat_order&&f({title:"创建证书订单",content:"检测到证书文件为let's encrypt证书，是否立即同步证书？",onConfirm:async()=>{x({request:h({ssl_hash:s.ssl_hash}),loading:"正在同步证书",message:!0,success:()=>{var e;null==(e=P[I.value])||e.call(P)}})}}),null==(e=P[I.value])||e.call(P))}catch(s){}}}),(e,s)=>{const a=i,d=p;return l(),r("div",g,[t(a,{type:"success",closable:!1},{title:o(()=>s[8]||(s[8]=[n("div",{class:"mr-[3.2rem] text-small pb-[5px]"},"温馨提示：支持拖拽证书文件上传，并自动识别。",-1)])),_:1}),n("div",j,[n("div",D,[s[9]||(s[9]=n("div",{class:"mb-[.4rem]"},"密钥(KEY)",-1)),n("div",{class:u(["drop-zone mb-[.2rem] p-[.2rem]",{over:v(F)}]),onDragover:s[1]||(s[1]=c(e=>F.value=!0,["prevent"])),onDragleave:s[2]||(s[2]=c(e=>F.value=!1,["prevent"])),onDrop:s[3]||(s[3]=e=>K("key",e))},[t(d,{type:"textarea",rows:22,modelValue:v(C),"onUpdate:modelValue":s[0]||(s[0]=e=>m(C)?C.value=e:null)},null,8,["modelValue"])],34)]),n("div",R,[s[10]||(s[10]=n("div",{class:"mb-[.4rem]"},"证书(PEM格式)",-1)),n("div",{class:u(["drop-zone mb-[.2rem] p-[.2rem]",{over:v(H)}]),onDragover:s[5]||(s[5]=c(e=>H.value=!0,["prevent"])),onDragleave:s[6]||(s[6]=c(e=>H.value=!1,["prevent"])),onDrop:s[7]||(s[7]=e=>K("csr",e))},[t(d,{type:"textarea",rows:22,modelValue:v(E),"onUpdate:modelValue":s[4]||(s[4]=e=>m(E)?E.value=e:null)},null,8,["modelValue"])],34)])])])}}}),[["__scopeId","data-v-6a29ead6"]]);export{w as default};
