"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["views/dns/records/edit"],{1528(e,t,s){s.r(t),s.d(t,{default:()=>n});var a=s(372),l=s(693),i=s(373);const n=({onClose:e,isOpen:t=!0,closeOnFormSuccess:s=!0,closeUrl:n="..",form:o,...r})=>{const d=(0,l.useNavigate)(),[u,c]=(0,a.useState)(t),m=(0,a.useRef)(null),p=(0,a.useCallback)((...t)=>{const s=e??(()=>d(n,{preventScrollReset:!0}));c(!1),m.current=setTimeout(()=>{s(...t),m.current=null},300)},[n,d,e]);(0,a.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,a.useEffect)(()=>{t?m.current&&clearTimeout(m.current):c(t)},[t]);const x=(0,a.useMemo)(()=>{if(o&&s){if((0,a.isValidElement)(o))return(0,a.cloneElement)(o,{onSuccess:(...e)=>{o.props.onSuccess?.(...e),p()}});if("object"==typeof o)return{...o,onSuccess:(...e)=>{o.onSuccess?.(...e),p()}}}return o},[s,p,o]);return(0,a.jsx)(i.Drawer,{...r,form:x,onClose:p,isOpen:u})}},2477(e,t,s){s.r(t),s.d(t,{default:()=>j});var a=s(372),l=s(785),i=s(676),n=s(693),o=s(373),r=s(1528),d=s(1402),u=s(95),c=s(2478),m=s(639);const p=u.Locale.getTranslate("smb.components.forms.dns-zone.record"),x=u.Locale.getSection("smb.components.forms.dns-zone.record"),f=i.gql`
    mutation UpdateDnsTemplateRecord($input: UpdateDnsTemplateRecordInput!) {
        updateDnsTemplate(input: $input) {
            dnsRecordTemplate {
                id
                type
                ttl
                opt
                host
                displayVal
                displayHost
                domainName
            }
        }
    }
