"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/dns/records/edit"],{1693:(e,t,s)=>{s.r(t),s.d(t,{default:()=>f});var a=s(241),l=s(447),n=s(748),i=s(719),o=s(242),r=s(910),d=s(877),u=s(90),p=s(1694),m=s(717);const c=u.Locale.getTranslate("smb.components.forms.dns-zone.record"),x=l.gql`
    mutation UpdateDnsTemplateRecord($input: UpdateDnsTemplateRecordInput!) {
        updateDnsTemplate(input: $input) {
            dnsRecordTemplate {
                id
                type
                ttl
                opt
                host
                displayVal
                displayHost
                domainName
            }
        }
    }
`,f=()=>{const e=(0,i.useParams)(),t=(0,i.useNavigate)(),[l,u]=(0,a.useState)(),{data:f}=(0,i.useLoaderData)(),{dns:{template:{isEnabled:j}}}=f,[y,g]=(0,a.useState)((()=>{if(f.node){const{toFormValues:e}=(0,p.default)(f.os.isUnix,j)[f.node.type];return"function"==typeof e?e(f.node):f.node}const e=j?"A":"NS";return{...(0,p.default)(f.os.isUnix,j)[e].defaults,type:e}})),[h,{loading:F}]=(0,n.useMutation)(x,{refetchQueries:f.node?[]:[{query:s(827),awaitRefetchQueries:!0}]}),b=e.id?"edit-title":j?"add-title":"add-ns-title",{fields:S}=(0,a.useMemo)((()=>f?(0,p.default)(f?.os?.isUnix,j)[y.type]??{}:{}),[y.type,f,j]),V=()=>t("..");return(0,a.jsx)(r.default,{"data-type":"dns-record-form",size:"sm",onClose:V,title:(0,a.jsx)(c,{content:b}),form:(0,a.jsx)(d.default,{mutation:h,applyButton:!1,values:y,onSubmit:e=>{const{__typename:t,...s}=e,{toSubmitValues:a}=(0,p.default)(f.os.isUnix,j)[s.type];return"function"==typeof a?a(s):s},onFieldChange:(e,t)=>{"type"===e&&(u(null),g({...(0,p.default)(f?.os?.isUnix,j)[t]?.defaults,type:t}))},onSuccess:()=>{(0,m.addToast)({intent:"success",message:(0,a.jsx)(c,{content:(e.id?"edit":"add")+"-success"})}),V()},onError:e=>{u(e.general)},state:F?"submit":null,submitButton:{id:"btn-send"},children:(0,a.jsxs)(a.Fragment,{children:[l?(0,a.jsx)(o.StatusMessage,{intent:"danger",children:(0,a.jsx)("span",{dangerouslySetInnerHTML:{__html:l}})}):null,j?(0,a.jsx)(o.FormFieldSelect,{width:"90px","data-type":"dns-type",name:"type",label:(0,a.jsx)(c,{content:"type"}),children:f.dns.supportedRecordTypes.map((e=>(0,a.jsx)(o.SelectOption,{value:e,children:e},e)))}):null,(0,a.jsx)(o.FormField,{label:(0,a.jsx)(c,{content:"ttl"}),name:"ttl",children:({getName:e,getValue:t,setValue:s})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Input,{min:0,max:4294967295,type:"number",name:e(),value:t(),onChange:({target:e})=>s(+e.value)})," ",(0,a.jsx)(c,{content:"ttl-seconds"})]})}),S]})})})}},1695:(e,t,s)=>{s.r(t),s.d(t,{default:()=>u});var a=s(242),l=s(243),n=s.n(l),i=s(90),o=s(241);const r=i.Locale.getTranslate("smb.components.forms.dns-zone.record"),d=({name:e="domainName",label:t="domainName"})=>(0,o.jsx)(a.FormField,{label:(0,o.jsx)(r,{content:t}),name:e,children:({getName:e,getValue:t,setValue:s})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.Input,{name:e(),value:t(),onChange:({target:e})=>s(e.value)})," ",(0,o.jsx)(r,{content:"domainNamePostfix"})]})});d.propTypes={name:n().string,label:n().string},d.defaultProps={name:"domainName",label:"domainName"};const u=d},1694:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var a=s(242),l=s(90),n=s(1695),i=s(241);const o=l.Locale.getTranslate("smb.components.forms.dns-zone.record"),r=l.Locale.getSection("smb.components.forms.dns-zone.record"),d=(e,t)=>({NS:{defaults:{},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[t?(0,i.jsx)(n.default,{},"ns_domain_name"):null,(0,i.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,i.jsx)(o,{content:"nameServer"}),inputProps:{suffix:".",size:"lg"}},"ns_ext_host")]},A:{defaults:{},fields:[(0,i.jsx)(n.default,{},"a_domain_name"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"ipAddress"}),description:(0,i.jsx)(o,{content:"ipAddressDescriptionExt"})},"A_ip")]},AAAA:{defaults:{},fields:[(0,i.jsx)(n.default,{},"aaaa_int_host"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"ipAddressV6"}),description:(0,i.jsx)(o,{content:"ipAddressV6DescriptionExt"})},"AAAA_ip")]},CNAME:{defaults:{},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,i.jsx)(n.default,{},"cname_int_host"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"canonicalName"})},"CNAME_canonical")]},MX:{defaults:{opt:"0"},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,i.jsx)(n.default,{label:"mailDomain"},"mx_displayHost"),(0,i.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"mxServer"})},"mx_displayVal"),(0,i.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,i.jsx)(o,{content:"mxServerPriority"}),children:[(0,i.jsx)(a.SelectOption,{value:"0",children:r.lmsg("priorityHigh",{priority:0})}),Array.from({length:9}).map(((e,t)=>{const s=0===t?1:5*t;return(0,i.jsx)(a.SelectOption,{value:s.toString(),children:s.toString()},s)})),(0,i.jsx)(a.SelectOption,{value:50,children:r.lmsg("priorityLow",{priority:50})})]},"mx_opt")]},PTR:{defaults:{},toFormValues:({displayHost:e,opt:t,displayVal:s,...a})=>({...a,displayVal:s.replace(/\.?<domain>./,""),ipMask:{ip:e,mask:t}}),toSubmitValues:({ipMask:e,...t})=>({...t,displayHost:e?.ip,opt:e?.mask}),fields:[(0,i.jsx)(a.FormField,{required:!0,label:(0,i.jsx)(o,{content:"ipAddress"}),name:"ipMask",description:(0,i.jsx)(o,{content:"ipAddressWithMaskDescriptionExt"}),children:({getId:e,getName:t,getValue:s,setValue:l})=>{const{ip:n,mask:o}=s()??{};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.Input,{id:`${e()}-ip`,size:"lg",name:`${t()}[ip]`,value:n,onChange:({target:e})=>l({ip:e.value,mask:o})})," / ",(0,i.jsx)(a.Input,{id:`${e()}-mask`,size:"sm",name:`${t()}[mask]`,value:o,onChange:({target:e})=>l({ip:n,mask:e.value})})]})}},"prt_ip"),(0,i.jsx)(n.default,{name:"displayVal"},"ptr_int_host")]},TXT:{defaults:e?{}:{value:"+all",spfSyntax:"spf"},toFormValues:t=>{if(e)return t;const{displayVal:s,...a}=t,l=s.startsWith("v=spf1 ")?"spf":"multiline";return{...a,spfSyntax:l,value:"spf"===l?s.slice(7):"",multilineValue:"spf"!==l?s:""}},toSubmitValues:t=>{if(e)return t;const{spfSyntax:s,value:a,multilineValue:l,displayHost:n,...i}=t;return{...i,displayHost:n,displayVal:"spf"===s?`v=spf1 ${a}`:l}},fields:[(0,i.jsx)(n.default,{},"txt_int_host"),e?(0,i.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",label:(0,i.jsx)(o,{content:"txtRecord"})},"TXT_ext_host"):(0,i.jsx)(a.FormFieldRadioButtons,{className:"dns-spf-radiobutton",name:"spfSyntax",label:(0,i.jsx)(o,{content:"txtRecordString"}),options:[{value:"spf",className:"mx-sfp",label:(0,i.jsx)(o,{content:"txtSpfSyntax"}),indentFields:[(0,i.jsx)(a.Input,{size:null,disabled:!0,value:"v=spf1",style:{width:"60px"}},"spf1"),(0,i.jsx)(a.FormFieldText,{name:"value",label:null},"txt_value")]},{value:"multiline",label:"",indentFields:[(0,i.jsx)(a.FormFieldText,{name:"multilineValue",multiline:!0,label:null},"txt_multiline_value")]}]},"txt_spf_syntax")]},SRV:{defaults:e?{priority:"5",weight:"25",displayVal:"."}:{priority:"5",weight:"10",displayVal:"."},toFormValues:({domainName:e,opt:t,...s})=>{const[a,l,n]=t.split(" "),{serviceName:i,protocol:o,domainName:r}=e.match(/_(?<serviceName>[a-zA-Z0-9-]+)\._(?<protocol>[a-zA-Z0-9-]+)(\.(?<domainName>[a-zA-Z0-9-]+))?$/)?.groups||{};return{...s,priority:a,weight:l,targetPort:n,serviceName:i,protocol:o,domainName:r}},toSubmitValues:({protocol:e,domainName:t,serviceName:s,priority:a,weight:l,targetPort:n,...i})=>({...i,domainName:s&&e?`_${s}._${e}${t?`.${t}`:""}`:void 0,opt:[a,l,n].join(" ")}),fields:[(0,i.jsx)(a.FormFieldText,{name:"serviceName",required:!0,label:(0,i.jsx)(o,{content:"serviceName"}),description:(0,i.jsx)(o,{content:"serviceNameDescription"})},"SRV_service_name"),(0,i.jsx)(a.FormFieldText,{name:"protocol",required:!0,label:(0,i.jsx)(o,{content:"protocol"}),description:(0,i.jsx)(o,{content:"protocolNameDescription"})},"SRV_protocol"),e?(0,i.jsx)(n.default,{name:"domainName"},"txt_int_host"):null,(0,i.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,i.jsx)(o,{content:"targetHost"}),description:(0,i.jsx)(o,{content:"targetHostDescription"})},"SRV_target_host"),(0,i.jsx)(a.FormFieldText,{required:!0,name:"targetPort",inputProps:{type:"number",max:65535,min:0},label:(0,i.jsx)(o,{content:"targetPort"})},"SRV_target_port"),(0,i.jsx)(a.FormFieldSelect,{name:"priority",label:(0,i.jsx)(o,{content:"priority"}),children:Array.from({length:11}).map(((e,t)=>{const s=5*t;let l;switch(s){case 0:l=r.lmsg("priorityHigh",{priority:s});break;case 50:l=r.lmsg("priorityLow",{priority:s});break;default:l=s.toString()}return(0,i.jsx)(a.SelectOption,{value:s.toString(),children:l},s)}))},"SRV_priority"),(0,i.jsx)(a.FormFieldSelect,{name:"weight",label:(0,i.jsx)(o,{content:"srvWeight"}),children:Array.from({length:e?11:10}).map(((t,s)=>{const l=e?5*Math.abs(s-10):10*(s+1);let n;if(e)switch(l){case 0:n=r.lmsg("weightLow",{weight:l});break;case 50:n=r.lmsg("weightHigh",{weight:l});break;default:n=l.toString()}else n=l.toString();return(0,i.jsx)(a.SelectOption,{value:l.toString(),children:n},l)}))},"SRV_weight")]},CAA:{defaults:{opt:"issue"},fields:[(0,i.jsx)(n.default,{},"caa_int_host"),(0,i.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,i.jsx)(o,{content:"caaTag"}),children:[(0,i.jsx)(a.SelectOption,{value:"issue",children:"issue"}),(0,i.jsx)(a.SelectOption,{value:"issuewild",children:"issuewild"}),(0,i.jsx)(a.SelectOption,{value:"iodef",children:"iodef"})]},"CAA_tag"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",label:(0,i.jsx)(o,{content:"caaRecord"}),size:"fill"},"CAA_value")]}})},1692:(e,t,s)=>{s.r(t),s.d(t,{default:()=>a.default});var a=s(1693)},910:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(241),l=s(243),n=s.n(l),i=s(242);const o=({onClose:e,isOpen:t,...s})=>{const[l,n]=(0,a.useState)(t),o=(0,a.useRef)(null),r=(0,a.useMemo)((()=>e?(...t)=>{n(!1),o.current=setTimeout((()=>{e(...t),o.current=null}),300)}:e),[e]);return(0,a.useEffect)((()=>()=>clearTimeout(o.current)),[]),(0,a.useEffect)((()=>{o.current&&clearTimeout(o.current)}),[t]),(0,a.jsx)(i.Drawer,{...s,onClose:r,isOpen:l})};o.propTypes={onClose:n().func,isOpen:n().bool},o.defaultProps={onClose:null,isOpen:!0};const r=o}}]);
//# sourceMappingURL=edit.js.map?ebec3ba8f854193c087a