"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[825],{4594:function(e,n,t){var r=t(5893),o=t(6514),i=t(5113),a=t(4656),s=t(482),l=t(2994),u=t(7357),c=t(9890),p=t(7169),d=t(1363),f=t(6284);function v(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function m(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var g=function(e){return(0,r.jsx)(o.Z,{in:!0,children:(0,r.jsx)(i.Z,m({},e))})};n.Z=function(e){var n=e.componentsProps,t=e.extendRenderInput,o=e.label,i=e.messageBoxProps,h=e.renderInput,b=e.sx,y=x(e,["componentsProps","extendRenderInput","label","messageBoxProps","renderInput","sx"]),j=m({paper:{sx:{backgroundColor:p.lD}}},n),S=null!==h&&void 0!==h?h:function(e){var n=e.fullWidth,i=e.InputProps,a=e.InputLabelProps,s=e.inputProps,l={formControlProps:{fullWidth:n,ref:i.ref},inputLabelProps:a,inputProps:{className:i.className,endAdornment:i.endAdornment,inputProps:s,startAdornment:i.startAdornment},label:o};return null===t||void 0===t||t.call(null,l,e),(0,r.jsx)(f.Z,m({},l))},U=m(v({},"& .".concat(a.Z.root," .").concat(s.Z.endAdornment),v({right:"7px"},"& .".concat(l.Z.root),{color:p.s7})),b);return(0,r.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(c.Z,m({PaperComponent:g},y,{componentsProps:j,renderInput:S,sx:U})),(0,r.jsx)(d.Z,m({},i))]})}},5521:function(e,n,t){t.d(n,{Z:function(){return E}});var r=t(5893),o=t(1113),i=t(1496),a=t(2293),s=t(7357),l=t(2992),u=t(4799),c=t(7294),p=t(7169),d=t(4433),f=t(9029),v=t(7533),m=t(8462),x=t(7212),g=t(8619),h=[{text:"Anvil",image:"/pngs/anvil_icon_on.png",uri:"/manage-element"},{text:"Files",image:"/pngs/files_on.png",uri:"/file-manager"},{text:"Configure",image:"/pngs/configure_icon_on.png",uri:"/config"},{text:"Help",image:"/pngs/help_icon_on.png",uri:"https://alteeve.com/w/Support"}],b={width:"40em",height:"40em"},y=t(4390),j=t(582),S=t(4690),U=t(1770),I=t(7750),P=t(1081);function O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t1&&void 0!==arguments[1]?arguments[1]:"suiapi.";return t["".concat(n).concat(e)]}),[t]),i=(0,c.useCallback)((function(){return o("user")}),[o]);return(0,c.useEffect)((function(){if(e){var n=document.cookie.split(/\s*;\s*/);r(n.reduce((function(e,n){var t,r=D(n.split("=",2),2),o=r[0],i=r[1],a=decodeURIComponent(i);if(a.startsWith("j:"))try{t=JSON.parse(a.substring(2))}catch(s){t=i}else t=i;return e[o]=t,e}),{}))}}),[e]),{cookieJar:t,getCookie:o,getSessionUser:i}};function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function C(e){for(var n=1;n0)},ref:n})]})}},4427:function(e,n,t){var r=t(5893),o=t(2429),i=t(9309),a=t(7169);function s(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(e){for(var n=1;n :first-child":{flexGrow:1},"& > :not(:last-child)":{marginRight:".5em"}},"&:hover\n .".concat(y.Z.root,"\n .").concat(j.Z.root,"\n .").concat(j.Z.notchedOutline),{borderColor:p.s7}),children:[(0,r.jsx)(b.Z,P({id:n,label:t},i)),(0,r.jsx)(U.Z,P({formControlProps:{fullWidth:!1},id:"".concat(n,"-nested-select"),selectItems:u},d))]}),(0,r.jsx)(S.Z,P({},l))]})};D.defaultProps=O;var Z=D,w=t(3679),C=t(3640),M=t(6727),k=t(1184),A=t(9),G=t(192),B=t(7750);function z(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function E(e){return function(e){if(Array.isArray(e))return z(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"===typeof e)return z(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return z(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var V={inputLabelProps:{},isAllowTextInput:!1,labelId:"",messageBoxProps:{},sliderProps:{}},W={root:"".concat("SliderInputLabelDecorator","-root")},R=function(e){var n=e.isFocused,t=e.label,o=p.s7,i="solid",s="0",l="0 .6em 0 .4em",u="1px 0 0 0",c="0.3";return n&&(s="-1px",l="0 1em 0 1em",u="2px 0 0 0",c="1"),(0,r.jsxs)(a.Z,{className:W.root,sx:{display:"flex",flexDirection:"row",position:"absolute",top:s,width:"calc(100% - 6px)","> :last-child":{flexGrow:1}},children:[(0,r.jsx)(a.Z,{sx:{borderColor:o,borderStyle:i,borderWidth:u,content:'""',opacity:c,width:".6em"}}),(0,r.jsx)(B.Ac,{sx:{fontSize:".75em",margin:l,visibility:"hidden"},text:t}),(0,r.jsx)(a.Z,{sx:{borderColor:o,borderStyle:i,borderWidth:u,content:'""',opacity:c}})]})},_=function(e,n){var t=Number.parseFloat(e);return Number.isNaN(t)?n:t},Q=function(e){return F(e,Array)?e.map((function(e){return String(e)})):[String(e)]},q=function(e){var n,t=e.messageBoxProps,i=void 0===t?V.messageBoxProps:t,s=e.isAllowTextInput,l=void 0===s?V.isAllowTextInput:s,u=e.label,c=e.labelId,d=void 0===c?V.labelId:c,f=e.inputLabelProps,v=void 0===f?V.inputLabelProps:f,m=e.sliderProps,x=void 0===m?V.sliderProps:m,g=e.value,h=x.max,b=x.min,y=x.onChange,U=x.sx,I=x.valueLabelDisplay,P=g,O=(0,o.useState)({range:Q(g)}),D=O[0],Z=O[1],w=(0,o.useState)(!1),B=w[0],z=w[1],q=function(){z(!1)},H=function(){z(!0)},J=function(){P=function(e,n){return F(n,Array)?e.map((function(e,t){return _(e,n[t])})):_(e[0],n)}(D.range,P),null===y||void 0===y||y.call(null,P)};return(0,r.jsxs)(C.Z,{sx:{display:"flex",flexDirection:"column","&:hover":(n={},T(n,"& .".concat(W.root," div"),{opacity:1}),T(n,"& .".concat(j.Z.notchedOutline),{borderColor:p.s7}),n)},children:[(0,r.jsx)(G.Z,N({className:B?M.Z.focused:"",id:d,shrink:!0},v,{children:u})),R({isFocused:B,label:u}),(0,r.jsxs)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row","> :first-child":{flexGrow:1}},children:[(0,r.jsx)(k.ZP,{"aria-labelledby":d,max:h,min:b,onBlur:q,onChange:function(e,n){Z({range:Q(n)}),null===y||void 0===y||y.call(null,n)},onFocus:H,sx:N(T({color:p.s7,marginLeft:"1em",marginRight:"1em"},"& .".concat(k.TW.thumb),{borderRadius:p.n_,transform:"translate(-50%, -50%) rotate(45deg)"}),U),value:P,valueLabelDisplay:I}),D.range.map((function(e,n){return function(e){var n=e.key,t=e.isFocused,o=L(e,["key","isFocused"]);return(0,r.jsx)(A.Z,N({key:n,className:t?j.Z.focused:"",type:"number"},o))}({key:"slider-nested-text-input-".concat(n),inputProps:{max:h,min:b},isFocused:B,onBlur:q,onChange:function(){for(var e=arguments.length,t=new Array(e),r=0;re.length)&&(n=e.length);for(var t=0,r=new Array(n);t=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function oe(e,n){return $(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,s=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==t.return||t.return()}finally{if(s)throw o}}return i}}(e,n)||se(e,n)||ne()}function ie(e){return $(e)||ee(e)||se(e,i)||ne()}function ae(e){return function(e){if(Array.isArray(e))return K(e)}(e)||ee(e)||se(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function se(e,n){if(e){if("string"===typeof e)return K(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?K(e,n):void 0}}var le,ue,ce=BigInt(0),pe=[{value:"B"},{value:"KiB"},{value:"MiB"},{value:"GiB"},{value:"TiB"}],de="GiB",fe=BigInt(65536),ve=BigInt(104857600),me={backgroundColor:p.Ej,color:p.lD,"&:hover":{backgroundColor:p.Ej}},xe=function(e,n){var t=n.onButtonClick;return(0,r.jsx)(m.Z,{disabled:void 0===t,onClick:t,sx:{minWidth:"unset",whiteSpace:"nowrap"},children:"Max: ".concat(e)})},ge=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.endAdornment,t=e.mainLabel,o=e.subLabel;return(0,r.jsxs)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row",width:"100%","& > :first-child":{flexGrow:1}},children:[(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:[t&&(0,r.jsx)(B.Ac,{inverted:!0,text:t}),o&&(0,r.jsx)(B.Ac,{inverted:!0,text:o})]}),n]})},he=function(e,n,t,r,o,i,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},l=s.includeAnvilUUIDs,u=void 0===l?[]:l,c=s.includeFileUUIDs,p=void 0===c?[]:c,d=s.includeStorageGroupUUIDs,f=void 0===d?[]:d,v=function(){return!0},m=function(){return!0},x=function(){return!0};u.length>0&&(v=function(e){return u.includes(e)}),p.length>0&&(m=function(e){return p.includes(e)}),f.length>0&&(x=function(e){return f.includes(e)});var g={},h=i.reduce((function(e,n,t){var r,i=null!==(r=o[t])&&void 0!==r?r:ce;return e.all+=i,""===n||(void 0===e[n]&&(e[n]=ce),e[n]+=i),e}),{all:ce}),b=e.reduce((function(e,s){var l=s.anvilUUID;if(v(l)){var u,c=s.anvilTotalCPUCores,p=s.anvilTotalAvailableMemory,d=s.files,f=s.fileUUIDs,b=s.storageGroups,y=[],j=ce,S=ce;if(b.forEach((function(e){var n=e.storageGroupUUID,t=e.storageGroupFree;x(n)&&(y.push(n),S+=t,t>j&&(j=t))})),[function(){return b.length>0},function(){return t<=c},function(){return r<=p},function(){return i.every((function(e,t){var r,i=null!==(r=o[t])&&void 0!==r?r:ce,a=!0,s=i<=j;return""!==e&&(a=y.includes(e),s=i<=n[e].storageGroupFree),a&&s}))},function(){return Object.entries(h).every((function(e){var t=oe(e,2),r=t[0],o=t[1];return"all"===r?o<=S:o<=n[r].storageGroupFree}))},function(){return a.every((function(e){return""===e||f.includes(e)}))}].every((function(e){return e()})))e.anvils.push(s),e.anvilUUIDs.push(l),e.maxCPUCores=Math.max(c,e.maxCPUCores),p>e.maxMemory&&(e.maxMemory=p),d.forEach((function(e){var n=e.fileUUID;m(n)&&(g[n]=!0)})),(u=e.storageGroupUUIDs).push.apply(u,ae(y)),e.maxVirtualDiskSizes.fill(j)}return e}),{anvils:[],anvilUUIDs:[],fileUUIDs:[],maxCPUCores:0,maxMemory:ce,maxVirtualDiskSizes:i.map((function(){return ce})),storageGroupUUIDs:[]});return b.fileUUIDs=Object.keys(g),i.forEach((function(e,t){""!==e&&(b.maxVirtualDiskSizes[t]=n[e].storageGroupFree)})),b},be=function(e){return e.filter((function(e){return""!==e}))},ye=function(e){return{fromUnit:"B",onSuccess:{string:e},precision:0,toUnit:"ibyte"}};(0,x.Bh)(fe,ye((function(e,n){le="".concat(e," ").concat(n)}))),(0,x.Bh)(ve,ye((function(e,n){ue="".concat(e," ").concat(n)})));var je=function(e){var n=e.dialogProps.open,t=e.onClose,i=(0,o.useState)([]),y=i[0],j=i[1],S=(0,o.useState)({}),I=S[0],P=S[1],O=(0,o.useState)({}),D=O[0],C=O[1],M=(0,o.useState)({}),k=M[0],A=M[1],G=(0,o.useState)({}),z=G[0],T=G[1],F=(0,o.useState)([]),N=F[0],L=F[1],E=(0,o.useState)([]),V=E[0],W=E[1],R=(0,o.useState)([]),_=R[0],Q=R[1],q=(0,o.useState)([]),K=q[0],$=q[1],ee=(0,o.useState)(""),ne=ee[0],se=ee[1],ye=(0,o.useState)(),je=ye[0],Se=ye[1],Ue=(0,o.useState)(1),Ie=Ue[0],Pe=Ue[1],Oe=(0,o.useState)(0),De=Oe[0],Ze=Oe[1],we=(0,o.useState)(),Ce=we[0],Me=we[1],ke=(0,o.useState)(ce),Ae=ke[0],Ge=ke[1],Be=(0,o.useState)(ce),ze=Be[0],Te=Be[1],Fe=(0,o.useState)(),Ne=Fe[0],Le=Fe[1],Ee=(0,o.useState)("0"),Ve=Ee[0],We=Ee[1],Re=(0,o.useState)(""),_e=Re[0],Qe=Re[1],qe=(0,o.useState)(de),He=qe[0],Je=qe[1],Ye=(0,o.useState)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.existingVirtualDisks,t=void 0===n?{stateIds:[],inputMaxes:[],inputSizeMessages:[],inputSizes:[],inputStorageGroupUUIDMessages:[],inputStorageGroupUUIDs:[],inputUnits:[],maxes:[],sizes:[]}:n,r=e.stateId,o=void 0===r?(0,c.Z)():r,i=e.inputMax,a=void 0===i?"0":i,s=e.inputSize,l=void 0===s?"":s,u=e.inputSizeMessage,p=void 0===u?void 0:u,d=e.inputStorageGroupUUID,f=void 0===d?"":d,v=e.inputStorageGroupUUIDMessage,m=void 0===v?void 0:v,x=e.inputUnit,g=void 0===x?de:x,h=e.max,b=void 0===h?ce:h,y=e.setVirtualDisks,j=e.size,S=void 0===j?ce:j,U=t.stateIds,I=t.inputMaxes,P=t.inputSizeMessages,O=t.inputSizes,D=t.inputStorageGroupUUIDMessages,Z=t.inputStorageGroupUUIDs,w=t.inputUnits,C=t.maxes,M=t.sizes;return U.push(o),I.push(a),P.push(p),O.push(l),D.push(m),Z.push(f),w.push(g),C.push(b),M.push(S),null===y||void 0===y||y.call(null,te({},t)),t}()),Ke=Ye[0],$e=Ye[1],Xe=(0,o.useState)(""),en=Xe[0],nn=Xe[1],tn=(0,o.useState)(),rn=tn[0],on=tn[1],an=(0,o.useState)(""),sn=an[0],ln=an[1],un=(0,o.useState)()[0],cn=(0,o.useState)(""),pn=cn[0],dn=cn[1],fn=(0,o.useState)(),vn=fn[0],mn=fn[1],xn=(0,o.useState)(null),gn=xn[0],hn=xn[1],bn=(0,o.useState)(),yn=bn[0],jn=bn[1],Sn=(0,o.useState)([]),Un=Sn[0],In=Sn[1],Pn=(0,o.useState)([]),On=Pn[0],Dn=Pn[1],Zn=(0,o.useState)([]),wn=Zn[0],Cn=Zn[1],Mn=(0,o.useState)(!1),kn=Mn[0],An=Mn[1],Gn=(0,o.useState)(!1),Bn=Gn[0],zn=Gn[1],Tn=(0,o.useState)(!1),Fn=Tn[0],Nn=Tn[1],Ln=(0,o.useState)(0),En=Ln[0],Vn=Ln[1],Wn={serverName:{defaults:{onSuccess:function(){Se(void 0)},value:ne},tests:[{onFailure:function(){Se({text:"The server name length must be 1 to 16 characters.",type:"warning"})},test:function(e){var n=e.value.length;return n>=1&&n<=16}},{onFailure:function(){Se({text:"The server name is expected to only contain alphanumeric, hyphen, or underscore characters.",type:"warning"})},test:function(e){var n=e.value;return/^[a-zA-Z0-9_-]+$/.test(n)}},{onFailure:function(){Se({text:"This server name already exists, please choose another name.",type:"warning"})},test:function(e){var n=e.value;return void 0===k[n]}}]},cpuCores:{defaults:{max:De,min:1,onSuccess:function(){Me(void 0)},value:Ie},tests:[{onFailure:function(){Me({text:"Non available.",type:"warning"})},test:Y.X7},{onFailure:function(e){var n=e.displayMax,t=e.displayMin;Me({text:"The number of CPU cores is expected to be between ".concat(t," and ").concat(n,"."),type:"warning"})},test:Y.SQ}]},memory:{defaults:{displayMax:"".concat(Ve," ").concat(He),displayMin:le,max:ze,min:fe,onSuccess:function(){Le(void 0)},value:Ae},tests:[{onFailure:function(){Le({text:"Non available.",type:"warning"})},test:Y.X7},{onFailure:function(e){var n=e.displayMax,t=e.displayMin;Le({text:"Memory is expected to be between ".concat(t," and ").concat(n,"."),type:"warning"})},test:Y.SQ}]},installISO:{defaults:{onSuccess:function(){on(void 0)},value:en},tests:[{test:Y.HJ}]},anvil:{defaults:{onSuccess:function(){mn(void 0)},value:pn},tests:[{test:Y.HJ}]},optimizeForOS:{defaults:{onSuccess:function(){jn(void 0)},value:null===gn||void 0===gn?void 0:gn.key},tests:[{test:Y.HJ}]}};Ke.inputSizeMessages.forEach((function(e,n){Wn["vd".concat(n,"Size")]={defaults:{displayMax:"".concat(Ke.inputMaxes[n]," ").concat(Ke.inputUnits[n]),displayMin:ue,max:Ke.maxes[n],min:ve,onSuccess:function(){Ke.inputSizeMessages[n]=void 0},value:Ke.sizes[n]},onFinishBatch:function(){$e(te({},Ke))},tests:[{onFailure:function(){Ke.inputSizeMessages[n]={text:"Non available.",type:"warning"}},test:Y.X7},{onFailure:function(e){var t=e.displayMax,r=e.displayMin;Ke.inputSizeMessages[n]={text:"Virtual disk ".concat(n," size is expected to be between ").concat(r," and ").concat(t,"."),type:"warning"}},test:Y.SQ}]},Wn["vd".concat(n,"StorageGroup")]={defaults:{onSuccess:function(){Ke.inputStorageGroupUUIDMessages[n]=void 0},value:Ke.inputStorageGroupUUIDs[n]},onFinishBatch:function(){$e(te({},Ke))},tests:[{test:Y.HJ}]}}));var Rn,_n,Qn,qn,Hn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.allAnvils,t=void 0===n?y:n,r=e.cpuCores,o=void 0===r?Ie:r,i=e.fileUUIDs,a=void 0===i?[en,sn]:i,s=e.includeAnvilUUIDs,l=void 0===s?be([pn]):s,u=e.includeFileUUIDs,c=e.includeStorageGroupUUIDs,p=e.inputMemoryUnit,d=void 0===p?He:p,f=e.memory,v=void 0===f?Ae:f,m=e.storageGroupUUIDMapToData,g=void 0===m?z:m,h=e.virtualDisks,b=void 0===h?Ke:h,j=he(t,g,o,v,b.sizes,b.inputStorageGroupUUIDs,a,{includeAnvilUUIDs:l,includeFileUUIDs:u,includeStorageGroupUUIDs:c}),S=j.anvilUUIDs,U=j.fileUUIDs,I=j.maxCPUCores,P=j.maxMemory,O=j.maxVirtualDiskSizes,D=j.storageGroupUUIDs;Ze(I),Te(P);var Z=[];b.maxes=O,b.maxes.forEach((function(e,n){(0,x.Bh)(e,{fromUnit:"B",onSuccess:{string:function(e,t){b.inputMaxes[n]=e,Z[n]="".concat(e," ").concat(t)}},toUnit:b.inputUnits[n]})})),$e(te({},b)),In(S),Dn(U),Cn(D);var w="";return(0,x.Bh)(P,{fromUnit:"B",onSuccess:{string:function(e,n){We(e),w="".concat(e," ").concat(n)}},toUnit:d}),{formattedMaxMemory:w,formattedMaxVDSizes:Z,maxCPUCores:I,maxMemory:P,maxVirtualDiskSizes:O}},Jn=(0,o.useCallback)(Hn,[]),Yn=function(){for(var e=arguments.length,n=new Array(e),t=0;t0&&void 0!==arguments[0]?arguments[0]:{},n=e.cmValue,t=void 0===n?ce:n,r=e.cmUnit,o=void 0===r?He:r;Ge(t);var i=Hn({inputMemoryUnit:o,memory:t}),a=i.formattedMaxMemory,s=i.maxMemory;Yn({inputs:{memory:{displayMax:a,max:s,value:t}}})},$n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.value,t=void 0===n?_e:n,r=e.unit,o=void 0===r?He:r;t!==_e&&Qe(t),o!==He&&Je(o),(0,x.KY)(t,o,(function(e){return Kn({cmValue:e,cmUnit:o})}),(function(){return Kn({cmUnit:o})}))},Xn=function(e){nn(e),Hn({fileUUIDs:[e,sn]})},et=function(e){ln(e),Hn({fileUUIDs:[en,e]})},nt=function(e){var n=be([e]);dn(e),Hn({includeAnvilUUIDs:n})};return(0,o.useEffect)((function(){d.Z.get("/anvil",{params:{anvilUUIDs:"all",isForProvisionServer:!0}}).then((function(e){var n=e.data,t=function(e){var n={},t=e.reduce((function(e,t){var o=t.anvilUUID,i=t.anvilName,s=t.anvilTotalMemory,l=t.anvilTotalAllocatedMemory,u=t.anvilTotalAvailableMemory,c=t.hosts,p=t.servers,d=t.storageGroups,f=t.files,v=d.reduce((function(n,t){var a=te({},t,{anvilUUID:o,anvilName:i,storageGroupSize:BigInt(t.storageGroupSize),storageGroupFree:BigInt(t.storageGroupFree),humanizedStorageGroupFree:""});return(0,x.Bh)(t.storageGroupFree,{fromUnit:"B",onSuccess:{string:function(e,n){a.humanizedStorageGroupFree="".concat(e," ").concat(n)}},precision:0,toUnit:"ibyte"}),n.anvilStorageGroupUUIDs.push(t.storageGroupUUID),n.anvilStorageGroups.push(a),e.storageGroups.push(a),e.storageGroupSelectItems.push({displayValue:ge({endAdornment:(0,r.jsx)(B.Ac,{inverted:!0,text:"~".concat(a.humanizedStorageGroupFree," free")}),mainLabel:t.storageGroupName,subLabel:i}),value:t.storageGroupUUID}),e.storageGroupUUIDMapToData[t.storageGroupUUID]=a,n}),{anvilStorageGroups:[],anvilStorageGroupUUIDs:[]}),m=v.anvilStorageGroups,g=v.anvilStorageGroupUUIDs,h=[];f.forEach((function(e){var t=e.fileUUID;h.push(t),n[t]=e}));var b=te({},t,{anvilTotalMemory:BigInt(s),anvilTotalAllocatedMemory:BigInt(l),anvilTotalAvailableMemory:BigInt(u),humanizedAnvilTotalAvailableMemory:"",hosts:c.map((function(e){return te({},e,{hostMemory:BigInt(e.hostMemory)})})),servers:p.map((function(n){var t=n.serverMemory,r=n.serverName,o=te({},re(n,["serverMemory","serverName"]),{serverMemory:BigInt(t),serverName:r});return e.serverNameMapToData[r]=o,o})),storageGroupUUIDs:g,storageGroups:m,fileUUIDs:h});return(0,x.Bh)(u,{fromUnit:"B",onSuccess:{string:function(e,n){b.humanizedAnvilTotalAvailableMemory="".concat(e," ").concat(n)}},precision:0,toUnit:"ibyte"}),e.anvils.push(b),e.anvilSelectItems.push({displayValue:ge({endAdornment:(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",width:"8rem"},children:[(0,r.jsx)(B.Ac,{inverted:!0,text:"CPU: ".concat(b.anvilTotalCPUCores," cores")}),(0,r.jsx)(B.Ac,{inverted:!0,text:"Memory: ~".concat(b.humanizedAnvilTotalAvailableMemory)})]}),mainLabel:b.anvilName,subLabel:b.anvilDescription}),value:o}),e.anvilUUIDMapToData[o]=b,e}),{anvils:[],anvilSelectItems:[],anvilUUIDMapToData:{},files:[],fileSelectItems:[],fileUUIDMapToData:{},serverNameMapToData:{},storageGroups:[],storageGroupSelectItems:[],storageGroupUUIDMapToData:{}});return Object.values(n).forEach((function(e){t.files.push(e),t.fileSelectItems.push({displayValue:e.fileName,value:e.fileUUID}),t.fileUUIDMapToData[e.fileUUID]=e})),t}(n.anvils),o=t.anvils,i=t.anvilSelectItems,s=t.anvilUUIDMapToData,l=t.fileSelectItems,u=t.fileUUIDMapToData,c=t.serverNameMapToData,p=t.storageGroupSelectItems,d=t.storageGroupUUIDMapToData;j(o),P(s),C(u),A(c),T(d),L(i),W(l),$(p),Jn({allAnvils:o,storageGroupUUIDMapToData:d}),Q(Object.entries(n.oses).map((function(e){var n=oe(e,2);return{key:n[0],label:n[1]}}))),An(!0)}))}),[Jn]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Z,{fullWidth:!0,maxWidth:"sm",open:n,PaperComponent:w.s_,PaperProps:{sx:{overflow:"visible"}},children:[(0,r.jsxs)(w.V9,{children:[(0,r.jsx)(B.z,{text:"Provision a Server"}),(0,r.jsx)(g.Z,{onClick:t,sx:{backgroundColor:p.hM,color:p.lD,"&:hover":{backgroundColor:p.hM}},children:(0,r.jsx)(u.Z,{})})]}),kn?(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",maxHeight:"50vh",overflowY:"scroll",paddingTop:".6em","& > :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(b.Z,{id:"ps-server-name",label:"Server name",inputProps:{onChange:function(e){var n=e.target.value;se(n),Yn({inputs:{serverName:{value:n}}})},value:ne},inputLabelProps:{isNotifyRequired:0===ne.length},messageBoxProps:je})}),(Rn="ps-cpu-cores",_n="CPU cores",Qn=Ie,qn={messageBoxProps:Ce,sliderProps:{onChange:function(e){var n=e;if(n!==Ie){Pe(n);var t=Hn({cpuCores:n}).maxCPUCores;Yn({inputs:{cpuCores:{max:t,value:n}}})}},max:De,min:1}},(0,r.jsx)(H,te({isAllowTextInput:!0,label:_n,labelId:"".concat(Rn,"-label"),value:Qn},qn))),(0,r.jsx)(Z,{id:"ps-memory",label:"Memory",messageBoxProps:Ne,inputWithLabelProps:{inputProps:{endAdornment:xe("".concat(Ve," ").concat(He),{onButtonClick:function(){Qe(Ve),Kn({cmValue:ze})}}),onChange:function(e){var n=e.target.value;$n({value:n})},type:"number",value:_e},inputLabelProps:{isNotifyRequired:Ae===ce}},selectItems:pe,selectWithLabelProps:{selectProps:{onChange:function(e){var n=e.target.value;$n({unit:n})},value:He}}}),Ke.stateIds.map((function(e,n){return function(e,n,t,o,i,s,l,u){var c=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n;return e[t][r]},p=function(r,o){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n;e[r][i]=o,t(te({},e))},d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ce;p("sizes",t);var r=s({virtualDisks:e}),o=r.formattedMaxVDSizes,i=r.maxVirtualDiskSizes;u({inputs:X({},"vd".concat(n,"Size"),{displayMax:"".concat(o[n]),max:i[n],value:t})})},f=function(e){var n=e.value,t=void 0===n?c("inputSizes"):n,r=e.unit,o=void 0===r?c("inputUnits"):r;t!==c("inputSizes")&&p("inputSizes",t),o!==c("inputUnits")&&p("inputUnits",o),(0,x.KY)(t,o,(function(e){return d(e)}),(function(){return d()}))},v=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c("inputStorageGroupUUIDs");n!==c("inputStorageGroupUUIDs")&&p("inputStorageGroupUUIDs",n),s({virtualDisks:e})};return(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(Z,{id:"ps-virtual-disk-size-".concat(n),label:"Virtual disk size",messageBoxProps:c("inputSizeMessages"),inputWithLabelProps:{inputProps:{endAdornment:xe("".concat(c("inputMaxes")," ").concat(c("inputUnits")),{onButtonClick:function(){p("inputSizes",c("inputMaxes")),d(c("maxes"))}}),onChange:function(e){var n=e.target.value;f({value:n})},type:"number",value:c("inputSizes")},inputLabelProps:{isNotifyRequired:c("sizes")===ce}},selectItems:pe,selectWithLabelProps:{selectProps:{onChange:function(e){var n=e.target.value;f({unit:n})},value:c("inputUnits")}}})}),(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(U.Z,{id:"ps-storage-group-".concat(n),label:"Storage group",disableItem:function(e){return!(i.includes(e)&&c("sizes")<=l[e].storageGroupFree)},inputLabelProps:{isNotifyRequired:0===c("inputStorageGroupUUIDs").length},messageBoxProps:c("inputStorageGroupUUIDMessages"),selectItems:o,selectProps:{onChange:function(e){var n=e.target.value;v(n)},onClearIndicatorClick:function(){return v("")},renderValue:function(e){var n,t=null!==(n=l[e])&&void 0!==n?n:{},r=t.anvilName,o=void 0===r?"?":r,i=t.storageGroupName,a=void 0===i?"Unknown (".concat(e,")"):i;return"".concat(a," (").concat(o,")")},value:c("inputStorageGroupUUIDs")}})})]},"ps-virtual-disk-".concat(c("stateIds")))}(Ke,n,$e,K,wn,Hn,z,Yn)})),(0,r.jsx)(U.Z,{disableItem:function(e){return e===sn},hideItem:function(e){return!On.includes(e)},id:"ps-install-image",inputLabelProps:{isNotifyRequired:0===en.length},label:"Install ISO",messageBoxProps:rn,selectItems:V,selectProps:{onChange:function(e){var n=e.target.value;Xn(n)},onClearIndicatorClick:function(){return Xn("")},value:en}}),(0,r.jsx)(U.Z,{disableItem:function(e){return e===en},hideItem:function(e){return!On.includes(e)},id:"ps-driver-image",label:"Driver ISO",messageBoxProps:un,selectItems:V,selectProps:{onChange:function(e){var n=e.target.value;et(n)},onClearIndicatorClick:function(){return et("")},value:sn}}),(0,r.jsx)(U.Z,{disableItem:function(e){return!Un.includes(e)},id:"ps-anvil",inputLabelProps:{isNotifyRequired:0===pn.length},label:"Anvil node",messageBoxProps:vn,selectItems:N,selectProps:{onChange:function(e){var n=e.target.value;nt(n)},onClearIndicatorClick:function(){return nt("")},renderValue:function(e){var n,t=(null!==(n=I[e])&&void 0!==n?n:{}).anvilName;return void 0===t?"Unknown ".concat(e):t},value:pn}}),(0,r.jsx)(f.Z,{id:"ps-optimize-for-os",extendRenderInput:function(e){var n=e.inputLabelProps;(void 0===n?{}:n).isNotifyRequired=null===gn},isOptionEqualToValue:function(e,n){return e.key===n.key},label:"Optimize for OS",messageBoxProps:yn,noOptionsText:"No matching OS",onChange:function(e,n){hn(n)},openOnFocus:!0,options:_,renderOption:function(e,n){return(0,o.createElement)("li",te({},e,{key:"ps-optimize-for-os-".concat(n.key),children:[n.label," (",n.key,")"]}))},value:gn})]}):(0,r.jsx)(J.Z,{}),(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",marginTop:"1em","& > :not(:first-child)":{marginTop:"1em"}},children:[En>0&&(0,r.jsx)(h.Z,{isAllowClose:!0,text:"Provision server job registered. You can provision another server, or exit; it won't affect the registered job."}),Fn?(0,r.jsx)(J.Z,{mt:0}):(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",width:"100%"},children:(0,r.jsx)(m.Z,{disabled:!Yn({isIgnoreOnCallbacks:!0}),onClick:function(){zn(!0)},sx:me,children:"Provision"})})]})]}),Bn&&(0,r.jsx)(v.Z,{actionProceedText:"Provision",content:(0,r.jsxs)(s.ZP,{container:!0,columns:8,direction:"column",children:[(0,r.jsx)(s.ZP,{direction:"row",item:!0,xs:8,children:(0,r.jsxs)(B.Ac,{children:["Server ",(0,r.jsx)(B.Q0,{text:ne})," will be created on anvil node"," ",(0,r.jsx)(B.Q0,{text:I[pn].anvilName})," ","with the following properties:"]})}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(B.Ac,{text:"CPU"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(B.Ac,{children:[(0,r.jsx)(B.Q0,{text:Ie})," core(s)"]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(B.Ac,{children:[(0,r.jsx)(B.Q0,{text:De})," core(s) available"]})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(B.Ac,{text:"Memory"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsx)(B.Q0,{text:"".concat(_e," ").concat(He)})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(B.Ac,{children:[(0,r.jsx)(B.Q0,{text:"".concat(Ve," ").concat(He)})," ","available"]})})]}),Ke.stateIds.map((function(e,n){var t=Ke.inputMaxes[n],o=Ke.inputSizes[n],i=Ke.inputUnits[n],a=z[Ke.inputStorageGroupUUIDs[n]].storageGroupName;return(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsxs)(B.Ac,{children:["Virtual disk ",(0,r.jsx)(B.Q0,{text:n})]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(B.Ac,{children:[(0,r.jsx)(B.Q0,{text:"".concat(o," ").concat(i)})," on"," ",a]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(B.Ac,{children:[(0,r.jsx)(B.Q0,{text:"".concat(t," ").concat(i)})," ","available"]})})]},"ps-virtual-disk-".concat(e,"-summary"))})),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(B.Ac,{text:"Install ISO"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:(0,r.jsx)(B.Q0,{text:D[en].fileName})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(B.Ac,{text:"Driver ISO"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:D[sn]?(0,r.jsx)(B.Q0,{text:D[sn].fileName}):(0,r.jsx)(B.Ac,{text:"none"})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(B.Ac,{text:"Optimize for OS"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:(0,r.jsx)(B.Ac,{text:"".concat(null===gn||void 0===gn?void 0:gn.label)})})]})]}),dialogProps:{open:Bn},onCancelAppend:function(){zn(!1)},onProceedAppend:function(){var e={serverName:ne,cpuCores:Ie,memory:Ae.toString(),virtualDisks:Ke.stateIds.map((function(e,n){return{storageSize:Ke.sizes[n].toString(),storageGroupUUID:Ke.inputStorageGroupUUIDs[n]}})),installISOFileUUID:en,driverISOFileUUID:sn,anvilUUID:pn,optimizeForOS:null===gn||void 0===gn?void 0:gn.key};Nn(!0),d.Z.post("/server",e).then((function(){Nn(!1),Vn(En+1)})),zn(!1)},proceedButtonProps:{sx:me},titleText:"Provision ".concat(ne,"?")})]})}},2519:function(e,n,t){t.d(n,{Z:function(){return D}});var r=t(5893),o=t(5603),i=t(8128),a=t(3640),s=t(7294),l=t(1363),u=t(4427),c=t(9),p=t(192),d=t(5537),f=t(9558),v=t(6239),m=t(7021),x=t(1057),g=t(4799),h=t(3213),b=t(7169);function y(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function j(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var U=function(e){var n=e.onClearIndicatorClick,t=S(e,["onClearIndicatorClick"]),i=t.sx,a=t.value,l=S(t,["sx","value"]),u=(0,s.useMemo)((function(){var e;return j((y(e={},"& .".concat(o.Z.icon),{color:b.s7}),y(e,"& .".concat(f.Z.root),{marginRight:".8em"}),y(e,"& .".concat(v.Z.root),{color:b.s7,visibility:"hidden"}),y(e,"&:hover .".concat(f.Z.root," .").concat(v.Z.root,",\n &.").concat(m.Z.focused," .").concat(f.Z.root," .").concat(v.Z.root),{visibility:"visible"}),e),i)}),[i]),c=(0,s.useMemo)((function(){return String(a).length>0&&n&&(0,r.jsx)(x.Z,{position:"end",children:(0,r.jsx)(g.Z,{onClick:n,children:(0,r.jsx)(d.Z,{fontSize:"small"})})})}),[n,a]);return(0,r.jsx)(h.Z,j({endAdornment:c,value:a},l,{sx:u}))};function I(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function P(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var D=function(e){var n=e.id,t=e.label,d=e.selectItems,f=e.checkItem,v=e.disableItem,m=e.formControlProps,x=e.hideItem,g=e.inputLabelProps,h=void 0===g?{}:g,b=e.isReadOnly,y=void 0!==b&&b,j=e.messageBoxProps,S=void 0===j?{}:j,D=e.name,Z=e.onBlur,w=e.onChange,C=e.onFocus,M=e.required,k=e.selectProps,A=void 0===k?{}:k,G=A.multiple,B=A.sx,z=e.value,T=e.isCheckableItems,F=void 0===T?G:T,N=O(e.selectProps,["multiple","sx"]),L=(0,s.useMemo)((function(){return y?P(I({},"& .".concat(o.Z.icon),{visibility:"hidden"}),B):B}),[y,B]),E=(0,s.useCallback)((function(e){return F&&(0,r.jsx)(i.Z,{checked:null===f||void 0===f?void 0:f.call(null,e)})}),[f,F]),V=(0,s.useCallback)((function(e,t){return(0,r.jsxs)(u.Z,{disabled:null===v||void 0===v?void 0:v.call(null,e),sx:{display:(null===x||void 0===x?void 0:x.call(null,e))?"none":void 0},value:e,children:[E(e),t]},"".concat(n,"-").concat(e))}),[E,v,x,n]),W=(0,s.useMemo)((function(){return"".concat(n,"-select-element")}),[n]),R=(0,s.useMemo)((function(){return(0,r.jsx)(c.Z,{id:n,label:t})}),[n,t]),_=(0,s.useMemo)((function(){return t&&(0,r.jsx)(p.Z,P({htmlFor:W,isNotifyRequired:M},h,{children:t}))}),[h,M,t,W]),Q=(0,s.useMemo)((function(){return d.map((function(e){var n="string"===typeof e?{value:e}:e,t=n.value,r=n.displayValue;return V(t,void 0===r?t:r)}))}),[V,d]);return(0,r.jsxs)(a.Z,P({fullWidth:!0},m,{children:[_,(0,r.jsx)(U,P({id:W,input:R,multiple:G,name:D,onBlur:Z,onChange:w,onFocus:C,readOnly:y,value:z},N,{sx:L,children:Q})),(0,r.jsx)(l.Z,P({},S))]}))}},1081:function(e,n,t){var r=t(7294);n.Z=function(){var e=(0,r.useRef)(!0);return e.current?(e.current=!1,!0):e.current}},5737:function(e,n,t){t.d(n,{Bh:function(){return o},KY:function(){return i},MU:function(){return a}});var r=t(4490),o=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.fromUnit,o=n.onFailure,i=n.onSuccess,a=n.precision,s=n.toUnit,l=(0,r.gO)(e,{fromUnit:t,precision:a,toUnit:s});if(l){var u=l.value,c=l.unit;try{var p,d,f;null===i||void 0===i||null===(p=i.bigint)||void 0===p||p.call(null,BigInt(u),c),null===i||void 0===i||null===(d=i.number)||void 0===d||d.call(null,parseFloat(u),c),null===i||void 0===i||null===(f=i.string)||void 0===f||f.call(null,u,c)}catch(v){null===o||void 0===o||o.call(null,v,u,c)}}else null===o||void 0===o||o.call(null)},i=function(e,n,t,r){o(e,{fromUnit:n,onFailure:r,onSuccess:{bigint:t},precision:0,toUnit:"B"})},a=function(e){return(0,r._d)(e,{toUnit:"ibyte"})}}}]);