`,j=()=>{const e=(0,n.useParams)(),[t,i]=(0,a.useState)(),{data:u}=(0,n.useLoaderData)(),{dns:{template:{isEnabled:j}}}=u,[g,y]=(0,a.useState)(()=>{if(u.node){const{toFormValues:e}=(0,c.default)(u.os.isUnix,j)[u.node.type];return"function"==typeof e?e(u.node):u.node}const e=j?"A":"NS";return{...(0,c.default)(u.os.isUnix,j)[e].defaults,type:e}}),[h,{loading:b}]=(0,l.useMutation)(f,{refetchQueries:u.node?[]:[{query:s(703),awaitRefetchQueries:!0}]}),S=e.id?"edit-title":j?"add-title":"add-ns-title",{fields:F}=(0,a.useMemo)(()=>u?(0,c.default)(u?.os?.isUnix,j)[g.type]??{}:{},[g.type,u,j]);return(0,a.jsx)(r.default,{"data-type":"dns-record-form",size:"sm",title:(0,a.jsx)(p,{content:S}),"aria-label":x.lmsg(S),form:(0,a.jsx)(d.default,{mutation:h,applyButton:!1,values:g,onSubmit:e=>{const{__typename:t,...s}=e,{toSubmitValues:a}=(0,c.default)(u.os.isUnix,j)[s.type];return"function"==typeof a?a(s):s},onFieldChange:(e,t)=>{"type"===e&&(i(null),y({...(0,c.default)(u?.os?.isUnix,j)[t]?.defaults,type:t}))},onSuccess:()=>{(0,m.addToast)({intent:"success",message:(0,a.jsx)(p,{content:(e.id?"edit":"add")+"-success"})})},onError:e=>{i(e.general)},state:b?"submit":null,submitButton:{id:"btn-send"},children:(0,a.jsxs)(a.Fragment,{children:[t?(0,a.jsx)(o.StatusMessage,{intent:"danger",role:"alert","aria-live":"assertive",children:(0,a.jsx)("span",{dangerouslySetInnerHTML:{__html:t}})}):null,j?(0,a.jsx)(o.FormFieldSelect,{width:"90px","data-type":"dns-type",name:"type",label:(0,a.jsx)(p,{content:"type"}),children:u.dns.supportedRecordTypes.map(e=>(0,a.jsx)(o.SelectOption,{value:e,children:e},e))}):null,(0,a.jsx)(o.FormField,{label:(0,a.jsx)(p,{content:"ttl"}),name:"ttl",children:({getId:e,getName:t,getValue:s,setValue:l})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Input,{id:e(),min:0,max:4294967295,type:"number",name:t(),value:s(),onChange:({target:e})=>l(+e.value),"aria-describedby":`${e()}-unit`})," ",(0,a.jsx)("span",{id:`${e()}-unit`,children:(0,a.jsx)(p,{content:"ttl-seconds"})})]})}),F]})})})}},2479(e,t,s){s.r(t),s.d(t,{default:()=>u});var a=s(373),l=s(762),i=s.n(l),n=s(95),o=s(372);const r=n.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:({getId:e,getName:t,getValue:s,setValue:l})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.Input,{id:e(),name:t(),value:s(),onChange:({target:e})=>l(e.value),"aria-describedby":`${e()}-suffix`})," ",(0,o.jsx)("span",{id:`${e()}-suffix`,children:(0,o.jsx)(r,{content:"domainNamePostfix"})})]})});d.propTypes={name:i().string,label:i().string};const u=d},2478(e,t,s){s.r(t),s.d(t,{default:()=>d});var a=s(373),l=s(95),i=s(2479),n=s(372);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,n.jsx)(i.default,{},"ns_domain_name"):null,(0,n.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,n.jsx)(o,{content:"nameServer"}),inputProps:{suffix:".",size:"lg"}},"ns_ext_host")]},A:{defaults:{},fields:[(0,n.jsx)(i.default,{},"a_domain_name"),(0,n.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,n.jsx)(o,{content:"ipAddress"}),description:(0,n.jsx)(o,{content:"ipAddressDescriptionExt"})},"A_ip")]},AAAA:{defaults:{},fields:[(0,n.jsx)(i.default,{},"aaaa_int_host"),(0,n.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,n.jsx)(o,{content:"ipAddressV6"}),description:(0,n.jsx)(o,{content:"ipAddressV6DescriptionExt"})},"AAAA_ip")]},CNAME:{defaults:{},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,n.jsx)(i.default,{},"cname_int_host"),(0,n.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,n.jsx)(o,{content:"canonicalName"})},"CNAME_canonical")]},MX:{defaults:{opt:"0"},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,n.jsx)(i.default,{label:"mailDomain"},"mx_displayHost"),(0,n.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",required:!0,label:(0,n.jsx)(o,{content:"mxServer"})},"mx_displayVal"),(0,n.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,n.jsx)(o,{content:"mxServerPriority"}),children:[(0,n.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,n.jsx)(a.SelectOption,{value:s.toString(),children:s.toString()},s)}),(0,n.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,n.jsx)(a.FormField,{required:!0,label:(0,n.jsx)(o,{content:"ipAddress"}),name:"ipMask",description:(0,n.jsx)(o,{content:"ipAddressWithMaskDescriptionExt"}),children:({getId:e,getName:t,getValue:s,setValue:l})=>{const{ip:i,mask:o}=s()??{};return(0,n.jsxs)("div",{role:"group","aria-label":r.lmsg("ipAddressWithMask"),children:[(0,n.jsx)(a.Input,{id:`${e()}-ip`,size:"lg",name:`${t()}[ip]`,value:i,"aria-label":r.lmsg("ipAddressField"),onChange:({target:e})=>l({ip:e.value,mask:o})})," / ",(0,n.jsx)(a.Input,{id:`${e()}-mask`,size:"sm",name:`${t()}[mask]`,value:o,"aria-label":r.lmsg("maskField"),onChange:({target:e})=>l({ip:i,mask:e.value})})]})}},"prt_ip"),(0,n.jsx)(i.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:i,...n}=t;return{...n,displayHost:i,displayVal:"spf"===s?`v=spf1 ${a}`:l}},fields:[(0,n.jsx)(i.default,{},"txt_int_host"),e?(0,n.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",label:(0,n.jsx)(o,{content:"txtRecord"})},"TXT_ext_host"):(0,n.jsx)(a.FormFieldRadioButtons,{className:"dns-spf-radiobutton",name:"spfSyntax",label:(0,n.jsx)(o,{content:"txtRecordString"}),options:[{value:"spf",className:"mx-sfp",label:(0,n.jsx)(o,{content:"txtSpfSyntax"}),indentFields:[(0,n.jsx)(a.Input,{size:null,disabled:!0,value:"v=spf1",style:{width:"60px"},"aria-label":r.lmsg("spfPrefix")},"spf1"),(0,n.jsx)(a.FormFieldText,{name:"value",label:null},"txt_value")]},{value:"multiline",label:"",indentFields:[(0,n.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,i]=t.split(" "),{serviceName:n,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:i,serviceName:n,protocol:o,domainName:r}},toSubmitValues:({protocol:e,domainName:t,serviceName:s,priority:a,weight:l,targetPort:i,...n})=>{t=t?`.${t}`:"";return{...n,domainName:s&&e?`_${s}._${e}${t}`:void 0,opt:[a,l,i].join(" "),serviceName:s,protocol:e}},fields:[(0,n.jsx)(a.FormFieldText,{name:"serviceName",required:!0,label:(0,n.jsx)(o,{content:"serviceName"}),description:(0,n.jsx)(o,{content:"serviceNameDescription"})},"SRV_service_name"),(0,n.jsx)(a.FormFieldText,{name:"protocol",required:!0,label:(0,n.jsx)(o,{content:"protocol"}),description:(0,n.jsx)(o,{content:"protocolNameDescription"})},"SRV_protocol"),e?(0,n.jsx)(i.default,{name:"domainName"},"txt_int_host"):null,(0,n.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,n.jsx)(o,{content:"targetHost"}),description:(0,n.jsx)(o,{content:"targetHostDescription"})},"SRV_target_host"),(0,n.jsx)(a.FormFieldText,{required:!0,name:"targetPort",inputProps:{type:"number",max:65535,min:0},label:(0,n.jsx)(o,{content:"targetPort"})},"SRV_target_port"),(0,n.jsx)(a.FormFieldSelect,{name:"priority",label:(0,n.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,n.jsx)(a.SelectOption,{value:s.toString(),children:l},s)})},"SRV_priority"),(0,n.jsx)(a.FormFieldSelect,{name:"weight",label:(0,n.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 i;if(e)switch(l){case 0:i=r.lmsg("weightLow",{weight:l});break;case 50:i=r.lmsg("weightHigh",{weight:l});break;default:i=l.toString()}else i=l.toString();return(0,n.jsx)(a.SelectOption,{value:l.toString(),children:i},l)})},"SRV_weight")]},CAA:{defaults:{opt:"issue"},fields:[(0,n.jsx)(i.default,{},"caa_int_host"),(0,n.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,n.jsx)(o,{content:"caaTag"}),children:[(0,n.jsx)(a.SelectOption,{value:"issue",children:"issue"}),(0,n.jsx)(a.SelectOption,{value:"issuewild",children:"issuewild"}),(0,n.jsx)(a.SelectOption,{value:"iodef",children:"iodef"})]},"CAA_tag"),(0,n.jsx)(a.FormFieldText,{name:"displayVal",label:(0,n.jsx)(o,{content:"caaRecord"}),size:"fill"},"CAA_value")]}})},2476(e,t,s){s.r(t),s.d(t,{default:()=>a.default});var a=s(2477)}}]);
//# sourceMappingURL=edit.js.map?f7d6982e8b48dbd763ca