(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{9993:(e,r,n)=>{"use strict";n.d(r,{g:()=>s});var i=n(7911);let s=(0,i.createServerReference)("78dbb9bb90114fd6df202c0c0a59303b73f21fc8f3",i.callServer,void 0,i.findSourceMapURL,"startTopicAction")},38992:(e,r,n)=>{"use strict";n.d(r,{h:()=>s});var i=n(7911);let s=(0,i.createServerReference)("7010628a78159b1f83a5690a4560f1bb4885d9c35a",i.callServer,void 0,i.findSourceMapURL,"generateTopicTitleAction")},63392:(e,r,n)=>{Promise.resolve().then(n.bind(n,89061)),Promise.resolve().then(n.bind(n,96253)),Promise.resolve().then(n.bind(n,28050)),Promise.resolve().then(n.bind(n,94904)),Promise.resolve().then(n.bind(n,13270)),Promise.resolve().then(n.bind(n,99730)),Promise.resolve().then(n.bind(n,89146)),Promise.resolve().then(n.bind(n,19078)),Promise.resolve().then(n.bind(n,67854)),Promise.resolve().then(n.bind(n,69050)),Promise.resolve().then(n.bind(n,63739)),Promise.resolve().then(n.bind(n,33976)),Promise.resolve().then(n.bind(n,12537)),Promise.resolve().then(n.bind(n,97485)),Promise.resolve().then(n.bind(n,41923)),Promise.resolve().then(n.bind(n,73868)),Promise.resolve().then(n.bind(n,53511)),Promise.resolve().then(n.bind(n,2018)),Promise.resolve().then(n.bind(n,18487)),Promise.resolve().then(n.bind(n,98346)),Promise.resolve().then(n.bind(n,14884)),Promise.resolve().then(n.bind(n,85314)),Promise.resolve().then(n.bind(n,17280)),Promise.resolve().then(n.bind(n,8855)),Promise.resolve().then(n.bind(n,86631)),Promise.resolve().then(n.bind(n,2604)),Promise.resolve().then(n.bind(n,27237)),Promise.resolve().then(n.bind(n,49455)),Promise.resolve().then(n.bind(n,39211)),Promise.resolve().then(n.bind(n,56360)),Promise.resolve().then(n.t.bind(n,54400,23))},89061:(e,r,n)=>{"use strict";n.d(r,{UniversalChatBar:()=>v});var i=n(4624),s=n(99356),t=n(69285),o=n(69709),l=n(95265),a=n(56221),d=n(49411),c=n(9993),m=n(38992),b=n(39121),u=n(63602),h=n(63514);function v(e){var r,n,v;let{spaces:p}=e,f=(0,t.useRouter)(),x=(0,d.c)("app"),[P,g]=(0,s.useState)(null!=(n=null==(r=p[0])?void 0:r.id)?n:""),[w,j]=(0,s.useState)(!1),[,k]=(0,s.useTransition)(),N=(0,s.useRef)(null),S=null!=(v=p.find(e=>e.id===P))?v:p[0];if((0,s.useEffect)(()=>{if(!w)return;let e=e=>{var r;(null==(r=N.current)?void 0:r.contains(e.target))||j(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[w]),!S)return(0,i.jsx)("div",{className:"border-t bg-background",children:(0,i.jsxs)("div",{className:"mx-auto max-w-3xl px-6 py-5 text-center text-xs text-muted-foreground",children:[x("universal.createFirstSpace1")," ",(0,i.jsx)("a",{href:"/onboarding?force=1",className:"underline",children:x("universal.wizardLink")})," ",x("universal.or")," ",(0,i.jsx)("a",{href:"/roots/new",className:"underline",children:x("universal.manualLink")}),"."]})});let L=p.length>1?(0,i.jsxs)("div",{className:"relative",ref:N,children:[(0,i.jsxs)("button",{type:"button",onClick:()=>j(e=>!e),className:"inline-flex items-center gap-1 rounded-full border bg-card/80 px-2 py-0.5 text-[10px] font-medium hover:bg-accent normal-case tracking-normal",title:x("universal.pickSpace"),children:[(0,i.jsx)("span",{className:"text-muted-foreground",children:x("universal.in")}),(0,i.jsx)("span",{children:S.label}),(0,i.jsx)(o.A,{className:"h-3 w-3 text-muted-foreground"})]}),w&&(0,i.jsx)("ul",{className:"absolute bottom-full right-0 mb-1 min-w-[200px] max-h-60 overflow-y-auto rounded-md border bg-popover shadow-lg z-40 py-1",children:p.map(e=>(0,i.jsx)("li",{children:(0,i.jsx)("button",{type:"button",onClick:()=>{g(e.id),j(!1)},className:"block w-full text-left px-3 py-1.5 text-sm hover:bg-accent "+(e.id===S.id?"font-semibold":""),children:e.label})},e.id))})]}):null,y=async e=>await new Promise(r=>{k(async()=>{let n=await (0,c.g)(S.id,e.message,e.attachments);if(!n.ok){a.oR.error(n.error),r(!1);return}(0,h.$d)(h.Zi.topicsChanged(S.id)),e.message.trim()&&(0,m.h)(S.id,n.topicId,e.message).then(e=>{e.ok&&(0,h.$d)(h.Zi.topicsChanged(S.id))}),f.push("/roots/".concat(S.id,"/chat/").concat(n.topicId)),r(!0)})});return(0,i.jsx)(u.E,{label:x("universal.label"),...L?{headerRight:L}:{},children:(0,i.jsx)(b.L,{rootId:S.id,placeholder:x("universal.placeholder"),submitLabel:x("universal.submitLabel"),pendingLabel:x("universal.pendingLabel"),SubmitIcon:l.A,onSubmit:y},S.id)})}}},e=>{e.O(0,[4400,4678,9776,6785,3335,9411,2038,6642,4933,146,7358],()=>e(e.s=63392)),_N_E=e.O()}]);