(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/ServerComponentsPage"],{1425:(e,n,t)=>{"use strict";t.r(n),t.d(n,{SORT_ASC:()=>d,SORT_DESC:()=>l,default:()=>f});var a=t(295),i=t(667),s=t.n(i),r=t(296);const o=t(90).Locale.getSection("components.list"),d="ASC",l="DESC",c="all",m={set(e,n){localStorage.setItem(e,JSON.stringify(n))},get(e){const n=localStorage.getItem(e);return JSON.parse(n)}},u=e=>`list-sort_${e}`,p=e=>`list-page_${e}`,g=({id:e,data:n,columns:t,itemsPerPage:i=25,itemsPerPageOptions:s=[10,25,100,c],sortColumn:l,sortDirection:g=d,searchField:f,locale:v={},emptyView:k,emptyFilteredView:y,toolbar:h,selection:C=[],onSelectionChange:S,searchBarInputProps:b,rowKey:N="key",useStorage:j=!0,...F})=>{const{sortColumn:I,sortDirection:x,setSortState:P}=((e,{sortColumn:n,sortDirection:t})=>{const[{sortColumn:i,sortDirection:s},r]=(0,a.useState)({sortColumn:m.get(u(e))?.sortColumn??n,sortDirection:m.get(u(e))?.sortDirection??t});return{sortColumn:i,sortDirection:s,setSortState:n=>{r(e=>({...e,...n})),m.set(u(e),{...m.get(u(e)),...n})}}})(e,{sortColumn:l??t.find(({sortable:e})=>e)?.key,sortDirection:g}),{page:T,itemsPerPage:O,searchPattern:E,setPageState:w}=((e,{itemsPerPage:n},t=!0)=>{const i=t?{page:m.get(p(e))?.page,itemsPerPage:m.get(p(e))?.itemsPerPage,searchPattern:m.get(p(e))?.searchPattern}:{},[{page:s,itemsPerPage:r,searchPattern:o},d]=(0,a.useState)({page:i.page??1,itemsPerPage:i.itemsPerPage??n,searchPattern:i.searchPattern??""});return{page:s,itemsPerPage:r,searchPattern:o,setPageState:n=>{d(e=>({...e,...n})),t&&m.set(p(e),{...m.get(p(e)),...n})}}})(e,{itemsPerPage:s.includes(i)?i:s[0]},j),D=(0,a.useMemo)(()=>E?y??(0,a.jsx)(r.ListEmptyView,{reason:"filtered","data-testid":"list-empty-view-filtered"}):k??(0,a.jsx)(r.ListEmptyView,{}),[E,k,y]),L=(0,a.useMemo)(()=>t.map(({sortDataField:e,...n})=>n),[t]),q=(0,a.useMemo)(()=>f&&E?n.filter(e=>(Array.isArray(f)?f:[f]).some(n=>e[n]&&String(e[n]).toLowerCase().includes(E.toLowerCase()))):n,[n,E,f]),$=(0,a.useMemo)(()=>{if(!I)return q;const e=t.find(({key:e})=>e===I)?.sortDataField??I,n=t.find(({key:e})=>e===I)?.sort??((n,t)=>n[e]<t[e]?-1:n[e]>t[e]?1:0);return[...q].sort((e,t)=>d===x?n(e,t):n(t,e))},[q,I,x,t]),R=(0,a.useMemo)(()=>{if(O===c)return $;const e=O*(T-1),n=e+O;return $.slice(e,n)},[T,$,O]),M=(0,a.useCallback)(e=>{w({searchPattern:e}),e!==E&&w({page:1})},[E]),_=(0,a.useCallback)(e=>{w({itemsPerPage:e});(e===c?1:Math.ceil(q.length/e))<T&&w({page:1})},[q.length,T]);return(0,a.useEffect)(()=>{if("function"==typeof S&&C.length){const e=q.map(e=>{return n=e,"function"==typeof(t=N)?t(n):n[t];var n,t}).filter(e=>C.includes(e));S(e)}},[q]),(0,a.jsx)(r.List,{pagination:(0,a.jsx)(r.Pagination,{current:T,total:O===c?1:Math.ceil(q.length/O),onSelect:e=>w({page:e}),itemsPerPage:O,itemsPerPageOptions:s,onItemsPerPageChange:_}),toolbar:(h||f)&&(0,a.jsxs)(r.Toolbar,{children:[h,f&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.ToolbarExpander,{}),(0,a.jsx)(r.ToolbarGroup,{title:"",children:(0,a.jsx)(r.SearchBar,{inputProps:{placeholder:o.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:E,...b??{}},onTyping:M})})]})]}),totalRows:q.length,sortColumn:I,sortDirection:x,onSortChange:P,columns:L,data:R,filtered:!!E,locale:{totalRows:({totalRows:e})=>o.formatMessage("recordsTotal",{total:e}),...v},emptyView:D,onSelectionChange:S,selection:C,rowKey:N,...F})};g.propTypes={id:s().string.isRequired,data:s().array.isRequired,columns:s().array.isRequired,itemsPerPage:s().number,itemsPerPageOptions:s().array,sortColumn:s().string,sortDirection:s().string,searchField:s().oneOfType([s().string,s().arrayOf(s().string.isRequired)]),locale:s().object,emptyView:s().node,emptyFilteredView:s().node,toolbar:s().node,onSelectionChange:s().func,selection:s().array,rowKey:s().oneOfType([s().string,s().func]),searchBarInputProps:s().object,useStorage:s().bool};const f=g},2490:(e,n,t)=>{"use strict";t.r(n),t.d(n,{deleteServerMailAntivirusCache:()=>a});const a=e=>e.modify({id:e.identify({__typename:"ServerMail"}),fields:{antivirus:(e,{DELETE:n})=>n,antivirusPolicy:(e,{DELETE:n})=>n}})},2516:(e,n,t)=>{"use strict";t.r(n),t.d(n,{ServerComponentsPage:()=>j,default:()=>F});var a=t(295),i=t(717),s=t(90),r=t(296),o=t(695),d=t(619),l=t(582),c=t(1425),m=t(674),u=t(345),p=t(545),g=t(2517),f=t(2525),v=t(650),k=t.n(v);const y="/admin/server/tools",h=s.Locale.getTranslate("components.lists.server-components"),C=s.Locale.getSection("components.lists.server-components"),S={warning:"tooltip.notStarted",danger:"tooltip.notConfigured",success:"tooltip.active",inactive:"tooltip.disabled"},b=l.gql`
    mutation UpdateServerComponents {
        updateServerComponents {
            query {
                server {
                    components {
                        name
                        version
                        state
                        status
                        error
                        depends
                        dependsType
                        providesType
                        description
                        isInstalled
                        isConfigurable
                        configured
                        allowedByLicense
                        parameters {
                            name
                            type
                            label
                            required
                            description
                            value
                            enum
                            disabled
                            disableReason
                        }
                        componentTypeInfo {
                            name
                            required
                            default
                            packagesCount
                        }
                        categoryInfo {
                            name
                            isConfigurable
                        }
                    }
                }
            }
        }
    }
`,N=(e,n)=>e.filter(e=>e.categoryInfo.name===n).some(e=>e.categoryInfo.isConfigurable),j=()=>{const{data:{os:{isUnix:e},server:{components:n}}}=(0,d.useQuery)(k()),[t,{loading:s}]=(0,o.useMutation)(b,{onCompleted:()=>{(0,p.addToast)({intent:"success",message:(0,a.jsx)(h,{content:"componentsListUpdated"})})}}),l=(0,a.useMemo)(()=>{if(e)return n.map(e=>({...e,key:e.name,information:e.version}));const t=n.reduce((e,t)=>{if(e[t.categoryInfo.name]||(e[t.categoryInfo.name]={isConfigurable:N(n,t.categoryInfo.name),packages:[]}),t.isInstalled){const n=""!==t.state?` ${C.lmsg(`defaultComponents.${t.state}`)}`:"";e[t.categoryInfo.name].packages.push({...t,description:t.description+n})}return e},{});return Object.entries(t).map(([e,n])=>({key:e,name:e,isCategoryConfigurable:n.isConfigurable,packages:n.packages,information:n.packages.map(({description:e})=>e).join(" ")}))},[n,e]),m=[{key:"name",sortable:!0,title:(0,a.jsx)(h,{content:"name"}),render:n=>e?n.name:n.isCategoryConfigurable?(0,a.jsx)(i.default,{to:`/cp/server/components/default/${n.name}`,"data-test-id":`setup-${n.name}`,children:(0,a.jsx)(h,{content:`componentName.${n.name}`})}):(0,a.jsx)(h,{content:`componentName.${n.name}`}),width:"25%"},{key:"information",sortable:!0,title:(0,a.jsx)(h,{content:"version"}),render:n=>{const{version:t,packages:s}=n;return e?t:s.length?(0,a.jsx)("div",{children:s.map(e=>(0,a.jsx)("div",{children:(0,a.jsx)(r.Tooltip,{title:(0,a.jsx)(h,{content:S[e.status]}),children:(0,a.jsx)(r.Status,{intent:e.status,children:e.isConfigurable?(0,a.jsx)(i.default,{to:`/cp/server/components/configuration/${e.name}`,"data-test-id":`configure-${e.name}`,children:e.description}):(0,a.jsx)("span",{children:e.description})})})},e.name))}):null}}];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.default,{id:"server-components-list",columns:m,data:l,sortColumn:"name",searchField:["name","information"],searchBarInputProps:{placeholder:C.lmsg("componentName")},toolbar:(0,a.jsx)(r.Button,{icon:"refresh",intent:"primary",state:s?"loading":void 0,"data-cy":"update-components-list",onClick:t,children:(0,a.jsx)(h,{content:"refresh"})}),emptyView:(0,a.jsx)(r.ListEmptyView,{title:(0,a.jsx)(h,{content:"noComponents"}),actions:(0,a.jsx)(r.Button,{icon:"refresh",intent:"primary",state:s?"loading":void 0,"data-cy":"update-components-list",onClick:t,children:(0,a.jsx)(h,{content:"refresh"})})})}),!e&&(0,a.jsx)(g.DefaultComponentsPage,{packages:n}),!e&&(0,a.jsx)(f.ComponentConfPage,{packages:n})]})},F=(0,m.withPageLayout)(j,()=>{const{showFrames:e,pageHeader:n,pageSidebar:t}=(0,u.default)(),a=[t.isPowerUserPanel?null:{title:s.Locale.getSection("admin.controllers.home.admin").lmsg("title"),href:"/admin/home"},{title:s.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:y},{title:s.Locale.getSection("components.lists.server-components").lmsg("bcTitle"),href:"/cp/server/components"}].filter(Boolean),i=s.Locale.getSection("components.lists.server-components").lmsg("title");return{showFrames:e,pageHeader:{...n,helpMenu:{...n.helpMenu,helpContext:"comp_info"}},pageSidebar:t,pageContentHeader:{breadcrumbs:a,pageTitle:i},pageTitle:i}})},2517:(e,n,t)=>{"use strict";t.r(n),t.d(n,{DefaultComponentsPage:()=>u});var a=t(295),i=t(667),s=t.n(i),r=t(598),o=t(296),d=t(90),l=t(2518);const c=d.Locale.getSection("components.lists.server-components"),m=d.Locale.getTranslate("components.lists.server-components"),u=({packages:e})=>{const n=(0,r.useNavigate)(),t=(0,r.useMatch)("/cp/server/components/default/:name"),i=t?.params?.name,s=(0,a.useCallback)(()=>{n("/cp/server/components")},[n]);return(0,a.jsx)(o.Drawer,{"data-type":"default-components",isOpen:Boolean(t),onClose:s,title:(0,a.jsx)(m,{content:"defaultComponents.title",params:{name:c.lmsg(`componentName.${t?.params?.name}`)}}),form:t?(0,a.jsx)(l.DefaultComponentsForm,{categoryName:i,packages:e,onClose:s}):null})};u.propTypes={packages:s().array.isRequired}},2518:(e,n,t)=>{"use strict";t.r(n),t.d(n,{DefaultComponentsForm:()=>C});var a=t(667),i=t.n(a),s=t(295),r=t(695),o=t(90),d=t(296),l=t(1300),c=t(545),m=t(2490),u=t(2519),p=t.n(u),g=t(2520),f=t(2522),v=t(2524),k=t(2523);const y=o.Locale.getSection("components.lists.server-components"),h=o.Locale.getTranslate("components.lists.server-components"),C=({packages:e,categoryName:n,onClose:t,...a})=>{const[i,o]=(0,s.useState)(!1),[u,C]=(0,s.useState)(!1),[S,b]=(0,s.useState)({}),[N]=(0,r.useMutation)(p(),{onCompleted:()=>{(0,c.addToast)({intent:"success",message:(0,s.jsx)(h,{content:"defaultComponents.success"})}),t()},update:m.deleteServerMailAntivirusCache}),{categories:j,depsError:F}=(0,s.useMemo)(()=>(0,v.splitByCategories)(e,n),[e,n]),I=(0,s.useMemo)(()=>(0,v.prepareInitialState)(j),[j]),[x,P]=(0,s.useState)(I),T=(0,s.useCallback)((e,n)=>{if((0,f.isParameterChanged)(e))return void P(t=>(0,d.setIn)(t,e,n));const[t,a]=e.split(/[\[\]]/g).filter(e=>e),i=(0,f.getComponentParameters)(j[t].packages,"default"===a?n:a);if(t===k.DNS_SERVER&&(0,d.getIn)(I,e)===k.DEFAULT_BIND&&n===k.DEFAULT_MSDNS)return C(!0),void P(n=>(0,d.setIn)(n,e,(0,d.getIn)(n,e)));t===k.MAIL_SERVER&&o((0,d.getIn)(I,e)!==n),P(s=>{const r="default"!==a?`${t}[${a}][params]`:`${t}[params]`;return n===k.NONE_OPTION?s=(0,v.resetValues)(s,j,t):(0,d.getIn)(s,e)===k.NONE_OPTION&&(s=(0,v.resetValues)(s,j,t,I)),s=(0,d.setIn)(s,r,i),(0,d.setIn)(s,e,n)})},[j,I]),O=(0,s.useCallback)((e,n)=>{const t=(0,s.jsx)(h,{content:`componentName.${e}`});return n?(0,s.jsxs)("div",{children:[t," ",(0,s.jsx)(d.Text,{intent:"danger",children:"*"})]}):t},[]),E=(0,s.useCallback)(n=>Object.entries(n).reduce((n,[t,a])=>{if(x[t]){if(x[t].default)return n[t]={default:a},n;const[e]=Object.keys(x[t]);return n[t]={[e]:{default:a}},n}const{categoryInfo:{name:i}}=e.find(e=>e.componentTypeInfo.name===t);return n[i]||(n[i]={}),n[i][t]={default:a},n},{}),[x,e]),w=(0,s.useCallback)(n=>{i&&o(!1),b({});const t=[],a={};for(const i of(0,v.prepareValues)(j,n)){const{categoryName:n,componentType:s,defaultComponent:r,params:o}=i,d={componentType:s,defaultComponent:r};if(Object.values(o).length&&r!==k.NONE_OPTION){const{parameters:t}=e.find(e=>e.name===r),i=(0,g.validateParameters)(o,t);Object.values(i).length&&(n?a[n]={...a[n]??{},[s]:{params:i}}:a[s]={params:i}),d.parameters=(0,f.adaptParameters)(o).filter(({name:e,value:n})=>t.find(n=>n.name===e).value!==n)}t.push(d)}if(!Object.values(a).length)return t;b(a)},[j,e,i]),D=(0,s.useCallback)(()=>{P(e=>(0,d.setIn)((0,v.resetValues)(e,j,k.DNS_SERVER),`${k.DNS_SERVER}[default]`,k.DEFAULT_MSDNS)),C(!1)},[j]);return F?(0,s.jsx)(l.default,{submitButton:!1,applyButton:!1,...a,children:(0,s.jsx)(d.StatusMessage,{intent:"danger",children:F})}):(0,s.jsxs)(l.default,{onSubmit:w,mutation:e=>N(e).catch(e=>{throw e.graphQLErrors?.length&&"validate"===e.graphQLErrors[0].extensions?.category&&(e.graphQLErrors[0].extensions.messages=E(e.graphQLErrors[0].extensions.messages)),e}),submitButton:{id:"submit",name:"submit"},cancelButton:{id:"cancel",name:"cancel",onClick:t},onFieldChange:T,applyButton:!1,values:x,autoComplete:"do-not-autofill",errors:S,...a,children:[(0,s.jsx)(d.Dialog,{size:"xs",title:(0,s.jsx)(h,{content:"defaultComponents.warning"}),isOpen:u,onClose:()=>C(!1),form:{onSubmit:D,submitButton:{children:(0,s.jsx)(h,{content:"defaultComponents.yes"})},cancelButton:{children:(0,s.jsx)(h,{content:"defaultComponents.no"})}},children:(0,s.jsx)(h,{content:"defaultComponents.dnsserverBindToMsdnsSwitchingWarning"})}),Object.entries(j).sort(([e],[t])=>e===n||t===n?1:-1).map(([n,t])=>(0,s.jsx)(d.Section,{title:O(n,t.isRequired),children:t.isMultiChoise?t.packages.map(t=>{const a=`${n}[${t.name}][default]`,{label:i,disabled:r,value:o,indentFields:l}=(0,v.getComponentOptions)(t,e,x,(0,d.getIn)(x,a,!1),!0);return(0,s.jsxs)("div",{children:[(0,s.jsx)(d.FormFieldCheckbox,{style:{marginBottom:0},label:i,disabled:r,name:a}),l&&(0,s.jsx)("div",{className:"pul-form-field-radio-buttons__content",children:l},`${a}_params`)]},o)}):(0,s.jsxs)(s.Fragment,{children:[n===k.MAIL_SERVER&&i&&(0,s.jsxs)(d.Alert,{intent:"warning",children:[(0,s.jsx)("h4",{children:(0,s.jsx)(h,{content:"defaultComponents.warning"})}),(0,s.jsx)(h,{content:"defaultComponents.mailserverSwitchingWarning"})]}),(0,s.jsx)(d.FormFieldRadioButtons,{label:null,name:`${n}[default]`,options:[...t.packages.map(t=>(0,v.getComponentOptions)(t,e,x,(0,d.getIn)(x,`${n}[default]`,"none")===t.name,!1)),{label:y.lmsg("defaultComponents.none"),value:k.NONE_OPTION}]})]})},n))]})};C.propTypes={packages:i().array.isRequired,categoryName:i().string.isRequired,onClose:i().func.isRequired}},2519:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateDefaultComponents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NamedType",name:{kind:"Name",value:"UpdateDefaultComponentsInput"}}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateDefaultComponents"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"query"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"server"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"components"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"version"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"status"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"error"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"depends"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"dependsType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"providesType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"description"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isInstalled"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isConfigurable"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"configured"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"allowedByLicense"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"componentTypeInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"required"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"default"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"packagesCount"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"categoryInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isConfigurable"},arguments:[],directives:[]}]}}]}}]}}]}}]}}]}}],loc:{start:0,end:979}};n.loc.source={body:"mutation UpdateDefaultComponents($input: [UpdateDefaultComponentsInput]!) {\r\n    updateDefaultComponents(input: $input) {\r\n        query {\r\n            server {\r\n                components {\r\n                    name\r\n                    version\r\n                    state\r\n                    status\r\n                    error\r\n                    depends\r\n                    dependsType\r\n                    providesType\r\n                    description\r\n                    isInstalled\r\n                    isConfigurable\r\n                    configured\r\n                    allowedByLicense\r\n                    componentTypeInfo {\r\n                        name\r\n                        required\r\n                        default\r\n                        packagesCount\r\n                    }\r\n                    categoryInfo {\r\n                        name\r\n                        isConfigurable\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}",name:"GraphQL request",locationOffset:{line:1,column:1}};function t(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var a=e.type;"NamedType"===a.kind&&n.add(a.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(e){t(e,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(e){t(e,n)}),e.definitions&&e.definitions.forEach(function(e){t(e,n)})}var a={};function i(e,n){for(var t=0;t<e.definitions.length;t++){var a=e.definitions[t];if(a.name&&a.name.value==n)return a}}n.definitions.forEach(function(e){if(e.name){var n=new Set;t(e,n),a[e.name.value]=n}}),e.exports=n,e.exports.UpdateDefaultComponents=function(e,n){var t={kind:e.kind,definitions:[i(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var s=a[n]||new Set,r=new Set,o=new Set;for(s.forEach(function(e){o.add(e)});o.size>0;){var d=o;o=new Set,d.forEach(function(e){r.has(e)||(r.add(e),(a[e]||new Set).forEach(function(e){o.add(e)}))})}return r.forEach(function(n){var a=i(e,n);a&&t.definitions.push(a)}),t}(n,"UpdateDefaultComponents")},2520:(e,n,t)=>{"use strict";t.r(n),t.d(n,{ComponentConfForm:()=>k,renderParameter:()=>v,validateParameters:()=>f});var a=t(295),i=t(695),s=t(667),r=t.n(s),o=t(90),d=t(296),l=t(1300),c=t(545),m=t(2521),u=t.n(m);const p=o.Locale.getSection("components.lists.server-components.componentConf"),g=o.Locale.getTranslate("components.lists.server-components.componentConf"),f=(e,n,t=e=>e)=>Object.entries(e).reduce((e,[a,i])=>{const s=n.find(e=>e.name===a);return!i&&s?.required&&(e[t(a)]=[p.lmsg("parameterIsRequired")]),"int"===s?.type&&isNaN(+i)&&(e[t(a)]=[p.lmsg("parameterShouldBeNumber")]),e},{}),v=(e,n)=>{let t;const i=e.disabled||void 0,s=n(e.name);switch(e.type){case"int":case"string":t=(0,a.jsx)(d.FormFieldText,{id:s,name:s,required:e.required,label:e.description,disabled:i},s);break;case"password":t=(0,a.jsx)(d.FormFieldPassword,{id:s,name:s,required:e.required,label:e.description,disabled:i,hideGenerateButton:e.hideGenerateButton||!1},s);break;case"bool":t=(0,a.jsx)(d.FormFieldCheckbox,{name:s,required:e.required,label:e.description,disabled:i},s);break;case"enum":t=(0,a.jsx)(d.FormFieldSelect,{name:s,required:e.required,label:e.description,disabled:i,children:Object.entries(e.enum).map(([e,n])=>(0,a.jsx)("option",{value:e,children:n},e))},s);break;default:t=(0,a.jsx)(d.FormField,{name:s,label:e.description,children:(0,a.jsx)(d.Input,{type:"hidden"})},s)}return e.disabled&&e.disableReason?(0,a.jsx)(d.Tooltip,{title:e.disableReason,children:t}):t},k=({packageName:e,parameters:n,onClose:t,...s})=>{const[r,o]=(0,a.useState)((e=>e.reduce((e,n)=>(e[n.name]="bool"===n.type?"true"===n.value:n.value,e),{}))(n)),[m,p]=(0,a.useState)({}),[k]=(0,i.useMutation)(u(),{onCompleted:()=>{(0,c.addToast)({intent:"success",message:(0,a.jsx)(g,{content:"success"})}),t()}}),y=(0,a.useCallback)((e,n)=>{o(t=>(0,d.setIn)(t,e,n))},[]),h=(0,a.useCallback)(t=>{p({});const a=f(t,n);if(0===Object.keys(a).length)return Object.entries(t).reduce((e,[n,t])=>(e.parameters.push({name:n,value:t.toString()}),e),{packageName:e,parameters:[]});p(a)},[n,e]);return(0,a.jsx)(l.default,{errors:m,onSubmit:h,mutation:k,submitButton:{id:"submit",name:"submit"},cancelButton:{id:"cancel",name:"cancel",onClick:t},onFieldChange:y,applyButton:!1,values:r,...s,children:n.map(e=>v(e,e=>e))})};k.propTypes={packageName:r().string.isRequired,parameters:r().array.isRequired,onClose:r().func.isRequired}},2521:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateComponentParameters"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UpdateComponentParametersInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateComponentParameters"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"query"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"server"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"components"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"version"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"status"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"error"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"depends"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"dependsType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"providesType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"description"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isInstalled"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isConfigurable"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"configured"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"allowedByLicense"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"parameters"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"type"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"label"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"required"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"description"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"value"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"enum"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"disabled"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"disableReason"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"componentTypeInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"required"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"default"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"packagesCount"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"categoryInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isConfigurable"},arguments:[],directives:[]}]}}]}}]}}]}}]}}]}}],loc:{start:0,end:1336}};n.loc.source={body:"mutation UpdateComponentParameters($input: UpdateComponentParametersInput!) {\r\n    updateComponentParameters(input: $input) {\r\n        query {\r\n            server {\r\n                components {\r\n                    name\r\n                    version\r\n                    state\r\n                    status\r\n                    error\r\n                    depends\r\n                    dependsType\r\n                    providesType\r\n                    description\r\n                    isInstalled\r\n                    isConfigurable\r\n                    configured\r\n                    allowedByLicense\r\n                    parameters {\r\n                        name\r\n                        type\r\n                        label\r\n                        required\r\n                        description\r\n                        value\r\n                        enum\r\n                        disabled\r\n                        disableReason\r\n                    }\r\n                    componentTypeInfo {\r\n                        name\r\n                        required\r\n                        default\r\n                        packagesCount\r\n                    }\r\n                    categoryInfo {\r\n                        name\r\n                        isConfigurable\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}",name:"GraphQL request",locationOffset:{line:1,column:1}};function t(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var a=e.type;"NamedType"===a.kind&&n.add(a.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(e){t(e,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(e){t(e,n)}),e.definitions&&e.definitions.forEach(function(e){t(e,n)})}var a={};function i(e,n){for(var t=0;t<e.definitions.length;t++){var a=e.definitions[t];if(a.name&&a.name.value==n)return a}}n.definitions.forEach(function(e){if(e.name){var n=new Set;t(e,n),a[e.name.value]=n}}),e.exports=n,e.exports.UpdateComponentParameters=function(e,n){var t={kind:e.kind,definitions:[i(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var s=a[n]||new Set,r=new Set,o=new Set;for(s.forEach(function(e){o.add(e)});o.size>0;){var d=o;o=new Set,d.forEach(function(e){r.has(e)||(r.add(e),(a[e]||new Set).forEach(function(e){o.add(e)}))})}return r.forEach(function(n){var a=i(e,n);a&&t.definitions.push(a)}),t}(n,"UpdateComponentParameters")},2522:(e,n,t)=>{"use strict";t.r(n),t.d(n,{adaptParameters:()=>s,getComponentParameters:()=>r,isParameterChanged:()=>i});var a=t(2523);const i=e=>e.includes("[params]"),s=e=>Object.entries(e).reduce((e,[n,t])=>(e.push({name:n,value:t.toString()}),e),[]),r=(e,n)=>n===a.NONE_OPTION?{}:e.find(e=>e.name===n).parameters.reduce((e,n)=>({...e,[n.name]:"bool"===n.type?"true"===n.value:n.value}),{})},2523:(e,n,t)=>{"use strict";t.r(n),t.d(n,{DEFAULT_BIND:()=>r,DEFAULT_MSDNS:()=>o,DNS_SERVER:()=>s,MAIL_SERVER:()=>i,NONE_OPTION:()=>a});const a="none",i="mailserver",s="dnsserver",r="bind",o="msdns"},2524:(e,n,t)=>{"use strict";t.r(n),t.d(n,{getComponentOptions:()=>f,isDependOn:()=>c,isPackageMultiChoice:()=>m,prepareInitialState:()=>p,prepareValues:()=>v,resetValues:()=>g,splitByCategories:()=>u});var a=t(2523),i=t(296),s=t(90),r=t(2520),o=t(295);const d=s.Locale.getSection("components.lists.server-components"),l=s.Locale.getTranslate("components.lists.server-components"),c=(e,n)=>!(!e.depends||e.depends!==n.name)||!(!e.dependsType||e.dependsType!==n.providesType),m=e=>1===e.componentTypeInfo.packagesCount,u=(e,n)=>{const t=new Map(e.filter(e=>e.categoryInfo.name===n).map(e=>[e.name,e])),a={};let i=t,s=new Map,r=new Set;for(;i.size>0;){for(const n of i.values())if(!r.has(n.name)){a[n.categoryInfo.name]??=[];for(const t of e){if(c(t,n)){if(a[t.categoryInfo.name]??=[],a[n.categoryInfo.name].includes(t.categoryInfo.name))return{categories:[],depsError:(0,o.jsx)(l,{content:"defaultComponents.circularDependencies",params:{cat1:(0,o.jsx)("b",{children:(0,o.jsx)(l,{content:`componentName.${t.categoryInfo.name}`})}),cat2:(0,o.jsx)("b",{children:(0,o.jsx)(l,{content:`componentName.${n.categoryInfo.name}`})})}})};a[t.categoryInfo.name].push(n.categoryInfo.name),s.set(t.name,t)}if(c(n,t)){if(a[t.categoryInfo.name]??=[],a[t.categoryInfo.name].includes(n.categoryInfo.name))return{categories:[],depsError:(0,o.jsx)(l,{content:"defaultComponents.circularDependencies",params:{cat1:(0,o.jsx)("b",{children:(0,o.jsx)(l,{content:`componentName.${t.categoryInfo.name}`})}),cat2:(0,o.jsx)("b",{children:(0,o.jsx)(l,{content:`componentName.${n.categoryInfo.name}`})})}})};a[n.categoryInfo.name].push(t.categoryInfo.name),s.set(t.name,t)}}}r=new Set([...r,...i.keys()]),i=s,s=new Map}const d=[...new Set(Object.entries(a).reduce((e,[n,t])=>(t.length>0&&(e=e.concat([n,...t])),e),[n]))];return{categories:e.filter(e=>d.includes(e.categoryInfo.name)).sort(e=>e.categoryInfo.name===n?-1:1).reduce((e,t)=>(e[t.categoryInfo.name]??={depends:[...new Set(a[t.categoryInfo.name])],isMultiChoise:m(t),isRequired:t.componentTypeInfo.name===n||t.componentTypeInfo.required,packages:[]},e[t.categoryInfo.name].packages.push(t),e),{}),depsError:null}},p=e=>Object.entries(e).reduce((e,[n,t])=>{if(t.isMultiChoise)e[n]=t.packages.reduce((e,n)=>({...e,[n.name]:{default:n.componentTypeInfo.default!==a.NONE_OPTION,params:n.parameters.reduce((e,n)=>({...e,[n.name]:"bool"===n.type?"true"===n.value:n.value}),{})}}),{});else{const i=t.packages.find(e=>e.componentTypeInfo.default===e.name);e[n]={default:i?.name??a.NONE_OPTION,params:i?.parameters?.reduce((e,n)=>({...e,[n.name]:"bool"===n.type?"true"===n.value:n.value}),{})??{}}}return e},{}),g=(e,n,t,s=null)=>Object.entries(e).reduce((e,[r,o])=>{if(n[r].depends.includes(t)){const n=o.default?{default:a.NONE_OPTION,params:{}}:Object.keys(o).reduce((e,n)=>({...e,[n]:{default:!1,params:{}}}),{});return(0,i.setIn)(e,r,s?(0,i.getIn)(s,r):n)}return e},e),f=(e,n,t,i,s)=>{let c="";if(e.allowedByLicense?e.state?c=d.lmsg(`defaultComponents.${e.state}`):!e.configured&&e.componentTypeInfo.required&&(c=d.lmsg("defaultComponents.not_configured")):c=d.lmsg("defaultComponents.no_license"),c)return{disabled:!0,value:e.name,label:`${e.description} ${c}`};let u=!1,p=!1;const g=[];if(e.depends){const a=n.find(n=>n.name===e.depends),i=m(a)?t[a.categoryInfo.name][a.name]:t[a.categoryInfo.name];i&&(u="string"==typeof i.default?i.default!==e.depends:!0!==i.default),g.push(a.description)}if(e.dependsType){const i=n.find(n=>n.providesType===e.dependsType),s=t[i.categoryInfo.name],r=n.find(e=>e.name===s?.default);p=s?.default===a.NONE_OPTION||r&&r.providesType!==e.dependsType,g.push(d.lmsg(`componentName.${i.providesType}`))}const f=g.length?d.lmsg("defaultComponents.depends_on",{name:g.join(", ")}):"";return{disabled:u||p,indentFields:i&&e.parameters.length?[(0,o.jsx)("h4",{children:(0,o.jsx)(l,{content:"defaultComponents.parametersOfComponent",params:{component:e.description}})},"header"),...e.parameters.map(n=>(0,r.renderParameter)(n,n=>s?`${e.categoryInfo.name}[${e.name}][params][${n}]`:`${e.categoryInfo.name}[params][${n}]`))]:[],value:e.name,label:`${e.description} ${f}`.trim()}},v=(e,n,t)=>Object.entries(n).reduce((n,[i,s])=>{if(Object.prototype.hasOwnProperty.call(s,"default")){let r=i;t&&(r=e[t].packages.find(e=>e.name===i).componentTypeInfo.name);let o=s.default;"boolean"==typeof s.default&&(o=s.default?i:a.NONE_OPTION),n.push({categoryName:t,componentType:r,defaultComponent:o,params:s.params})}else n=n.concat(v(e,s,i));return n},[])},2525:(e,n,t)=>{"use strict";t.r(n),t.d(n,{ComponentConfPage:()=>u});var a=t(295),i=t(667),s=t.n(i),r=t(598),o=t(296),d=t(90),l=t(2520);const c=d.Locale.getSection("components.lists.server-components"),m=d.Locale.getTranslate("components.lists.server-components.componentConf"),u=({packages:e})=>{const n=(0,r.useNavigate)(),t=(0,r.useMatch)("/cp/server/components/configuration/:name"),i=(0,a.useMemo)(()=>{if(t)return e.find(e=>e.name===t.params.name)},[e,t]),s=(0,a.useMemo)(()=>{if(!i)return"";const e=""!==i.state?` ${c.lmsg(`defaultComponents.${i.state}`)}`:"";return i.description+e},[i]),d=(0,a.useCallback)(()=>{n("/cp/server/components")},[n]);return(0,a.jsx)(o.Drawer,{"data-type":"components-config",isOpen:Boolean(t),onClose:d,title:(0,a.jsx)(m,{content:"title",params:{compDesc:s}}),form:i?(0,a.jsx)(l.ComponentConfForm,{packageName:i.name,parameters:i.parameters,onClose:d}):null})};u.propTypes={packages:s().array.isRequired}}}]);
//# sourceMappingURL=ServerComponentsPage.js.map?ab5a9e4f5fbef9781f10