import{d as a,_ as e}from"./public.js?v=1764830988434";import{o as l,T as s,cH as i,gT as n,gU as t,x as u}from"./page_layout.js?v=1764830988434";import{_ as o}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764830988434";import{k as r,P as p,r as m,c as d,e as _,a2 as c,V as v,a3 as h,W as f,an as y,U as k,l as b,S,v as g,j as w,a4 as D}from"./vue.js?v=1764830988434";import{dR as x,dj as P,dV as L,au as j}from"./naive.js?v=1764830988434";import"./common.js?v=1764830988434";import"./__commonjsHelpers__.js?v=1764830988434";const I={class:"w-300px"},A={class:"w-300px"},U={class:"w-300px"},$=r({__name:"form",props:{row:{},isEdit:{type:Boolean}},emits:["refresh"],setup(r,{expose:$,emit:C}){const T=r,F=C,{isEdit:N,row:B}=T,{t:E}=p(),q=m(null),K=m([]),V=d(()=>"CloudFlareDns"===R.name),W=d(()=>"NameSiloDns"!==R.name&&"global"===R.permission),H=d(()=>"PorkBunDns"===R.name||"GodaddyDns"===R.name),R=_({name:"",api_user:"",api_key:"",alias:"",permission:"global",status:1}),G={api_user:{required:!0,trigger:"blur",validator:(a,e)=>!("CloudFlareDns"!==R.name&&!e)||new Error(E("SSL.Domain.index_1"))},api_key:{required:!0,trigger:"blur",message:E("SSL.Domain.index_2")},alias:{required:!0,trigger:"blur",message:E("SSL.Domain.index_6")}},z=a=>{var e;"CloudFlareDns"!==a&&"limit"===R.permission&&(R.permission="global"),null==(e=q.value)||e.restoreValidation()},J=m(""),M=m(!0),O=()=>{M.value&&(R.api_user="")},Q=()=>{!R.api_user&&M.value?R.api_user=J.value:R.api_user&&(M.value=!1)},X=()=>({id:N&&B?B.id:null,name:N&&B&&R.name===B.name?null:R.name,api_user:N&&B&&R.api_user===B.api_user?null:W.value?R.api_user:"",api_key:N&&B&&R.api_key===B.api_key?null:R.api_key,permission:N&&B&&R.permission===B.permission?null:"CloudFlareDns"===R.name?R.permission:"",status:N&&B&&R.status===B.status?null:R.status,alias:N&&B&&R.alias===B.alias?null:R.alias}),{loading:Y,setLoading:Z}=a();return(async()=>{try{Z(!0);const{message:a}=await t();u(a)&&a.length>0&&(R.name=a[0],K.value=a.map(a=>({label:a,value:a})))}finally{(()=>{const{row:a,isEdit:e}=T;e&&a&&(R.name=a.name,R.api_user=a.api_user,J.value=a.api_user,R.api_key=a.api_key,R.permission=a.permission,R.status=a.status,R.alias=a.alias)})(),Z(!1)}})(),$({onConfirm:async()=>{var a;await(null==(a=q.value)?void 0:a.validate()),N&&B?await i(X()):await n(X()),F("refresh")}}),(a,i)=>{const n=P,t=x,u=L,r=j,p=o,m=l,d=e,_=s;return v(),c(_,{class:"p-20px",show:k(Y)},{default:h(()=>[f(p,{ref_key:"formRef",ref:q,model:k(R),rules:G},{default:h(()=>[f(t,{label:a.$t("Public.Table.Status"),path:"status"},{default:h(()=>[f(n,{value:k(R).status,"onUpdate:value":i[0]||(i[0]=a=>k(R).status=a),"checked-value":1,"unchecked-value":0},null,8,["value"])]),_:1},8,["label"]),f(t,{label:a.$t("Config.Alarm.index_43"),path:"name"},{default:h(()=>[f(u,{class:"w-300px",value:k(R).name,"onUpdate:value":[i[1]||(i[1]=a=>k(R).name=a),z],options:k(K),disabled:k(N)},null,8,["value","options","disabled"])]),_:1},8,["label"]),k(W)?(v(),c(t,{key:0,label:k(H)?"Secret Key":"API User",path:"api_user"},{default:h(()=>[S("div",I,[f(r,{value:k(R).api_user,"onUpdate:value":i[2]||(i[2]=a=>k(R).api_user=a),placeholder:k(H)?"Please enter Secret Key":a.$t("SSL.Domain.index_1"),onFocus:O,onBlur:Q},null,8,["value","placeholder"])])]),_:1},8,["label"])):y("",!0),f(t,{label:"API Key",path:"api_key"},{default:h(()=>[S("div",A,[f(r,{value:k(R).api_key,"onUpdate:value":i[3]||(i[3]=a=>k(R).api_key=a),placeholder:a.$t("SSL.Domain.index_2")},null,8,["value","placeholder"])])]),_:1}),f(t,{label:a.$t("Config.Panel.index_36"),path:"alias"},{default:h(()=>[S("div",U,[f(r,{value:k(R).alias,"onUpdate:value":i[4]||(i[4]=a=>k(R).alias=a),placeholder:a.$t("SSL.Domain.index_6")},null,8,["value","placeholder"])])]),_:1},8,["label"]),b(f(t,{label:"API-Limit",path:"permission"},{default:h(()=>[f(n,{value:k(R).permission,"onUpdate:value":i[5]||(i[5]=a=>k(R).permission=a),"checked-value":"limit","unchecked-value":"global"},null,8,["value"])]),_:1},512),[[g,k(V)]])]),_:1},8,["model"]),k(V)?(v(),c(d,{key:0},{default:h(()=>[S("li",null,[f(m,{target:"_blank",href:"https://www.aapanel.com/docs/Function/Tutorial/DNS_API_Tutorial.html"},{default:h(()=>[w(D(a.$t("SSL.Domain.index_3")),1)]),_:1})])]),_:1})):y("",!0),"NameCheapDns"===k(R).name?(v(),c(d,{key:1},{default:h(()=>[i[6]||(i[6]=S("li",null," Namecheap API needs added in Whitelisted IPs (only IPv4): Profile > Tools menu > Namecheap API Access > Whitelisted IPs, please check: ",-1)),S("li",null,[f(m,{target:"_blank",href:"https://www.namecheap.com/support/api/intro/"},{default:h(()=>[w(D(a.$t("SSL.Domain.index_3")),1)]),_:1})])]),_:1,__:[6]})):y("",!0),"NameSiloDns"===k(R).name||"PorkBunDns"===k(R).name?(v(),c(d,{key:2},{default:h(()=>[S("li",null,[f(m,{target:"_blank",href:"https://www.aapanel.com/docs/Function/Tutorial/DNS_API_Tutorial.html"},{default:h(()=>[w(D(a.$t("SSL.Domain.index_3")),1)]),_:1})])]),_:1})):y("",!0)]),_:1},8,["show"])}}});export{$ as default};
