"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{33785:function(e,s,a){a.r(s),a.d(s,{NewWorkspace:function(){return p}});var t=a(85893),r=a(67294),c=a(11163),l=a(41664),n=a.n(l),i=a(5152),o=a.n(i),m=a(17324),d=a(30803),x=a(42557),h=a(29749),u=a(37673);let k=o()(()=>Promise.all([a.e(739),a.e(798),a.e(850),a.e(683),a.e(329),a.e(243),a.e(899)]).then(a.bind(a,63195)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[63195]},ssr:!1});function p(){(0,c.useRouter)();let[e,s]=(0,r.useState)(""),[a,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)({}),[p,w]=(0,r.useState)(!0);(0,r.useEffect)(()=>{N()},[]);let N=async()=>{try{let e=await (0,m.getWorkspaces)();o(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{w(!1)}},b=()=>{e.trim()&&!f&&l(!0)},f=e.trim()&&i.hasOwnProperty(e.trim()),j=e.trim()&&!f;return a?(0,t.jsx)(k,{workspaceName:e,isNewWorkspace:!0}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(n(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,t.jsxs)(u.Zb,{className:"max-w-md",children:[(0,t.jsx)(u.Ol,{children:(0,t.jsx)(u.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,t.jsxs)(u.aY,{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(h._,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,t.jsx)(x.I,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&j&&b()}}),f?(0,t.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,t.jsx)(n(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,t.jsx)(d.z,{onClick:b,disabled:!j||p,className:"w-full bg-sky-600 hover:bg-sky-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:p?"Loading...":"Next: Configure Workspace"})]})]})]})}}}]);