mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-16 15:30:59 +00:00
1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,48456,e=>{"use strict";let t=(0,e.i(83227).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);e.s(["Loader2",()=>t],48456)},4480,(e,t,s)=>{t.exports=e.r(96387)},56907,20317,e=>{"use strict";var t=e.i(15742);e.i(81795).BackendClient,e.s([],56907),e.s(["httpClient",()=>t.backendClient],20317)},66413,e=>{e.v("/_next/static/media/langbot-logo.41703e3d.webp")},28963,e=>{"use strict";let t={src:e.i(66413).default,width:548,height:548,blurWidth:8,blurHeight:8,blurDataURL:"data:image/webp;base64,UklGRkgBAABXRUJQVlA4TDwBAAAvB8ABEM1VICICHghADgIAAID9kaQyqoQRAgYAAAAAAAAAAgAAAAAAAAAAAAAAAAA8CEQq2ACp+X0AAIAHApCDAAAAcP73X1iZlvQiAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAi9FlrQzHkgaDkIAAAA579vFdLQshAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAARI60WJXS80AGDQAAAADOfwgAAAAAAAAAAA4AAAAAAAAAAAAAAADgCAAAAAAAAAAAQq7H/N7TgYqB84swNqv3dIDSDJdp2dhYkABUvKcDlW46uNVkSJ+yZV9U4QEqBAwpu54oU8IbpObN2wr6M3CUFHW4lf3rrTUAUGQIBOO8K7pPO55sLEIJUvNE2HEP7tzbr5Fu5+TMkYCxWePXLpbO8zf0qxUBY7MC"};e.s(["default",0,t])},16700,e=>{"use strict";var t=e.i(60498),s=e.i(48456),a=e.i(14407);let c={sm:"h-4 w-4",default:"h-8 w-8",lg:"h-12 w-12"},i={sm:"text-xs",default:"text-sm",lg:"text-base"};function r({size:e="default",className:r,text:l="加载中...",fullPage:n=!1}){let A=(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,t.jsx)(s.Loader2,{className:(0,a.cn)("animate-spin text-primary",c[e],r)}),l&&(0,t.jsx)("p",{className:(0,a.cn)("text-muted-foreground",i[e]),children:l})]});return n?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-background",children:A}):A}function l({text:e}){return(0,t.jsx)(r,{fullPage:!0,text:e})}e.s(["LoadingPage",()=>l,"LoadingSpinner",()=>r])},92784,e=>{"use strict";let t=(0,e.i(83227).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],92784)},8078,e=>{"use strict";var t=e.i(60498),s=e.i(49311),a=e.i(4480);e.i(56907);var c=e.i(20317),i=e.i(50098);e.i(26128);var r=e.i(91830),l=e.i(48456),n=e.i(92784),A=e.i(83227);let o=(0,A.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),m=(0,A.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var u=e.i(81817),d=e.i(74035),g=e.i(16700),x=e.i(28963);function h(){let e=(0,a.useRouter)(),A=(0,a.useSearchParams)(),{t:h}=(0,r.useTranslation)(),[p,f]=(0,s.useState)("loading"),[b,k]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[L,v]=(0,s.useState)(""),B=(0,s.useCallback)(async t=>{try{let s=await c.httpClient.exchangeSpaceOAuthCode(t);localStorage.setItem("token",s.token),s.user&&localStorage.setItem("userEmail",s.user),f("success"),i.toast.success(h("common.spaceLoginSuccess")),setTimeout(()=>{e.push("/home")},1e3)}catch(e){f("error"),(e?.msg||"").toLowerCase().includes("account email mismatch")?k(h("account.spaceEmailMismatch")):k(h("common.spaceLoginFailed"))}},[e,h]),[I,D]=(0,s.useState)(null),T=(0,s.useCallback)(async(t,s)=>{N(!0);try{let a=await c.httpClient.bindSpaceAccount(t,s);localStorage.setItem("token",a.token),a.user&&localStorage.setItem("userEmail",a.user),f("success"),i.toast.success(h("account.bindSpaceSuccess")),setTimeout(()=>{e.push("/home")},1e3)}catch(e){f("error"),(e?.msg||"").toLowerCase().includes("account email mismatch")?k(h("account.spaceEmailMismatch")):k(h("account.bindSpaceFailed"))}finally{N(!1)}},[e,h]);return(0,s.useEffect)(()=>{let e=A.get("code"),t=A.get("error"),s=A.get("error_description"),a=A.get("mode"),c=A.get("state");if(t){f("error"),k(s||t||h("common.spaceLoginFailed"));return}if(!e){f("error"),k(h("common.spaceLoginNoCode"));return}if(y(e),"bind"===a){if(!c){f("error"),k(h("account.bindSpaceInvalidState"));return}D(c),S(!0),v(localStorage.getItem("userEmail")||""),f("confirm")}else B(e)},[A,B,h]),(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-neutral-900",children:(0,t.jsxs)(u.Card,{className:"w-[400px] shadow-lg dark:shadow-white/10",children:[(0,t.jsxs)(u.CardHeader,{className:"text-center",children:[(0,t.jsx)("img",{src:x.default.src,alt:"LangBot",className:"w-16 h-16 mb-4 mx-auto"}),(0,t.jsxs)(u.CardTitle,{className:"text-xl",children:["loading"===p&&h("common.spaceLoginProcessing"),"confirm"===p&&h("account.bindSpaceConfirmTitle"),"success"===p&&(C?h("account.bindSpaceSuccess"):h("common.spaceLoginSuccess")),"error"===p&&(C?h("account.bindSpaceFailed"):h("common.spaceLoginError"))]}),(0,t.jsxs)(u.CardDescription,{children:["loading"===p&&h("common.spaceLoginProcessingDescription"),"confirm"===p&&h("account.bindSpaceConfirmDescription"),"success"===p&&h("common.spaceLoginSuccessDescription"),"error"===p&&b]})]}),(0,t.jsxs)(u.CardContent,{className:"flex flex-col items-center space-y-4",children:["loading"===p&&(0,t.jsx)(g.LoadingSpinner,{size:"lg",text:""}),"confirm"===p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m,{className:"h-12 w-12 text-yellow-500"}),(0,t.jsx)("p",{className:"text-sm text-center text-muted-foreground px-4",children:h("account.bindSpaceWarning",{localEmail:L||"-"})}),(0,t.jsxs)("div",{className:"flex gap-3 w-full",children:[(0,t.jsx)(d.Button,{variant:"outline",className:"flex-1",onClick:()=>{e.push("/home")},disabled:w,children:h("common.cancel")}),(0,t.jsxs)(d.Button,{className:"flex-1",onClick:()=>{j&&I&&T(j,I)},disabled:w,children:[w?(0,t.jsx)(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):null,h("common.confirm")]})]})]}),"success"===p&&(0,t.jsx)(o,{className:"h-12 w-12 text-green-500"}),"error"===p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.AlertCircle,{className:"h-12 w-12 text-red-500"}),(0,t.jsx)(d.Button,{onClick:()=>e.push(C?"/home":"/login"),className:"w-full mt-4",children:C?h("common.backToHome"):h("common.backToLogin")})]})]})]})})}function p(){return(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-neutral-900",children:(0,t.jsx)(u.Card,{className:"w-[400px] shadow-lg dark:shadow-white/10",children:(0,t.jsx)(u.CardContent,{className:"flex flex-col items-center py-12",children:(0,t.jsx)(g.LoadingSpinner,{size:"lg",text:""})})})})}function f(){return(0,t.jsx)(s.Suspense,{fallback:(0,t.jsx)(p,{}),children:(0,t.jsx)(h,{})})}e.s(["default",()=>f],8078)}]); |