"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[116],{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"]),U=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))},j=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:U,renderInput:S,sx:j})),(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),U=t(582),S=t(4690),j=t(1770),I=t(7750),P=t(1081);function D(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=w(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 O(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function A(e){for(var n=1;n0)},ref:n})]})}},4968:function(e,n,t){t.d(n,{Z:function(){return Ue}});var r=t(5893),o=t(7294),a=t(7357),s=t(6886),l=t(8262),u=t(5537),c=t(5934),p=t(7169),d=t(4390),f=t(4594),v=t(157),m=t(4825),x=t(5737),g=t(1706),h=t(8187),b=t(6284),y=t(7120),U=t(4656),S=t(1363),j=t(7783);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 :first-child":{flexGrow:1},"& > :not(:last-child)":{marginRight:".5em"}},"&:hover\n .".concat(y.Z.root,"\n .").concat(U.Z.root,"\n .").concat(U.Z.notchedOutline),{borderColor:p.s7}),children:[(0,r.jsx)(b.Z,P({id:n,label:t},i)),(0,r.jsx)(j.Z,P({formControlProps:{fullWidth:!1},id:"".concat(n,"-nested-select"),selectItems:u},d))]}),(0,r.jsx)(S.Z,P({},l))]})};w.defaultProps=D;var Z=w,O=t(3679),A=t(3640),C=t(6727),M=t(1184),k=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 W={inputLabelProps:{},isAllowTextInput:!1,labelId:"",messageBoxProps:{},sliderProps:{}},V={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:V.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 N(e,Array)?e.map((function(e){return String(e)})):[String(e)]},q=function(e){var n,t=e.messageBoxProps,i=void 0===t?W.messageBoxProps:t,s=e.isAllowTextInput,l=void 0===s?W.isAllowTextInput:s,u=e.label,c=e.labelId,d=void 0===c?W.labelId:c,f=e.inputLabelProps,v=void 0===f?W.inputLabelProps:f,m=e.sliderProps,x=void 0===m?W.sliderProps:m,g=e.value,h=x.max,b=x.min,y=x.onChange,j=x.sx,I=x.valueLabelDisplay,P=g,D=(0,o.useState)({range:Q(g)}),w=D[0],Z=D[1],O=(0,o.useState)(!1),B=O[0],z=O[1],q=function(){z(!1)},H=function(){z(!0)},J=function(){P=function(e,n){return N(n,Array)?e.map((function(e,t){return _(e,n[t])})):_(e[0],n)}(w.range,P),null===y||void 0===y||y.call(null,P)};return(0,r.jsxs)(A.Z,{sx:{display:"flex",flexDirection:"column","&:hover":(n={},T(n,"& .".concat(V.root," div"),{opacity:1}),T(n,"& .".concat(U.Z.notchedOutline),{borderColor:p.s7}),n)},children:[(0,r.jsx)(G.Z,F({className:B?C.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)(M.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:F(T({color:p.s7,marginLeft:"1em",marginRight:"1em"},"& .".concat(M.TW.thumb),{borderRadius:p.n_,transform:"translate(-50%, -50%) rotate(45deg)"}),j),value:P,valueLabelDisplay:I}),w.range.map((function(e,n){return function(e){var n=e.key,t=e.isFocused,o=L(e,["key","isFocused"]);return(0,r.jsx)(k.Z,F({key:n,className:t?U.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 K(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 K(e)||ee(e)||se(e,i)||ne()}function ae(e){return function(e){if(Array.isArray(e))return Y(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 Y(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)?Y(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=[],U=ce,S=ce;if(b.forEach((function(e){var n=e.storageGroupUUID,t=e.storageGroupFree;x(n)&&(y.push(n),S+=t,t>U&&(U=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<=U;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(U)}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 Ue=function(e){var n=e.dialogProps.open,t=e.onClose,i=(0,o.useState)([]),y=i[0],U=i[1],S=(0,o.useState)({}),I=S[0],P=S[1],D=(0,o.useState)({}),w=D[0],A=D[1],C=(0,o.useState)({}),M=C[0],k=C[1],G=(0,o.useState)({}),z=G[0],T=G[1],N=(0,o.useState)([]),F=N[0],L=N[1],E=(0,o.useState)([]),W=E[0],V=E[1],R=(0,o.useState)([]),_=R[0],Q=R[1],q=(0,o.useState)([]),Y=q[0],K=q[1],ee=(0,o.useState)(""),ne=ee[0],se=ee[1],ye=(0,o.useState)(),Ue=ye[0],Se=ye[1],je=(0,o.useState)(1),Ie=je[0],Pe=je[1],De=(0,o.useState)(0),we=De[0],Ze=De[1],Oe=(0,o.useState)(),Ae=Oe[0],Ce=Oe[1],Me=(0,o.useState)(ce),ke=Me[0],Ge=Me[1],Be=(0,o.useState)(ce),ze=Be[0],Te=Be[1],Ne=(0,o.useState)(),Fe=Ne[0],Le=Ne[1],Ee=(0,o.useState)("0"),We=Ee[0],Ve=Ee[1],Re=(0,o.useState)(""),_e=Re[0],Qe=Re[1],qe=(0,o.useState)(de),He=qe[0],Je=qe[1],$e=(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,U=e.size,S=void 0===U?ce:U,j=t.stateIds,I=t.inputMaxes,P=t.inputSizeMessages,D=t.inputSizes,w=t.inputStorageGroupUUIDMessages,Z=t.inputStorageGroupUUIDs,O=t.inputUnits,A=t.maxes,C=t.sizes;return j.push(o),I.push(a),P.push(p),D.push(l),w.push(m),Z.push(f),O.push(g),A.push(b),C.push(S),null===y||void 0===y||y.call(null,te({},t)),t}()),Ye=$e[0],Ke=$e[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],Un=bn[1],Sn=(0,o.useState)([]),jn=Sn[0],In=Sn[1],Pn=(0,o.useState)([]),Dn=Pn[0],wn=Pn[1],Zn=(0,o.useState)([]),On=Zn[0],An=Zn[1],Cn=(0,o.useState)(!1),Mn=Cn[0],kn=Cn[1],Gn=(0,o.useState)(!1),Bn=Gn[0],zn=Gn[1],Tn=(0,o.useState)(!1),Nn=Tn[0],Fn=Tn[1],Ln=(0,o.useState)(0),En=Ln[0],Wn=Ln[1],Vn={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===M[n]}}]},cpuCores:{defaults:{max:we,min:1,onSuccess:function(){Ce(void 0)},value:Ie},tests:[{onFailure:function(){Ce({text:"Non available.",type:"warning"})},test:$.X7},{onFailure:function(e){var n=e.displayMax,t=e.displayMin;Ce({text:"The number of CPU cores is expected to be between ".concat(t," and ").concat(n,"."),type:"warning"})},test:$.SQ}]},memory:{defaults:{displayMax:"".concat(We," ").concat(He),displayMin:le,max:ze,min:fe,onSuccess:function(){Le(void 0)},value:ke},tests:[{onFailure:function(){Le({text:"Non available.",type:"warning"})},test:$.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:$.SQ}]},installISO:{defaults:{onSuccess:function(){on(void 0)},value:en},tests:[{test:$.HJ}]},anvil:{defaults:{onSuccess:function(){mn(void 0)},value:pn},tests:[{test:$.HJ}]},optimizeForOS:{defaults:{onSuccess:function(){Un(void 0)},value:null===gn||void 0===gn?void 0:gn.key},tests:[{test:$.HJ}]}};Ye.inputSizeMessages.forEach((function(e,n){Vn["vd".concat(n,"Size")]={defaults:{displayMax:"".concat(Ye.inputMaxes[n]," ").concat(Ye.inputUnits[n]),displayMin:ue,max:Ye.maxes[n],min:ve,onSuccess:function(){Ye.inputSizeMessages[n]=void 0},value:Ye.sizes[n]},onFinishBatch:function(){Ke(te({},Ye))},tests:[{onFailure:function(){Ye.inputSizeMessages[n]={text:"Non available.",type:"warning"}},test:$.X7},{onFailure:function(e){var t=e.displayMax,r=e.displayMin;Ye.inputSizeMessages[n]={text:"Virtual disk ".concat(n," size is expected to be between ").concat(r," and ").concat(t,"."),type:"warning"}},test:$.SQ}]},Vn["vd".concat(n,"StorageGroup")]={defaults:{onSuccess:function(){Ye.inputStorageGroupUUIDMessages[n]=void 0},value:Ye.inputStorageGroupUUIDs[n]},onFinishBatch:function(){Ke(te({},Ye))},tests:[{test:$.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?ke:f,m=e.storageGroupUUIDMapToData,g=void 0===m?z:m,h=e.virtualDisks,b=void 0===h?Ye:h,U=he(t,g,o,v,b.sizes,b.inputStorageGroupUUIDs,a,{includeAnvilUUIDs:l,includeFileUUIDs:u,includeStorageGroupUUIDs:c}),S=U.anvilUUIDs,j=U.fileUUIDs,I=U.maxCPUCores,P=U.maxMemory,D=U.maxVirtualDiskSizes,w=U.storageGroupUUIDs;Ze(I),Te(P);var Z=[];b.maxes=D,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]})})),Ke(te({},b)),In(S),wn(j),An(w);var O="";return(0,x.Bh)(P,{fromUnit:"B",onSuccess:{string:function(e,n){Ve(e),O="".concat(e," ").concat(n)}},toUnit:d}),{formattedMaxMemory:O,formattedMaxVDSizes:Z,maxCPUCores:I,maxMemory:P,maxVirtualDiskSizes:D}},Jn=(0,o.useCallback)(Hn,[]),$n=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;$n({inputs:{memory:{displayMax:a,max:s,value:t}}})},Kn=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 Yn({cmValue:e,cmUnit:o})}),(function(){return Yn({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;U(o),P(s),A(u),k(c),T(d),L(i),V(l),K(p),Jn({allAnvils:o,storageGroupUUIDMapToData:d}),Q(n.osList.map((function(e){var n=oe(e.replace(/^key=([^\s]+),name=['"](.*)['"]$/,"$1,$2").split(","),2),t=n[0];return{label:n[1],key:t}}))),kn(!0)}))}),[Jn]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Z,{fullWidth:!0,maxWidth:"sm",open:n,PaperComponent:O.s_,PaperProps:{sx:{overflow:"visible"}},children:[(0,r.jsxs)(O.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,{})})]}),Mn?(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),$n({inputs:{serverName:{value:n}}})},value:ne},inputLabelProps:{isNotifyRequired:0===ne.length},messageBoxProps:Ue})}),(Rn="ps-cpu-cores",_n="CPU cores",Qn=Ie,qn={messageBoxProps:Ae,sliderProps:{onChange:function(e){var n=e;if(n!==Ie){Pe(n);var t=Hn({cpuCores:n}).maxCPUCores;$n({inputs:{cpuCores:{max:t,value:n}}})}},max:we,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:Fe,inputWithLabelProps:{inputProps:{endAdornment:xe("".concat(We," ").concat(He),{onButtonClick:function(){Qe(We),Yn({cmValue:ze})}}),onChange:function(e){var n=e.target.value;Kn({value:n})},type:"number",value:_e},inputLabelProps:{isNotifyRequired:ke===ce}},selectItems:pe,selectWithLabelProps:{selectProps:{onChange:function(e){var n=e.target.value;Kn({unit:n})},value:He}}}),Ye.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)(j.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")))}(Ye,n,Ke,Y,On,Hn,z,$n)})),(0,r.jsx)(j.Z,{disableItem:function(e){return e===sn},hideItem:function(e){return!Dn.includes(e)},id:"ps-install-image",inputLabelProps:{isNotifyRequired:0===en.length},label:"Install ISO",messageBoxProps:rn,selectItems:W,selectProps:{onChange:function(e){var n=e.target.value;Xn(n)},onClearIndicatorClick:function(){return Xn("")},value:en}}),(0,r.jsx)(j.Z,{disableItem:function(e){return e===en},hideItem:function(e){return!Dn.includes(e)},id:"ps-driver-image",label:"Driver ISO",messageBoxProps:un,selectItems:W,selectProps:{onChange:function(e){var n=e.target.value;et(n)},onClearIndicatorClick:function(){return et("")},value:sn}}),(0,r.jsx)(j.Z,{disableItem:function(e){return!jn.includes(e)},id:"ps-anvil",inputLabelProps:{isNotifyRequired:0===pn.length},label:"Anvil node pair",messageBoxProps:vn,selectItems:F,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."}),Nn?(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:!$n({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 pair"," ",(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:we})," 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(We," ").concat(He)})," ","available"]})})]}),Ye.stateIds.map((function(e,n){var t=Ye.inputMaxes[n],o=Ye.inputSizes[n],i=Ye.inputUnits[n],a=z[Ye.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:w[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:w[sn]?(0,r.jsx)(B.Q0,{text:w[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:ke.toString(),virtualDisks:Ye.stateIds.map((function(e,n){return{storageSize:Ye.sizes[n].toString(),storageGroupUUID:Ye.inputStorageGroupUUIDs[n]}})),installISOFileUUID:en,driverISOFileUUID:sn,anvilUUID:pn,optimizeForOS:null===gn||void 0===gn?void 0:gn.key};Fn(!0),d.Z.post("/server",e).then((function(){Fn(!1),Wn(En+1)})),zn(!1)},proceedButtonProps:{sx:me},titleText:"Provision ".concat(ne,"?")})]})}},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}},8336:function(e,n){n.Z=function(e,n){return fetch(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}},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"})}}}]);