import{b,d as $,e as h,h as G,m as P,p as B,q as v,s as L}from"./chunk-25A34CYL.js";import{b as I}from"./chunk-F7TB6D2I.js";import{c as y,d as A}from"./chunk-EMAOG2GJ.js";import"./chunk-CKZXQWC5.js";import{a as w,c as V,g as x,l as X,y as U}from"./chunk-KYG6FTJ2.js";import"./chunk-BE77QZG7.js";import"./chunk-OXZWBTVI.js";import{Ab as i,Bb as r,Cb as _,D as g,L as T,Mb as C,Nb as O,Ob as f,Qa as F,Rb as N,Sb as m,X as u,db as R,fc as M,ib as S,rb as c,rc as k,ta as p,tb as D,wb as E}from"./chunk-5ONOZUNN.js";import"./chunk-C6Q5SG76.js";var j=()=>["/"];function z(l,e){l&1&&(i(0,"spk-form-field")(1,"label",11),f(2,2),r(),_(3,"input",12),r())}var a=new v,d=class l{#t=u(V);#e=u(I);#o=u(y);isRestoring=p(!1);isSecureFile=p(!1);importForm=a.group({config:a.control(""),cmdline:a.control(!1),importMetadata:a.control(!1),direct:a.control(!1),passphrase:a.control("")});selectedFile=p(null);onFileDropped(e){let t=e.target?.files?.item(0);if(t){let n=new FileReader;this.isSecureFile.set(t.type!=="application/json"),n.onload=this.#n.bind(this),n.readAsArrayBuffer(t)}}#n(e){let o=e.target?.result;this.importForm.patchValue({config:this.#r(o)})}#r(e){let o=new Uint8Array(e),t=o.byteLength,n="";for(let s=0;s<t;s++)n+=String.fromCharCode(o[s]);return btoa(n)}submit(){this.isRestoring.set(!0),this.#e.postApiV1BackupsImport({requestBody:this.importForm.value}).pipe(T(e=>this.#e.postApiV1Backups({requestBody:e.data,temporary:!0})),g(()=>this.isRestoring.set(!1))).subscribe({next:e=>{this.#o.navigate(["/restore-draft",e.ID])},error:e=>{this.#t.error(e.message)}})}static \u0275fac=function(o){return new(o||l)};static \u0275cmp=R({type:l,selectors:[["app-restore-from-config"]],decls:16,vars:7,consts:()=>{let e;e=$localize` Restore from config ${"\uFFFD#3\uFFFD"}:START_TAG_DIV:${"\uFFFD#4\uFFFD"}:START_TAG_BUTTON:${"[\uFFFD#5\uFFFD|\uFFFD#7\uFFFD]"}:START_TAG_SPK_ICON:arrow-left${"[\uFFFD/#5\uFFFD|\uFFFD/#7\uFFFD]"}:CLOSE_TAG_SPK_ICON: Back ${"[\uFFFD/#4\uFFFD|\uFFFD/#6\uFFFD]"}:CLOSE_TAG_BUTTON:${"\uFFFD#6\uFFFD"}:START_TAG_BUTTON_1:${"[\uFFFD#5\uFFFD|\uFFFD#7\uFFFD]"}:START_TAG_SPK_ICON:download-simple${"[\uFFFD/#5\uFFFD|\uFFFD/#7\uFFFD]"}:CLOSE_TAG_SPK_ICON: Restore ${"[\uFFFD/#4\uFFFD|\uFFFD/#6\uFFFD]"}:CLOSE_TAG_BUTTON:${"\uFFFD/#3\uFFFD"}:CLOSE_TAG_DIV:`,e=N(e);let o;o=$localize`Select a configuration file`;let t;return t=$localize`Passphrase`,[e,o,t,[1,"actions"],["spk-button","","type","button",1,"outlined",3,"routerLink"],["spk-button","","type","submit",1,"raised","primary",3,"click","disabled"],["autocomplete","off",3,"formGroup"],["spkDragDrop","",3,"fileDropped"],["for","file"],["type","file","accept",".json,.aes",3,"change"],["suffix",""],["for","passphrase"],["type","password","formControlName","passphrase"]]},template:function(o,t){o&1&&(i(0,"header")(1,"h3"),C(2,0),i(3,"div",3)(4,"button",4),_(5,"spk-icon"),r(),i(6,"button",5),m("click",function(){return t.submit()}),_(7,"spk-icon"),r()(),O(),r()(),i(8,"form",6)(9,"spk-form-field",7),m("fileDropped",function(s){return t.onFileDropped(s)}),i(10,"label",8),f(11,1),r(),i(12,"input",9),m("change",function(s){return t.onFileDropped(s)}),r(),i(13,"spk-icon",10),M(14,"upload"),r()(),S(15,z,4,0,"spk-form-field"),r()),o&2&&(F(4),c("routerLink",k(6,j)),F(2),D("loader",t.isRestoring()),c("disabled",t.isRestoring()),F(2),c("formGroup",t.importForm),F(7),E(t.isSecureFile()?15:-1))},dependencies:[L,G,b,$,h,P,B,A,U,X,w,x],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;gap:2rem;padding:3rem}h3[_ngcontent-%COMP%]{font:var(--title-30);display:flex;align-items:center;justify-content:space-between}.actions[_ngcontent-%COMP%]{display:flex;gap:.5rem}form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;max-width:31.25rem}"],changeDetection:0})};export{d as default};
