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/current/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/current/share/lxd-ui/assets//CreateInstance-CpkTc2si.js
import{r as b,J as Ve,w as st,b as Be,V as Ge,W as me,j as e,d as o,X as De,D as ae,F as nt,x as ot,v as rt,B as it,Y as se,K as xe,s as Ce,c as ye,h as je,e as Se,Z as Fe,q as $e,R as Z,_ as ke,t as te,$ as ze,o as Ke,S as Pe,T as lt,a0 as ct,f as ut,a1 as Ee,a2 as dt}from"./index-C5moRkRM.js";import{u as mt}from"./userKeys-DCvuKatN.js";import{u as pt,c as qe}from"./useInstances-B6o12EBG.js";import{g as gt,l as ht,b as ft,L as le,i as ce,a as ue,c as bt}from"./images-CQST2R8G.js";import{M as Te,Y as ie,I as vt,D as we,N as xt,G as Ct,P as yt,O as jt,R as St,S as Ft,a as It,b as Nt,B as Rt,C as Pt,c as Et,d as Tt,y as wt,o as Lt}from"./YamlSwitch-BMEQ02g-.js";import{P as Ot}from"./ProfileSelector-BEBWQwD6.js";import{u as At,a as Ut,l as _t,c as Mt,m as Vt,i as Bt}from"./useImages-B2pew3-d.js";import{u as Gt}from"./useImageRegistries-CUqZ1QFj.js";import{g as Dt,i as $t,a as be}from"./imageRegistry-DUJSvWII.js";import{b as kt}from"./useClusterGroups-Cie_-_5l.js";import{u as zt}from"./PlacementGroupExplanationTooltip-CDsyUuy1.js";import{u as Ye}from"./useClusterMembers-DYP3yC8I.js";import{P as Kt,C as qt,S as Yt,U as Qt,h as Wt,a as Ht,b as Le,D as Xt,N as Jt,G as Zt,c as ea,O as ta,R as aa,d as sa,I as na,M as oa,B as ra,e as ia,f as la}from"./NetworkDevicePanel-D9XqFCT2.js";import{P as ca}from"./PlacementGroupForm-Bv_Mtswm.js";import{C as Oe}from"./ClusterMemberExplanationTooltip-DgqwBVWT.js";import{C as ua}from"./ClusterGroupExplanationTooltip-BpyFXNg7.js";import{A as da}from"./AutoExpandingTextArea-BtMcH1Et.js";import{S as ma}from"./ScrollableForm-B4FKGNcE.js";import{P as pa}from"./ProgressBar-DkFjDALx.js";import{S as Qe}from"./StoragePoolSelector-B2DFQOGf.js";import{R as de}from"./ResourceLabel-5vQU6ndJ.js";import{I as Ie}from"./InstanceRichChip-maOU00Yu.js";import{C as ga}from"./ClusterMemberSelector-BPvr-eqW.js";import{I as ha}from"./InstanceExplanationTooltip-Bvex_VST.js";import{r as fa,u as ba,s as va,c as xa,b as Ca,m as ya,a as ja,d as Sa,e as Fa,f as Ia,i as Na}from"./instanceAndProfilePayloads-OWzzIEo8.js";import{B as Ra}from"./BaseLayout-CVDACG-R.js";import{F as Pa}from"./FormFooterLayout-CeiFxYRr.js";import{Y as Ea}from"./NetworkDefaultACLSelector-CRhN8t5d.js";import{u as Ta,I as wa}from"./devices-DziiOcJy.js";import{u as La,p as Ae}from"./useEscCallback-CiLQokzn.js";import"./promises-DrIa_NWl.js";import"./index-BCn5QfZZ.js";import"./FormMenuItem-C57SBRlg.js";import"./ProfileExplanationTooltip-CikfuDsk.js";import"./ExplanationTooltip-AfbgOckm.js";import"./image-registries-CGiwo-wc.js";import"./cluster-members-B9SkLa7e.js";import"./scroll-BSkJfxH1.js";import"./ProfileRichChip-DiaW3-Ut.js";import"./ResourceLink-CSSa-WON.js";import"./ProfileResourceLimits-l412cqLM.js";import"./ItemName-Dt16GXN3.js";import"./RichTooltipTable-D64CU4ks.js";import"./usedBy-DXaW3nP7.js";import"./resourceDetails-XsDjMA3V.js";import"./storageVolume-D_kSLHXQ.js";import"./storageBucket-Dt08U0oy.js";import"./TruncatedList-BLaVrNb3.js";import"./options-DGWNjuoa.js";import"./ConfigurationTable-CbP4ksvx.js";import"./ConfigFieldDescription-qFQi1Efr.js";import"./useStoragePools-Crzn42fh.js";import"./useConfigOptions-BxC1oiVQ.js";import"./ScrollableConfigurationTable-Co066DBV.js";import"./StorageVolumeForm-CGooyDb1.js";import"./DiskSizeSelector-T95OK-_Q.js";import"./StoragePoolSize-BVlyAxMa.js";import"./Meter-BW_a3lG4.js";import"./ProjectRichChip-CJO1yxV_.js";import"./StoragePoolExplanationTooltip-CY366rOX.js";import"./snapshots-DbU7kFr9.js";import"./useResources-5hLrDJjf.js";import"./formChangeCount-DmPjPAAr.js";import"./StoragePoolRichChip-DkAfThM9.js";import"./projects-BYXh-TO0.js";import"./useVolumes-B6TAUFFs.js";import"./storage-volumes-tZVWU3jH.js";import"./BackLink-CIO3yW-G.js";import"./CustomIsoExplanationTooltip-D4c8NHJP.js";import"./useNetworks-CeA2QAgG.js";import"./ExpandableList-Z2D161-q.js";import"./NetworkRichChip-C-nl3r3p.js";import"./NetworkSelector-C5MLjtvJ.js";import"./useNetworkAcls-B32adf6l.js";import"./network-acls-1vYkJB4_.js";import"./InstanceStatus-BeAPw0ld.js";import"./ConfirmationCheckbox-DamTlu4y.js";const J="any",Ue="container",_e="virtual-machine",ve="view:builtin-and-local",Oa=({onSelect:t,onClose:c})=>{const[i,p]=b.useState(""),[l,r]=b.useState(""),[f,y]=b.useState(""),[h,C]=b.useState("amd64"),[S,P]=b.useState(void 0),[L,O]=b.useState(J),[F,A]=b.useState(ve),[_,B]=b.useState(""),[G,M]=b.useState(!1),[g,U]=b.useState(!1),{project:D}=Ve(),w=st(1090),{data:n,isLoading:E}=Be(),{hasImageRegistries:u}=Ge(),{project:j,isLoading:d}=me(),{data:q=[],error:Y,isLoading:I,isSuccess:v}=Gt(u),s=E||u&&(d||j===void 0||!v),m=F===ve,T=m?void 0:Dt(F),{data:N,isLoading:k,error:V}=At(q,T,!u||v),{data:z=[],isLoading:pe}=Ut(D??"default",m),ne=[...new Set([Y?.message,V?.message,N?.error].filter(Boolean))].join(". ");ne!==_&&(B(ne),M(!1));const oe=k||pe||E||I||u&&d,He=gt(n?.environment?.architectures??[]),Xe=m?z.map(ht).sort(ft):[],Q=oe?[]:Xe.concat(N?.images??[]).filter(a=>He.includes(a.arch)),re=Q.length>0,Je=a=>{A(a),r(""),y(""),O(J),B(""),M(!1)},W=[{label:"Built-in & local",value:ve}];if(u){const a=q.filter(x=>$t(x,j)).sort((x,ee)=>x.name.localeCompare(ee.name)),X=a.filter(x=>x.builtin),$=a.filter(x=>!x.builtin);$.length>0&&(W.push({label:e.jsx("strong",{className:"image-registry-category",children:"Custom registries"}),text:"Custom registries",value:"category:custom",disabled:!0}),W.push(...$.map(x=>({label:x.name,value:be(x.name)}))),W.push({label:e.jsx("strong",{className:"image-registry-category",children:"Built-in registries"}),text:"Built-in registries",value:"category:builtin",disabled:!0})),W.push(...X.map(x=>({label:x.name,value:be(x.name)})))}else W.push(..._t.map(a=>({label:a.label,value:be(a.server)})));const H=[...new Set(Q.map(a=>a.arch))].filter(a=>a!=="").sort(),ge=H.map(a=>({label:a,value:a}));ge.length===0&&ge.push({label:oe?"Loading architectures...":"No architectures available",value:""});const Ze=[...new Set(Q.map(a=>a.variant))].sort();!oe&&!H.includes(h)&&H.length>0&&C(H[0]);const Ne=(a,X=()=>!0)=>{const $=[...new Set(Q.filter(X).map(a))].sort().map(x=>({label:x,value:x}));return $.unshift({label:"Any",value:""}),$},et=Q.filter(a=>{const X=a.server===le;return S===_e&&ce(a)||S===Ue&&ue(a)||h!==a.arch&&!X||L!==J&&L!==a.variant||l&&a.os!==l||f&&a.release!==f?!1:i?a.aliases.toLowerCase().includes(i)||a.arch.toLowerCase().includes(i)||a.os.toLowerCase().includes(i)||a.release.toLowerCase().includes(i):!0}).map(a=>{const $=a.type?a.type:ue(a)?_e:ce(a)?Ue:"all",x=K=>{K.stopPropagation(),t(a,a.type??S)},ee=a.os==="Ubuntu"&&a.release_title&&!a.release.includes(a.release_title)?a.release_title:a.release,he=a.os==="Ubuntu"&&a.release_title&&!a.variant&&!a.release.includes(a.release_title)?a.release:a.variant,at=()=>{let K="Custom";!a.cached&&a.created_at&&(K="Local"),a.registryName&&(K=a.registryBuiltIn?a.registryName.split("-").map(nt).join(" "):a.registryName);const fe=["images","ubuntu","ubuntu-minimal",""].includes(a.registryName??"");return a.server===Mt&&fe&&(K="Ubuntu"),a.server===Vt&&fe&&(K="Ubuntu Minimal"),a.server===Bt&&fe&&(K="LXD Images"),K};return{key:$+a.os+ee+he+a.server+a.fingerprint+a.registryName,className:"u-row",columns:[{content:a.os,role:"rowheader","aria-label":"Distribution",onClick:x},{content:ee,role:"cell","aria-label":"Release",onClick:x},{content:he,role:"cell","aria-label":"Variant",onClick:x},{content:$,role:"cell","aria-label":"Type",onClick:x},{content:a.aliases.split(",").pop(),title:a.aliases.split(",").pop(),role:"cell","aria-label":"Alias",onClick:x},{content:at(),role:"cell","aria-label":"Source",onClick:x},{content:a.cached?"Cached":"Remote",role:"cell","aria-label":"Cached",onClick:x},{content:e.jsx(o.Button,{onClick:x,type:"button",dense:!w,className:"u-no-margin--bottom",appearance:a.cached||a.server===bt?"positive":"default",children:"Select"}),role:"cell","aria-label":"Action",onClick:x}],sortData:{os:a.os.toLowerCase(),release:ee.toLowerCase(),variant:he?.toLowerCase(),type:$,alias:a.aliases,cached:a.cached?"Cached":"Remote"}}}),tt=[{content:"Distribution",sortKey:"os"},{content:"Release",sortKey:"release"},{content:"Variant",sortKey:"variant"},{content:"Type",sortKey:"type"},{content:"Alias",sortKey:"alias"},{content:"Source"},{content:"Cached",sortKey:"cached"},{content:"","aria-label":"Actions"}],Re=e.jsxs("div",{className:"image-select-filters",children:[e.jsx(o.CustomSelect,{id:"image-registry",label:"Registry",name:"registry",onChange:Je,options:W,value:F,disabled:s}),e.jsx(o.Select,{label:"Distribution",name:"distribution",onChange:a=>{r(a.target.value),y("")},options:Ne(a=>a.os),value:l,disabled:!re}),e.jsx(o.Select,{label:"Release",name:"release",onChange:a=>{y(a.target.value)},options:Ne(a=>a.release,a=>a.os===l),value:f,disabled:!re||l===""}),e.jsx(o.Select,{label:"Variant",name:"variant",onChange:a=>{O(a.target.value)},options:[{label:"Any",value:J}].concat(Ze.filter(a=>!!a).map(a=>({label:a??"",value:a??""}))),value:L,disabled:!re}),e.jsx(o.Select,{label:"Architecture",name:"architecture",onChange:a=>{C(a.target.value)},options:ge,value:H.length>0?h:"",disabled:H.length===0}),e.jsx(o.Select,{label:"Type",name:"type",onChange:a=>{P(a.target.value===J?void 0:a.target.value)},options:[{label:"Any",value:J},...De],value:S??"",disabled:!re})]});return e.jsx(o.Modal,{close:c,title:"Select base image",className:"image-select-modal",children:e.jsxs(o.Row,{className:"u-no-padding--left u-no-padding--right",children:[e.jsx(o.Col,{size:3,className:"u-hide--small u-hide--medium",children:Re}),e.jsxs(o.Col,{size:9,small:12,medium:12,children:[e.jsxs("div",{className:"image-select-header",children:[_&&!G?e.jsx(o.Notification,{severity:"negative",title:"Failed loading images",onDismiss:()=>{M(!0)},children:_}):e.jsx("div",{children:e.jsx(o.SearchBox,{autoFocus:!0,className:"search-image",name:"search-image",type:"text",onChange:a=>{p(a.toLowerCase()),r(""),y("")},placeholder:"Search an image"})}),e.jsx(o.Button,{type:"button",hasIcon:!0,className:"image-filter-toggle u-no-margin--bottom u-hide--large","aria-expanded":g,"aria-label":g?"Hide filters":"Show filters",onClick:()=>{U(a=>!a)},children:e.jsx(ae,{icon:"filter"})})]}),w&&g&&Re,e.jsx("div",{className:"image-list",children:e.jsx(o.ScrollableTable,{dependencies:[Q],tableId:"image-selector-table",children:e.jsx(o.MainTable,{id:"image-selector-table",className:"table-image-select",emptyStateMsg:oe?e.jsx(o.Spinner,{className:"u-loader",text:"Loading images..."}):"No matching images found",headers:tt,rows:et,paginate:null,responsive:!0,sortable:!0})})})]})]})})},Aa=({onSelect:t})=>{const{openPortal:c,closePortal:i,isOpen:p,Portal:l}=o.usePortal(),r=(f,y)=>{i(),t(f,y)};return e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{appearance:"positive",onClick:c,type:"button",id:"select-image",children:e.jsx("span",{children:"Browse images"})}),p&&e.jsx(l,{children:e.jsx(Oa,{onClose:i,onSelect:r})})]})},R={AUTO:"auto",CLUSTER_GROUP:"clusterGroup",CLUSTER_MEMBER:"clusterMember",PLACEMENT_GROUP:"placementGroup"},Ua=t=>t.target?.startsWith(se)?R.CLUSTER_GROUP:t.placementGroup?R.PLACEMENT_GROUP:t.target?R.CLUSTER_MEMBER:R.AUTO,_a=t=>t?.startsWith(se)?t.split(se)[1]:"",Me=t=>!t||t.startsWith(se)?"":t,Ma=({formik:t})=>{if(!ot())return e.jsx(e.Fragment,{});const{canOverrideClusterTargetRestriction:i}=rt(),{project:p}=me(),l=Ua(t.values),r=b.useRef(null),f=b.useRef(null),y=b.useRef(null),{data:h=[],isLoading:C}=kt(),S=p?.config.restricted==="true",P=p?.config["restricted.cluster.groups"],L=h.filter(u=>u.members.length<1?!1:S&&P?P.includes(u.name):!0).map(u=>({label:e.jsxs("div",{className:"label",children:[e.jsx("span",{className:"name",children:u.name}),e.jsx("span",{className:"members",children:u.members.length})]}),text:`${u.name} (${u.members.length} ${it("member",u.members.length)})`,value:u.name})),{data:O=[]}=Ye(),F=O.map(u=>({label:u.server_name,value:u.server_name})),{data:A=[]}=zt(p?.name??"default"),_=()=>{t.setFieldValue("target",void 0),t.setFieldValue("placementGroup",void 0)},B=u=>{t.setFieldValue("target",`${se}${u}`),t.values.placementGroup&&t.setFieldValue("placementGroup",void 0)},G=u=>{t.setFieldValue("target",u),t.values.placementGroup&&t.setFieldValue("placementGroup",void 0)},M=u=>{t.setFieldValue("placementGroup",u),t.values.target&&t.setFieldValue("target",void 0)},g=A.find(u=>u.name===t.values.placementGroup),U=g&&g.used_by.length===0&&g.config.policy===ca,D=p?.config["restricted.cluster.target"],w=S&&!i()&&(D==="block"||D===void 0),n=t.values.targetSelectedByVolume;if(C)return e.jsx(o.Spinner,{className:"u-loader",text:"Loading..."});if(n)return e.jsx(o.Input,{id:"clusterMember",label:e.jsx(Oe,{children:"Cluster member"}),value:t.values.target,disabled:!0,help:"Member is determined by the selected ISO volume and can't be changed.",type:"text"});const E=t.values.image?void 0:"Please select an image before adding a placement group";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"instance-target-selector",children:[e.jsx(o.Select,{id:"target",label:"Target",wrapperClassName:"select-input",value:l,options:[{label:"Auto",value:R.AUTO},{label:"Cluster group",value:R.CLUSTER_GROUP,disabled:L.length===0},{label:"Cluster member",value:R.CLUSTER_MEMBER,disabled:F.length===0||w},{label:"Placement group",value:R.PLACEMENT_GROUP}],onChange:u=>{const j=u.target.value;j===R.AUTO&&_(),j===R.CLUSTER_GROUP&&(B(L[0].value),setTimeout(()=>f.current?.open(),100)),j===R.CLUSTER_MEMBER&&(G(F[0].value),setTimeout(()=>r.current?.open(),100)),j===R.PLACEMENT_GROUP&&(M(A[0]?.name??"-"),A.length>0&&setTimeout(()=>y.current?.open(),100))},disabled:!t.values.image,error:l===R.PLACEMENT_GROUP&&A.length===0?"No placement groups found for this project.":"",title:E}),l===R.CLUSTER_GROUP&&e.jsx(o.CustomSelect,{id:"clusterGroup",label:e.jsx(ua,{children:"Cluster group"}),wrapperClassName:"select-input",dropdownClassName:"instance-target-dropdown",selectRef:f,onChange:B,value:_a(t.values.target),options:L,header:e.jsxs("div",{className:"header",children:[e.jsx("span",{className:"name",children:"Name"}),e.jsx("span",{className:"members",children:"Members"})]}),disabled:!t.values.image}),l===R.CLUSTER_MEMBER&&e.jsx(o.CustomSelect,{id:"clusterMember",label:e.jsx(Oe,{children:"Cluster member"}),wrapperClassName:"select-input",dropdownClassName:"instance-target-dropdown",selectRef:r,onChange:G,value:Me(t.values.target),options:F,disabled:!t.values.image}),l===R.PLACEMENT_GROUP&&e.jsx(Kt,{value:t.values.placementGroup,setValue:M,project:p?.name??"default",ref:y,disabled:!t.values.image,profileNames:t.values.profiles,isCreateInstance:!0}),U&&e.jsx(o.CustomSelect,{id:"clusterMember",label:"Anchor",wrapperClassName:"select-input",dropdownClassName:"instance-target-dropdown",selectRef:r,onChange:u=>{const j=u??void 0;t.setFieldValue("target",j)},value:Me(t.values.target),options:[{label:"Auto",value:""}].concat(...F),disabled:!t.values.image,help:"Cluster member to anchor the placement group"})]}),l===R.AUTO&&e.jsx("p",{className:"p-form-help-text",children:"LXD automatically selects a cluster member for the instance, unless a target is specified."})]})},Va=({onSelect:t})=>{const{openPortal:c,closePortal:i,isOpen:p,Portal:l}=o.usePortal(),r=(f,y)=>{i(),t(f,y)};return e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{onClick:c,type:"button",id:"select-custom-iso",children:e.jsx("span",{children:"Use custom ISO"})}),p&&e.jsx(l,{children:e.jsx(qt,{onClose:i,onSelect:r})})]})},We=({value:t,onChange:c})=>e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"file-type",children:"Select upload file type"}),e.jsxs("div",{id:"file-type",children:[e.jsx("div",{className:"u-sv1",children:e.jsx(o.RadioInput,{label:"LXD backup archive (.tar.gz)",checked:t==="instance-backup",onChange:()=>{c("instance-backup")}})}),e.jsx("div",{className:"u-sv3",children:e.jsx(o.RadioInput,{label:e.jsxs("span",{children:["External format (.qcow2, .vmdk,"," ",e.jsx("abbr",{title:".qcow, .vdi, .vhdx",children:"etc..."}),")"]}),checked:t==="external-format",onChange:()=>{c("external-format")}})})]})]}),Ba=({close:t,uploadState:c,setUploadState:i,fileType:p,setFileType:l,defaultInstanceName:r})=>{const{project:f,isLoading:y}=me(),h=xe(),C=o.useToastNotification(),S=o.useNotify(),P=Ce(),L=ye(),[O,F]=b.useState(null),A=b.useState(null),_=n=>{const E=`${Z}/ui/project/${encodeURIComponent(f?.name??"")}/instance/${encodeURIComponent(n)}`,u=e.jsxs(e.Fragment,{children:["Created instance"," ",e.jsx(Ie,{instanceName:n,projectName:f?.name??""}),"."]}),j=[{label:"Configure",onClick:async()=>L(`${E}/configuration`)}];C.success(u,j)},B=n=>{C.failure("Instance creation failed.",new Error(n))},G=()=>{P.invalidateQueries({predicate:n=>n.queryKey[0]===te.instances})},M=n=>{const E=new AbortController;F(E),pt(n.instanceFile,n.name,f?.name,n.pool,i,E).then(u=>{C.info(e.jsxs(e.Fragment,{children:["Upload completed. Now creating instance"," ",e.jsx(de,{bold:!0,type:"instance",value:n.name}),"."]})),h.set(u.metadata.id,()=>{_(n.name)},B,G),U(),L(`${Z}/ui/project/${encodeURIComponent(f?.name??"")}/instances`)}).catch(u=>{const j=new Error(u.response?.data.error);S.failure("Instance upload failed",j),g.setSubmitting(!1),i(null)})},g=je({initialValues:{name:r||"",pool:"",instanceFile:null},validateOnMount:!0,validationSchema:Se().shape({name:Fe(f?.name||"",A).optional()}),onSubmit:M}),U=b.useCallback(()=>{O?.abort(),i(null),F(null),g.resetForm(),t(),S.clear()},[O,g.resetForm,t,S]),D=async n=>{const{onChange:E}=g.getFieldProps("instanceFile");if(E(n),n.currentTarget.files){const u=n.currentTarget.files[0];if(await g.setFieldValue("instanceFile",u),!r){const j=ke(u.name,"-import");await g.setFieldValue("name",j),await g.validateField("name"),g.setFieldTouched("name",!0,!0),g.errors.name||g.setFieldError("name",void 0)}}},w=g.values.instanceFile?"":"Please select a file before adding custom configuration.";return e.jsxs(e.Fragment,{children:[e.jsxs(o.Form,{onSubmit:g.handleSubmit,className:$e({"u-hide":c}),children:[e.jsx(We,{value:p,onChange:l}),e.jsx(o.Input,{id:"instance-file",name:"instanceFile",type:"file",accept:".tar, application/gzip, application/x-bzip, application/x-xz, application/x-lzma, application/x-squashfs, application/x-qcow2, application/zstd",label:"Local file",labelClassName:"u-hide",onChange:n=>{D(n)}}),e.jsx(o.Input,{...g.getFieldProps("name"),id:"upload-instance-name",type:"text",label:"New instance name",placeholder:"Enter name",error:g.touched.name?g.errors.name:null,disabled:!!w,title:w}),e.jsx(Qe,{value:g.values.pool,setValue:n=>{g.setFieldValue("pool",n)},selectProps:{id:"pool",label:"Root storage pool",disabled:y||!!w,title:w}})]}),e.jsxs("footer",{className:"p-modal__footer",id:"modal-footer",children:[e.jsx(o.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:U,children:"Cancel"}),e.jsx(o.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:g.isSubmitting||!!c,disabled:!g.isValid||g.isSubmitting||y||!g.values.instanceFile,onClick:()=>{g.submitForm()},children:"Upload and create"})]})]})},Ga=t=>[{value:"x86_64",label:"x86_64"},{value:"aarch64",label:"aarch64"},{value:"ppc64le",label:"ppc64le"},{value:"s390x",label:"s390x"}].filter(i=>t.includes(i.value)),Da=t=>{const c=t.file?.size||0,i=[];t.formatConversion&&i.push("format"),t.virtioConversion&&i.push("virtio");const p={source:{type:"conversion",mode:"push",conversion_options:i,source_disk_size:c},devices:{root:{path:"/",type:"disk",pool:t.pool}},type:"virtual-machine",name:t.name,architecture:t.architecture};return JSON.stringify(p)},$a=(t,c,i,p)=>{const r=new WebSocket(t);return r.onopen=()=>{const f=new FileReader;let y=0;const h=()=>{if(!c)return;const C=c.slice(y,y+1048576);if(!C.size){r.close(1e3,"File upload complete");return}f.readAsArrayBuffer(C)};f.onload=C=>{if(!c||r.readyState===WebSocket.CLOSING||r.readyState===WebSocket.CLOSED)return;const S=C.target?.result;let P;S&&typeof S=="string"?P=new TextEncoder().encode(S).buffer:P=S,r.send(P),y+=P.byteLength,i&&i(y,c.size),setTimeout(h,0)},f.onerror=C=>{p&&p(C.target?.error?C.target.error:new Error("Failed to read read file"))},h()},r},ka=async t=>new Promise(c=>{const i=new FileReader;i.onload=p=>{const l=p.target?.result,r=new Uint8Array(l);r[510]===85&&r[511]===170?c(!0):c(!1)},i.onerror=()=>{c(!1)},i.readAsArrayBuffer(t.slice(0,512))}),za=({close:t,uploadState:c,setUploadState:i,fileType:p,setFileType:l,defaultInstanceName:r})=>{const{project:f,isLoading:y}=me(),h=b.useState(null),[C,S]=b.useState(),[P,L]=b.useState(""),O=o.useToastNotification(),F=o.useNotify(),A=ye(),_=xe(),B=Ce(),{data:G}=Be(),{data:M=[]}=Ye(),g=(v,s,m)=>{i({percentage:Math.floor(s/m*100),loaded:s,total:m}),s===m&&(t(),O.info(e.jsxs(e.Fragment,{children:["Upload completed. Now creating instance"," ",e.jsx(de,{bold:!0,type:"instance",value:v}),"."]})),A(`${Z}/ui/project/${encodeURIComponent(f?.name??"")}/instances`))},U=v=>{F.failure("File upload failed.",v),i(null)},D=()=>{C&&C.readyState===WebSocket.OPEN&&C.close(1e3,"cancel upload"),_.remove(P)},w=v=>{const s=`${Z}/ui/project/${encodeURIComponent(f?.name??"")}/instance/${encodeURIComponent(v)}`,m=e.jsxs(e.Fragment,{children:["Created instance"," ",e.jsx(Ie,{instanceName:v,projectName:f?.name??""}),"."]}),T=[{label:"Configure",onClick:async()=>A(`${s}/configuration`)}];O.success(m,T)},n=v=>{O.failure("Instance creation failed.",new Error(v))},E=()=>{B.invalidateQueries({predicate:v=>v.queryKey[0]===te.instances})},u=v=>{qe(Da(v),f?.name||"",v.member).then(s=>{const m=s.metadata.id,T=s.metadata.metadata?.fs??"",N=ze(s.metadata),V=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${Z}/1.0/operations/${encodeURIComponent(m)}/websocket?secret=${encodeURIComponent(T)}`,z=$a(V,d.values.file,g.bind(null,N),U);S(z),L(m),_.set(m,()=>{w(N)},n,E)}).catch(s=>{F.failure("Instance creation failed.",s),d.setSubmitting(!1),i(null)})},j=Ga(G?.environment?.architectures||[]),d=je({initialValues:{name:r||"",pool:"",member:M?.[0]?.server_name,file:null,formatConversion:!0,virtioConversion:!1,architecture:j[0]?.value},enableReinitialize:!0,validateOnMount:!0,validationSchema:Se().shape({name:Fe(f?.name||"",h).optional()}),onSubmit:u}),q=async v=>{const{onChange:s}=d.getFieldProps("file");if(s(v),v.currentTarget.files){const m=v.currentTarget.files[0];if(await d.setFieldValue("file",m),!r){const N=ke(m.name,"-import");await d.setFieldValue("name",N),await d.validateField("name"),d.setFieldTouched("name",!0,!0),d.errors.name||d.setFieldError("name",void 0)}const T=await ka(m);await d.setFieldValue("formatConversion",!T)}},Y=b.useCallback(()=>{d.resetForm(),t(),F.clear(),D()},[d.resetForm,t,F,C]),I=d.values.file?"":"Please select a file before adding custom configuration.";return e.jsxs(e.Fragment,{children:[e.jsxs(o.Form,{onSubmit:d.handleSubmit,className:$e({"u-hide":c}),children:[e.jsx(We,{value:p,onChange:l}),e.jsx(o.Input,{id:"image-file",name:"file",type:"file",label:"Local file",accept:".img, .qcow, .qcow2, .vdi, .vhdx, .vmdk",labelClassName:"u-hide",onChange:v=>{q(v)}}),e.jsx(o.Input,{...d.getFieldProps("name"),id:"upload-instance-name",type:"text",label:"New instance name",placeholder:"Enter name",error:d.touched.name?d.errors.name:null,disabled:!!I,title:I}),e.jsx(ga,{...d.getFieldProps("member"),id:"member",label:"Target cluster member"}),e.jsx(Qe,{value:d.values.pool,setValue:v=>{d.setFieldValue("pool",v)},selectProps:{id:"pool",label:"Root storage pool",disabled:!f||!!I,title:I}}),e.jsx(o.Select,{...d.getFieldProps("architecture"),id:"architecture",label:"Image architecture",options:j,disabled:!!I,title:I}),e.jsx("label",{htmlFor:"",children:"Conversion options"}),e.jsx(o.CheckboxInput,{...d.getFieldProps("formatConversion"),label:e.jsxs("span",{title:I,children:["Convert to raw format"," ",e.jsx("span",{title:I||"Can be skipped if the image is already in raw format to speed up the import.",children:e.jsx(ae,{icon:"information"})})]}),disabled:!!I,checked:d.values.formatConversion}),e.jsx(o.CheckboxInput,{...d.getFieldProps("virtioConversion"),label:e.jsxs("span",{title:I,children:["Add Virtio drivers"," ",e.jsx("span",{title:I||"Mandatory, if the image does not have Virtio drivers installed.",children:e.jsx(ae,{icon:"information"})})]}),disabled:!!I,checked:d.values.virtioConversion})]}),e.jsxs("footer",{className:"p-modal__footer",id:"modal-footer",children:[e.jsx(o.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:Y,children:"Cancel"}),e.jsx(o.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:d.isSubmitting||!!c,disabled:!d.isValid||d.isSubmitting||y||!d.values.file,onClick:()=>{d.submitForm()},children:"Upload and create"})]})]})},Ka=({close:t,name:c})=>{const[i,p]=b.useState("instance-backup"),[l,r]=b.useState(null);return e.jsxs(o.Modal,{close:t,className:"upload-instance-modal",title:"Upload instance file",closeOnOutsideClick:!1,children:[e.jsx(Ke,{className:"u-no-padding u-no-margin"}),l&&e.jsxs(e.Fragment,{children:[e.jsx(pa,{percentage:Math.floor(l.percentage)}),e.jsxs("p",{children:[Pe(l.loaded)," loaded of"," ",Pe(l.total??0)]})]}),i==="instance-backup"&&e.jsx(Ba,{close:t,uploadState:l,setUploadState:r,fileType:i,setFileType:p,defaultInstanceName:c}),i==="external-format"&&e.jsx(za,{close:t,uploadState:l,setUploadState:r,fileType:i,setFileType:p,defaultInstanceName:c})]})},qa=({name:t})=>{const{openPortal:c,closePortal:i,isOpen:p,Portal:l}=o.usePortal();return e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{onClick:c,type:"button",children:e.jsx("span",{children:"Upload instance file"})}),p&&e.jsx(l,{children:e.jsx(Ka,{close:i,name:t})})]})},Ya=({formik:t,onSelectImage:c,project:i})=>{const p=()=>{const l=t.values.image;return l?l.variant?.toLocaleLowerCase().includes("desktop")?`${l.os} ${l.release} ${l.aliases.split(",")[0]}`:l.variant==="iso"?`${l.os} - ${l.aliases.split(",")[0]}`:`${l.os} ${l.release} ${l.release_title}`:""};return e.jsxs(ma,{children:[e.jsx(o.Row,{children:e.jsxs(o.Col,{size:12,children:[e.jsx(o.Input,{id:"name",name:"name",type:"text",label:"Instance name",placeholder:"Enter name",onBlur:t.handleBlur,onChange:t.handleChange,value:t.values.name,error:t.touched.name?t.errors.name:null}),e.jsx(da,{id:"description",name:"description",label:"Description",placeholder:"Enter description",onBlur:t.handleBlur,onChange:t.handleChange,value:t.values.description})]})}),e.jsx(o.Row,{children:e.jsxs(o.Col,{size:12,children:[e.jsx(o.Label,{forId:"select-image",required:!0,children:"Base Image"}),e.jsx("div",{className:"p-form__control u-clearfix base-image",children:t.values.image?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"u-text--muted u-truncate u-sv3 image-name",children:p()}),e.jsx(o.Button,{appearance:"base",type:"button",onClick:async()=>t.setFieldValue("image",void 0),title:"Clear",hasIcon:!0,children:e.jsx(ae,{icon:"close"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Aa,{onSelect:c}),e.jsx(Va,{onSelect:c}),e.jsx(qa,{name:t.values.name})]})}),e.jsx(o.Select,{id:"instanceType",label:"Instance type",name:"instanceType",onBlur:t.handleBlur,onChange:t.handleChange,options:De,value:t.values.instanceType,disabled:!t.values.image||ce(t.values.image)||ue(t.values.image),title:t.values.image?"":"Please select an image before adding a type"}),e.jsx(Ma,{formik:t})]})}),e.jsx(Ot,{project:i,selected:t.values.profiles,setSelected:l=>{t.setFieldValue("profiles",l)},readOnly:!t.values.image,title:t.values.image?"":"Please select an image before adding profiles"}),e.jsx(Yt,{formik:t,disabledReason:t.values.image?"":"Please select an image before adding SSH Keys"}),e.jsx(Qt,{formik:t,disabledReason:t.values.image?"":"Please select an image before adding user keys"})]})},vn=()=>{const t=xe(),c=lt(),i=ye(),p=o.useToastNotification(),l=o.useNotify(),{project:r}=Ve(),f=Ce(),y=b.useState(null),[h,C]=b.useState(Te),{hasImageRegistries:S}=Ge(),P=La();if(!r)return e.jsx(e.Fragment,{children:"Missing project"});const L=Se().shape({name:Fe(r,y).optional(),instanceType:ut().required("Instance type is required"),limits_memory:ct().test("non-zero","Limit must be greater than 0",s=>s?.value!==0),user_keys:mt}),O=()=>{dt("form-contents","p-bottom-controls")};b.useEffect(O,[h]),o.useListener(window,O,"resize",!0);const F=()=>{f.invalidateQueries({queryKey:[te.instances]}),f.invalidateQueries({queryKey:[te.operations,r]}),f.invalidateQueries({queryKey:[te.projects,r]})},A=(s,m)=>{p.info(e.jsxs(e.Fragment,{children:["Creation for instance"," ",e.jsx(de,{bold:!0,type:m,value:s})," started."]}))},_=s=>{p.success(e.jsxs(e.Fragment,{children:["Created and started instance ",s,"."]})),F()},B=(s,m)=>{p.success(e.jsxs(e.Fragment,{children:["Created instance ",s,".",m]})),F()},G=(s,m,T,N,k)=>{(N==="toast"?p:l).failure("Instance creation failed",s,null,[{label:"Check configuration",onClick:()=>{i(m,{state:{retryFormValues:T,retryFormSection:k}})}}]),F()},M=(s,m)=>{p.info(e.jsxs(e.Fragment,{children:["Instance ",e.jsx(de,{bold:!0,type:m,value:s})," ","creation has begun. The instance will automatically start upon completion."]}))},g=(s,m,T)=>{const N=e.jsx(Ie,{instanceName:s,projectName:r}),k=`${Z}/ui/project/${encodeURIComponent(r)}/instance/${encodeURIComponent(s)}/console`,V=T&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Continue the installation process from its console."}),e.jsxs(o.Button,{onClick:async()=>i(k),hasIcon:!0,children:[e.jsx(ae,{icon:"canvas"}),e.jsx("span",{children:"Open console"})]})]});m?_(N):B(N,V)},{data:U=[],isLoading:D}=Ta(r),w=(s,m=!0)=>{const T=s.yaml?wt(s.yaml):j(s);if(Le(s,U)){C(we);return}const N=c.pathname+c.search;i(Ee(r));const k={...T,start:m};qe(JSON.stringify(k),r,s.target).then(V=>{const z=ze(V.metadata);if(!z)return;m?M(z,s.instanceType):A(z,s.instanceType);const pe=s.image?.server===le;t.set(V.metadata.id,()=>{g(z,m,pe)},ne=>{G(new Error(ne),N,s,"toast",h)})}).catch(V=>{V.message!=="Cancelled"&&G(V,N,s,void 0,h)})},n=je({initialValues:c.state?.retryFormValues??{instanceType:"container",profiles:["default"],devices:[],cloud_init_ssh_keys:[],user_keys:[],readOnly:!1,entityType:"instance",isCreating:!0},validationSchema:L,onSubmit:s=>{w(s)}});b.useEffect(()=>{D||U.find(m=>m.name==="default")||n.setFieldValue("profiles",[])},[D,U]);const E=n.values.image?.server===le,u=(s,m)=>{n.setFieldValue("image",s);const T=n.values.devices.filter(N=>N.type!==wa);if(s.server===le){const N=fa(s);T.push(N)}n.setFieldValue("devices",T),m?n.setFieldValue("instanceType",m):ue(s)?n.setFieldValue("instanceType","virtual-machine"):ce(s)&&n.setFieldValue("instanceType","container"),s.volume?.location&&s.volume.location!=="none"?(n.setFieldValue("target",s.volume?.location),n.setFieldValue("targetSelectedByVolume",!0)):n.setFieldValue("targetSelectedByVolume",void 0)};b.useEffect(()=>{const s=c.state?.selectedImage;s&&u(s,s.type)},[c.state?.selectedImage]),b.useEffect(()=>{c.state?.retryFormSection&&C(c.state.retryFormSection)},[c.state?.retryFormSection]);const j=s=>({...Na(s,S),devices:Ia(s.devices),config:{...Fa(s),...Sa(s),...ja(s),...ya(s),...Ca(s),...xa(s),...va(s),...ba(s),...s.placementGroup&&{"placement.group":s.placementGroup}}}),d=s=>{n.values.yaml&&s!==ie&&n.setFieldValue("yaml",void 0),C(s)},q=()=>{if(c.state?.retryFormSection===ie&&n.values.yaml)return n.values.yaml;const s=j(n.values);return Lt(s)},Y=Wt(n),I=Ht(n),v=!n.isValid||!n.values.image||Y||I;return e.jsxs(Ra,{title:e.jsx(ha,{isConfigVariant:!0,children:"Create an instance"}),contentClassName:"create-instance",children:[e.jsxs(o.Form,{onSubmit:n.handleSubmit,className:"form",children:[h!==ie&&e.jsx(vt,{active:h,setActive:d,isDisabled:!n.values.image,hasDiskError:Y||Le(n.values,U),hasNetworkError:I,formik:n}),e.jsx(o.Row,{className:"form-contents",children:e.jsxs(o.Col,{size:12,children:[e.jsx(Ke,{}),h===Te&&e.jsx(Ya,{formik:n,project:r,onSelectImage:u}),h===we&&e.jsx(Xt,{formik:n,project:r}),h===xt&&e.jsx(Jt,{formik:n,project:r}),h===Ct&&e.jsx(Zt,{formik:n,project:r}),h===yt&&e.jsx(ea,{formik:n,project:r}),h===jt&&e.jsx(ta,{formik:n,project:r}),h===St&&e.jsx(aa,{formik:n}),h===Ft&&e.jsx(sa,{formik:n,setSection:d}),h===It&&e.jsx(na,{formik:n}),h===Nt&&e.jsx(oa,{formik:n}),h===Rt&&e.jsx(ra,{formik:n}),h===Pt&&e.jsx(ia,{formik:n,project:r}),h===ie&&e.jsx(Et,{yaml:q(),setYaml:s=>{n.setFieldValue("yaml",s)},children:e.jsx(Ea,{entity:"instance",docPath:"/instances"})})]})},h)]}),e.jsxs(Pa,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(Tt,{formik:n,section:h,setSection:d,disableReason:n.values.image?void 0:"Please select an image before adding custom configuration"})}),e.jsx(o.Button,{appearance:"base",onClick:async()=>i(c.state?.cancelLocation??Ee(r)),children:"Cancel"}),e.jsx(o.ActionButton,{loading:n.isSubmitting,disabled:v||n.isSubmitting,appearance:E?"positive":"default",onClick:()=>{w(n.values,!1)},children:"Create"}),!E&&e.jsx(o.ActionButton,{appearance:"positive",loading:n.isSubmitting,disabled:v||n.isSubmitting,onClick:()=>{w(n.values)},children:"Create and start"})]}),(P.panel===Ae.editNetworkDevice||P.panel===Ae.createNetworkDevice)&&e.jsx(la,{project:r,formik:n})]})};export{vn as default};

Youez - 2016 - github.com/yon3zu
LinuXploit