import{d as s,r as o,j as e,a as c,u as d,N as p}from"./index-lOezWVmi.js";import{N as h}from"./NotificationRow-DdxAfFhk.js";const x=()=>{const i=s.useNotify(),[t,n]=o.useState(""),r=()=>{const a=t.trim().split(/\r?\n|\r|\n/g).at(-1)??"";c(a).then(()=>{location.reload()}).catch(l=>i.failure("Error using token",l))};return e.jsxs(s.Form,{children:[e.jsx(s.Textarea,{id:"token",name:"token",label:"Paste the token from the previous step",placeholder:"Paste your token here",rows:3,onChange:a=>{n(a.target.value)}}),e.jsx(s.Button,{appearance:"positive",disabled:t.length<1,type:"button",onClick:r,children:"Import"})]})},u=()=>{const{isAuthenticated:i,isAuthLoading:t}=d(),n=s.useNotify();return t?e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):i?e.jsx(p,{to:"/ui",replace:!0}):e.jsxs(s.CustomLayout,{mainClassName:"certificate-generate",header:e.jsx("div",{className:"p-panel__header is-sticky",children:e.jsx("h1",{className:"p-panel__title",children:"Add existing certificate"})}),children:[n.notification?e.jsx(h,{}):e.jsx(s.Row,{children:e.jsxs(s.Notification,{severity:"caution",children:["A client certificate must be present and selected in your browser.",e.jsx("br",{})]})}),e.jsx(s.Row,{className:"u-no-margin--left",children:e.jsx(s.Col,{size:12,children:e.jsxs("ol",{className:"p-stepped-list--detailed",children:[e.jsx("li",{className:"p-stepped-list__item",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Create token"})}),e.jsx(s.Col,{size:6,children:e.jsxs("div",{className:"p-stepped-list__content",children:[e.jsx("p",{children:"Generate a token on the command line"}),e.jsx("div",{className:"p-code-snippet",children:e.jsx("pre",{className:"p-code-snippet__block--icon",children:e.jsx("code",{children:"incus config trust add incus-ui"})})})]})})]})}),e.jsx("li",{className:"p-stepped-list__item",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Import"})}),e.jsx(s.Col,{size:6,children:e.jsx("div",{className:"p-stepped-list__content",children:e.jsx(x,{})})})]})}),e.jsx("li",{className:"p-stepped-list__item u-no-margin--bottom",children:e.jsxs(s.Row,{children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-stepped-list__title p-heading--5",children:"Done"})}),e.jsx(s.Col,{size:6,children:e.jsx("div",{className:"p-stepped-list__content",children:e.jsx("p",{children:"Enjoy Incus UI."})})})]})})]})})})]})};export{u as default};
