GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 143.110.188.43  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.57 (Ubuntu)
System : Linux Client-Droplet 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.10-2ubuntu2.2
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /snap/lxd/41172/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/41172/share/lxd-ui/assets/NetworkDevicePanel-DOIT31lz.js
import{j as e,d as s,L as pt,R as Ne,B as Mt,V as Ge,aq as Ut,Q as Te,r as V,H as mt,q as E,bn as kt,w as Kt,S as qt,bo as vt,bp as Gt,bq as Ht,ao as zt,o as bt,s as Yt,J as Xt,b as Qt,e as Ae,f as le,h as gt,t as Be,a1 as Wt,br as Jt,bs as Oe,b6 as Le,bt as Qe,v as Zt,M as es,O as ts,G as We,bu as ss,bv as as,bw as Je,a5 as ns,bd as is}from"./index-H4PaR1Ay.js";import{u as os,P as ls}from"./PlacementGroupExplanationTooltip-DitUqaPL.js";import{u as G,w as cs,x as se,q as be,y as ge,s as rs,t as Me,z as fe,I as ds,A as us,e as hs,j as xe,B as xt,C as yt,v as Ue,D as ce,o as Ze,E as ps,F as ms,G as vs}from"./devices-BmVPmxwo.js";import{e as w}from"./FormMenuItem-wWC_cxfa.js";import{n as bs,o as gs,q as xs,t as ye,v as K,w as Ce,x as de,r as ys,y as et,z as ue,A as je,B as tt}from"./instanceAndProfilePayloads-DnzPlN57.js";import{A as js}from"./AutoExpandingTextArea-BxIWUale.js";import{E as Ns}from"./ExplanationTooltip-BtzkKEJm.js";import{a as fs}from"./scroll-BSkJfxH1.js";import{P as he}from"./ProfileRichChip-BLxwj1Me.js";import{f as Y,o as O}from"./FormFooterLayout-BAdc854l.js";import{a as Cs,b as Is,c as ws,h as st,d as at}from"./userKeys--m55T-U-.js";import{a as A,b as z,c as Ss}from"./options-DGWNjuoa.js";import{g as F,a as _,b as Rs,c as jt,C as U,d as _s,e as Nt,f as Ds,h as Ps,i as Fs,j as nt}from"./ConfigurationTable-DEm36PYo.js";import{S as ae}from"./ScrollableConfigurationTable-gvGDy_Ul.js";import{B as Vs,c as ft}from"./YamlSwitch-B3aH5O73.js";import{S as Es,a as $s,g as Ts,R as Ct,D as As,b as Bs,v as Os,h as it,c as Ls}from"./StorageVolumeForm-D9fkrXvn.js";import{i as Ms}from"./snapshots-oc8RhmUf.js";import{R as It}from"./ResourceLink-uXW9L0Ar.js";import{R as Us}from"./ResourceLabel-BMIFVwPY.js";import{l as ks,M as Q,B as ke,C as W,D as Ks}from"./DiskSizeSelector-97sBb-TL.js";import{u as qs}from"./useResources-CPhpL_ul.js";import{S as Gs}from"./StoragePoolSelector-CJRwrd1Y.js";import{i as X}from"./formChangeCount-obF4N3HN.js";import{u as He}from"./useConfigOptions-qesCQJVe.js";import{t as ze,g as te,C as Ie,a as wt}from"./ConfigFieldDescription-BuOtqnNZ.js";import{S as St}from"./StoragePoolRichChip-B2CCdBci.js";import{r as Hs,t as zs}from"./storageVolume-B1nkHAqF.js";import{u as Ys}from"./projects-CsVQvwvI.js";import{u as Xs,a as Qs}from"./useVolumes-Xg79hRkT.js";import{u as Rt}from"./useStoragePools-R3ZOO4pU.js";import{c as Ws}from"./storage-volumes-fC4CfBPB.js";import{B as re,F as Fe}from"./BackLink-Cuy7YFjT.js";import{U as Js,C as Zs}from"./CustomIsoExplanationTooltip-vPTmYoBF.js";import{S as pe}from"./ScrollableForm-BtdYbmZT.js";import{h as _t}from"./useNetworks-CX5r56DC.js";import{u as Ye,a as ea,p as ot}from"./useEscCallback-zQN3vs8-.js";import{E as ta}from"./ExpandableList-CQ-CShP2.js";import{N as sa}from"./NetworkRichChip-_Wd7Km7z.js";import{a as aa,N as na,b as ia}from"./NetworkDefaultACLSelector-B5SPtM37.js";import{N as oa}from"./NetworkSelector-Di2e2NuZ.js";import{a as la}from"./useNetworkAcls-XKZxGxZP.js";const Dn=({value:t,setValue:a,project:n,ref:i,hasNoneOption:o=!1,isCreateInstance:c=!1,disabled:r=!1,profileNames:m=[]})=>{const{data:u=[]}=G(n),{data:l=[]}=os(n),y=l.map(p=>({label:e.jsxs("div",{className:"label",children:[e.jsx("span",{className:"name u-truncate",title:p.name,children:p.name}),e.jsx("span",{className:"policy",children:p.config.policy}),e.jsx("span",{className:"rigor",children:p.config.rigor}),e.jsx("span",{className:"used_by",children:p.used_by.length})]}),text:p.name,selectedLabel:e.jsxs(e.Fragment,{children:[p.name," ",e.jsxs("span",{className:"u-text--muted",children:["(",p.config.policy,", ",p.config.rigor,")"]})]}),value:p.name})),b=()=>{let p=null;for(const x of m){const f=u.find(h=>h.name===x);f?.config["placement.group"]&&(p=e.jsxs(e.Fragment,{children:[f.config["placement.group"]," ",e.jsxs("span",{className:"u-text--muted",children:["(from profile ",e.jsx("code",{children:f.name}),")"]})]}))}return p};if(o){const p=b();y.push({label:e.jsx("div",{className:"label",children:e.jsx("span",{className:"name",children:p??"None"})}),selectedLabel:p??void 0,text:"None",value:""})}const N=p=>e.jsx(pt,{to:`${Ne}/ui/project/${n}/placement-groups`,target:"_blank",children:Mt("placement group",p)}),v=()=>l.length===0?e.jsxs(e.Fragment,{children:[!c&&"No placement groups found for this project. ",e.jsxs(e.Fragment,{children:["Create your first ",N(1),"."]})]}):e.jsxs(e.Fragment,{children:[!c&&"Update does not move the instance. Changed placement policy applies only to future LXD scheduling events such as evacuation. ",e.jsxs(e.Fragment,{children:["Manage ",N(2)," for this project."]})]});return e.jsx(s.CustomSelect,{id:"placementGroup",label:e.jsx(ls,{children:"Placement group"}),wrapperClassName:"select-input",dropdownClassName:"placement-group-dropdown",selectRef:i,onChange:a,value:t??"",header:e.jsxs("div",{className:"header",children:[e.jsx("span",{className:"name",children:"Name"}),e.jsx("span",{className:"policy",children:"Policy"}),e.jsx("span",{className:"rigor",children:"Rigor"}),e.jsx("span",{className:"used_by",children:"Used by"})]}),help:v(),options:y,disabled:r||l.length===0})},ca=({primaryImage:t,onSelect:a,onUpload:n,onCancel:i,cancelButtonText:o="Cancel"})=>{const{project:c}=Ge(),r=c?.name??"",{data:m=[],isLoading:u}=Xs(r),l=[{content:"Name",sortKey:"name"},{content:"Storage pool",sortKey:"storagePool"},{content:"Upload date",sortKey:"uploadedAt"},{content:"Size",sortKey:"size"},{"aria-label":"Actions",className:"actions"}],y=m.map(b=>{const N=()=>{a(b,"virtual-machine")};return{key:b.fingerprint,className:"u-row",columns:[{content:e.jsx("div",{className:"u-truncate iso-name",title:b.aliases,children:b.aliases}),role:"rowheader","aria-label":"Name",onClick:N},{content:b.pool,role:"cell","aria-label":"Storage pool",onClick:N},{content:Ut(new Date(b.created_at).toISOString()),role:"cell","aria-label":"Uploaded at",onClick:N},{content:b.volume?.config.size&&Te(+b.volume.config.size),role:"cell","aria-label":"Size",onClick:N},{content:e.jsx(s.Button,{appearance:t?.name===b.aliases&&t?.pool===b.pool?"positive":"",onClick:v=>{v.stopPropagation(),N()},dense:!0,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:N}],sortData:{name:b.aliases.toLowerCase(),storagePool:b.pool?.toLowerCase(),size:+(b.volume?.config.size??0),uploadedAt:b.created_at}}});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iso-table",children:e.jsx(s.MainTable,{headers:l,rows:y,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:u?e.jsx(s.Spinner,{className:"u-loader",text:"Loading images..."}):"No custom ISOs found"})}),e.jsxs("footer",{className:"p-modal__footer",children:[e.jsx(s.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:i,children:o}),e.jsx(s.Button,{appearance:y.length===0?"positive":"",onClick:n,type:"button",className:"iso-btn u-no-margin--bottom",children:e.jsx("span",{children:"Upload custom ISO"})})]})]})},ee="selectIso",Ve="uploadIso",ra=({onClose:t,onSelect:a,onCancel:n,cancelButtonText:i,backLinkText:o})=>{const[c,r]=V.useState(ee),[m,u]=V.useState(null),l="Select custom ISO",y=()=>{switch(c){case ee:return o?e.jsx(re,{title:l,onClick:n??t,linkText:o}):e.jsx(Zs,{children:l});case Ve:return e.jsx(re,{title:"Upload custom ISO",onClick:()=>{r(ee)},linkText:l});default:return""}};return e.jsxs(s.Modal,{close:t,title:y(),className:"custom-iso-modal",children:[c===ee&&e.jsx(ca,{primaryImage:m,onSelect:a,onUpload:()=>{r(Ve)},onCancel:n??t,cancelButtonText:i}),c===Ve&&e.jsx(Js,{onCancel:()=>{r(ee)},onFinish:(b,N)=>{r(ee),u({name:b,pool:N})}})]})},da=({keyName:t,setSSHPublicKey:a})=>{const[n,i]=V.useState(),[o,c]=V.useState(),[r,m]=V.useState(!1),u=async()=>{a("");const v=await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-384"},!0,["sign","verify"]);i(v.privateKey),c(v.publicKey)};V.useEffect(()=>{u()},[]);const l=v=>{const p=new Uint8Array(v),x="nistp384",f="ecdsa-sha2-nistp384",h=g=>{const C=typeof g=="string"?new TextEncoder().encode(g):g,I=new Uint8Array(4);return new DataView(I.buffer).setUint32(0,C.length,!1),new Uint8Array([...I,...C])},d=new Uint8Array([...h(f),...h(x),...h(p)]),j=btoa(String.fromCharCode(...d));return`${f} ${j}`},y=(v,p)=>{const x=window.btoa(String.fromCharCode(...new Uint8Array(v))),f=x.match(/.{1,64}/g)?.join(`
`)??x;return`-----BEGIN ${p}-----
${f}
-----END ${p}-----`},b=(v,p)=>{const x=new Blob([v],{type:"application/x-pem-file"}),f=URL.createObjectURL(x),h=document.createElement("a");h.href=f,h.download=p,h.click(),URL.revokeObjectURL(f),m(!0)},N=async()=>{if(!n||!o)return;const v=await window.crypto.subtle.exportKey("pkcs8",n),p=y(v,"EC PRIVATE KEY");b(p,`lxd-${location.hostname}-${t}`);const x=await window.crypto.subtle.exportKey("raw",o),f=l(x);a(f)};return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"u-text--muted",children:r?"Your private key was downloaded successfully.":"Your key pair was generated successfully."}),e.jsx(s.Button,{disabled:!n,type:"button",onClick:N,children:"Download private key"})]})},ua=({initialName:t,onSelect:a,onClose:n})=>{const[i,o]=V.useState(t),[c,r]=V.useState("root"),[m,u]=V.useState("clipboard"),[l,y]=V.useState({github:"",launchpad:"",fileUpload:"",clipboard:"",generate:""}),b=()=>{switch(m){case"github":return`gh:${l.github}`;case"launchpad":return`lp:${l.launchpad}`;case"fileUpload":return l.fileUpload;case"clipboard":return l.clipboard;case"generate":return l.generate}},N=h=>{h.preventDefault(),h.stopPropagation();const d=b();a(i,c,d)},v=(h,d)=>e.jsx("button",{className:"p-segmented-control__button",role:"tab",type:"button","aria-selected":m===h?"true":"false","aria-controls":`${h}-tab`,id:h,onClick:()=>{u(h),h==="fileUpload"&&setTimeout(x,0)},children:d}),p=(h,d)=>h!==m?null:e.jsx("div",{role:"tabpanel",id:`${h}-tab`,"aria-labelledby":h,children:d}),x=()=>{document.getElementById("ssh-file-upload")?.click()},f=h=>{y({...l,generate:h})};return e.jsxs(s.Modal,{close:n,title:"Add SSH key",className:"ssh-key-add-modal",children:[e.jsxs(s.Form,{onSubmit:N,children:[e.jsx(s.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(s.Input,{label:"Name",type:"text",placeholder:"Enter name",value:i,onChange:h=>{o(h.target.value)}}),e.jsx(s.Input,{label:"Linux User",type:"text",placeholder:"ubuntu",value:c,onChange:h=>{r(h.target.value)}}),e.jsx(s.Label,{forId:"source",children:"Source"}),e.jsx("div",{className:"p-segmented-control",children:e.jsxs("div",{className:"p-segmented-control__list",id:"source",role:"tablist","aria-label":"Source",children:[v("clipboard","Clipboard"),v("generate","Generate key"),v("fileUpload","File upload"),v("github","Github"),v("launchpad","Launchpad")]})}),e.jsxs("div",{className:"source-input",children:[p("clipboard",e.jsx(js,{placeholder:"ecdsa-sha2-nistp384 ...",help:"Paste the contents of the public key file (.pub)",className:"u-break-all",autoFocus:!0,cols:50,value:l.clipboard,onChange:h=>{y({...l,clipboard:h.target.value})}})),p("generate",e.jsx(da,{keyName:i,setSSHPublicKey:f})),p("fileUpload",e.jsxs("div",{className:"u-flex",children:[e.jsx(s.Button,{type:"button",onClick:x,children:"Choose file"}),e.jsx(s.Input,{id:"ssh-file-upload",className:"ssh-file-upload",type:"file",accept:".pub",autoFocus:!0,onChange:h=>{if(!h.target.files){y({...l,fileUpload:""});return}const d=h.target.files[0];if(!d){y({...l,fileUpload:""});return}const j=new FileReader;j.onload=g=>{const C=g.target?.result;C&&y({...l,fileUpload:C})},j.readAsText(d)}})]})),p("github",e.jsx(s.Input,{type:"text",placeholder:"Enter GitHub username",help:"Instance must have internet access to import SSH keys from GitHub.",autoFocus:!0,value:l.github,onChange:h=>{y({...l,github:h.target.value})}})),p("launchpad",e.jsx(s.Input,{type:"text",placeholder:"Enter launchpad username",help:"Instance must have internet access to import SSH keys from Launchpad.",autoFocus:!0,value:l.launchpad,onChange:h=>{y({...l,launchpad:h.target.value})}}))]})]}),e.jsxs("footer",{className:"p-modal__footer",id:"modal-footer",children:[e.jsx(s.Button,{appearance:"",className:"u-no-margin--bottom",onClick:n,children:"Cancel"}),e.jsx(s.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:N,disabled:i.length===0||c.length===0||l[m].length===0,children:"Add key"})]})]})},ha=({children:t})=>e.jsx(Ns,{className:"explanation-tooltip-wrapper--inline",explanation:"Cloud init must be enabled on the instance to apply the keys. Additional keys get applied on instance creation or restart. SSH keys are not removed automatically.",docPath:"/reference/instance_options/#instance-cloud-init:cloud-init.ssh-keys.KEYNAME",docLabel:"Learn more about SSH keys",children:t}),pa=(t,a)=>{const n=[];if(t.entityType==="instance"){const i=cs(t,a);for(const o of i)bs(o).forEach(r=>n.push({sshKey:r,source:o.name}))}return n},Pn=({formik:t,disabledReason:a})=>{const{project:n}=mt(),{data:i=[]}=G(n??""),{openPortal:o,closePortal:c,isOpen:r,Portal:m}=s.usePortal(),u=t.values.cloud_init_ssh_keys??[],l=pa(t.values,i),y=()=>{const f=u.map(g=>g.id),h=l.map(g=>g.sshKey.id),d=new Set(f.concat(h)),j=t.values.entityType==="profile"?"profile":"ssh";for(let g=1;g<1e3;g++){const C=`${j}-key-${g}`;if(!d.has(C))return C}return`${j}-key-1`},b=(f,h,d)=>{t.setFieldValue("cloud_init_ssh_keys",[...u,{id:y(),name:f,user:h,fingerprint:d}]),c(),setTimeout(()=>{fs("add-ssh-key-btn")},100)},N=[{content:"Name",className:"name"},{content:"User",className:"user"},{content:"Key",className:"key"},...l.length>0?[{content:"Profile",className:"profile"}]:[],{"aria-label":"Actions",className:"actions"}],v=l.map(f=>{const h=u.some(g=>g.id===f.sshKey.id),d=()=>{w(t),t.setFieldValue("cloud_init_ssh_keys",[...u,{id:f.sshKey.id,name:f.sshKey.id,user:"nouser",fingerprint:"nokey"}])},j=()=>{w(t),t.setFieldValue("cloud_init_ssh_keys",u.filter(g=>g.id!==f.sshKey.id))};return{key:`inherited-${f.sshKey.id}`,className:h?"u-text--muted u-text--line-through":"",columns:[{content:f.sshKey.name,role:"rowheader","aria-label":"Name",className:"name"},{content:f.sshKey.user,role:"cell","aria-label":"User",className:"user"},{content:f.sshKey.fingerprint,title:f.sshKey.fingerprint,role:"cell","aria-label":"Key",className:"key u-truncate"},...l.length>0?[{content:e.jsx(he,{profileName:f.source,projectName:n??"",className:"force-truncate",disabled:h}),role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:h?e.jsxs(s.Button,{onClick:j,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(s.Button,{onClick:d,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]}),role:"cell","aria-label":"Actions",className:"actions u-align--right"}]}}),p=u?.filter(f=>!l.some(h=>h.sshKey.id===f.id)).map(f=>{const h=()=>{w(t),t.setFieldValue("cloud_init_ssh_keys",u.filter(d=>d.id!==f.id))};return{key:`local-${f.id}`,columns:[{content:f.name,role:"cell","aria-label":"Name",className:"name"},{content:f.user,role:"cell","aria-label":"User",className:"user"},{content:f.fingerprint,title:f.fingerprint,role:"cell","aria-label":"Key",className:"key u-truncate"},...l.length>0?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:e.jsxs(s.Button,{onClick:h,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"delete"}),e.jsx("span",{children:"Delete"})]}),role:"cell","aria-label":"Actions",className:"actions u-align--right"}]}}),x=v.concat(p);return e.jsxs("div",{className:"ssh-key-form",children:[e.jsx("p",{className:"p-form__label u-sv-1",children:e.jsx(ha,{children:"SSH keys"})}),x.length>0&&e.jsx(s.MainTable,{id:"ssh-keys-table",headers:N,rows:x,sortable:!0,className:"ssh-key-table"}),e.jsxs(s.Button,{id:"add-ssh-key-btn",type:"button",onClick:f=>{w(t),o(f)},hasIcon:!0,disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"New SSH key"})]}),r&&e.jsx(m,{children:e.jsx(ua,{initialName:y(),onClose:c,onSelect:b})})]})},Fn=({formik:t,disabledReason:a})=>{const{project:n}=mt(),{data:i=[]}=G(n??""),o=t.values.user_keys??[],c=Cs(o),r=Is(t.values,i),m=r.length>0,u=t.values.readOnly,l=g=>{w(t),t.setFieldValue("user_keys",g)},y=(g,C)=>{l(o.map((I,P)=>P===g?{...I,...C}:I))},b=g=>{l(o.filter((C,I)=>I!==g))},N=(g,C)=>{const I=o.findIndex(R=>R.sortKey===void 0||R.sortKey>=g),P=I<0?o.length:I;l(o.slice(0,P).concat({key:g,value:C,sortKey:g}).concat(o.slice(P))),Y(`user-key-value-${P}`)},v=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"u-hide--large",children:"Profile"}),e.jsx("span",{className:"u-hide--small u-hide--medium",children:"Inherited from profile"})]}),p=[{content:"Key",className:"key"},{content:"Value",className:"value"},...m?[{content:v,className:"profile"}]:[],{"aria-label":"Actions",className:"actions"}],x=(g,C,I,P)=>e.jsxs(s.Button,{onClick:I,type:"button",hasIcon:!0,appearance:"base",disabled:!!a,title:a??g,"aria-label":`${g} ${P}`,className:"u-no-margin--bottom",children:[e.jsx(s.Icon,{name:C}),e.jsx("span",{className:"u-hide--small u-hide--medium",children:g})]}),f=(g,C,I)=>{const P=o.findIndex($=>$.key===g),R=P>=0;return{key:`inherited-${g}`,className:R?"u-text--muted u-text--line-through":"",columns:[{content:g,role:"rowheader","aria-label":"Key",className:"key u-truncate",title:g},{content:C,title:C,role:"cell","aria-label":"Value",className:"value u-truncate"},{content:e.jsx(he,{profileName:I,projectName:n??"",className:"force-truncate",disabled:R}),role:"cell","aria-label":"Profile",className:"profile"},{content:R?x("Revert","restart",()=>{b(P)},g):x("Override","edit",()=>{N(g,C)},g),role:"cell","aria-label":"Actions",className:"actions"}]}},h=(g,C)=>({key:`local-${C}`,columns:[{content:g.key,role:"rowheader","aria-label":"Key",className:"key u-truncate",title:g.key},{content:g.value,title:g.value,role:"cell","aria-label":"Value",className:"value u-truncate"},...m?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:x("Edit","edit",()=>{w(t),Y(`user-key-value-${C}`)},g.key),role:"cell","aria-label":"Actions",className:"actions"}]}),d=(g,C)=>({key:`local-${C}`,columns:[{content:e.jsx(s.Input,{id:`user-key-name-${C}`,"aria-label":`User key ${C+1}`,placeholder:"Key",type:"text",value:g.key,error:c[C],caution:st(g)&&!at(g)?"Key is required, this entry will not be saved":void 0,disabled:!!a,title:a,onChange:I=>{y(C,{key:I.target.value})}}),role:"rowheader","aria-label":"Key",className:"key"},{content:e.jsx(s.Input,{id:`user-key-value-${C}`,"aria-label":`User key value ${C+1}`,placeholder:"Value",type:"text",value:g.value,caution:at(g)&&!st(g)?"Value is required, this entry will not be saved":void 0,disabled:!!a,title:a,onChange:I=>{y(C,{value:I.target.value})}}),role:"cell","aria-label":"Value",className:"value"},...m?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:x("Remove","delete",()=>{b(C)},`user key ${C+1}`),role:"cell","aria-label":"Actions",className:"actions"}]}),j=ws(o,r).map(g=>g.type==="inherited"?f(g.userKey.key,g.userKey.value,g.source):u?h(g.userKey,g.index):d(g.userKey,g.index));return e.jsxs("div",{className:"user-keys-form",children:[e.jsxs("p",{className:"p-form__label u-sv-1",children:["User keys"," ",e.jsx(s.Tooltip,{message:"Custom user.* configuration keys, used to tag an instance.",children:e.jsx(s.Icon,{name:"information"})})]}),j.length>0&&e.jsx(s.MainTable,{id:"user-keys-table",headers:p,rows:j,className:"user-keys-table"}),e.jsxs(s.Button,{id:"add-user-key-btn",type:"button",onClick:()=>{l(o.concat({key:"",value:""})),Y(`user-key-name-${o.length}`)},hasIcon:!0,disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Add user key"})]})]})},Vn=({formik:t,setSection:a})=>{const i=t.values.entityType==="instance"&&t.values.instanceType!=="container";return e.jsx(ae,{rows:[F({formik:t,label:"Protect deletion",name:"security_protection_delete",defaultValue:"",readOnlyRenderer:o=>O(o,A),children:e.jsx(s.Select,{options:A})}),F({formik:t,label:"Privileged (Containers only)",name:"security_privileged",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,z),children:e.jsx(s.Select,{options:z,disabled:i})}),F({formik:t,label:"Nesting (Containers only)",name:"security_nesting",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,z),children:e.jsx(s.Select,{options:z,disabled:i})}),F({formik:t,label:"Protect UID/GID shift (Containers only)",name:"security_protection_shift",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,A),children:e.jsx(s.Select,{options:A,disabled:i})}),F({formik:t,label:"Base host id (Containers only)",name:"security_idmap_base",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,children:e.jsx(s.Input,{placeholder:"Enter ID",type:"text",disabled:i,labelClassName:E({"is-disabled":i})})}),F({formik:t,label:"Idmap size (Containers only)",name:"security_idmap_size",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,children:e.jsx(s.Input,{placeholder:"Enter number",type:"number",min:0,disabled:i,labelClassName:E({"is-disabled":i})})}),F({formik:t,label:"Unique idmap (Containers only)",name:"security_idmap_isolated",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,A),children:e.jsx(s.Select,{options:A,disabled:i})}),F({formik:t,label:"Allow /dev/lxd in the instance (Containers only)",name:"security_devlxd",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,A),children:e.jsx(s.Select,{options:A,disabled:i})}),F({formik:t,label:"Make /1.0/images API available over /dev/lxd (Containers only)",name:"security_devlxd_images",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>O(o,A),children:e.jsx(s.Select,{options:A,disabled:i})}),_({className:"u-text--muted",configuration:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Enable secureboot (VMs only)"})," and"," ",e.jsx("b",{children:"Enable CSM (VMs only)"})]}),inherited:"",override:e.jsx(s.Button,{appearance:"link",type:"button",onClick:()=>{a(Vs)},children:"See boot mode"})})]})},En=({formik:t})=>{const{project:a}=Ge(),n=Ms(a);return e.jsxs(e.Fragment,{children:[n&&e.jsx(s.Notification,{severity:"caution",title:`Snapshot creation has been disabled for instances in the project ${a?.name}`,children:e.jsx(Es,{project:a})}),e.jsx(ae,{rows:[F({formik:t,label:"Snapshot name pattern",name:"snapshots_pattern",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter name pattern",type:"text"})}),F({formik:t,label:"Expire after",name:"snapshots_expiry",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter expiry expression",type:"text"})}),F({formik:t,label:"Snapshot stopped instances",name:"snapshots_schedule_stopped",defaultValue:"",readOnlyRenderer:i=>O(i,A),children:e.jsx(s.Select,{options:A})}),F({formik:t,label:"Schedule",name:"snapshots_schedule",defaultValue:"",children:e.jsx($s,{value:t.values.snapshots_schedule,setValue:i=>{t.setFieldValue("snapshots_schedule",i)}})})]})]})},lt=({config:t,setConfig:a})=>e.jsx("div",{className:"cloud-init-config",children:e.jsx(ft,{yaml:t,setYaml:a,readOnly:!a,readOnlyMessage:"Read only editor for inherited value. Create an override to modify."})}),ma=({title:t,onClose:a,applyChanges:n,readOnly:i,readOnlyMessage:o,initialValue:c})=>{const[r,m]=V.useState(c??"");V.useEffect(()=>{m(c??"")},[c]);const u=()=>{i||n(r),a()};return e.jsx(s.Modal,{close:u,title:t,className:"cloud-init-full-editor-modal",closeOnOutsideClick:!1,children:e.jsx("div",{className:"cloud-init-modal-content",children:e.jsx(ft,{yaml:r,setYaml:m,readOnly:i,readOnlyMessage:o,autoResize:!0})})})},va={cloud_init_network_config:"cloud-init network config",cloud_init_user_data:"cloud-init user data",cloud_init_vendor_data:"cloud-init vendor data"},ct=({formik:t,project:a,name:n,initialValue:i,source:o,onApplyChanges:c,isReadOnly:r,className:m})=>{const{showModal:u,hideModal:l}=kt(),y=Kt(),b=qt(),N=()=>{const x=va[n],f=t.values.name||"",h=t.values.entityType,j=b.pathname.includes("/create")||!f,g=o&&o!==f;let C=null;return!j&&f?C=e.jsx(It,{type:h,value:f,to:`${Ne}/ui/project/${encodeURIComponent(a)}/${h}/${encodeURIComponent(f)}`}):j&&f&&(C=e.jsx(Us,{type:h,value:f})),e.jsxs("div",{className:"u-no-margin",onClick:I=>{I.target.closest("a")&&(I.ctrlKey||I.metaKey||I.shiftKey||l())},children:[e.jsxs("h4",{className:"p-heading--4 u-no-margin--bottom",children:[r?"View":"Edit"," ",x]}),e.jsxs("p",{className:"p-heading--6 u-text--muted u-no-margin--top u-no-margin--bottom font-weight-normal",children:["For ",j&&"new ",h," ",C,y&&e.jsx("br",{}),g&&e.jsxs(e.Fragment,{children:[" inherited from ",o]})]})]})},v=x=>{w(t),t.setFieldValue(n,x),c?.()},p=x=>{u(e.jsx(ma,{title:N(),onClose:l,applyChanges:v,readOnly:r||!!t.values.editRestriction,readOnlyMessage:r?"Read only editor for inherited value. Create an override to modify.":t.values.editRestriction,initialValue:t.values[n]||i}),x)};return e.jsx(s.Button,{onClick:p,type:"button",appearance:"base",title:r?"Expand view":"Expand editor",hasIcon:!0,className:E("u-no-margin--bottom",m),children:e.jsx(s.Icon,{name:"fullscreen",className:"full-screen-icon"})})},$n=({formik:t,project:a})=>{const n=(i,o,c)=>{const[r,m]=V.useState(0),u=Rs(t.values,o),l=c!==void 0,y=()=>{m(x=>x+1)},b=u?.source||"",v=b&&b!==t.values.name?se(b):null,p=v?e.jsxs(e.Fragment,{children:["profile"," ",e.jsx(he,{profileName:v,projectName:a,className:E({"u-text--line-through":l})})]}):b;return _({configuration:e.jsx("strong",{children:i}),inherited:e.jsxs("div",{className:E({"u-text--muted":l,"u-text--line-through":l}),children:[e.jsx("div",{className:"mono-font",children:e.jsx(lt,{config:u.value},`cloud-init-${o}-${u.value}`)}),u&&e.jsxs("div",{className:"u-d-flex u-margin-top--small",children:[e.jsxs("span",{className:"p-text--small u-text--muted",children:["From ",p]}),u.value&&e.jsx(ct,{formik:t,project:a,name:o,source:p,initialValue:u.value,isReadOnly:!0,className:"u-no-margin--top u-margin-left--small"})]})]}),override:l?e.jsxs(e.Fragment,{children:[e.jsx(lt,{config:c??"",setConfig:x=>{w(t),t.setFieldValue(o,x)}},`cloud-init-override-${o}-${r}`),e.jsx(s.Button,{onClick:()=>{w(t),t.setFieldValue(o,void 0)},type:"button",appearance:"base",title:t.values.editRestriction??"Clear override",disabled:!!t.values.editRestriction,hasIcon:!0,className:"u-no-margin--bottom u-no-margin--right",children:e.jsx(s.Icon,{name:"close",className:"clear-configuration-icon"})}),e.jsx(ct,{formik:t,project:a,name:o,initialValue:c??"",onApplyChanges:y,isReadOnly:!!t.values.editRestriction})]}):e.jsx(s.Button,{onClick:()=>{w(t),t.setFieldValue(o,`

`)},className:"u-no-margin--bottom",type:"button",appearance:"base",title:t.values.editRestriction??"Create override",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(s.Icon,{name:"edit"})})})};return e.jsx("div",{className:"cloud-init",children:e.jsx(ae,{configurationExtra:e.jsx(s.Tooltip,{message:"Applied only to images that have the cloud-init package installed.",className:"configuration-extra",children:e.jsx(s.Icon,{name:"warning-grey"})}),rows:[n("Network config","cloud_init_network_config",t.values.cloud_init_network_config),n("User data","cloud_init_user_data",t.values.cloud_init_user_data),n("Vendor data","cloud_init_vendor_data",t.values.cloud_init_vendor_data)]})})},Dt=(t,a)=>{const n=s.useNotify(),i=vt(a),{data:o,error:c,isLoading:r}=qs(i),{project:m}=Ge(),u=t==="memory"?"limits.memory":"limits.cpu",l=m?.config[u]?ks(m?.config[u]):void 0;if(c)return n.failure("Loading resources failed",c),null;if(r||!o)return null;const b=Gt(o).map(N=>t==="cpu"?N.cpu.total:N.memory.total);return Ts(b,i,m,l)},rt=({formik:t})=>{const a=Dt("memory",t);if(!a)return null;const{min:n,max:i,sourceType:o,sourceName:c}=a,r=n!==i;return e.jsxs(e.Fragment,{children:["Total memory:"," ",e.jsxs("b",{children:[Te(n),n!==i&&` - ${Te(i)}`,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx(s.Icon,{name:"information",className:"help-link-icon",title:'The available memory depends on the cluster member that the instance will be created on.  To determine the available memory exactly, go to the "Main configuration" section, and from  the "Target" dropdown, select the "Cluster Member" option, then choose a member.'})]})]}),e.jsx("br",{}),c&&o&&e.jsx(Ct,{source:c,sourceType:o})]})},Ke=t=>{if(t==="")return;const a=Number(t);if(!isNaN(a))return a},ba=({formik:t,memoryLimit:a,setMemoryLimit:n})=>{if(!a)return null;const i=()=>Object.values(ke).map(o=>({label:o,value:o}));return e.jsxs("div",{children:[e.jsxs("div",{className:"memory-limit-label",children:[e.jsx(s.RadioInput,{label:"absolute",checked:a.selectedType===Q.FIXED,onChange:()=>{n({unit:ke.GIB,selectedType:Q.FIXED})}}),e.jsx(s.RadioInput,{label:"percentage",checked:a.selectedType===Q.PERCENT,onChange:()=>{n({unit:"%",selectedType:Q.PERCENT})}})]}),a.selectedType===Q.PERCENT&&e.jsx(s.Input,{id:"limits_memory",name:"limits_memory",type:"number",min:"0",max:"100",step:"Any",placeholder:"Enter percentage",onChange:o=>{n({...a,value:Ke(o.target.value)})},value:a.value??"",help:e.jsx(rt,{formik:t}),error:t.errors.limits_memory}),a.selectedType===Q.FIXED&&e.jsxs("div",{className:"memory-limit-with-unit",children:[e.jsx(s.Input,{id:"limits_memory",name:"limits_memory",type:"number",min:"0",step:"Any",placeholder:"Enter value",onChange:o=>{n({...a,value:Ke(o.target.value)})},value:a.value??"",help:e.jsx(rt,{formik:t}),error:t.errors.limits_memory}),e.jsx(s.Select,{id:"memUnitSelect",name:"memUnitSelect",label:"Select memory size unit",labelClassName:"u-off-screen",options:i(),onChange:o=>{n({...a,unit:o.target.value})},value:a.unit})]})]})},ga=({formik:t})=>{const a=Dt("cpu",t);if(!a)return null;const{min:n,max:i,sourceType:o,sourceName:c}=a,r=n!==i;return e.jsxs(e.Fragment,{children:["Total number of CPU cores:"," ",e.jsxs("b",{children:[n,n!==i&&` - ${i}`,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx(s.Icon,{name:"information",className:"help-link-icon",title:'The total number of CPU cores depends on the cluster member that the instance will be created on.      To determine the number of cores exactly, go to the "Main configuration" section, and from      the "Target" dropdown, select the "Cluster Member" option, then choose a member.'})]})]}),e.jsx("br",{}),o&&c&&e.jsx(Ct,{source:c,sourceType:o})]})},dt=({help:t,formik:a,...n})=>{const i=e.jsx(ga,{formik:a});return e.jsx(s.Input,{...n,help:e.jsxs(e.Fragment,{children:[t,t&&i&&e.jsx("br",{}),i]})})},xa=({cpuLimit:t,setCpuLimit:a,help:n,formik:i})=>t?e.jsxs("div",{children:[e.jsxs("div",{className:"cpu-limit-label",children:[e.jsx(s.RadioInput,{label:"number",checked:t.selectedType===W.DYNAMIC,onChange:()=>{a({selectedType:W.DYNAMIC})}}),e.jsx(s.RadioInput,{label:"fixed",checked:t.selectedType===W.FIXED,onChange:()=>{a({selectedType:W.FIXED})}})]}),t.selectedType===W.DYNAMIC&&e.jsx(dt,{id:"limits_cpu",name:"limits_cpu",type:"number",min:"1",step:"1",placeholder:"Number of exposed cores",onChange:o=>{a({...t,dynamicValue:Ke(o.target.value)})},value:t.dynamicValue??"",help:n,formik:i}),t.selectedType===W.FIXED&&e.jsx(dt,{id:"limits_cpu",name:"limits_cpu",type:"text",placeholder:"Comma-separated core numbers",onChange:o=>{a({...t,fixedValue:o.target.value})},value:t.fixedValue??"",help:n,formik:i})]}):null,ya={selectedType:W.DYNAMIC},ja={unit:ke.GIB,selectedType:Q.FIXED},Tn=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="container";return e.jsx(ae,{rows:[F({formik:t,name:"limits_cpu",label:"Exposed CPU limit",defaultValue:ya,readOnlyRenderer:i=>gs(i),children:e.jsx(xa,{formik:t,cpuLimit:t.values.limits_cpu,setCpuLimit:i=>{t.setFieldValue("limits_cpu",i)}})}),F({formik:t,name:"limits_memory",label:"Memory limit",defaultValue:ja,readOnlyRenderer:i=>xs(i)??"",children:e.jsx(ba,{formik:t,memoryLimit:t.values.limits_memory,setMemoryLimit:i=>{t.setFieldValue("limits_memory",i)}})}),F({formik:t,name:"limits_memory_swap",label:"Memory swap (Containers only)",defaultValue:"",disabled:n,disabledReason:n?"Only available for containers":void 0,readOnlyRenderer:i=>O(i,z),children:e.jsx(s.Select,{options:z,disabled:n})}),F({formik:t,name:"limits_disk_priority",label:"Disk priority",defaultValue:"",children:e.jsx(s.Select,{options:Ht})}),F({formik:t,name:"limits_processes",label:"Max number of processes (Containers only)",defaultValue:"",disabled:n,disabledReason:n?"Only available for containers":void 0,children:e.jsx(s.Input,{placeholder:"Enter number",min:1,type:"number",disabled:n})})]})},B=({id:t,label:a,inheritValue:n,inheritSource:i,readOnly:o,overrideValue:c,overrideForm:r,addOverride:m,clearOverride:u,isDeactivated:l,className:y,disabledReason:b,monoFont:N=!0})=>_({className:E("no-border-top",y),configuration:t?!o&&c?e.jsx(s.Label,{forId:t,children:a}):e.jsx("p",{className:"p-form__label u-no-margin--bottom u-no-padding--top",children:a}):e.jsx("div",{children:a}),inherited:n&&e.jsxs("div",{className:E({"u-text--muted":c||l,"u-text--line-through":c||l}),children:[e.jsx("div",{className:E({"mono-font":N}),children:N?e.jsx("b",{children:n}):n}),i&&e.jsxs("div",{className:"p-text--small u-text--muted u-no-margin--bottom",children:["From: ",i]})]}),override:o?c?e.jsx("div",{className:"mono-font",children:e.jsx("b",{children:c})}):"":c?e.jsxs("div",{className:"override-form",children:[e.jsx("div",{children:r}),u&&e.jsx("div",{children:e.jsx(s.Button,{onClick:u,type:"button",appearance:"base",title:b??"Clear override",hasIcon:!0,className:"u-no-margin--bottom",disabled:!!b,children:e.jsx(s.Icon,{name:"close",className:"clear-configuration-icon"})})})]}):m&&e.jsx(s.Button,{onClick:m,type:"button",appearance:"base",title:b??"Create override",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!b,children:e.jsx(s.Icon,{name:"edit"})})}),me=({project:t,profile:a,hasLocalOverride:n,isDetached:i,className:o})=>B({className:o,label:"From profile",inheritValue:e.jsxs(e.Fragment,{children:[e.jsx(he,{profileName:a,projectName:t,className:E({"u-text--line-through":n||i})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"with local override"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"detached"})]})]}),readOnly:!0,monoFont:!1}),Na=(t,a)=>t.entityType!=="instance"?!1:fa(t.devices)&&!Ca(t,a),fa=t=>!t.some(be),Ca=(t,a)=>{const[n]=jt(t,a);return!!n},An=t=>!t.values.yaml&&t.values.devices.some((a,n)=>Pt(t,n)),Pt=(t,a)=>{const n=t.values.devices[a];return n.path===void 0||n.type!=="disk"?!1:!!(t.touched.devices&&t.touched.devices[a]&&t.touched.devices[a].path)&&n.path.length<1},Bn=t=>!t.values.yaml&&t.values.devices.some((a,n)=>Ia(t,n)),Ia=(t,a)=>{const n=t.values.devices[a];return n.name||n.type!=="nic"?!1:!!(t.touched.devices&&t.touched.devices[a]&&t.touched.devices[a].name)},wa=({formik:t,pools:a,profiles:n,project:i})=>{const o=t.values.readOnly,c=t.values.devices.findIndex(be),r=c!==-1,m=t.values.devices[c],u=t.values.entityType==="instance"&&!ye(t),l=t.values.entityType==="instance"&&t.values.instanceType==="virtual-machine",y=l?"10GiB":"not specified",b=a.find(I=>I.name===m?.pool),N=b?.driver,[v,p]=jt(t.values,n),x=vt(t),f=()=>{const I=[...t.values.devices];I.push({type:"disk",name:v?.name??"root",path:"/",pool:v?.pool??a[0]?.name}),t.setFieldValue("devices",I)},h=m?.name||(v?.name?v.name:"root"),d=X(t,h),g=t.initialValues.devices.some(be)&&!r,C=d||g;return e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"disk-device-root-configuration-table",rows:[_({className:"override-with-form disk-device-root-header-row",configuration:e.jsxs("div",{className:"disk-device-root-header u-flex u-gap--small",children:[e.jsx("h2",{className:"p-heading--4 u-no-margin--bottom",children:"Root storage"}),C&&e.jsx(s.Icon,{name:"status-in-progress-small",title:"This device has unsaved changes"})]}),inherited:"",override:e.jsx("div",{children:r?e.jsxs(s.Button,{onClick:()=>{w(t),K(c,t)},type:"button",appearance:"base",title:t.values.editRestriction??"Clear override",hasIcon:!0,className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,dense:!0,children:[e.jsx(s.Icon,{name:"close",className:"clear-configuration-icon"}),e.jsx("span",{children:"Clear"})]}):e.jsxs(s.Button,{onClick:()=>{w(t),f()},type:"button",appearance:"base",title:t.values.editRestriction??"Create override",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"edit"}),e.jsx("span",{children:"Edit"})]})})}),...p&&p!=="LXD"?[me({project:i,profile:se(p),hasLocalOverride:r,className:"has-margin-left"})]:[],B({label:"Pool",id:"storage-pool-selector-disk",className:"override-with-form has-margin-left",inheritValue:v?.pool??"",readOnly:o,disabledReason:t.values.editRestriction,overrideValue:r&&e.jsxs(e.Fragment,{children:[m?.pool,t.values.entityType==="profile"&&e.jsx(s.Button,{onClick:()=>{w(t),Y("storage-pool-selector")},type:"button",appearance:"base",title:t.values.editRestriction??"Edit",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(s.Icon,{name:"edit"})})]}),overrideForm:e.jsx(e.Fragment,{children:e.jsx(Gs,{value:m?.pool??"",setValue:I=>{t.setFieldValue(`devices.${c}.pool`,I)},selectProps:{id:"storage-pool-selector-disk",className:u?"":"u-no-margin--bottom",disabled:u,help:u?"Use the migrate button in the header to change root storage.":""}})})}),B({label:"Size",id:"limits_disk",className:"override-with-form has-margin-left",inheritValue:v?.size??(v?y:""),readOnly:o,disabledReason:t.values.editRestriction,overrideValue:r&&e.jsxs(e.Fragment,{children:[m?.size??"unlimited",e.jsx(s.Button,{onClick:()=>{w(t),Y("limits_disk")},type:"button",appearance:"base",title:t.values.editRestriction??"Edit",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(s.Icon,{name:"edit"})})]}),overrideForm:r&&e.jsxs(e.Fragment,{children:[e.jsx(Ks,{value:m?.size??"GiB",setMemoryLimit:I=>{t.setFieldValue(`devices.${c}.size`,I)}}),e.jsxs("p",{className:"p-form-help-text",children:[e.jsx(As,{driver:N}),"If empty, root storage will"," ",l?"be limited at 10GiB.":"not have a size limit.",e.jsx("br",{}),e.jsx(Bs,{pool:b,clusterMember:x})]})]})})]}),Na(t.values,n)&&e.jsx("div",{className:"is-error ",children:e.jsxs("p",{className:"p-form-validation__message",children:[e.jsx("strong",{children:"Error:"})," Missing root storage. Create an override, or add a profile with root storage."]})})]})},qe=({onDetach:t,disabledReason:a,isInstanceCreation:n})=>n?e.jsxs(s.Button,{appearance:"base",type:"button",title:a??"Detach disk",className:"has-icon u-no-margin--bottom is-dense",onClick:t,disabled:!!a,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]}):e.jsxs(s.ConfirmationButton,{appearance:"base",type:"button",title:a??"Detach disk",className:"has-icon u-no-margin--bottom is-dense",confirmationModalProps:{title:"Confirm disk detachment",children:e.jsxs("p",{children:["Are you sure you want to clear this disk attachment?",e.jsx("br",{}),"This action may result in data loss if the disk is still mounted."]}),confirmButtonLabel:"Detach",onConfirm:t},shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!a,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]}),J=({name:t,hasChanges:a,isDetached:n=!1})=>e.jsxs("div",{className:"device-header device-name u-gap--small u-flex",children:[e.jsx("b",{className:E("device-header-name",{"u-text--muted u-text--line-through":n,"has-changes":a}),children:t}),a&&e.jsx(s.Icon,{name:"status-in-progress-small",title:"This device has unsaved changes"})]}),Sa=({formik:t,inheritedDiskDevices:a,project:n})=>{const i=t.values.readOnly,{data:o}=He(),c=o?.configs?.["device-disk"],r=c?ze(c):[],m=(l,y)=>e.jsxs("div",{className:"configuration-label-with-help",children:[e.jsx("span",{children:l}),e.jsx("span",{className:"configuration-help",children:e.jsx(Ie,{description:wt(r,y)})})]}),u=[];return a.forEach(l=>{const y=Ce(l.key,t),b=y!==-1;if(u.push(_({className:"override-with-form device-first-row",configuration:e.jsx(J,{name:l.key,hasChanges:X(t,l.key),isDetached:b}),inherited:null,override:b?e.jsx("div",{children:e.jsxs(s.Button,{appearance:"base",type:"button",title:t.values.editRestriction??"Reattach device",onClick:()=>{w(t),K(y,t)},className:"has-icon u-no-margin--bottom",disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]})}):e.jsx("div",{children:e.jsx(qe,{onDetach:()=>{w(t),de(l.key,t)},disabledReason:t.values.editRestriction,isInstanceCreation:ye(t)})})})),u.push(me({project:n,profile:se(l.source),isDetached:b})),ge(l))u.push(B({label:m("Source","source"),inheritValue:l.disk.source,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction})),u.push(B({label:m("Pool","pool"),inheritValue:e.jsx(St,{poolName:l.disk.pool??"",projectName:n,className:E({"u-text--line-through":b})}),readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,monoFont:!1}));else{rs(l.disk)?u.push(B({label:"Host path",inheritValue:l.disk.source,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction})):u.push(B({label:"Pool / volume",inheritValue:e.jsxs(e.Fragment,{children:[l.disk.pool," / ",l.disk.source]}),readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction}));const N=t.values.entityType==="profile"||t.values.instanceType==="container",v=Me(l.disk),p=!v||l.disk.path!==void 0,x=!v,f=N&&!v,h=l.disk.readonly??te(r,"readonly"),d=x?l.disk.recursive??te(r,"recursive"):void 0,j=l.disk.required??te(r,"required"),g=f?l.disk.shift??te(r,"shift"):void 0,C=h!==void 0,I=d!==void 0,P=j!==void 0,R=g!==void 0;p&&u.push(B({label:"Mount point",inheritValue:l.disk.path,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!C&&!I&&!P&&!R?"device-last-row":void 0})),C&&u.push(B({label:m("Read-only","readonly"),inheritValue:h,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!I&&!P&&!R?"device-last-row":void 0})),I&&u.push(B({label:m("Recursive","recursive"),inheritValue:d,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!P&&!R?"device-last-row":void 0})),P&&u.push(B({label:m("Required","required"),inheritValue:j,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:R?void 0:"device-last-row"})),R&&u.push(B({label:m("Shift","shift"),inheritValue:g,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:"device-last-row"}))}}),a.length>0?e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited disk devices"}),e.jsx(U,{rows:u,className:"inherited-disk-device-configuration-table"})]}):null},Ra=({project:t,primaryVolume:a,instanceLocation:n,onFinish:i,onCancel:o,onCreate:c,hasPrevStep:r})=>{const m=s.useNotify(),{canCreateStorageVolumes:u}=Ys(),{data:l}=zt(t),{data:y=[],error:b,isLoading:N,isFetching:v}=Qs(t,{refetchOnMount:h=>h.state.isInvalidated});b&&m.failure("Loading storage volumes failed",b);const p=h=>{m.clear(),i(h)},x=[{content:"Name"},{content:"Pool"},...n?[{content:"Location"}]:[],{content:"Content type"},{content:"Used by"},{"aria-label":"Actions",className:"actions"}],f=v?[]:y.sort((h,d)=>h.created_at>d.created_at?-1:1).map(h=>{const d=!!h.location,j=n!==void 0&&d&&n!==h.location,g=j?`Instance location (${n}) does not match local volume location (${h.location}). `:void 0,C=()=>{g||p(h)};return{key:h.name,className:E("u-row",{"u-text--muted":j,"u-row--disabled":j}),columns:[{content:e.jsx("div",{className:"u-truncate iso-name",title:`Volume ${h.name}`,children:h.name}),role:"rowheader","aria-label":"Name",onClick:C},{content:h.pool,role:"cell","aria-label":"Storage pool",onClick:C},...n?[{content:h.location,role:"cell","aria-label":"Location",onClick:C}]:[],{content:Hs(h),role:"cell","aria-label":"Content type",onClick:C},{content:h.used_by?.length,role:"cell","aria-label":"Used by",onClick:C},{content:e.jsx(s.Button,{onClick:()=>{p(h)},dense:!0,appearance:a?.name===h.name&&a?.type===h.type&&a?.pool==h.pool?"positive":"",title:j?g:`Select ${h.name}`,disabled:j,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:C}]}});return e.jsxs(e.Fragment,{children:[e.jsx(bt,{}),e.jsx(s.ScrollableTable,{dependencies:[y,f,m.notification],belowIds:["modal-footer"],tableId:"volume-select-table",children:e.jsx(s.MainTable,{id:"volume-select-table",headers:x,rows:f,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:N||v?e.jsx(s.Spinner,{className:"u-loader",text:"Loading volumes..."}):"No custom volumes found"})}),!N&&e.jsxs("footer",{className:"p-modal__footer create-volume-modal-footer",id:"modal-footer",children:[e.jsx(s.Button,{className:"u-no-margin--bottom",onClick:o,appearance:"base",children:r?"Back":"Cancel"}),e.jsx(s.Button,{className:"u-no-margin--bottom",appearance:y.length===0?"positive":"",onClick:c,disabled:!u(l),title:u(l)?"":"You do not have permission to create storage volumes in this project",children:"Create volume"})]})]})},_a=({project:t,instanceLocation:a,onCancel:n,onFinish:i})=>{const o=s.useNotify(),c=Yt(),r=V.useState(null),m=Xt(),{data:u}=Qt(),{data:l=[]}=Rt(),y=Ae().shape({name:le().test(...zs(t,"custom",r)).required("This field is required")}),b=d=>{c.invalidateQueries({queryKey:[Be.storage]}),c.invalidateQueries({queryKey:[Be.customVolumes,t]}),o.success(`Storage volume ${d.name} created.`),i(d)},N=d=>{o.failure("Storage volume creation failed",d)},v=()=>{p.setSubmitting(!1)},p=gt({initialValues:{content_type:"filesystem",name:"",project:t,pool:"",clusterMember:a,size:"GiB",volumeType:"custom",readOnly:!1,isCreating:!0,isClusterMemberLocked:!0,entityType:"storageVolume"},validationSchema:y,onSubmit:d=>{const j=Os(d,t),g=it(d.pool,l,u)?a:void 0;Ws(d.pool,t,j,g).then(C=>{m.set(C.metadata.id,()=>{b(j)},I=>{N(new Error(I))},v)}).catch(N)}}),x=!it(p.values.pool,l,u)||a!=="any",f=x?void 0:"Please select a remote storage pool, or set a cluster member for the instance",h=()=>{Wt("volume-create-form","p-modal__footer",32,void 0,[])};return V.useEffect(h,[o.notification?.message]),s.useListener(window,h,"resize",!0),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"volume-create-form",children:e.jsx(Ls,{formik:p,poolError:f,pools:l,settings:u,clusterMembers:a?[{server_name:a}]:[]})}),e.jsxs("footer",{className:"p-modal__footer",children:[e.jsx(s.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:n,children:"Back"}),e.jsx(s.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{p.submitForm()},disabled:!p.isValid||p.isSubmitting||!x,loading:p.isSubmitting,children:"Create volume"})]})]})},Ee="selectVolume",$e="createVolume",Ft=({formik:t,project:a,onFinish:n,onCancel:i,onClose:o,title:c})=>{const[r,m]=V.useState(Ee),[u,l]=V.useState(void 0),y=Jt(t),b=p=>{l(p),n(p)},N=()=>{m(Ee)};let v=c??"Choose custom volume";return r===$e&&(v=c?e.jsx(re,{title:"Create volume",onClick:N,linkText:"Attach custom volume"}):"Create volume"),e.jsxs(s.Modal,{className:"custom-volume-modal",close:o,title:v,children:[r===Ee&&e.jsx(Ra,{project:a,primaryVolume:u,instanceLocation:y,onFinish:n,onCancel:i,onCreate:()=>{m($e)},hasPrevStep:!!c}),r===$e&&e.jsx(_a,{project:a,instanceLocation:y,onCancel:N,onFinish:b})]})},Da=({formik:t,children:a,buttonProps:n,project:i,setValue:o})=>{const{openPortal:c,closePortal:r,isOpen:m,Portal:u}=s.usePortal(),l=y=>{o(y),r()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{onClick:c,type:"button",hasIcon:!0,...n,children:a}),m&&e.jsx(u,{children:e.jsx(Ft,{formik:t,project:i,onFinish:l,onCancel:r,onClose:r})})]})},we=({name:t,index:a,setName:n,disableReason:i,formik:o})=>{const[c,r]=V.useState(!1);return e.jsx("div",{className:"rename-device device-name",children:c?e.jsx(s.Input,{autoFocus:!0,className:"u-no-margin--bottom",type:"text",value:t,onChange:m=>{n(m.target.value)},onBlur:()=>{r(!1)}}):e.jsxs(e.Fragment,{children:[e.jsx(s.Label,{forId:`device-${a}-name`,children:e.jsx(J,{name:t,hasChanges:X(o,t)})}),e.jsx(s.Button,{id:`device-${a}-name`,hasIcon:!0,dense:!0,onClick:()=>{r(!0)},appearance:"base",className:"u-no-margin--bottom","aria-label":"Rename device",disabled:!!i,title:i,children:e.jsx(s.Icon,{name:"edit"})})]})})},Pa=({formik:t,onFinish:a,onCancel:n,onClose:i,title:o})=>{const[c,r]=V.useState(""),[m,u]=V.useState(""),l=V.useRef({source:!1,path:!1});V.useEffect(()=>{Y("host-path")},[]);const y=()=>{a({type:"disk",source:c,path:m})},b=!!c&&!!m&&!t.isSubmitting,N=v=>{v.key==="Enter"&&(v.preventDefault(),l.current.source=!0,l.current.path=!0,b&&y())};return e.jsxs(s.Modal,{className:"host-path-device-modal",close:i,title:o,buttonRow:e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:n,children:"Back"}),e.jsx(s.Button,{appearance:"positive",className:"u-no-margin--bottom",type:"button",loading:t.isSubmitting,disabled:!b,onClick:y,children:"Attach"})]}),children:[e.jsx(s.Input,{id:"host-path",value:c,onChange:v=>{l.current.source=!0,r(v.target.value)},onKeyDown:N,type:"text",label:"Host path",required:!0,error:!c&&l.current.source?"Host path is required":void 0,placeholder:"Enter full path (e.g. /home)"}),e.jsx(s.Input,{value:m,onChange:v=>{l.current.path=!0,u(v.target.value)},onKeyDown:N,type:"text",label:"Mount point",required:!0,error:!m&&l.current.path?"Mount point is required":void 0,placeholder:"Enter full path (e.g. /data)"})]})},Fa=({close:t,formik:a,project:n,onFinish:i})=>{const[o,c]=V.useState("choose type"),r=()=>{c("choose type")},m=p=>{const x={type:"disk",pool:p.pool,source:p.name,path:p.content_type==="filesystem"?"":void 0};i(x)},u=p=>{const x=ys(p);i(x)},l="Choose disk type",b=(()=>{switch(o){case"custom volume":return e.jsx(re,{title:"Attach custom volume",onClick:r,linkText:l});case"host path":return e.jsx(re,{title:"Mount host path",onClick:r,linkText:l});default:return l}})(),N=a.values.devices.some(ge),v=a.values.entityType==="profile"||a.values.entityType==="instance"&&a.values.instanceType==="virtual-machine";return e.jsxs(e.Fragment,{children:[o==="choose type"&&e.jsx(s.Modal,{close:t,className:"migrate-instance-modal",title:b,children:e.jsxs("div",{className:"choose-migration-type",children:[e.jsx(Fe,{icon:"add-logical-volume",title:"Attach custom volume",onClick:()=>{c("custom volume")}}),e.jsx(Fe,{icon:"mount",title:"Mount host path",onClick:()=>{c("host path")}}),v&&e.jsx(Fe,{icon:"iso",title:"Attach ISO",onClick:()=>{c("iso")},disabled:N,onHoverText:N?"Only one ISO volume can be attached at a time":void 0})]})}),o==="custom volume"&&e.jsx(Ft,{formik:a,project:n,onFinish:m,onCancel:r,onClose:t,title:b}),o==="host path"&&e.jsx(Pa,{formik:a,onFinish:i,onCancel:r,onClose:t,title:b}),o==="iso"&&e.jsx(ra,{onClose:t,onSelect:u,onCancel:r,cancelButtonText:"Back",backLinkText:l})]})},Va=({formik:t,children:a,buttonProps:n,project:i,setValue:o})=>{const{openPortal:c,closePortal:r,isOpen:m,Portal:u}=s.usePortal(),l=y=>{o(y),r()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{onClick:c,type:"button",hasIcon:!0,...n,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:a}),m&&e.jsx(u,{children:e.jsx(Fa,{formik:t,project:i,onFinish:l,close:r})})]})},Ea=({formik:t,project:a,profiles:n})=>{const i=t.values.readOnly,o=fe(t.values,n),c=t.values.entityType==="profile",{data:r}=He(),m=r?.configs?.["device-disk"],u=m?ze(m):[],l=({id:d,label:j,key:g,required:C=!1})=>e.jsxs("div",{className:"configuration-label-with-help",children:[e.jsx(s.Label,{forId:d,required:C,children:j}),e.jsx("span",{className:"configuration-help",children:e.jsx(Ie,{description:wt(u,g)})})]}),y=(d,j)=>d===ds?j?us:hs:ue("disk-device",1,o),b=d=>{const j=[...t.values.devices],g={...d,name:y(d.type,c)};j.push(g),t.setFieldValue("devices",j);const C=`devices.${j.length-1}.path`;Y(C)},N=(d,j,g)=>{t.setFieldValue(`devices.${g}.pool`,d.pool),t.setFieldValue(`devices.${g}.source`,d.name),d.content_type==="filesystem"&&j.path===void 0&&t.setFieldValue(`devices.${g}.path`,""),d.content_type==="block"&&t.setFieldValue(`devices.${g}.path`,void 0)},v=d=>e.jsx(s.Button,{appearance:"base",className:"u-no-margin--bottom",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Edit",onClick:()=>{w(t),Y(d)},disabled:!!t.values.editRestriction,children:e.jsx(s.Icon,{name:"edit"})}),p=(d,j,g)=>{const C=j??te(u,g);return e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"custom-disk-value",children:e.jsx("b",{children:O(C,A)||"-"})}),v(d)]})},x=d=>{const j=te(u,d),g=O(j,A),C=g?`LXD default (${g})`:"LXD default";return A.map((I,P)=>P===0?{...I,label:C}:I)},f=[];let h=0;for(let d=0;d<t.values.devices.length;d++){const j=t.values.devices[d];if(!(!(et(j)||ge(j))||be(j))){if(ge(j)){const C=!t.initialValues.devices.some(I=>I.name===j.name);f.push(_({className:"device-first-row",configuration:e.jsx(J,{name:j.name,hasChanges:C}),inherited:null,override:e.jsx("div",{children:e.jsx(qe,{onDetach:()=>{w(t),K(d,t)},disabledReason:t.values.editRestriction,isInstanceCreation:ye(t)})})})),f.push(_({className:"no-border-top has-margin-left",configuration:e.jsx("div",{children:"Source"}),inherited:e.jsx("b",{className:"mono-font",children:j.source}),override:null})),f.push(_({className:"no-border-top has-margin-left",configuration:e.jsx("div",{children:"Pool"}),inherited:e.jsx(St,{poolName:j.pool,projectName:a}),override:null}))}else{if(!et(j))continue;f.push(_({className:"custom-device-name device-first-row",configuration:e.jsx(we,{name:j.name,index:d,setName:T=>{w(t),t.setFieldValue(`devices.${d}.name`,T)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsx("div",{children:e.jsx(qe,{onDetach:()=>{w(t),K(d,t)},disabledReason:t.values.editRestriction,isInstanceCreation:ye(t)})})}));const C=()=>_({className:E("no-border-top inherited-with-form"),configuration:e.jsx(s.Label,{forId:`devices.${d}.pool`,className:"u-text--muted",children:"Pool / volume"}),inherited:e.jsxs("div",{className:"custom-disk-volume-source",children:[e.jsx("div",{className:E("mono-font","u-truncate"),title:`${j.pool} / ${j.source??""}`,children:e.jsxs("b",{children:[j.pool," / ",j.source]})}),e.jsx(Da,{formik:t,project:a,setValue:T=>{w(t),N(T,j,d)},buttonProps:{id:`devices.${d}.pool`,appearance:"base",className:"u-no-margin--bottom",title:t.values.editRestriction??"Select storage volume",dense:!0,disabled:!!t.values.editRestriction},children:e.jsx(s.Icon,{name:"edit"})})]}),override:""}),I=()=>_({className:E("no-border-top inherited-with-form"),configuration:e.jsx(s.Label,{forId:`devices.${d}.source`,className:"u-text--muted",children:"Host path"}),inherited:i?e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"mono-font custom-disk-value u-truncate",children:e.jsx("b",{children:j.source})}),v(`devices.${d}.source`)]}):e.jsx(s.Input,{id:`devices.${d}.source`,name:`devices.${d}.source`,onBlur:t.handleBlur,onChange:T=>{t.setFieldValue(`devices.${d}.source`,T.target.value)},value:j.source,type:"text",placeholder:"Enter full host path (e.g. /data)",className:j.source?"u-no-margin--bottom":void 0,error:j.source?void 0:"Host path is required"}),override:""}),P=c||t.values.instanceType==="container",R=Me(j),$=j.readonly==="true",k=j.recursive==="true",ne=!R||j.path!==void 0,Se=!R,Re=P&&!R,D=!Re;if(f.push(Me(j)?C():I()),ne){const T=Pt(t,d);f.push(_({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:`devices.${d}.path`,className:"u-text--muted",required:!0,children:"Mount point"}),inherited:i?e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"mono-font custom-disk-value",children:e.jsx("b",{children:j.path})}),v(`devices.${d}.path`)]}):e.jsx(s.Input,{id:`devices.${d}.path`,name:`devices.${d}.path`,onBlur:t.handleBlur,onChange:q=>{t.setFieldValue(`devices.${d}.path`,q.target.value)},value:j.path,type:"text",placeholder:"Enter full path (e.g. /data)",className:T?void 0:"u-no-margin--bottom",error:T?"Path is required":void 0}),override:""}))}f.push(_({className:"no-border-top inherited-with-form",configuration:l({id:`devices.${d}.readonly`,label:"Read-only",key:"readonly"}),inherited:i?p(`devices.${d}.readonly`,j.readonly,"readonly"):e.jsx(s.Select,{id:`devices.${d}.readonly`,name:`devices.${d}.readonly`,onBlur:t.handleBlur,onChange:T=>{w(t);const q=T.target.value||void 0;t.setFieldValue(`devices.${d}.readonly`,q),q==="true"&&t.setFieldValue(`devices.${d}.recursive`,void 0)},value:j.readonly??"",options:x("readonly"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction||k,title:t.values.editRestriction??(k?"Cannot set read-only with recursive bind mounts":void 0)}),override:""})),Se&&f.push(_({className:"no-border-top inherited-with-form",configuration:l({id:`devices.${d}.recursive`,label:"Recursive",key:"recursive"}),inherited:i?p(`devices.${d}.recursive`,j.recursive,"recursive"):e.jsx(s.Select,{id:`devices.${d}.recursive`,name:`devices.${d}.recursive`,onBlur:t.handleBlur,onChange:T=>{w(t);const q=T.target.value||void 0;t.setFieldValue(`devices.${d}.recursive`,q),q==="true"&&t.setFieldValue(`devices.${d}.readonly`,void 0)},value:j.recursive??"",options:x("recursive"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction||$,title:t.values.editRestriction??($?"Recursive read-only bind mounts are not supported":void 0)}),override:""})),f.push(_({className:E("no-border-top inherited-with-form",{"device-last-row":D}),configuration:l({id:`devices.${d}.required`,label:"Required",key:"required"}),inherited:i?p(`devices.${d}.required`,j.required,"required"):e.jsx(s.Select,{id:`devices.${d}.required`,name:`devices.${d}.required`,onBlur:t.handleBlur,onChange:T=>{w(t),t.setFieldValue(`devices.${d}.required`,T.target.value||void 0)},value:j.required??"",options:x("required"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""})),Re&&f.push(_({className:"no-border-top inherited-with-form device-last-row",configuration:l({id:`devices.${d}.shift`,label:"Shift",key:"shift"}),inherited:i?p(`devices.${d}.shift`,j.shift,"shift"):e.jsx(s.Select,{id:`devices.${d}.shift`,name:`devices.${d}.shift`,onBlur:t.handleBlur,onChange:T=>{w(t),t.setFieldValue(`devices.${d}.shift`,T.target.value||void 0)},value:j.shift??"",options:x("shift"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""}))}h++}}return e.jsxs("div",{className:"custom-devices",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"p-heading--4",children:"Custom disk devices"}),e.jsx(U,{rows:f,className:"custom-disk-device-configuration-table"})]}),e.jsxs(Va,{formik:t,project:a,setValue:d=>{w(t),b(d)},children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Attach disk device"})]})]})},On=({formik:t,project:a})=>{const n=s.useNotify(),{data:i=[],isLoading:o,error:c}=G(a);c&&n.failure("Loading profiles failed",c);const{data:r=[],isLoading:m,error:u}=Rt();if(u&&n.failure("Loading storage pools failed",u),o||m)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading..."});const l=_s(t.values,i);return e.jsx("div",{className:E("disk-device-form","device-form",{"disk-device-form--edit":!t.values.readOnly}),children:e.jsxs(pe,{children:[e.jsx(s.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(wa,{formik:t,pools:r,profiles:i,project:a}),e.jsx(Sa,{formik:t,inheritedDiskDevices:l,project:a}),e.jsx(Ea,{formik:t,project:a,profiles:i})]})})},Vt=({formik:t,device:a,inheritedDevice:n})=>{const i=Ye(),o=n&&!a,c=n&&a&&xe(a),r=n&&a&&xt(a),m=n&&a&&je(a),u=!n&&a,l=!!(u&&je(a)||o&&n?.network&&yt(n.network)||m),y=!!t.values.editRestriction,N=t.values.editRestriction?t.values.editRestriction:l?"Use the YAML configuration to edit a custom network":o||r?"Create override":c?"Edit override":"Edit network",v=()=>{o||r?i.openEditNetworkDevice(n.key):a&&xe(a)&&i.openEditNetworkDevice(a.name||"")},p=()=>{w(t),tt({formik:t,deviceName:a?.name||""})},x=()=>{w(t),de(n?.key||"",t)},f=()=>{w(t),tt({formik:t,deviceName:a?.name||""})},h=()=>{const d=[];return(o||u||c||m)&&d.push(e.jsxs(s.Button,{onClick:v,type:"button",appearance:"base",title:N,className:"p-segmented-control__button p-action-button p-button",hasIcon:!0,dense:!0,disabled:y||l,children:[e.jsx(s.Icon,{name:"edit"}),e.jsx("span",{children:"Edit"})]},"edit-button")),o&&d.push(e.jsxs(s.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:x,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]},"detach-inherited-button")),(c||m)&&d.push(e.jsxs(s.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:x,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]},"detach-overridden-button")),r&&d.push(e.jsxs(s.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:p,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Reattach inherited network",disabled:y,children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]},"reattach-button")),u&&d.push(e.jsxs(s.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:f,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]},"detach-local-button")),(c||m)&&d.push(e.jsxs(s.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:p,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Clear override",disabled:y,children:[e.jsx(s.Icon,{name:"close"}),e.jsx("span",{children:"Clear"})]},"clear-override-button")),d};return e.jsx("div",{className:"network-device-actions p-segmented-control",children:e.jsx("div",{className:"p-segmented-control__list",children:h()})})},$a=({network:t,device:a,family:n})=>{if(!t||!t.config)return null;const i=n==="IPv4"?"ipv4.address":"ipv6.address",o=t.config[i],c=a[i];return o!=="none"?c||"dynamic":null},Et=({project:t,managedNetworks:a,device:n,showIpAddresses:i,isDetached:o,hasChanges:c,actions:r,sourceProfile:m})=>{const u=[];if(!n)return u;if(u.push(_({className:"device-first-row",configuration:e.jsx(J,{name:n.name||"",hasChanges:c,isDetached:o}),inherited:null,override:r})),m&&u.push(_({className:"no-border-top",configuration:e.jsx("div",{children:"From profile"}),inherited:m,override:null})),n.type==="custom-nic")return u.push(_({className:"no-border-top device-last-row",configuration:e.jsxs("div",{className:E({"u-text--line-through":o}),children:["custom network"," ",e.jsx(s.Tooltip,{message:"A custom network can be viewed and edited only from the YAML configuration",children:e.jsx(s.Icon,{name:"information"})})]}),inherited:null,override:null})),u;const l=a.find(y=>y.name===n.network);if(l){u.push(_({className:"no-border-top",configuration:e.jsx("div",{children:"Network"}),inherited:e.jsx("div",{children:e.jsx(sa,{networkName:n.network,projectName:t||"default",className:E({"u-text--line-through":o})})}),override:null}));const y=Oe(Le(l),Ue(n));if(i){const N=["IPv4","IPv6"].map(v=>({family:v,ip:$a({network:l,device:n,family:v})})).filter(v=>!!v.ip);N.forEach(({family:v,ip:p},x)=>{u.push(_({className:E("no-border-top",{"device-last-row":y.length===0&&x===N.length-1}),configuration:e.jsx("div",{children:v}),inherited:e.jsx("div",{children:e.jsx("b",{className:E("mono-font ip-address",{"u-text--line-through":o}),children:p})}),override:null}))})}if(y.length>0&&u.push(_({className:"no-border-top",configuration:e.jsx("div",{children:"Access control lists"}),inherited:e.jsx("div",{children:e.jsx(ta,{items:y.map(b=>e.jsx(It,{type:"network-acl",value:b,to:`${Ne}/ui/project/${encodeURIComponent(t||"default")}/network-acl/${encodeURIComponent(b)}`,className:E("acl-chip",{"u-text--line-through":o})},b))})}),override:null})),y.length>0){const b=()=>({Egress:n["security.acls.default.egress.action"]??l.config["security.acls.default.egress.action"]??"",Ingress:n["security.acls.default.ingress.action"]??l.config["security.acls.default.ingress.action"]??""});u.push(_({className:E("no-border-top device-last-row acl-defaults",{"u-text--line-through":o}),configuration:e.jsx("div",{}),inherited:e.jsx("div",{children:e.jsx(aa,{values:b()})}),override:null}))}}return u},Ta=({formik:t,inheritedNetworkDevices:a,project:n,managedNetworks:i})=>{if(a.length===0)return null;const o=a.flatMap(c=>{const r=t.values.devices.find(f=>f.name===c.key),m=r!==void 0,u=r&&xt(r),l=c&&r&&xe(r),y=c&&r&&je(r),N=r&&xe(r)||r&&je(r)?r:c.network?yt(c.network)?{name:c.key,type:"custom-nic",bare:c.network}:{...c.network,name:c.key}:null,v=r&&X(t,c.key),x=t.initialValues.devices.find(f=>f.name===c.key)&&!r;return Et({project:n,managedNetworks:i,device:N,isDetached:!!u,hasChanges:v||x,showIpAddresses:t.values.entityType==="instance",sourceProfile:e.jsxs(e.Fragment,{children:[e.jsx(he,{profileName:c.sourceProfile,projectName:n,className:E({"u-text--line-through":m})}),(l||y)&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"with local override"})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"detached"})]})]}),actions:e.jsx(Vt,{formik:t,device:r,inheritedDevice:c})})});return e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited network devices"}),e.jsx(U,{className:"inherited-network-device-configuration-table",rows:o})]})},Aa=({formik:t,inheritedNetworkDevices:a,project:n,managedNetworks:i})=>{const o=t.values.devices.filter(r=>{const m=r.type?.includes("nic")||r.type?.includes("custom-nic"),u=a.map(l=>l.key).includes(r.name);return m&&!u});if(o.length===0)return null;const c=o.flatMap(r=>{const m=r.name||"",u=r,l=a.find(y=>y.key===m);return Et({project:n,managedNetworks:i,device:u,hasChanges:X(t,m),showIpAddresses:t.values.entityType==="instance",actions:u.type?.includes("nic")?e.jsx(Vt,{formik:t,device:u,inheritedDevice:l}):null})});return e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Custom network devices"}),e.jsx(U,{className:"custom-network-device-configuration-table",rows:c})]})},Ln=({formik:t,project:a})=>{const n=s.useNotify(),i=Ye(),{data:o=[],isLoading:c,error:r}=G(a);r&&n.failure("Loading profiles failed",r);const{data:m=[],isLoading:u,error:l}=_t(a);if(V.useEffect(()=>{l&&n.failure("Loading networks failed",l)},[l]),c||u)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading..."});const y=m.filter(N=>N.managed),b=Nt(t.values,o);return e.jsx("div",{className:"network-device-form device-form",children:e.jsxs(pe,{children:[e.jsx(Ta,{formik:t,inheritedNetworkDevices:b,project:a,managedNetworks:y}),e.jsx(Aa,{formik:t,inheritedNetworkDevices:b,project:a,managedNetworks:y}),e.jsxs(s.Button,{onClick:i.openCreateNetworkDevice,type:"button",hasIcon:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Attach network"})]})]})})},Mn=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="virtual-machine";return e.jsx(ae,{rows:[F({formik:t,label:"Stateful migration (VMs only)",name:"migration_stateful",defaultValue:"",disabled:n,disabledReason:n?"Only available for virtual machines":void 0,readOnlyRenderer:i=>O(i,z),children:e.jsx(s.Select,{options:z,disabled:n})}),F({formik:t,label:"Cluster evacuation",name:"cluster_evacuate",defaultValue:"auto",readOnlyRenderer:i=>O(i,Qe),children:e.jsx(s.Select,{options:Qe})})]})},Ba=({onSelect:t,onClose:a})=>{const{canViewResources:n}=Zt(),{data:i,isLoading:o}=es({queryKey:[Be.resources],queryFn:async()=>ts(),enabled:n()}),c=[{content:"Vendor"},{content:"Driver"},{content:"PCI address"},{content:"ID"},{"aria-label":"Actions",className:"actions"}],r=o?[]:i?.gpu?.cards?.map(u=>{const l=()=>{t(u)};return{key:u.pci_address,className:"u-row",columns:[{content:u.vendor,role:"rowheader","aria-label":"Vendor",onClick:l},{content:e.jsxs(e.Fragment,{children:[u.driver," ",e.jsx("span",{className:"u-text--muted",children:u.driver_version})]}),role:"cell","aria-label":"Driver",onClick:l},{content:u.pci_address,role:"cell","aria-label":"PCI Address",onClick:l},{content:u.drm?.id??"-",role:"cell","aria-label":"ID",onClick:l},{content:e.jsx(s.Button,{onClick:l,dense:!0,"aria-label":`Select ${u.pci_address}`,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:l}]}}),m=()=>n()?e.jsx(s.ScrollableTable,{dependencies:[i,r],belowIds:["modal-footer"],tableId:"gpu-select-table",children:e.jsx(s.MainTable,{id:"gpu-select-table",headers:c,rows:r,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:o?e.jsx(s.Spinner,{className:"u-loader",text:"Loading GPUs..."}):"No GPUs found"})}):e.jsx(s.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to view available GPUs on the server."});return e.jsxs(s.Modal,{close:a,title:"Select GPU",children:[m(),e.jsx("footer",{className:"p-modal__footer",id:"modal-footer",children:e.jsx(s.Button,{className:"u-no-margin--bottom",onClick:()=>{t({pci_address:""})},children:"Enter details manually"})})]})},Oa=({onSelect:t,disabledReason:a})=>{const{openPortal:n,closePortal:i,isOpen:o,Portal:c}=s.usePortal(),r=m=>{i(),t(m)};return e.jsxs(e.Fragment,{children:[e.jsxs(s.Button,{onClick:n,type:"button",hasIcon:!0,disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Attach GPU"})]}),o&&e.jsx(c,{children:e.jsx(Ba,{onClose:i,onSelect:r})})]})},La=({device:t,onChange:a,disableReason:n})=>{const[i,o]=V.useState(t.pci?"pci":"id"),c=i==="pci",r=`device.${t.name}.${c?"pci":"id"}`;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"u-sv1",children:[e.jsx(s.RadioInput,{inline:!0,className:"margin-right--large",label:"ID",checked:!c,onClick:()=>{o("id")},disabled:!!n}),e.jsx(s.RadioInput,{inline:!0,label:"PCI",checked:c,onClick:()=>{o("pci")},disabled:!!n})]}),e.jsx(s.Input,{type:"text",label:c?"PCI Address":"ID",value:c?t.pci:t.id,onChange:m=>a?.(c?m.target.value:void 0,c?void 0:m.target.value),disabled:!!n},r)]})},Un=({formik:t,project:a})=>{const n=s.useNotify(),{data:i=[],isLoading:o,error:c}=G(a);c&&n.failure("Loading profiles failed",c);const r=Ds(t.values,i),m=fe(t.values,i),u=N=>{const v=N.drm?.id?N.drm.id.toString():void 0,p=[...t.values.devices];p.push({type:"gpu",gputype:"physical",pci:N.pci_address,id:N.pci_address===void 0?v:void 0,name:ue("gpu",1,m)}),t.setFieldValue("devices",p)},l=t.values.devices.some(N=>N.type==="gpu"),y=[];r.forEach(N=>{const v=Ce(N.key,t),p=v!==-1;y.push(_({className:"no-border-top override-with-form",configuration:e.jsx(J,{name:N.key,hasChanges:X(t,N.key),isDetached:p}),inherited:null,override:p?e.jsxs(s.Button,{appearance:"base",type:"button",title:"Reattach GPU",onClick:()=>{w(t),K(v,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(s.Button,{appearance:"base",type:"button",onClick:()=>{w(t),de(N.key,t)},className:"has-icon u-no-margin--bottom",title:t.values.editRestriction??"Detach GPU",disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),y.push(me({project:a,profile:se(N.source),isDetached:p})),Object.keys(N.gpu).forEach(x=>{x==="name"||x==="type"||y.push(B({label:ce(x),inheritValue:N.gpu[x],readOnly:!1,isDeactivated:p}))})});const b=[];return t.values.devices.forEach((N,v)=>{if(N.type!=="gpu")return;const p=t.values.devices[v];b.push(_({className:"no-border-top custom-device-name",configuration:e.jsx(we,{name:p.name,index:v,setName:x=>{w(t),t.setFieldValue(`devices.${v}.name`,x)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(s.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{w(t),K(v,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach GPU",disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),Object.keys(p).forEach(x=>{x==="name"||x==="type"||x==="pci"||x==="id"||b.push(B({label:ce(x),inheritValue:p[x],readOnly:!1}))}),b.push(B({label:"Identify by",inheritValue:e.jsx(La,{device:p,onChange:(x,f)=>{w(t),t.setFieldValue(`devices.${v}.pci`,x),t.setFieldValue(`devices.${v}.id`,f)},disableReason:t.values.editRestriction}),readOnly:!1}))}),o?e.jsx(s.Spinner,{className:"u-loader",text:"Loading..."}):e.jsxs(pe,{className:"device-form",children:[e.jsx(s.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsxs(s.Notification,{severity:"information",title:"GPU passthrough",children:["Learn more about"," ",e.jsx(We,{docPath:"/reference/devices_gpu/#devices-gpu",children:"GPU devices"})," ","and"," ",e.jsx(We,{docPath:"/howto/container_gpu_passthrough_with_docker/#container-gpu-passthrough-with-docker",children:"container GPU passthrough with Docker"})]}),y.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited GPU devices"}),e.jsx(U,{rows:y})]}),l&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom GPU devices"}),e.jsx(U,{rows:b})]}),e.jsx(Oa,{onSelect:N=>{w(t),u(N)},disabledReason:t.values.editRestriction})]})},kn=({formik:t,project:a})=>{const n=s.useNotify(),i=t.values.entityType==="instance",o=i&&t.values.instanceType==="container",c=i&&t.values.instanceType==="virtual-machine",{data:r,isLoading:m}=He(),{data:u=[],isLoading:l,error:y}=G(a);y&&n.failure("Loading profiles failed",y);const b=Ps(t.values,u),N=fe(t.values,u),v=()=>{const h=[...t.values.devices];h.push({type:"usb",name:ue("custom-device",1,N)}),t.setFieldValue("devices",h)};if(l||m)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading..."});const p=t.values.devices.some(Ze),x=[];b.forEach(h=>{const d=Ce(h.key,t),j=d!==-1,g=t.initialValues.devices.some(R=>R.name===h.key),C=t.values.devices.some(R=>R.name===h.key),I=g&&!C,P=X(t,h.key)||I;x.push(_({className:"no-border-top override-with-form",configuration:e.jsx(J,{name:h.key,hasChanges:P,isDetached:j}),inherited:null,override:j?e.jsxs(s.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{w(t),K(d,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:"Attach device",children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(s.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{w(t),de(h.key,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach device",disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),x.push(me({project:a,profile:se(h.source),isDetached:j})),Object.keys(h.device).forEach(R=>{R!=="name"&&x.push(B({label:ce(R),inheritValue:h.device[R],readOnly:!1,isDeactivated:j}))})});const f=[];return t.values.devices.forEach((h,d)=>{if(!Ze(h))return;const j=t.values.devices[d],g=j.type==="usb"?"unix-usb":j.type,C=`device-${g}`,I=r?.configs[C],P=I?ze(I):[];f.push(_({className:"no-border-top custom-device-name",configuration:e.jsx(we,{name:j.name,index:d,setName:R=>{w(t),t.setFieldValue(`devices.${d}.name`,R)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(s.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{w(t),K(d,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach device",disabled:!!t.values.editRestriction,children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),f.push(_({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:`devices.${d}.type`,children:"Type"}),inherited:e.jsx(s.Select,{name:`devices.${d}.type`,id:`devices.${d}.type`,className:"u-no-margin--bottom",onBlur:t.handleBlur,onChange:R=>{w(t),t.setFieldValue(`devices.${d}`,{type:R.target.value,name:j.name})},value:j.type,options:[{label:"Infiniband (Containers only)",value:"infiniband",disabled:c},{label:"PCI (VMs only)",value:"pci",disabled:o},{label:"TPM",value:"tpm"},{label:"Unix Block (Containers only)",value:"unix-block",disabled:c},{label:"Unix Char (Containers only)",value:"unix-char",disabled:c},{label:"Unix Hotplug (Containers only)",value:"unix-hotplug",disabled:c},{label:"USB",value:"usb"}],disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""})),P.forEach(R=>{const $=`devices.${d}.${R.key}`,k=j[R.key];R.key!=="name"&&f.push(_({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:$,children:ce(R.key)}),inherited:e.jsx(s.Input,{name:$,id:$,onBlur:t.handleBlur,onChange:ne=>{w(t),t.handleChange(ne)},value:k,type:"text",placeholder:R.default,help:e.jsx(Ie,{description:R.shortdesc}),helpClassName:"configuration-help",className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction},`${$}-${g}`),override:""}))})}),e.jsxs(pe,{className:"device-form",children:[e.jsx(s.Input,{type:"submit",hidden:!0,value:"Hidden input"}),x.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited devices"}),e.jsx(U,{rows:x})]}),p&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom devices"}),e.jsx(U,{rows:f})]}),e.jsxs(s.Button,{onClick:()=>{w(t),v()},type:"button",hasIcon:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Attach custom device"})]})]})},Ma=({onSelect:t,disabledReason:a})=>e.jsxs(s.Button,{onClick:t,type:"button",hasIcon:!0,disabled:!!a,title:a,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"New Proxy Device"})]}),ut=(t,a,n,i,o,c)=>{const r=a[i]?.split(":")||[],m=r.length>0?r[0]:"tcp",u=r.length>1?r[1]:"",l=r.length>2?r[2]:"";t.push(_({className:"no-border-top inherited-with-form p-heading--6",configuration:c,inherited:"",override:""})),t.push(_({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:`devices.${n}.${i}`,children:"Type"}),inherited:e.jsx(s.Select,{id:`devices.${n}.${i}`,onChange:y=>{w(o);const b=y.target.value;if(o.setFieldValue(`devices.${n}.${i}`,`${b}:${u}:${l}`),a.nat==="true"){const N=a.connect?.split(":")||[],v=N.length>1?N[1]:"",p=N.length>2?N[2]:"";o.setFieldValue(`devices.${n}.connect`,`${b}:${v}:${p}`)}},value:m,options:ss,className:"u-no-margin--bottom",disabled:!!o.values.editRestriction||i==="connect"&&a.nat==="true",title:o.values.editRestriction??(a.nat?"This is determined by the listen type when nat mode is enabled":void 0)}),override:""})),t.push(_({className:"no-border-top inherited-with-form",configuration:m==="unix"?e.jsx(s.Label,{forId:`devices.${n}.${i}.unixsocket`,required:!0,children:"Socket path"}):e.jsx(s.Label,{forId:`devices.${n}.${i}.address`,required:!0,children:"Address"}),inherited:m==="unix"?e.jsx(s.Input,{id:`devices.${n}.${i}.unixsocket`,onChange:y=>{w(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`unix:${b}`)},value:u,placeholder:"/<socket_path>",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}):e.jsx(s.Input,{id:`devices.${n}.${i}.address`,onChange:y=>{w(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`${m}:${b}:${l}`)},value:u,placeholder:"127.0.0.1",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}),override:""})),m!=="unix"&&t.push(_({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:`devices.${n}.${i}.port`,required:!0,children:"Port"}),inherited:e.jsx(s.Input,{id:`devices.${n}.${i}.port`,onChange:y=>{w(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`${m}:${u}:${b}`)},value:l,placeholder:"00[-00]",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}),override:""}))},Kn=({formik:t,project:a})=>{const n=s.useNotify(),{data:i=[],isLoading:o,error:c}=G(a);c&&n.failure("Loading profiles failed",c);const r=Fs(t.values,i),m=[];m.push(...r.map(v=>v.key)),m.push(...t.values.devices.map(v=>v.name));const u=()=>{const v=[...t.values.devices],p=t.values.entityType!=="profile"&&t.values.instanceType!=="container";v.push({type:"proxy",name:ue("proxy",1,m),nat:String(p)}),t.setFieldValue("devices",v)},l=t.values.devices.some(v=>v.type==="proxy"),y=(v,p,x,f,h,d,j,g)=>{const C=`devices.${x}.${p}`;return _({className:"no-border-top inherited-with-form",configuration:e.jsx(s.Label,{forId:C,children:v}),inherited:e.jsx(s.Select,{name:C,id:C,onBlur:t.handleBlur,onChange:I=>{w(t),t.setFieldValue(C,I.target.value),j?.(I.target.value)},value:h??"",options:f,help:e.jsx(Ie,{description:d}),helpClassName:"configuration-help",className:"u-no-margin--bottom",disabled:!!g||!!t.values.editRestriction,title:t.values.editRestriction??g},C),override:""})},b=[];r.forEach(v=>{const p=Ce(v.key,t),x=p!==-1,f=t.initialValues.devices.some(g=>g.name===v.key),h=t.values.devices.some(g=>g.name===v.key),d=f&&!h,j=X(t,v.key)||d;b.push(_({className:"no-border-top override-with-form",configuration:e.jsx(J,{name:v.key,hasChanges:j,isDetached:x}),inherited:null,override:x?e.jsxs(s.Button,{appearance:"base",type:"button",title:"Reattach volume",onClick:()=>{w(t),K(p,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(s.Icon,{name:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(s.Button,{disabled:!!t.values.editRestriction,title:t.values.editRestriction,appearance:"base",type:"button",onClick:()=>{w(t),de(v.key,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),b.push(me({project:a,profile:se(v.source),isDetached:x})),Object.keys(v.proxy).forEach(g=>{g==="name"||g==="type"||b.push(B({label:ce(g),inheritValue:v.proxy[g],readOnly:!1,isDeactivated:x}))})});const N=[];return t.values.devices.forEach((v,p)=>{if(v.type!=="proxy")return;const x=t.values.devices[p],f=x.listen?.split(":")||[],h=f.length>0?f[0]:"tcp",d=x.connect?.split(":")||[],j=d.length>1?d[1]:"",g=d.length>2?d[2]:"";N.push(_({className:"no-border-top custom-device-name",configuration:e.jsx(we,{name:x.name,index:p,setName:C=>{w(t),t.setFieldValue(`devices.${p}.name`,C)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(s.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{w(t),K(p,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction??"Detach Proxy",children:[e.jsx(s.Icon,{name:"disconnect"}),e.jsx("span",{children:"Detach"})]})})),N.push(y("Bind","bind",p,[{label:"Select option",value:"",disabled:!0},{label:"Host",value:"host"},{label:"Instance",value:"instance"}],x.bind,"Whether to bind the listen address to the instance or host",C=>{C==="instance"&&t.setFieldValue(`devices.${p}.nat`,void 0)})),N.push(y("NAT mode","nat",p,Ss,x.nat,void 0,C=>{C==="true"&&t.setFieldValue(`devices.${p}.connect`,`${h}:${j}:${g}`)},x.bind==="instance"?"Only host-bound proxies can use NAT":void 0)),ut(N,x,p,"listen",t,"Listen"),ut(N,x,p,"connect",t,"Connect")}),o?e.jsx(s.Spinner,{className:"u-loader",text:"Loading..."}):e.jsxs(pe,{className:"device-form",children:[e.jsx(s.Input,{type:"submit",hidden:!0,value:"Hidden input"}),b.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited Proxy devices"}),e.jsx(U,{rows:b})]}),l&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom Proxy devices"}),e.jsx(U,{rows:N})]}),e.jsx(Ma,{onSelect:()=>{w(t),u()},disabledReason:t.values.editRestriction})]})},qn=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="virtual-machine";return e.jsx(ae,{rows:[F({formik:t,label:"Autostart",name:"boot_autostart",defaultValue:"",readOnlyRenderer:i=>i==="-"?"-":O(i,A),children:e.jsx(s.Select,{options:A})}),F({formik:t,label:"Autostart delay",name:"boot_autostart_delay",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter number",type:"number"})}),F({formik:t,label:"Autostart priority",name:"boot_autostart_priority",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter number",type:"number"})}),F({formik:t,label:"Host shutdown timeout",name:"boot_host_shutdown_timeout",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter number",type:"number"})}),F({formik:t,label:"Boot mode (VMs only)",name:"boot_mode",defaultValue:"",disabled:n,disabledReason:n?"Only available for virtual machines":void 0,children:e.jsx(s.Select,{options:as,disabled:n})}),F({formik:t,label:"Stop priority",name:"boot_stop_priority",defaultValue:"",children:e.jsx(s.Input,{placeholder:"Enter number",type:"number"})})]})},ht=({formik:t,network:a,family:n})=>{if(!a||!a.config)return null;const i=n==="IPv4"?"ipv4.address":"ipv6.address",o=n.toLowerCase(),c=a.config?.[i],r=t.values[o],m=nt(a.type,n==="IPv4"?"ipv4_dhcp":"ipv6_dhcp"),u=nt(a.type,"ipv6_dhcp_stateful"),l=ps(t.values,a,n,m.value,u.value);return l?e.jsx(s.Input,{id:i,label:`${n} address reservation`,type:"text",disabled:!0,help:l,value:"-"}):e.jsx(s.PrefixedIpInput,{id:i,name:i,cidr:c||"",ip:r||"",label:`${n} address reservation`,onIpChange:y=>{t.setFieldValue(o,y)},onBlur:()=>{t.setFieldTouched(o,!0)},error:t.touched[o]?t.errors[o]:void 0,help:n==="IPv6"&&e.jsx(e.Fragment,{})})},Gn=({project:t,formik:a,onSave:n})=>{const i=s.useNotify(),o=Ye(),{data:c=[],isLoading:r}=G(t),{data:m=[],isLoading:u}=_t(t),{data:l=[],isLoading:y}=la(t),b=r||u||y,N=fe(a.values,c),v=a.values.entityType==="instance",p=o?.deviceName,x=a.values.devices.find(S=>S.name===p&&S.type==="nic"),f=Nt(a.values,c),h=f.find(S=>S.key===p),d=o?.panel===ot.createNetworkDevice,j=h&&!x,g=h&&x,C=!!(j||g),I=o.panel===ot.editNetworkDevice,P=ms(a.values,f),R=S=>{if(!S.managed)return!1;const M=I&&(x?.network===S.name||h?.network?.network===S.name),H=P.includes(S.name),Z=a.values.entityType==="profile",ie=S.config["dns.mode"]==="none"||Z;return M||!H||ie},$=m.filter(R),k=S=>{const M=$.find(H=>H.name===S);return Le(M)},ne=N.filter(S=>S!==x?.name),Se=b?Ae({}):Ae({ipv4:le().test("is-valid-ipv4","Please enter a valid IPv4 address",S=>!S||s.isIPv4(S)),ipv6:le().test("is-valid-ipv6","Please enter a valid IPv6 address",S=>!S||vs(S)),...!C&&{name:le().required("Device name is required").min(1,"Name must be at least 1 character long").max(63,"Name must be at most 63 characters long").matches(/^[A-Za-z0-9/\-:_.]+$/,{message:"Name can only contain alphanumeric, forward slash, hyphen, colon, underscore and full stop characters"}).notOneOf(ne,"A device with this name already exists")},network:le().required("Network is required")}),D=gt({enableReinitialize:!0,initialValues:(()=>{const S=$[0]?.name??"",M=k(S).join(",");if(d)return{name:ue("eth",1,N),network:S,acls:M,ipv4:"",ipv6:""};if(j)return{name:h.key,network:h.network?.network||S,acls:Oe(k(h.network?.name||""),Ue(h.network)).join(","),ipv4:"",ipv6:""};const H=x?.network||S,Z=Oe(k(H),Ue(x)).join(",");return{name:x?.name||"",network:H,acls:Z,ipv4:x?.["ipv4.address"]||"",ipv6:x?.["ipv6.address"]||"",security_acls_default_egress_action:x?.["security.acls.default.egress.action"]||"",security_acls_default_ingress_action:x?.["security.acls.default.ingress.action"]||""}})(),validationSchema:Se,onSubmit:S=>{const M=S.acls?S.acls.split(","):[],H=Le($.find(oe=>oe.name===S.network)),Z=M.filter(oe=>!H.includes(oe)),ie={name:S.name,type:"nic",network:S.network,"security.acls":Z.length>0?Z.join(","):void 0,"ipv4.address":S.ipv4||void 0,"ipv6.address":S.ipv6||void 0,"security.acls.default.egress.action":S.security_acls_default_egress_action||void 0,"security.acls.default.ingress.action":S.security_acls_default_ingress_action||void 0},Lt=p,{devices:Pe}=a.values,Xe=Pe.findIndex(oe=>oe.name===Lt);let ve;Xe!==-1?(ve=[...Pe],ve[Xe]=ie):ve=[...Pe,ie],a.setFieldValue("devices",ve),n?.(),o.clear()}}),T=()=>{if($.length===0)return"No available networks found.";if(D.touched.network)return D.errors.network},q=()=>d?"Create network device":j?"Create override":g?"Edit override":"Edit network device",L=$.find(S=>S.name===D.values.network),_e=k(D.values.network),$t=D.values.acls?D.values.acls.split(","):[],Tt=Array.from(new Set(_e.concat($t))),At=()=>{if(Je(L))return _e.length>0?"Some ACLs are inherited from the network. They cannot be deselected here.":void 0;if(!L||!is.includes(L.type))return"ACLs require an OVN or a bridge network.";const S=e.jsx(pt,{to:`${Ne}/ui/project/${t}/network/${L.name}`,children:"detail page"});return L.type==="bridge"?e.jsxs(e.Fragment,{children:["Instance device ACLs require an OVN network. Manage ACLs for all instances using this network in the ",S,"."]}):e.jsxs(e.Fragment,{children:["Instance device ACLs can be customized. Manage ACLs for all instances using this network in the ",S,"."]})},De=()=>{D.resetForm(),i.clear(),o.clear()};if(ea(De),!b&&!d&&!x&&!h)return e.jsxs(s.SidePanel,{children:[e.jsx(s.SidePanel.Header,{children:e.jsx(s.SidePanel.HeaderTitle,{children:"Device not found"})}),e.jsx(s.SidePanel.Content,{className:"padding--medium",children:e.jsx(s.ScrollableContainer,{dependencies:[i.notification],belowIds:["panel-footer"],children:e.jsxs(s.Notification,{severity:"negative",children:["The device ",p&&e.jsx("strong",{children:p})," could not be found. It may have been deleted or the URL is incorrect."]})})}),e.jsx(s.SidePanel.Footer,{className:"u-align--right",children:e.jsx(s.Button,{appearance:"base",onClick:De,children:"Close"})})]});const Bt=()=>({Egress:D.values.security_acls_default_egress_action??L?.config["security.acls.default.egress.action"]??"",Ingress:D.values.security_acls_default_ingress_action??L?.config["security.acls.default.ingress.action"]??""}),Ot={Egress:"security_acls_default_egress_action",Ingress:"security_acls_default_ingress_action"};return e.jsxs(s.SidePanel,{children:[e.jsx(s.SidePanel.Header,{children:e.jsx(s.SidePanel.HeaderTitle,{children:q()})}),e.jsx(bt,{className:"u-no-padding"}),e.jsx(s.SidePanel.Content,{className:"u-no-padding",children:e.jsx(s.ScrollableContainer,{dependencies:[i.notification],belowIds:["panel-footer"],children:e.jsxs(s.Form,{onSubmit:D.handleSubmit,stacked:!0,children:[e.jsx(s.Input,{label:"Device name",required:!0,id:"name",...D.getFieldProps("name"),type:"text",placeholder:"Enter device name",error:D.touched.name&&D.errors.name,disabled:C}),e.jsx(oa,{value:D.values.network,setValue:S=>{D.setFieldValue("network",S);const M=k(S);D.setFieldValue("acls",M.join(",")),D.setFieldValue("ipv4",""),D.setFieldValue("ipv6","")},networkList:$,disabled:$.length===0,id:"network",label:"Network",required:!0,error:T()}),v&&L&&e.jsxs(e.Fragment,{children:[e.jsx(ht,{formik:D,network:L,family:"IPv4"}),e.jsx(ht,{formik:D,network:L,family:"IPv6"})]}),e.jsx(na,{project:t,selectedAcls:Tt,setSelectedAcls:S=>{D.setFieldValue("acls",S.join(","))},inheritedAcls:_e,canSelectManualAcls:Je(L),help:At(),label:"Access Control Lists",availableAcls:l}),e.jsx(ia,{onChange:(S,M)=>{D.setFieldValue(S,M)},values:Bt(),disabled:D.values.acls?.length===0||L?.type!==ns,directionField:Ot})]})})}),e.jsxs(s.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(s.Button,{appearance:"base",onClick:De,type:"button",children:"Cancel"}),e.jsx(s.ActionButton,{appearance:"positive",loading:D.isSubmitting,disabled:b||!D.isValid,onClick:()=>{D.submitForm()},type:"submit",children:"Apply changes"})]})]})};export{qn as B,ra as C,On as D,Un as G,En as I,Mn as M,Ln as N,kn as O,Dn as P,Tn as R,Pn as S,Fn as U,Bn as a,Na as b,Kn as c,Vn as d,$n as e,Gn as f,An as h};

Youez - 2016 - github.com/yon3zu
LinuXploit