"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[825],{4594:function(e,t,n){var r=n(5893),o=n(6514),i=n(5113),a=n(4656),s=n(482),l=n(2994),u=n(7357),c=n(9890),p=n(7169),d=n(1363),f=n(6284);function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var g=function(e){return(0,r.jsx)(o.Z,{in:!0,children:(0,r.jsx)(i.Z,m({},e))})};t.Z=function(e){var t=e.componentsProps,n=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}}},t),j=null!==h&&void 0!==h?h:function(e){var t=e.fullWidth,i=e.InputProps,a=e.InputLabelProps,s=e.inputProps,l={formControlProps:{fullWidth:t,ref:i.ref},inputLabelProps:a,inputProps:{className:i.className,endAdornment:i.endAdornment,inputProps:s,startAdornment:i.startAdornment},label:o};return null===n||void 0===n||n.call(null,l,e),(0,r.jsx)(f.Z,m({},l))},S=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:j,sx:S})),(0,r.jsx)(d.Z,m({},i))]})}},5521:function(e,t,n){n.d(t,{Z:function(){return E}});var r=n(5893),o=n(1113),i=n(1496),a=n(2293),s=n(7357),l=n(2992),u=n(4799),c=n(7294),p=n(7169),d=n(4433),f=n(9029),v=n(7533),m=n(8462),x=n(7212),g=n(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=n(4390),U=n(582),j=n(4690),S=n(1770),I=n(7750),P=n(1081);function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:"suiapi.";return n["".concat(t).concat(e)]}),[n]),i=(0,c.useCallback)((function(){return o("user")}),[o]);return(0,c.useEffect)((function(){if(e){var t=document.cookie.split(/\s*;\s*/);r(t.reduce((function(e,t){var n,r=w(t.split("=",2),2),o=r[0],i=r[1],a=decodeURIComponent(i);if(a.startsWith("j:"))try{n=JSON.parse(a.substring(2))}catch(s){n=i}else n=i;return e[o]=n,e}),{}))}}),[e]),{cookieJar:n,getCookie:o,getSessionUser:i}};function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function A(e){for(var t=1;t0)},ref:t})]})}},4968:function(e,t,n){n.d(t,{Z:function(){return Ue}});var r=n(5893),o=n(7294),a=n(7357),s=n(6886),l=n(8262),u=n(5537),c=n(5934),p=n(7169),d=n(4390),f=n(4594),v=n(157),m=n(4825),x=n(5737),g=n(1706),h=n(8187),b=n(6284),y=n(7120),U=n(4656),j=n(1363),S=n(7783);function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e){for(var t=1;t :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:t,label:n},i)),(0,r.jsx)(S.Z,P({formControlProps:{fullWidth:!1},id:"".concat(t,"-nested-select"),selectItems:u},d))]}),(0,r.jsx)(j.Z,P({},l))]})};w.defaultProps=D;var Z=w,O=n(3679),A=n(3640),M=n(6727),C=n(1184),k=n(9),G=n(192),B=n(7750);function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}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,t){if(!e)return;if("string"===typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,t)}(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 t=e.isFocused,n=e.label,o=p.s7,i="solid",s="0",l="0 .6em 0 .4em",u="1px 0 0 0",c="0.3";return t&&(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:n}),(0,r.jsx)(a.Z,{sx:{borderColor:o,borderStyle:i,borderWidth:u,content:'""',opacity:c}})]})},_=function(e,t){var n=Number.parseFloat(e);return Number.isNaN(n)?t:n},Q=function(e){return N(e,Array)?e.map((function(e){return String(e)})):[String(e)]},q=function(e){var t,n=e.messageBoxProps,i=void 0===n?W.messageBoxProps:n,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,S=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,t){return N(t,Array)?e.map((function(e,n){return _(e,t[n])})):_(e[0],t)}(w.range,P),null===y||void 0===y||y.call(null,P)};return(0,r.jsxs)(A.Z,{sx:{display:"flex",flexDirection:"column","&:hover":(t={},T(t,"& .".concat(V.root," div"),{opacity:1}),T(t,"& .".concat(U.Z.notchedOutline),{borderColor:p.s7}),t)},children:[(0,r.jsx)(G.Z,F({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)(C.ZP,{"aria-labelledby":d,max:h,min:b,onBlur:q,onChange:function(e,t){Z({range:Q(t)}),null===y||void 0===y||y.call(null,t)},onFocus:H,sx:F(T({color:p.s7,marginLeft:"1em",marginRight:"1em"},"& .".concat(C.TW.thumb),{borderRadius:p.n_,transform:"translate(-50%, -50%) rotate(45deg)"}),S),value:P,valueLabelDisplay:I}),w.range.map((function(e,t){return function(e){var t=e.key,n=e.isFocused,o=L(e,["key","isFocused"]);return(0,r.jsx)(k.Z,F({key:t,className:n?U.Z.focused:"",type:"number"},o))}({key:"slider-nested-text-input-".concat(t),inputProps:{max:h,min:b},isFocused:B,onBlur:q,onChange:function(){for(var e=arguments.length,n=new Array(e),r=0;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function oe(e,t){return $(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}}(e,t)||se(e,t)||te()}function ie(e){return $(e)||ee(e)||se(e,i)||te()}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,t){if(e){if("string"===typeof e)return K(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?K(e,t):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,t){var n=t.onButtonClick;return(0,r.jsx)(m.Z,{disabled:void 0===n,onClick:n,sx:{minWidth:"unset",whiteSpace:"nowrap"},children:"Max: ".concat(e)})},ge=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.endAdornment,n=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:[n&&(0,r.jsx)(B.Ac,{inverted:!0,text:n}),o&&(0,r.jsx)(B.Ac,{inverted:!0,text:o})]}),t]})},he=function(e,t,n,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,t,n){var r,i=null!==(r=o[n])&&void 0!==r?r:ce;return e.all+=i,""===t||(void 0===e[t]&&(e[t]=ce),e[t]+=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,j=ce;if(b.forEach((function(e){var t=e.storageGroupUUID,n=e.storageGroupFree;x(t)&&(y.push(t),j+=n,n>U&&(U=n))})),[function(){return b.length>0},function(){return n<=c},function(){return r<=p},function(){return i.every((function(e,n){var r,i=null!==(r=o[n])&&void 0!==r?r:ce,a=!0,s=i<=U;return""!==e&&(a=y.includes(e),s=i<=t[e].storageGroupFree),a&&s}))},function(){return Object.entries(h).every((function(e){var n=oe(e,2),r=n[0],o=n[1];return"all"===r?o<=j:o<=t[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 t=e.fileUUID;m(t)&&(g[t]=!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,n){""!==e&&(b.maxVirtualDiskSizes[n]=t[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,t){le="".concat(e," ").concat(t)}))),(0,x.Bh)(ve,ye((function(e,t){ue="".concat(e," ").concat(t)})));var Ue=function(e){var t=e.dialogProps.open,n=e.onClose,i=(0,o.useState)([]),y=i[0],U=i[1],j=(0,o.useState)({}),I=j[0],P=j[1],D=(0,o.useState)({}),w=D[0],A=D[1],M=(0,o.useState)({}),C=M[0],k=M[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)([]),K=q[0],$=q[1],ee=(0,o.useState)(""),te=ee[0],se=ee[1],ye=(0,o.useState)(),Ue=ye[0],je=ye[1],Se=(0,o.useState)(1),Ie=Se[0],Pe=Se[1],De=(0,o.useState)(0),we=De[0],Ze=De[1],Oe=(0,o.useState)(),Ae=Oe[0],Me=Oe[1],Ce=(0,o.useState)(ce),ke=Ce[0],Ge=Ce[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],Ye=(0,o.useState)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.existingVirtualDisks,n=void 0===t?{stateIds:[],inputMaxes:[],inputSizeMessages:[],inputSizes:[],inputStorageGroupUUIDMessages:[],inputStorageGroupUUIDs:[],inputUnits:[],maxes:[],sizes:[]}:t,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,j=void 0===U?ce:U,S=n.stateIds,I=n.inputMaxes,P=n.inputSizeMessages,D=n.inputSizes,w=n.inputStorageGroupUUIDMessages,Z=n.inputStorageGroupUUIDs,O=n.inputUnits,A=n.maxes,M=n.sizes;return S.push(o),I.push(a),P.push(p),D.push(l),w.push(m),Z.push(f),O.push(g),A.push(b),M.push(j),null===y||void 0===y||y.call(null,ne({},n)),n}()),Ke=Ye[0],$e=Ye[1],Xe=(0,o.useState)(""),et=Xe[0],tt=Xe[1],nt=(0,o.useState)(),rt=nt[0],ot=nt[1],it=(0,o.useState)(""),at=it[0],st=it[1],lt=(0,o.useState)()[0],ut=(0,o.useState)(""),ct=ut[0],pt=ut[1],dt=(0,o.useState)(),ft=dt[0],vt=dt[1],mt=(0,o.useState)(null),xt=mt[0],gt=mt[1],ht=(0,o.useState)(),bt=ht[0],yt=ht[1],Ut=(0,o.useState)([]),jt=Ut[0],St=Ut[1],It=(0,o.useState)([]),Pt=It[0],Dt=It[1],wt=(0,o.useState)([]),Zt=wt[0],Ot=wt[1],At=(0,o.useState)(!1),Mt=At[0],Ct=At[1],kt=(0,o.useState)(!1),Gt=kt[0],Bt=kt[1],zt=(0,o.useState)(!1),Tt=zt[0],Nt=zt[1],Ft=(0,o.useState)(0),Lt=Ft[0],Et=Ft[1],Wt={serverName:{defaults:{onSuccess:function(){je(void 0)},value:te},tests:[{onFailure:function(){je({text:"The server name length must be 1 to 16 characters.",type:"warning"})},test:function(e){var t=e.value.length;return t>=1&&t<=16}},{onFailure:function(){je({text:"The server name is expected to only contain alphanumeric, hyphen, or underscore characters.",type:"warning"})},test:function(e){var t=e.value;return/^[a-zA-Z0-9_-]+$/.test(t)}},{onFailure:function(){je({text:"This server name already exists, please choose another name.",type:"warning"})},test:function(e){var t=e.value;return void 0===C[t]}}]},cpuCores:{defaults:{max:we,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 t=e.displayMax,n=e.displayMin;Me({text:"The number of CPU cores is expected to be between ".concat(n," and ").concat(t,"."),type:"warning"})},test:Y.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:Y.X7},{onFailure:function(e){var t=e.displayMax,n=e.displayMin;Le({text:"Memory is expected to be between ".concat(n," and ").concat(t,"."),type:"warning"})},test:Y.SQ}]},installISO:{defaults:{onSuccess:function(){ot(void 0)},value:et},tests:[{test:Y.HJ}]},anvil:{defaults:{onSuccess:function(){vt(void 0)},value:ct},tests:[{test:Y.HJ}]},optimizeForOS:{defaults:{onSuccess:function(){yt(void 0)},value:null===xt||void 0===xt?void 0:xt.key},tests:[{test:Y.HJ}]}};Ke.inputSizeMessages.forEach((function(e,t){Wt["vd".concat(t,"Size")]={defaults:{displayMax:"".concat(Ke.inputMaxes[t]," ").concat(Ke.inputUnits[t]),displayMin:ue,max:Ke.maxes[t],min:ve,onSuccess:function(){Ke.inputSizeMessages[t]=void 0},value:Ke.sizes[t]},onFinishBatch:function(){$e(ne({},Ke))},tests:[{onFailure:function(){Ke.inputSizeMessages[t]={text:"Non available.",type:"warning"}},test:Y.X7},{onFailure:function(e){var n=e.displayMax,r=e.displayMin;Ke.inputSizeMessages[t]={text:"Virtual disk ".concat(t," size is expected to be between ").concat(r," and ").concat(n,"."),type:"warning"}},test:Y.SQ}]},Wt["vd".concat(t,"StorageGroup")]={defaults:{onSuccess:function(){Ke.inputStorageGroupUUIDMessages[t]=void 0},value:Ke.inputStorageGroupUUIDs[t]},onFinishBatch:function(){$e(ne({},Ke))},tests:[{test:Y.HJ}]}}));var Vt,Rt,_t,Qt,qt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.allAnvils,n=void 0===t?y:t,r=e.cpuCores,o=void 0===r?Ie:r,i=e.fileUUIDs,a=void 0===i?[et,at]:i,s=e.includeAnvilUUIDs,l=void 0===s?be([ct]):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?Ke:h,U=he(n,g,o,v,b.sizes,b.inputStorageGroupUUIDs,a,{includeAnvilUUIDs:l,includeFileUUIDs:u,includeStorageGroupUUIDs:c}),j=U.anvilUUIDs,S=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,t){(0,x.Bh)(e,{fromUnit:"B",onSuccess:{string:function(e,n){b.inputMaxes[t]=e,Z[t]="".concat(e," ").concat(n)}},toUnit:b.inputUnits[t]})})),$e(ne({},b)),St(j),Dt(S),Ot(w);var O="";return(0,x.Bh)(P,{fromUnit:"B",onSuccess:{string:function(e,t){Ve(e),O="".concat(e," ").concat(t)}},toUnit:d}),{formattedMaxMemory:O,formattedMaxVDSizes:Z,maxCPUCores:I,maxMemory:P,maxVirtualDiskSizes:D}},Ht=(0,o.useCallback)(qt,[]),Jt=function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.cmValue,n=void 0===t?ce:t,r=e.cmUnit,o=void 0===r?He:r;Ge(n);var i=qt({inputMemoryUnit:o,memory:n}),a=i.formattedMaxMemory,s=i.maxMemory;Jt({inputs:{memory:{displayMax:a,max:s,value:n}}})},Kt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.value,n=void 0===t?_e:t,r=e.unit,o=void 0===r?He:r;n!==_e&&Qe(n),o!==He&&Je(o),(0,x.KY)(n,o,(function(e){return Yt({cmValue:e,cmUnit:o})}),(function(){return Yt({cmUnit:o})}))},$t=function(e){tt(e),qt({fileUUIDs:[e,at]})},Xt=function(e){st(e),qt({fileUUIDs:[et,e]})},en=function(e){var t=be([e]);pt(e),qt({includeAnvilUUIDs:t})};return(0,o.useEffect)((function(){d.Z.get("/anvil",{params:{anvilUUIDs:"all",isForProvisionServer:!0}}).then((function(e){var t=e.data,n=function(e){var t={},n=e.reduce((function(e,n){var o=n.anvilUUID,i=n.anvilName,s=n.anvilTotalMemory,l=n.anvilTotalAllocatedMemory,u=n.anvilTotalAvailableMemory,c=n.hosts,p=n.servers,d=n.storageGroups,f=n.files,v=d.reduce((function(t,n){var a=ne({},n,{anvilUUID:o,anvilName:i,storageGroupSize:BigInt(n.storageGroupSize),storageGroupFree:BigInt(n.storageGroupFree),humanizedStorageGroupFree:""});return(0,x.Bh)(n.storageGroupFree,{fromUnit:"B",onSuccess:{string:function(e,t){a.humanizedStorageGroupFree="".concat(e," ").concat(t)}},precision:0,toUnit:"ibyte"}),t.anvilStorageGroupUUIDs.push(n.storageGroupUUID),t.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:n.storageGroupName,subLabel:i}),value:n.storageGroupUUID}),e.storageGroupUUIDMapToData[n.storageGroupUUID]=a,t}),{anvilStorageGroups:[],anvilStorageGroupUUIDs:[]}),m=v.anvilStorageGroups,g=v.anvilStorageGroupUUIDs,h=[];f.forEach((function(e){var n=e.fileUUID;h.push(n),t[n]=e}));var b=ne({},n,{anvilTotalMemory:BigInt(s),anvilTotalAllocatedMemory:BigInt(l),anvilTotalAvailableMemory:BigInt(u),humanizedAnvilTotalAvailableMemory:"",hosts:c.map((function(e){return ne({},e,{hostMemory:BigInt(e.hostMemory)})})),servers:p.map((function(t){var n=t.serverMemory,r=t.serverName,o=ne({},re(t,["serverMemory","serverName"]),{serverMemory:BigInt(n),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,t){b.humanizedAnvilTotalAvailableMemory="".concat(e," ").concat(t)}},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(t).forEach((function(e){n.files.push(e),n.fileSelectItems.push({displayValue:e.fileName,value:e.fileUUID}),n.fileUUIDMapToData[e.fileUUID]=e})),n}(t.anvils),o=n.anvils,i=n.anvilSelectItems,s=n.anvilUUIDMapToData,l=n.fileSelectItems,u=n.fileUUIDMapToData,c=n.serverNameMapToData,p=n.storageGroupSelectItems,d=n.storageGroupUUIDMapToData;U(o),P(s),A(u),k(c),T(d),L(i),V(l),$(p),Ht({allAnvils:o,storageGroupUUIDMapToData:d}),Q(Object.entries(t.oses).map((function(e){var t=oe(e,2);return{key:t[0],label:t[1]}}))),Ct(!0)}))}),[Ht]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Z,{fullWidth:!0,maxWidth:"sm",open:t,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:n,sx:{backgroundColor:p.hM,color:p.lD,"&:hover":{backgroundColor:p.hM}},children:(0,r.jsx)(u.Z,{})})]}),Mt?(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 t=e.target.value;se(t),Jt({inputs:{serverName:{value:t}}})},value:te},inputLabelProps:{isNotifyRequired:0===te.length},messageBoxProps:Ue})}),(Vt="ps-cpu-cores",Rt="CPU cores",_t=Ie,Qt={messageBoxProps:Ae,sliderProps:{onChange:function(e){var t=e;if(t!==Ie){Pe(t);var n=qt({cpuCores:t}).maxCPUCores;Jt({inputs:{cpuCores:{max:n,value:t}}})}},max:we,min:1}},(0,r.jsx)(H,ne({isAllowTextInput:!0,label:Rt,labelId:"".concat(Vt,"-label"),value:_t},Qt))),(0,r.jsx)(Z,{id:"ps-memory",label:"Memory",messageBoxProps:Fe,inputWithLabelProps:{inputProps:{endAdornment:xe("".concat(We," ").concat(He),{onButtonClick:function(){Qe(We),Yt({cmValue:ze})}}),onChange:function(e){var t=e.target.value;Kt({value:t})},type:"number",value:_e},inputLabelProps:{isNotifyRequired:ke===ce}},selectItems:pe,selectWithLabelProps:{selectProps:{onChange:function(e){var t=e.target.value;Kt({unit:t})},value:He}}}),Ke.stateIds.map((function(e,t){return function(e,t,n,o,i,s,l,u){var c=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return e[n][r]},p=function(r,o){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;e[r][i]=o,n(ne({},e))},d=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ce;p("sizes",n);var r=s({virtualDisks:e}),o=r.formattedMaxVDSizes,i=r.maxVirtualDiskSizes;u({inputs:X({},"vd".concat(t,"Size"),{displayMax:"".concat(o[t]),max:i[t],value:n})})},f=function(e){var t=e.value,n=void 0===t?c("inputSizes"):t,r=e.unit,o=void 0===r?c("inputUnits"):r;n!==c("inputSizes")&&p("inputSizes",n),o!==c("inputUnits")&&p("inputUnits",o),(0,x.KY)(n,o,(function(e){return d(e)}),(function(){return d()}))},v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c("inputStorageGroupUUIDs");t!==c("inputStorageGroupUUIDs")&&p("inputStorageGroupUUIDs",t),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(t),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 t=e.target.value;f({value:t})},type:"number",value:c("inputSizes")},inputLabelProps:{isNotifyRequired:c("sizes")===ce}},selectItems:pe,selectWithLabelProps:{selectProps:{onChange:function(e){var t=e.target.value;f({unit:t})},value:c("inputUnits")}}})}),(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(S.Z,{id:"ps-storage-group-".concat(t),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 t=e.target.value;v(t)},onClearIndicatorClick:function(){return v("")},renderValue:function(e){var t,n=null!==(t=l[e])&&void 0!==t?t:{},r=n.anvilName,o=void 0===r?"?":r,i=n.storageGroupName,a=void 0===i?"Unknown (".concat(e,")"):i;return"".concat(a," (").concat(o,")")},value:c("inputStorageGroupUUIDs")}})})]},"ps-virtual-disk-".concat(c("stateIds")))}(Ke,t,$e,K,Zt,qt,z,Jt)})),(0,r.jsx)(S.Z,{disableItem:function(e){return e===at},hideItem:function(e){return!Pt.includes(e)},id:"ps-install-image",inputLabelProps:{isNotifyRequired:0===et.length},label:"Install ISO",messageBoxProps:rt,selectItems:W,selectProps:{onChange:function(e){var t=e.target.value;$t(t)},onClearIndicatorClick:function(){return $t("")},value:et}}),(0,r.jsx)(S.Z,{disableItem:function(e){return e===et},hideItem:function(e){return!Pt.includes(e)},id:"ps-driver-image",label:"Driver ISO",messageBoxProps:lt,selectItems:W,selectProps:{onChange:function(e){var t=e.target.value;Xt(t)},onClearIndicatorClick:function(){return Xt("")},value:at}}),(0,r.jsx)(S.Z,{disableItem:function(e){return!jt.includes(e)},id:"ps-anvil",inputLabelProps:{isNotifyRequired:0===ct.length},label:"Anvil node",messageBoxProps:ft,selectItems:F,selectProps:{onChange:function(e){var t=e.target.value;en(t)},onClearIndicatorClick:function(){return en("")},renderValue:function(e){var t,n=(null!==(t=I[e])&&void 0!==t?t:{}).anvilName;return void 0===n?"Unknown ".concat(e):n},value:ct}}),(0,r.jsx)(f.Z,{id:"ps-optimize-for-os",extendRenderInput:function(e){var t=e.inputLabelProps;(void 0===t?{}:t).isNotifyRequired=null===xt},isOptionEqualToValue:function(e,t){return e.key===t.key},label:"Optimize for OS",messageBoxProps:bt,noOptionsText:"No matching OS",onChange:function(e,t){gt(t)},openOnFocus:!0,options:_,renderOption:function(e,t){return(0,o.createElement)("li",ne({},e,{key:"ps-optimize-for-os-".concat(t.key),children:[t.label," (",t.key,")"]}))},value:xt})]}):(0,r.jsx)(J.Z,{}),(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",marginTop:"1em","& > :not(:first-child)":{marginTop:"1em"}},children:[Lt>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."}),Tt?(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:!Jt({isIgnoreOnCallbacks:!0}),onClick:function(){Bt(!0)},sx:me,children:"Provision"})})]})]}),Gt&&(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:te})," will be created on anvil node"," ",(0,r.jsx)(B.Q0,{text:I[ct].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"]})})]}),Ke.stateIds.map((function(e,t){var n=Ke.inputMaxes[t],o=Ke.inputSizes[t],i=Ke.inputUnits[t],a=z[Ke.inputStorageGroupUUIDs[t]].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:t})]})}),(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(n," ").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[et].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[at]?(0,r.jsx)(B.Q0,{text:w[at].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===xt||void 0===xt?void 0:xt.label)})})]})]}),dialogProps:{open:Gt},onCancelAppend:function(){Bt(!1)},onProceedAppend:function(){var e={serverName:te,cpuCores:Ie,memory:ke.toString(),virtualDisks:Ke.stateIds.map((function(e,t){return{storageSize:Ke.sizes[t].toString(),storageGroupUUID:Ke.inputStorageGroupUUIDs[t]}})),installISOFileUUID:et,driverISOFileUUID:at,anvilUUID:ct,optimizeForOS:null===xt||void 0===xt?void 0:xt.key};Nt(!0),d.Z.post("/server",e).then((function(){Nt(!1),Et(Lt+1)})),Bt(!1)},proceedButtonProps:{sx:me},titleText:"Provision ".concat(te,"?")})]})}},1081:function(e,t,n){var r=n(7294);t.Z=function(){var e=(0,r.useRef)(!0);return e.current?(e.current=!1,!0):e.current}},5737:function(e,t,n){n.d(t,{Bh:function(){return o},KY:function(){return i},MU:function(){return a}});var r=n(4490),o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.fromUnit,o=t.onFailure,i=t.onSuccess,a=t.precision,s=t.toUnit,l=(0,r.gO)(e,{fromUnit:n,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,t,n,r){o(e,{fromUnit:t,onFailure:r,onSuccess:{bigint:n},precision:0,toUnit:"B"})},a=function(e){return(0,r._d)(e,{toUnit:"ibyte"})}}}]);