Files
LangBot/web/.next/static/chunks/e75176208e875e31.js
T

7 lines
77 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,85860,e=>{e.v({homeLayoutContainer:"layout-module__8oqbmW__homeLayoutContainer",main:"layout-module__8oqbmW__main",mainContent:"layout-module__8oqbmW__mainContent",sidebar:"layout-module__8oqbmW__sidebar"})},32268,e=>{e.v({langbotIcon:"HomeSidebar-module__TL0h5a__langbotIcon",langbotIconContainer:"HomeSidebar-module__TL0h5a__langbotIconContainer",langbotText:"HomeSidebar-module__TL0h5a__langbotText",langbotTextContainer:"HomeSidebar-module__TL0h5a__langbotTextContainer",langbotVersion:"HomeSidebar-module__TL0h5a__langbotVersion",sidebarBottomChildContainer:"HomeSidebar-module__TL0h5a__sidebarBottomChildContainer",sidebarBottomContainer:"HomeSidebar-module__TL0h5a__sidebarBottomContainer",sidebarChildContainer:"HomeSidebar-module__TL0h5a__sidebarChildContainer",sidebarChildIcon:"HomeSidebar-module__TL0h5a__sidebarChildIcon",sidebarChildName:"HomeSidebar-module__TL0h5a__sidebarChildName",sidebarContainer:"HomeSidebar-module__TL0h5a__sidebarContainer",sidebarItemsContainer:"HomeSidebar-module__TL0h5a__sidebarItemsContainer",sidebarSelected:"HomeSidebar-module__TL0h5a__sidebarSelected",sidebarTopContainer:"HomeSidebar-module__TL0h5a__sidebarTopContainer",sidebarUnselected:"HomeSidebar-module__TL0h5a__sidebarUnselected"})},14119,e=>{e.v({helpLink:"HomeTittleBar-module__W7I6JG__helpLink",subtitleText:"HomeTittleBar-module__W7I6JG__subtitleText",titleBarContainer:"HomeTittleBar-module__W7I6JG__titleBarContainer",titleText:"HomeTittleBar-module__W7I6JG__titleText"})},64934,e=>{"use strict";let t;var s=e.i(60498),a=e.i(85860),l=e.i(32268),n=e.i(49311);class o{id;icon;name;route;description;helpLink;constructor(e){this.id=e.id,this.icon=e.icon,this.name=e.name,this.route=e.route,this.description=e.description,this.helpLink=e.helpLink}}function i({icon:e,name:t,isSelected:a,onClick:n}){return(0,s.jsxs)("div",{className:`${l.default.sidebarChildContainer} ${a?l.default.sidebarSelected:l.default.sidebarUnselected}`,onClick:n,children:[(0,s.jsx)("div",{className:`${l.default.sidebarChildIcon}`,children:e}),(0,s.jsx)("span",{className:`${l.default.sidebarChildName}`,children:t})]})}var r=e.i(4480),d=e.i(18090);let c=[new o({id:"bots",name:d.default.t("bots.title"),icon:(0,s.jsx)("svg",{className:`${l.default.sidebarChildIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M13.5 2C13.5 2.44425 13.3069 2.84339 13 3.11805V5H18C19.6569 5 21 6.34315 21 8V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V8C3 6.34315 4.34315 5 6 5H11V3.11805C10.6931 2.84339 10.5 2.44425 10.5 2C10.5 1.17157 11.1716 0.5 12 0.5C12.8284 0.5 13.5 1.17157 13.5 2ZM6 7C5.44772 7 5 7.44772 5 8V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V8C19 7.44772 18.5523 7 18 7H13H11H6ZM2 10H0V16H2V10ZM22 10H24V16H22V10ZM9 14.5C9.82843 14.5 10.5 13.8284 10.5 13C10.5 12.1716 9.82843 11.5 9 11.5C8.17157 11.5 7.5 12.1716 7.5 13C7.5 13.8284 8.17157 14.5 9 14.5ZM15 14.5C15.8284 14.5 16.5 13.8284 16.5 13C16.5 12.1716 15.8284 11.5 15 11.5C14.1716 11.5 13.5 12.1716 13.5 13C13.5 13.8284 14.1716 14.5 15 14.5Z"})}),route:"/home/bots",description:d.default.t("bots.description"),helpLink:{en_US:"https://docs.langbot.app/en/usage/platforms/readme.html",zh_Hans:"https://docs.langbot.app/zh/usage/platforms/readme.html",ja_JP:"https://docs.langbot.app/ja/usage/platforms/readme.html"}}),new o({id:"pipelines",name:d.default.t("pipelines.title"),icon:(0,s.jsx)("svg",{className:`${l.default.sidebarChildIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M6 21.5C4.067 21.5 2.5 19.933 2.5 18C2.5 16.067 4.067 14.5 6 14.5C7.5852 14.5 8.92427 15.5539 9.35481 16.9992L15 16.9994V15L17 14.9994V9.24339L14.757 6.99938H9V9.00003H3V3.00003H9V4.99939H14.757L18 1.75739L22.2426 6.00003L19 9.24139V14.9994L21 15V21H15V18.9994L9.35499 19.0003C8.92464 20.4459 7.58543 21.5 6 21.5ZM6 16.5C5.17157 16.5 4.5 17.1716 4.5 18C4.5 18.8285 5.17157 19.5 6 19.5C6.82843 19.5 7.5 18.8285 7.5 18C7.5 17.1716 6.82843 16.5 6 16.5ZM19 17H17V19H19V17ZM18 4.58581L16.5858 6.00003L18 7.41424L19.4142 6.00003L18 4.58581ZM7 5.00003H5V7.00003H7V5.00003Z"})}),route:"/home/pipelines",description:d.default.t("pipelines.description"),helpLink:{en_US:"https://docs.langbot.app/en/usage/pipelines/readme.html",zh_Hans:"https://docs.langbot.app/zh/usage/pipelines/readme.html",ja_JP:"https://docs.langbot.app/ja/usage/pipelines/readme.html"}}),new o({id:"monitoring",name:d.default.t("monitoring.title"),icon:(0,s.jsx)("svg",{className:`${l.default.sidebarChildIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM4 5V19H20V5H4ZM6 7H18V9H6V7ZM6 11H18V13H6V11ZM6 15H12V17H6V15Z"})}),route:"/home/monitoring",description:d.default.t("monitoring.description"),helpLink:{en_US:"https://docs.langbot.app/en/features/monitoring.html",zh_Hans:"https://docs.langbot.app/zh/features/monitoring.html"}}),new o({id:"knowledge",name:d.default.t("knowledge.title"),icon:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M3 18.5V5C3 3.34315 4.34315 2 6 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22H6.5C4.567 22 3 20.433 3 18.5ZM19 20V17H6.5C5.67157 17 5 17.6716 5 18.5C5 19.3284 5.67157 20 6.5 20H19ZM10 4H6C5.44772 4 5 4.44772 5 5V15.3368C5.45463 15.1208 5.9632 15 6.5 15H19V4H17V12L13.5 10L10 12V4Z"})}),route:"/home/knowledge",description:d.default.t("knowledge.description"),helpLink:{en_US:"https://docs.langbot.app/en/usage/knowledge/readme.html",zh_Hans:"https://docs.langbot.app/zh/usage/knowledge/readme.html",ja_JP:"https://docs.langbot.app/ja/usage/knowledge/readme.html"}}),new o({id:"plugins",name:d.default.t("plugins.title"),icon:(0,s.jsx)("svg",{className:`${l.default.sidebarChildIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M7 5C7 2.79086 8.79086 1 11 1C13.2091 1 15 2.79086 15 5H18C18.5523 5 19 5.44772 19 6V9C21.2091 9 23 10.7909 23 13C23 15.2091 21.2091 17 19 17V20C19 20.5523 18.5523 21 18 21H4C3.44772 21 3 20.5523 3 20V6C3 5.44772 3.44772 5 4 5H7ZM11 3C9.89543 3 9 3.89543 9 5C9 5.23554 9.0403 5.45952 9.11355 5.66675C9.22172 5.97282 9.17461 6.31235 8.98718 6.57739C8.79974 6.84243 8.49532 7 8.17071 7H5V19H17V15.8293C17 15.5047 17.1576 15.2003 17.4226 15.0128C17.6877 14.8254 18.0272 14.7783 18.3332 14.8865C18.5405 14.9597 18.7645 15 19 15C20.1046 15 21 14.1046 21 13C21 11.8954 20.1046 11 19 11C18.7645 11 18.5405 11.0403 18.3332 11.1135C18.0272 11.2217 17.6877 11.1746 17.4226 10.9872C17.1576 10.7997 17 10.4953 17 10.1707V7H13.8293C13.5047 7 13.2003 6.84243 13.0128 6.57739C12.8254 6.31235 12.7783 5.97282 12.8865 5.66675C12.9597 5.45952 13 5.23555 13 5C13 3.89543 12.1046 3 11 3Z"})}),route:"/home/plugins",description:d.default.t("plugins.description"),helpLink:{en_US:"https://docs.langbot.app/en/usage/plugin/plugin-intro.html",zh_Hans:"https://docs.langbot.app/zh/usage/plugin/plugin-intro.html",ja_JP:"https://docs.langbot.app/ja/usage/plugin/plugin-intro.html"}})];var m=e.i(28963);e.i(56907);var u=e.i(15742),h=e.i(20317);e.i(26128);var x=e.i(91830),p=e.i(47108),g=e.i(29136),j=e.i(23371),f=e.i(83227);let v=(0,f.default)("circle-help",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),b=(0,f.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]),C=(0,f.default)("log-out",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),w=(0,f.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var y=e.i(73344),N=e.i(90285),k=e.i(74035),S=e.i(67046),_=e.i(78083),L=e.i(50098),M=e.i(88274),P=e.i(45855),T=e.i(63686),D=e.i(14407);e.i(2147);let H=(0,T.cva)("group/item flex items-center border border-transparent text-sm rounded-md transition-colors [a]:hover:bg-accent/50 [a]:transition-colors duration-100 flex-wrap outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-transparent",outline:"border-border",muted:"bg-muted/50"},size:{default:"p-4 gap-4 ",sm:"py-3 px-4 gap-2.5"}},defaultVariants:{variant:"default",size:"default"}});function I({className:e,variant:t="default",size:a="default",asChild:l=!1,...n}){let o=l?P.Slot:"div";return(0,s.jsx)(o,{"data-slot":"item","data-variant":t,"data-size":a,className:(0,D.cn)(H({variant:t,size:a,className:e})),...n})}let z=(0,T.cva)("flex shrink-0 items-center justify-center gap-2 group-has-[[data-slot=item-description]]/item:self-start [&_svg]:pointer-events-none group-has-[[data-slot=item-description]]/item:translate-y-0.5",{variants:{variant:{default:"bg-transparent",icon:"size-8 border rounded-sm bg-muted [&_svg:not([class*='size-'])]:size-4",image:"size-10 rounded-sm overflow-hidden [&_img]:size-full [&_img]:object-cover"}},defaultVariants:{variant:"default"}});function F({className:e,variant:t="default",...a}){return(0,s.jsx)("div",{"data-slot":"item-media","data-variant":t,className:(0,D.cn)(z({variant:t,className:e})),...a})}function B({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"item-content",className:(0,D.cn)("flex flex-1 flex-col gap-1 [&+[data-slot=item-content]]:flex-none",e),...t})}function R({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"item-title",className:(0,D.cn)("flex w-fit items-center gap-2 text-sm leading-snug font-medium",e),...t})}function V({className:e,...t}){return(0,s.jsx)("p",{"data-slot":"item-description",className:(0,D.cn)("text-muted-foreground line-clamp-2 text-sm leading-normal font-normal text-balance","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",e),...t})}function $({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"item-actions",className:(0,D.cn)("flex items-center gap-2",e),...t})}var E=e.i(48456),O=e.i(56604),A=e.i(57728),q=e.i(16585),U=e.i(19309),Z=e.i(64339),K=e.i(87980);function W({open:e,onOpenChange:t,hasPassword:a=!0}){let{t:l}=(0,x.useTranslation)(),[o,i]=(0,n.useState)(!1),r=U.z.object({currentPassword:a?U.z.string().min(1,{message:l("common.currentPasswordRequired")}):U.z.string().optional(),newPassword:U.z.string().min(1,{message:l("common.newPasswordRequired")}),confirmNewPassword:U.z.string().min(1,{message:l("common.confirmPasswordRequired")})}).refine(e=>e.newPassword===e.confirmNewPassword,{message:l("common.passwordsDoNotMatch"),path:["confirmNewPassword"]}),d=(0,A.useForm)({resolver:(0,q.zodResolver)(r),defaultValues:{currentPassword:"",newPassword:"",confirmNewPassword:""}});(0,n.useEffect)(()=>{e&&d.reset({currentPassword:"",newPassword:"",confirmNewPassword:""})},[e,a,d]);let c=async e=>{i(!0);try{a?(await h.httpClient.changePassword(e.currentPassword,e.newPassword),L.toast.success(l("common.changePasswordSuccess"))):(await h.httpClient.setPassword(e.newPassword,void 0),L.toast.success(l("account.passwordSetSuccess"))),d.reset(),t(!1)}catch{L.toast.error(l("common.changePasswordFailed"))}finally{i(!1)}};return(0,s.jsx)(M.Dialog,{open:e,onOpenChange:t,children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(M.DialogHeader,{children:(0,s.jsx)(M.DialogTitle,{children:a?l("common.changePassword"):l("account.setPassword")})}),(0,s.jsx)(Z.Form,{...d,children:(0,s.jsxs)("form",{onSubmit:d.handleSubmit(c),className:"space-y-4",children:[a&&(0,s.jsx)(Z.FormField,{control:d.control,name:"currentPassword",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsx)(Z.FormLabel,{children:l("common.currentPassword")}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{type:"password",placeholder:l("common.enterCurrentPassword"),...e})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsx)(Z.FormField,{control:d.control,name:"newPassword",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsx)(Z.FormLabel,{children:l("common.newPassword")}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{type:"password",placeholder:l("common.enterNewPassword"),...e})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsx)(Z.FormField,{control:d.control,name:"confirmNewPassword",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsx)(Z.FormLabel,{children:l("common.confirmNewPassword")}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{type:"password",placeholder:l("common.enterConfirmPassword"),...e})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsxs)(M.DialogFooter,{children:[(0,s.jsx)(k.Button,{type:"button",variant:"outline",onClick:()=>t(!1),disabled:o,children:l("common.cancel")}),(0,s.jsx)(k.Button,{type:"submit",disabled:o,children:o?l("common.saving"):l("common.save")})]})]})})]})})}function G({open:e,onOpenChange:t}){let{t:a}=(0,x.useTranslation)(),[l,o]=(0,n.useState)("local"),[i,r]=(0,n.useState)(!1),[d,c]=(0,n.useState)(""),[m,p]=(0,n.useState)(!0),[g,j]=(0,n.useState)(!1),[f,v]=(0,n.useState)(!1);async function b(){p(!0);try{let e=await h.httpClient.getUserInfo();o(e.account_type),r(e.has_password),c(e.user)}catch{L.toast.error(a("common.error"))}finally{p(!1)}}(0,n.useEffect)(()=>{e&&b()},[e]);let C=async()=>{j(!0);try{let e=localStorage.getItem("token");if(!e){L.toast.error(a("common.error")),j(!1);return}let t=window.location.origin,s=`${t}/auth/space/callback?mode=bind`,l=await h.httpClient.getSpaceAuthorizeUrl(s,e);window.location.href=l.authorize_url}catch{L.toast.error(a("common.spaceLoginFailed")),j(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M.Dialog,{open:e,onOpenChange:t,children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsxs)(M.DialogHeader,{children:[(0,s.jsx)(M.DialogTitle,{children:a("account.settings")}),(0,s.jsx)(M.DialogDescription,{children:d})]}),m?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(E.Loader2,{className:"h-6 w-6 animate-spin"})}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(I,{size:"sm",variant:"muted",className:"rounded-lg",children:[(0,s.jsx)(F,{variant:"icon",children:(0,s.jsx)(w,{className:"h-4 w-4"})}),(0,s.jsxs)(B,{children:[(0,s.jsx)(R,{children:a("account.passwordStatus")}),(0,s.jsx)(V,{children:i?a("account.passwordSetDescription"):a("account.setPasswordHint")})]}),(0,s.jsx)($,{children:(0,s.jsx)(k.Button,{variant:"outline",size:"sm",onClick:()=>v(!0),disabled:!u.systemInfo.allow_modify_login_info,children:i?a("common.changePassword"):a("account.setPassword")})})]}),(0,s.jsxs)(I,{size:"sm",variant:"muted",className:"rounded-lg",children:[(0,s.jsx)(F,{variant:"icon",children:(0,s.jsxs)("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),(0,s.jsxs)(B,{children:[(0,s.jsx)(R,{children:a("account.spaceStatus")}),(0,s.jsx)(V,{children:"space"===l?a("account.spaceBoundDescription"):a("account.bindSpaceDescription")})]}),"local"===l&&(0,s.jsx)($,{children:(0,s.jsxs)(k.Button,{variant:"outline",size:"sm",onClick:C,disabled:g||!u.systemInfo.allow_modify_login_info,children:[g?(0,s.jsx)(E.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(O.ExternalLink,{className:"mr-2 h-4 w-4"}),a("account.bindSpaceButton")]})})]})]})]})}),(0,s.jsx)(W,{open:f,onOpenChange:e=>{v(e),e||b()},hasPassword:i})]})}var J=e.i(17755),X=e.i(18941);let Y=(0,f.default)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);var Q=e.i(63737),ee=e.i(70917),et=e.i(13781),es=e.i(29601),ea=e.i(67658),el=e.i(30479),en=e.i(34216),eo=e.i(15822),ei=Symbol("radix.slottable"),er="AlertDialog",[ed,ec]=(0,ea.createContextScope)(er,[en.createDialogScope]),em=(0,en.createDialogScope)(),eu=e=>{let{__scopeAlertDialog:t,...a}=e,l=em(t);return(0,s.jsx)(en.Root,{...l,...a,modal:!0})};eu.displayName=er,n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,n=em(a);return(0,s.jsx)(en.Trigger,{...n,...l,ref:t})}).displayName="AlertDialogTrigger";var eh=e=>{let{__scopeAlertDialog:t,...a}=e,l=em(t);return(0,s.jsx)(en.Portal,{...l,...a})};eh.displayName="AlertDialogPortal";var ex=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,n=em(a);return(0,s.jsx)(en.Overlay,{...n,...l,ref:t})});ex.displayName="AlertDialogOverlay";var ep="AlertDialogContent",[eg,ej]=ed(ep),ef=((t=({children:e})=>(0,s.jsx)(s.Fragment,{children:e})).displayName="AlertDialogContent.Slottable",t.__radixId=ei,t),ev=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,children:l,...o}=e,i=em(a),r=n.useRef(null),d=(0,el.useComposedRefs)(t,r),c=n.useRef(null);return(0,s.jsx)(en.WarningProvider,{contentName:ep,titleName:eb,docsSlug:"alert-dialog",children:(0,s.jsx)(eg,{scope:a,cancelRef:c,children:(0,s.jsxs)(en.Content,{role:"alertdialog",...i,...o,ref:d,onOpenAutoFocus:(0,eo.composeEventHandlers)(o.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,s.jsx)(ef,{children:l}),(0,s.jsx)(e_,{contentRef:r})]})})})});ev.displayName=ep;var eb="AlertDialogTitle",eC=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,n=em(a);return(0,s.jsx)(en.Title,{...n,...l,ref:t})});eC.displayName=eb;var ew="AlertDialogDescription",ey=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,n=em(a);return(0,s.jsx)(en.Description,{...n,...l,ref:t})});ey.displayName=ew;var eN=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,n=em(a);return(0,s.jsx)(en.Close,{...n,...l,ref:t})});eN.displayName="AlertDialogAction";var ek="AlertDialogCancel",eS=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,...l}=e,{cancelRef:n}=ej(ek,a),o=em(a),i=(0,el.useComposedRefs)(t,n);return(0,s.jsx)(en.Close,{...o,...l,ref:i})});eS.displayName=ek;var e_=({contentRef:e})=>{let t=`\`${ep}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${ep}\` by passing a \`${ew}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ep}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return n.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null};let eL=n.forwardRef(({className:e,...t},a)=>(0,s.jsx)(ex,{className:(0,D.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:a}));eL.displayName=ex.displayName,n.forwardRef(({className:e,...t},a)=>(0,s.jsxs)(eh,{children:[(0,s.jsx)(eL,{}),(0,s.jsx)(ev,{ref:a,className:(0,D.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]})).displayName=ev.displayName;let eM=({className:e,...t})=>(0,s.jsx)("div",{className:(0,D.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});eM.displayName="AlertDialogHeader";let eP=({className:e,...t})=>(0,s.jsx)("div",{className:(0,D.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});eP.displayName="AlertDialogFooter";let eT=n.forwardRef(({className:e,...t},a)=>(0,s.jsx)(eC,{ref:a,className:(0,D.cn)("text-lg font-semibold",e),...t}));eT.displayName=eC.displayName;let eD=n.forwardRef(({className:e,...t},a)=>(0,s.jsx)(ey,{ref:a,className:(0,D.cn)("text-sm text-muted-foreground",e),...t}));eD.displayName=ey.displayName;let eH=n.forwardRef(({className:e,...t},a)=>(0,s.jsx)(eN,{ref:a,className:(0,D.cn)((0,k.buttonVariants)(),e),...t}));eH.displayName=eN.displayName;let eI=n.forwardRef(({className:e,...t},a)=>(0,s.jsx)(eS,{ref:a,className:(0,D.cn)((0,k.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));function ez({open:e,onOpenChange:t}){let{t:a}=(0,x.useTranslation)(),l=(0,r.useRouter)(),o=(0,r.usePathname)(),i=(0,r.useSearchParams)(),[d,c]=(0,n.useState)("apikeys"),[m,h]=(0,n.useState)([]),[p,g]=(0,n.useState)([]),[j,f]=(0,n.useState)(!1),[v,b]=(0,n.useState)(!1),[C,w]=(0,n.useState)(""),[y,N]=(0,n.useState)(""),[S,_]=(0,n.useState)(null),[P,T]=(0,n.useState)(null),[D,H]=(0,n.useState)(!1),[I,z]=(0,n.useState)(""),[F,B]=(0,n.useState)(""),[R,V]=(0,n.useState)(""),[$,E]=(0,n.useState)(!0),[O,A]=(0,n.useState)(null),[q,U]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(e){let e=new URLSearchParams(i.toString());e.set("action","showApiIntegrationSettings"),l.replace(`${o}?${e.toString()}`,{scroll:!1})}},[e]),(0,n.useEffect)(()=>{if(!P&&!O){let e=()=>{document.body.style.removeProperty("pointer-events")};e();let t=setTimeout(e,100);return()=>clearTimeout(t)}},[P,O]),(0,n.useEffect)(()=>{e&&(Z(),el())},[e]);let Z=async()=>{f(!0);try{let e=await u.backendClient.get("/api/v1/apikeys");h(e.keys||[])}catch(e){L.toast.error(`Failed to load API keys: ${e}`)}finally{f(!1)}},W=async()=>{if(!C.trim())return void L.toast.error(a("common.apiKeyNameRequired"));try{let e=await u.backendClient.post("/api/v1/apikeys",{name:C,description:y});_(e.key),L.toast.success(a("common.apiKeyCreated")),w(""),N(""),b(!1),Z()}catch(e){L.toast.error(`Failed to create API key: ${e}`)}},G=async e=>{try{await u.backendClient.delete(`/api/v1/apikeys/${e}`),L.toast.success(a("common.apiKeyDeleted")),Z(),T(null)}catch(e){L.toast.error(`Failed to delete API key: ${e}`)}},ea=e=>{navigator.clipboard.writeText(e),U(e),setTimeout(()=>U(null),2e3)},el=async()=>{f(!0);try{let e=await u.backendClient.get("/api/v1/webhooks");g(e.webhooks||[])}catch(e){L.toast.error(`Failed to load webhooks: ${e}`)}finally{f(!1)}},en=async()=>{if(!I.trim())return void L.toast.error(a("common.webhookNameRequired"));if(!F.trim())return void L.toast.error(a("common.webhookUrlRequired"));try{await u.backendClient.post("/api/v1/webhooks",{name:I,url:F,description:R,enabled:$}),L.toast.success(a("common.webhookCreated")),z(""),B(""),V(""),E(!0),H(!1),el()}catch(e){L.toast.error(`Failed to create webhook: ${e}`)}},eo=async e=>{try{await u.backendClient.delete(`/api/v1/webhooks/${e}`),L.toast.success(a("common.webhookDeleted")),el(),A(null)}catch(e){L.toast.error(`Failed to delete webhook: ${e}`)}},ei=async e=>{try{await u.backendClient.put(`/api/v1/webhooks/${e.id}`,{enabled:!e.enabled}),el()}catch(e){L.toast.error(`Failed to update webhook: ${e}`)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M.Dialog,{open:e,onOpenChange:e=>{if(e||!P&&!O){if(!e){let e=new URLSearchParams(i.toString());e.delete("action");let t=e.toString()?`${o}?${e.toString()}`:o;l.replace(t,{scroll:!1})}t(e)}},children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-[800px] h-[26rem] flex flex-col",children:[(0,s.jsx)(M.DialogHeader,{children:(0,s.jsx)(M.DialogTitle,{children:a("common.manageApiIntegration")})}),(0,s.jsxs)(ee.Tabs,{value:d,onValueChange:c,className:"w-full flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ee.TabsList,{className:"shadow-md py-3 bg-[#f0f0f0] dark:bg-[#2a2a2e]",children:[(0,s.jsx)(ee.TabsTrigger,{className:"px-5 py-4 cursor-pointer",value:"apikeys",children:a("common.apiKeys")}),(0,s.jsx)(ee.TabsTrigger,{className:"px-5 py-4 cursor-pointer",value:"webhooks",children:a("common.webhooks")})]}),(0,s.jsxs)(ee.TabsContent,{value:"apikeys",className:"space-y-4 flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:a("common.apiKeyHint")}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsxs)(k.Button,{onClick:()=>b(!0),size:"sm",className:"gap-2",children:[(0,s.jsx)(Q.Plus,{className:"h-4 w-4"}),a("common.createApiKey")]})}),j?(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:a("common.loading")}):0===m.length?(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:a("common.noApiKeys")}):(0,s.jsx)("div",{className:"border rounded-md overflow-auto flex-1",children:(0,s.jsxs)(es.Table,{children:[(0,s.jsx)(es.TableHeader,{children:(0,s.jsxs)(es.TableRow,{children:[(0,s.jsx)(es.TableHead,{className:"min-w-[120px]",children:a("common.name")}),(0,s.jsx)(es.TableHead,{className:"min-w-[200px]",children:a("common.apiKeyValue")}),(0,s.jsx)(es.TableHead,{className:"w-[100px]",children:a("common.actions")})]})}),(0,s.jsx)(es.TableBody,{children:m.map(e=>{var t;return(0,s.jsxs)(es.TableRow,{children:[(0,s.jsx)(es.TableCell,{children:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium",children:e.name}),e.description&&(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:e.description})]})}),(0,s.jsx)(es.TableCell,{children:(0,s.jsx)("code",{className:"text-sm bg-muted px-2 py-1 rounded",children:(t=e.key).length<=8?t:`${t.substring(0,8)}...${t.substring(t.length-4)}`})}),(0,s.jsx)(es.TableCell,{children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(k.Button,{variant:"ghost",size:"sm",onClick:()=>ea(e.key),title:a("common.copyApiKey"),children:q===e.key?(0,s.jsx)(X.Check,{className:"h-4 w-4 text-green-600"}):(0,s.jsx)(J.Copy,{className:"h-4 w-4"})}),(0,s.jsx)(k.Button,{variant:"ghost",size:"sm",onClick:()=>T(e.id),title:a("common.delete"),children:(0,s.jsx)(Y,{className:"h-4 w-4"})})]})})]},e.id)})})]})})]}),(0,s.jsxs)(ee.TabsContent,{value:"webhooks",className:"space-y-4 flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:a("common.webhookHint")}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsxs)(k.Button,{onClick:()=>H(!0),size:"sm",className:"gap-2",children:[(0,s.jsx)(Q.Plus,{className:"h-4 w-4"}),a("common.createWebhook")]})}),j?(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:a("common.loading")}):0===p.length?(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:a("common.noWebhooks")}):(0,s.jsx)("div",{className:"border rounded-md overflow-auto flex-1 max-w-full",children:(0,s.jsxs)(es.Table,{className:"table-fixed w-full",children:[(0,s.jsx)(es.TableHeader,{children:(0,s.jsxs)(es.TableRow,{children:[(0,s.jsx)(es.TableHead,{className:"w-[150px]",children:a("common.name")}),(0,s.jsx)(es.TableHead,{className:"w-[380px]",children:a("common.webhookUrl")}),(0,s.jsx)(es.TableHead,{className:"w-[80px]",children:a("common.webhookEnabled")}),(0,s.jsx)(es.TableHead,{className:"w-[80px]",children:a("common.actions")})]})}),(0,s.jsx)(es.TableBody,{children:p.map(e=>(0,s.jsxs)(es.TableRow,{children:[(0,s.jsx)(es.TableCell,{className:"truncate",children:(0,s.jsxs)("div",{className:"truncate",children:[(0,s.jsx)("div",{className:"font-medium truncate",title:e.name,children:e.name}),e.description&&(0,s.jsx)("div",{className:"text-sm text-muted-foreground truncate",title:e.description,children:e.description})]})}),(0,s.jsx)(es.TableCell,{children:(0,s.jsx)("div",{className:"overflow-x-auto max-w-[380px]",children:(0,s.jsx)("code",{className:"text-sm bg-muted px-2 py-1 rounded whitespace-nowrap inline-block",children:e.url})})}),(0,s.jsx)(es.TableCell,{children:(0,s.jsx)(et.Switch,{checked:e.enabled,onCheckedChange:()=>ei(e)})}),(0,s.jsx)(es.TableCell,{children:(0,s.jsx)(k.Button,{variant:"ghost",size:"sm",onClick:()=>A(e.id),title:a("common.delete"),children:(0,s.jsx)(Y,{className:"h-4 w-4"})})})]},e.id))})]})})]})]}),(0,s.jsx)(M.DialogFooter,{children:(0,s.jsx)(k.Button,{variant:"outline",onClick:()=>t(!1),children:a("common.close")})})]})}),(0,s.jsx)(M.Dialog,{open:v,onOpenChange:b,children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(M.DialogHeader,{children:(0,s.jsx)(M.DialogTitle,{children:a("common.createApiKey")})}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.name")}),(0,s.jsx)(K.Input,{value:C,onChange:e=>w(e.target.value),placeholder:a("common.name"),className:"mt-1"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.description")}),(0,s.jsx)(K.Input,{value:y,onChange:e=>N(e.target.value),placeholder:a("common.description"),className:"mt-1"})]})]}),(0,s.jsxs)(M.DialogFooter,{children:[(0,s.jsx)(k.Button,{variant:"outline",onClick:()=>b(!1),children:a("common.cancel")}),(0,s.jsx)(k.Button,{onClick:W,children:a("common.create")})]})]})}),(0,s.jsx)(M.Dialog,{open:!!S,onOpenChange:()=>_(null),children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsxs)(M.DialogHeader,{children:[(0,s.jsx)(M.DialogTitle,{children:a("common.apiKeyCreated")}),(0,s.jsx)(M.DialogDescription,{children:a("common.apiKeyCreatedMessage")})]}),(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.apiKeyValue")}),(0,s.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,s.jsx)(K.Input,{value:S?.key||"",readOnly:!0}),(0,s.jsx)(k.Button,{onClick:()=>S&&ea(S.key),variant:"outline",size:"icon",children:q===S?.key?(0,s.jsx)(X.Check,{className:"h-4 w-4 text-green-600"}):(0,s.jsx)(J.Copy,{className:"h-4 w-4"})})]})]})}),(0,s.jsx)(M.DialogFooter,{children:(0,s.jsx)(k.Button,{onClick:()=>_(null),children:a("common.close")})})]})}),(0,s.jsx)(M.Dialog,{open:D,onOpenChange:H,children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(M.DialogHeader,{children:(0,s.jsx)(M.DialogTitle,{children:a("common.createWebhook")})}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.name")}),(0,s.jsx)(K.Input,{value:I,onChange:e=>z(e.target.value),placeholder:a("common.webhookName"),className:"mt-1"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.webhookUrl")}),(0,s.jsx)(K.Input,{value:F,onChange:e=>B(e.target.value),placeholder:"https://example.com/webhook",className:"mt-1"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.description")}),(0,s.jsx)(K.Input,{value:R,onChange:e=>V(e.target.value),placeholder:a("common.description"),className:"mt-1"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(et.Switch,{checked:$,onCheckedChange:E}),(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.webhookEnabled")})]})]}),(0,s.jsxs)(M.DialogFooter,{children:[(0,s.jsx)(k.Button,{variant:"outline",onClick:()=>H(!1),children:a("common.cancel")}),(0,s.jsx)(k.Button,{onClick:en,children:a("common.create")})]})]})}),(0,s.jsx)(M.Dialog,{open:!!S,onOpenChange:()=>_(null),children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsxs)(M.DialogHeader,{children:[(0,s.jsx)(M.DialogTitle,{children:a("common.apiKeyCreated")}),(0,s.jsx)(M.DialogDescription,{children:a("common.apiKeyCreatedMessage")})]}),(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium",children:a("common.apiKeyValue")}),(0,s.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,s.jsx)(K.Input,{value:S?.key||"",readOnly:!0}),(0,s.jsx)(k.Button,{onClick:()=>S&&ea(S.key),variant:"outline",size:"icon",children:q===S?.key?(0,s.jsx)(X.Check,{className:"h-4 w-4 text-green-600"}):(0,s.jsx)(J.Copy,{className:"h-4 w-4"})})]})]})}),(0,s.jsx)(M.DialogFooter,{children:(0,s.jsx)(k.Button,{onClick:()=>_(null),children:a("common.close")})})]})}),(0,s.jsx)(eu,{open:!!P,children:(0,s.jsxs)(eh,{children:[(0,s.jsx)(eL,{className:"z-[60]",onClick:()=>T(null)}),(0,s.jsxs)(ev,{className:"fixed left-[50%] top-[50%] z-[60] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",onEscapeKeyDown:()=>T(null),children:[(0,s.jsxs)(eM,{children:[(0,s.jsx)(eT,{children:a("common.confirmDelete")}),(0,s.jsx)(eD,{children:a("common.apiKeyDeleteConfirm")})]}),(0,s.jsxs)(eP,{children:[(0,s.jsx)(eI,{onClick:()=>T(null),children:a("common.cancel")}),(0,s.jsx)(eH,{onClick:()=>P&&G(P),children:a("common.delete")})]})]})]})}),(0,s.jsx)(eu,{open:!!O,children:(0,s.jsxs)(eh,{children:[(0,s.jsx)(eL,{className:"z-[60]",onClick:()=>A(null)}),(0,s.jsxs)(ev,{className:"fixed left-[50%] top-[50%] z-[60] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",onEscapeKeyDown:()=>A(null),children:[(0,s.jsxs)(eM,{children:[(0,s.jsx)(eT,{children:a("common.confirmDelete")}),(0,s.jsx)(eD,{children:a("common.webhookDeleteConfirm")})]}),(0,s.jsxs)(eP,{children:[(0,s.jsx)(eI,{onClick:()=>A(null),children:a("common.cancel")}),(0,s.jsx)(eH,{onClick:()=>O&&eo(O),children:a("common.delete")})]})]})]})})]})}eI.displayName=eS.displayName;var eF=e.i(93245),eB=e.i(49230),eR=e.i(37328),eV=e.i(45880),e$=e.i(10047);function eE({open:e,onOpenChange:t,release:a}){let{t:l}=(0,x.useTranslation)();return a?(0,s.jsx)(M.Dialog,{open:e,onOpenChange:t,children:(0,s.jsxs)(M.DialogContent,{className:"sm:max-w-[600px] max-h-[80vh] flex flex-col",children:[(0,s.jsx)(M.DialogHeader,{className:"flex-shrink-0",children:(0,s.jsxs)(M.DialogTitle,{className:"flex items-center gap-2",children:[l("version.newVersionAvailable"),(0,s.jsx)("span",{className:"text-primary font-mono",children:a.tag_name})]})}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 pr-2",children:(0,s.jsx)("div",{className:"markdown-body max-w-none text-sm",children:(0,s.jsx)(eF.default,{remarkPlugins:[eB.default],rehypePlugins:[eR.default,eV.default],components:{ul:({children:e})=>(0,s.jsx)("ul",{className:"list-disc",children:e}),ol:({children:e})=>(0,s.jsx)("ol",{className:"list-decimal",children:e}),li:({children:e})=>(0,s.jsx)("li",{className:"ml-4",children:e}),a:({href:e,children:t})=>(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:t})},children:a.body||l("version.noReleaseNotes")})})}),(0,s.jsxs)(M.DialogFooter,{className:"flex-shrink-0 flex flex-col sm:flex-row gap-2 pt-2",children:[(0,s.jsx)(k.Button,{variant:"outline",onClick:()=>t(!1),className:"w-full sm:w-auto",children:l("common.close")}),(0,s.jsxs)(k.Button,{onClick:()=>{let e;window.open("zh-Hans"===(e=e$.default.language)||"zh-Hant"===e?"https://docs.langbot.app/zh/deploy/update.html":"ja-JP"===e?"https://docs.langbot.app/ja/deploy/update.html":"https://docs.langbot.app/en/deploy/update.html","_blank")},className:"w-full sm:w-auto flex items-center gap-2",children:[l("version.viewUpdateGuide"),(0,s.jsx)(O.ExternalLink,{className:"w-4 h-4"})]})]})]})}):null}let eO=(0,f.default)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var eA=e.i(47977),eq=e.i(11607);function eU({providerId:e,onFormSubmit:t,onFormCancel:a}){let{t:l}=(0,x.useTranslation)(),o=U.z.object({name:U.z.string().min(1,{message:l("models.providerNameRequired")}),requester:U.z.string().min(1,{message:l("models.requesterRequired")}),base_url:U.z.string(),api_key:U.z.string().optional()}),i=(0,A.useForm)({resolver:(0,q.zodResolver)(o),defaultValues:{name:"",requester:"",base_url:"",api_key:""}}),[r,d]=(0,n.useState)([]);async function c(){d((await h.httpClient.getProviderRequesters()).requesters.filter(e=>"space-chat-completions"!==e.name).map(e=>({label:(0,eq.extractI18nObject)(e.label),value:e.name,category:e.spec.provider_category||"manufacturer",defaultUrl:e.spec.config.find(e=>"base_url"===e.name)?.default?.toString()||"",description:(0,eq.extractI18nObject)(e.description)})))}async function m(e){let t=(await h.httpClient.getModelProvider(e)).provider;i.setValue("name",t.name),i.setValue("requester",t.requester),i.setValue("base_url",t.base_url),i.setValue("api_key",t.api_keys?.[0]||"")}async function u(s){let a={name:s.name,requester:s.requester,base_url:s.base_url,api_keys:s.api_key?[s.api_key]:[]};try{e?(await h.httpClient.updateModelProvider(e,a),L.toast.success(l("models.providerSaved"))):(await h.httpClient.createModelProvider(a),L.toast.success(l("models.providerCreated"))),t()}catch(e){L.toast.error(l("models.providerSaveError")+e.msg)}}return(0,n.useEffect)(()=>{c(),e&&m(e)},[e]),(0,s.jsx)(Z.Form,{...i,children:(0,s.jsxs)("form",{onSubmit:i.handleSubmit(u),className:"space-y-4",children:[(0,s.jsx)(Z.FormField,{control:i.control,name:"name",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsxs)(Z.FormLabel,{children:[l("models.providerName"),(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{...e})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsx)(Z.FormField,{control:i.control,name:"requester",render:({field:t})=>{let a=r.find(e=>e.value===t.value);return(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsxs)(Z.FormLabel,{children:[l("models.requester"),(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsxs)(eA.Select,{onValueChange:s=>{t.onChange(s);let a=r.find(e=>e.value===s);!a||e&&i.getValues("base_url")||i.setValue("base_url",a.defaultUrl)},value:t.value,children:[(0,s.jsx)(eA.SelectTrigger,{className:"bg-background",children:a?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(a.value),alt:a.label,className:"h-5 w-5 rounded"}),(0,s.jsx)("span",{children:a.label})]}):(0,s.jsx)(eA.SelectValue,{placeholder:l("models.selectRequester")})}),(0,s.jsxs)(eA.SelectContent,{children:[(0,s.jsxs)(eA.SelectGroup,{children:[(0,s.jsx)(eA.SelectLabel,{children:l("models.builtin")}),r.filter(e=>"builtin"===e.category).map(e=>(0,s.jsx)(eA.SelectItem,{value:e.value,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(e.value),alt:e.label,className:"h-5 w-5 rounded"}),(0,s.jsx)("span",{children:e.label})]})},e.value))]}),(0,s.jsxs)(eA.SelectGroup,{children:[(0,s.jsx)(eA.SelectLabel,{children:l("models.modelManufacturer")}),r.filter(e=>"manufacturer"===e.category).map(e=>(0,s.jsx)(eA.SelectItem,{value:e.value,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(e.value),alt:e.label,className:"h-5 w-5 rounded"}),(0,s.jsx)("span",{children:e.label})]})},e.value))]}),(0,s.jsxs)(eA.SelectGroup,{children:[(0,s.jsx)(eA.SelectLabel,{children:l("models.aggregationPlatform")}),r.filter(e=>"maas"===e.category).map(e=>(0,s.jsx)(eA.SelectItem,{value:e.value,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(e.value),alt:e.label,className:"h-5 w-5 rounded"}),(0,s.jsx)("span",{children:e.label})]})},e.value))]}),(0,s.jsxs)(eA.SelectGroup,{children:[(0,s.jsx)(eA.SelectLabel,{children:l("models.selfDeployed")}),r.filter(e=>"self-hosted"===e.category).map(e=>(0,s.jsx)(eA.SelectItem,{value:e.value,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(e.value),alt:e.label,className:"h-5 w-5 rounded"}),(0,s.jsx)("span",{children:e.label})]})},e.value))]})]})]}),(0,s.jsx)(Z.FormMessage,{}),a?.description&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:a.description})]})}}),(0,s.jsx)(Z.FormField,{control:i.control,name:"base_url",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsx)(Z.FormLabel,{children:l("models.requestURL")}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{...e})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsx)(Z.FormField,{control:i.control,name:"api_key",render:({field:e})=>(0,s.jsxs)(Z.FormItem,{children:[(0,s.jsx)(Z.FormLabel,{children:l("models.apiKey")}),(0,s.jsx)(Z.FormControl,{children:(0,s.jsx)(K.Input,{...e,type:"password"})}),(0,s.jsx)(Z.FormMessage,{})]})}),(0,s.jsxs)(M.DialogFooter,{children:[(0,s.jsx)(k.Button,{type:"submit",children:l("common.save")}),(0,s.jsx)(k.Button,{type:"button",variant:"outline",onClick:a,children:l("common.cancel")})]})]})})}var eZ=e.i(54944),eK=e.i(54647);function eW({args:e,onChange:t,disabled:a=!1}){let{t:l}=(0,x.useTranslation)(),n=(s,a,l)=>{let n=[...e];n[s]={...n[s],[a]:l},t(n)};return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(eK.Label,{children:l("models.extraParameters")}),!a&&(0,s.jsxs)(k.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{t([...e,{key:"",type:"string",value:""}])},children:[(0,s.jsx)(Q.Plus,{className:"h-3 w-3 mr-1"}),l("models.addParameter")]})]}),0===e.length?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:l("common.none")}):e.map((o,i)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)(K.Input,{placeholder:l("models.keyName"),value:o.key,className:"flex-1",disabled:a,onChange:e=>n(i,"key",e.target.value)}),(0,s.jsxs)(eA.Select,{value:o.type,disabled:a,onValueChange:e=>n(i,"type",e),children:[(0,s.jsx)(eA.SelectTrigger,{className:"w-24",children:(0,s.jsx)(eA.SelectValue,{})}),(0,s.jsxs)(eA.SelectContent,{children:[(0,s.jsx)(eA.SelectItem,{value:"string",children:l("models.string")}),(0,s.jsx)(eA.SelectItem,{value:"number",children:l("models.number")}),(0,s.jsx)(eA.SelectItem,{value:"boolean",children:l("models.boolean")})]})]}),(0,s.jsx)(K.Input,{placeholder:l("models.value"),value:o.value,className:"flex-1",disabled:a,onChange:e=>n(i,"value",e.target.value)}),!a&&(0,s.jsx)(k.Button,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:()=>{t(e.filter((e,t)=>t!==i))},children:(0,s.jsx)(eZ.X,{className:"h-4 w-4"})})]},i))]})}var eG=e.i(7377),eJ=e.i(53397),eX=e.i(74110);function eY(e){return e?Object.entries(e).map(([e,t])=>{let s="string";return"number"==typeof t?s="number":"boolean"==typeof t&&(s="boolean"),{key:e,type:s,value:String(t)}}):[]}function eQ({model:e,modelType:t,isLangBotModels:a,editModelPopoverOpen:l,deleteConfirmOpen:o,onOpenEditModel:i,onCloseEditModel:r,onOpenDeleteConfirm:d,onCloseDeleteConfirm:c,onDeleteModel:m,onUpdateModel:h,onTestModel:p,isSubmitting:g,isTesting:j,testResult:f,onResetTestResult:v}){let{t:b}=(0,x.useTranslation)(),[C,w]=(0,n.useState)(e.name),[y,S]=(0,n.useState)("llm"===t&&e.abilities||[]),[L,M]=(0,n.useState)(eY(e.extra_args)),P=l===e.uuid,T=o===e.uuid;(0,n.useEffect)(()=>{P&&(w(e.name),S("llm"===t&&e.abilities||[]),M(eY(e.extra_args)),v())},[P]);let D=async()=>{await h(C,y,L)},H=async()=>{await p(C,y,L)},I=(e,t)=>{t?S([...y,e]):S(y.filter(t=>t!==e))},z=a&&u.userInfo?.account_type!=="space";return(0,s.jsxs)(N.Popover,{open:P&&!z,onOpenChange:t=>{z||(t?i(e.uuid):r())},children:[(0,s.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,s.jsxs)("div",{className:`flex items-center justify-between py-2 px-3 rounded-md border bg-background ${z?"cursor-not-allowed opacity-60":"hover:bg-accent cursor-pointer"}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,s.jsx)(_.Badge,{variant:"secondary",className:"text-xs",children:b("llm"===t?"models.chat":"models.embedding")}),"llm"===t&&e.abilities?.includes("vision")&&(0,s.jsx)(_.Badge,{variant:"outline",className:"text-xs gap-1",children:(0,s.jsx)(eG.Eye,{className:"h-3 w-3"})}),"llm"===t&&e.abilities?.includes("func_call")&&(0,s.jsx)(_.Badge,{variant:"outline",className:"text-xs gap-1",children:(0,s.jsx)(eJ.Wrench,{className:"h-3 w-3"})})]}),!a&&(0,s.jsxs)(N.Popover,{open:T,onOpenChange:t=>t?d(e.uuid):c(),children:[(0,s.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,s.jsx)(k.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 flex-shrink-0",onClick:e=>{e.stopPropagation()},children:(0,s.jsx)(Y,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"})})}),(0,s.jsx)(N.PopoverContent,{className:"w-64",align:"end",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm",children:b("models.deleteConfirmation")}),(0,s.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,s.jsx)(k.Button,{variant:"outline",size:"sm",onClick:()=>c(),children:b("common.cancel")}),(0,s.jsx)(k.Button,{variant:"destructive",size:"sm",onClick:()=>{m(),c()},children:b("common.delete")})]})]})})]})]})}),(0,s.jsx)(N.PopoverContent,{className:"w-80",align:"start",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eK.Label,{children:b("models.modelName")}),(0,s.jsx)(K.Input,{placeholder:b("models.modelName"),value:C,onChange:e=>w(e.target.value),disabled:a})]}),"llm"===t&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eK.Label,{children:b("models.abilities")}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eX.Checkbox,{id:`edit-vision-${e.uuid}`,checked:y.includes("vision"),disabled:a,onCheckedChange:e=>I("vision",e)}),(0,s.jsxs)(eK.Label,{htmlFor:`edit-vision-${e.uuid}`,className:"text-sm",children:[(0,s.jsx)(eG.Eye,{className:"h-3 w-3 inline mr-1"}),b("models.visionAbility")]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eX.Checkbox,{id:`edit-func-call-${e.uuid}`,checked:y.includes("func_call"),disabled:a,onCheckedChange:e=>I("func_call",e)}),(0,s.jsxs)(eK.Label,{htmlFor:`edit-func-call-${e.uuid}`,className:"text-sm",children:[(0,s.jsx)(eJ.Wrench,{className:"h-3 w-3 inline mr-1"}),b("models.functionCallAbility")]})]})]})]}),(0,s.jsx)(eW,{args:L,onChange:M,disabled:a}),(0,s.jsxs)("div",{className:"flex gap-2",children:[!a&&(0,s.jsx)(k.Button,{className:"flex-1",size:"sm",onClick:D,disabled:g||j,children:b(g?"common.saving":"common.save")}),(0,s.jsx)(k.Button,{className:a?"w-full":"flex-1",size:"sm",variant:"outline",onClick:H,disabled:g||j,children:j?b("common.loading"):f?.success?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(X.Check,{className:"h-4 w-4 mr-1 text-green-500"}),(f.duration/1e3).toFixed(1),"s"]}):b("common.test")})]})]})})]})}let e0=(0,f.default)("message-square-text",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]),e1=(0,f.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);function e2({isOpen:e,onOpen:t,onClose:a,onAddModel:l,onTestModel:o,isSubmitting:i,isTesting:r,testResult:d,onResetTestResult:c}){let{t:m}=(0,x.useTranslation)(),[u,h]=(0,n.useState)("llm"),[p,g]=(0,n.useState)(""),[j,f]=(0,n.useState)([]),[v,b]=(0,n.useState)([]);(0,n.useEffect)(()=>{e&&(h("llm"),g(""),f([]),b([]),c())},[e]);let C=async()=>{await l(u,p,j,v)},w=async()=>{await o(p,u,"llm"===u?j:[],v)},y=(e,t)=>{t?f([...j,e]):f(j.filter(t=>t!==e))};return(0,s.jsxs)(N.Popover,{open:e,onOpenChange:e=>e?t():a(),children:[(0,s.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,s.jsxs)(k.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(Q.Plus,{className:"h-3 w-3 mr-1"}),m("models.addModel")]})}),(0,s.jsx)(N.PopoverContent,{className:"w-80",align:"end",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)(ee.Tabs,{value:u,onValueChange:e=>h(e),children:[(0,s.jsxs)(ee.TabsList,{className:"grid w-full grid-cols-2",children:[(0,s.jsxs)(ee.TabsTrigger,{value:"llm",children:[(0,s.jsx)(e0,{className:"h-4 w-4 mr-1"}),m("models.chat")]}),(0,s.jsxs)(ee.TabsTrigger,{value:"embedding",children:[(0,s.jsx)(e1,{className:"h-4 w-4 mr-1"}),m("models.embedding")]})]}),(0,s.jsxs)(ee.TabsContent,{value:"llm",className:"space-y-3 mt-3",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eK.Label,{children:m("models.modelName")}),(0,s.jsx)(K.Input,{placeholder:m("models.modelName"),value:p,onChange:e=>g(e.target.value)})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eK.Label,{children:m("models.abilities")}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eX.Checkbox,{id:"add-vision",checked:j.includes("vision"),onCheckedChange:e=>y("vision",e)}),(0,s.jsxs)(eK.Label,{htmlFor:"add-vision",className:"text-sm",children:[(0,s.jsx)(eG.Eye,{className:"h-3 w-3 inline mr-1"}),m("models.visionAbility")]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eX.Checkbox,{id:"add-func-call",checked:j.includes("func_call"),onCheckedChange:e=>y("func_call",e)}),(0,s.jsxs)(eK.Label,{htmlFor:"add-func-call",className:"text-sm",children:[(0,s.jsx)(eJ.Wrench,{className:"h-3 w-3 inline mr-1"}),m("models.functionCallAbility")]})]})]})]}),(0,s.jsx)(eW,{args:v,onChange:b}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(k.Button,{className:"flex-1",size:"sm",onClick:C,disabled:i||r,children:m(i?"common.saving":"common.add")}),(0,s.jsx)(k.Button,{className:"flex-1",size:"sm",variant:"outline",onClick:w,disabled:i||r,children:r?m("common.loading"):d?.success?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(X.Check,{className:"h-4 w-4 mr-1 text-green-500"}),(d.duration/1e3).toFixed(1),"s"]}):m("common.test")})]})]}),(0,s.jsxs)(ee.TabsContent,{value:"embedding",className:"space-y-3 mt-3",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eK.Label,{children:m("models.modelName")}),(0,s.jsx)(K.Input,{placeholder:m("models.modelName"),value:p,onChange:e=>g(e.target.value)})]}),(0,s.jsx)(eW,{args:v,onChange:b}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(k.Button,{className:"flex-1",size:"sm",onClick:C,disabled:i||r,children:m(i?"common.saving":"common.add")}),(0,s.jsx)(k.Button,{className:"flex-1",size:"sm",variant:"outline",onClick:w,disabled:i||r,children:r?m("common.loading"):d?.success?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(X.Check,{className:"h-4 w-4 mr-1 text-green-500"}),(d.duration/1e3).toFixed(1),"s"]}):m("common.test")})]})]})]})})]})}var e5=e.i(21984),e4=e.i(37106),e7=e.i(79154);let e3=(0,f.default)("log-in",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);var e8=e.i(60677),e6=e.i(25815),e9=e.i(4372),te=e.i(33036),tt=e.i(21619),ts="Collapsible",[ta,tl]=(0,ea.createContextScope)(ts),[tn,to]=ta(ts),ti=n.forwardRef((e,t)=>{let{__scopeCollapsible:a,open:l,defaultOpen:o,disabled:i,onOpenChange:r,...d}=e,[c,m]=(0,e8.useControllableState)({prop:l,defaultProp:o??!1,onChange:r,caller:ts});return(0,s.jsx)(tn,{scope:a,disabled:i,contentId:(0,tt.useId)(),open:c,onOpenToggle:n.useCallback(()=>m(e=>!e),[m]),children:(0,s.jsx)(e9.Primitive.div,{"data-state":th(c),"data-disabled":i?"":void 0,...d,ref:t})})});ti.displayName=ts;var tr="CollapsibleTrigger",td=n.forwardRef((e,t)=>{let{__scopeCollapsible:a,...l}=e,n=to(tr,a);return(0,s.jsx)(e9.Primitive.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":th(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...l,ref:t,onClick:(0,eo.composeEventHandlers)(e.onClick,n.onOpenToggle)})});td.displayName=tr;var tc="CollapsibleContent",tm=n.forwardRef((e,t)=>{let{forceMount:a,...l}=e,n=to(tc,e.__scopeCollapsible);return(0,s.jsx)(te.Presence,{present:a||n.open,children:({present:e})=>(0,s.jsx)(tu,{...l,ref:t,present:e})})});tm.displayName=tc;var tu=n.forwardRef((e,t)=>{let{__scopeCollapsible:a,present:l,children:o,...i}=e,r=to(tc,a),[d,c]=n.useState(l),m=n.useRef(null),u=(0,el.useComposedRefs)(t,m),h=n.useRef(0),x=h.current,p=n.useRef(0),g=p.current,j=r.open||d,f=n.useRef(j),v=n.useRef(void 0);return n.useEffect(()=>{let e=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,e6.useLayoutEffect)(()=>{let e=m.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();h.current=t.height,p.current=t.width,f.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(l)}},[r.open,l]),(0,s.jsx)(e9.Primitive.div,{"data-state":th(r.open),"data-disabled":r.disabled?"":void 0,id:r.contentId,hidden:!j,...i,ref:u,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:j&&o})});function th(e){return e?"open":"closed"}function tx({...e}){return(0,s.jsx)(ti,{"data-slot":"collapsible",...e})}function tp({...e}){return(0,s.jsx)(td,{"data-slot":"collapsible-trigger",...e})}function tg({...e}){return(0,s.jsx)(tm,{"data-slot":"collapsible-content",...e})}var tj=e.i(81817);function tf({provider:e,isLangBotModels:t=!1,isExpanded:a,isLoading:l,models:o,accountType:i,spaceCredits:r,addModelPopoverOpen:d,editModelPopoverOpen:c,deleteConfirmOpen:p,onToggle:g,onEditProvider:j,onDeleteProvider:f,onSpaceLogin:v,onOpenAddModel:b,onCloseAddModel:C,onAddModel:w,onOpenEditModel:y,onCloseEditModel:S,onUpdateModel:L,onOpenDeleteConfirm:M,onCloseDeleteConfirm:P,onDeleteModel:T,onTestModel:D,isSubmitting:H,isTesting:I,testResult:z,onResetTestResult:F}){var B;let{t:R}=(0,x.useTranslation)(),[V,$]=(0,n.useState)(!1),E=!t&&0===(e.llm_count||0)&&0===(e.embedding_count||0),O=(e.llm_count||0)+(e.embedding_count||0);return(0,s.jsx)(tj.Card,{className:"mb-2",children:(0,s.jsxs)(tx,{open:a,onOpenChange:g,children:[(0,s.jsxs)(tj.CardHeader,{className:"py-0 px-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[t?(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg overflow-hidden flex-shrink-0",children:(0,s.jsx)("img",{src:m.default.src,alt:"LangBot",className:"w-full h-full object-cover"})}):(0,s.jsx)("img",{src:h.httpClient.getProviderRequesterIconURL(e.requester),alt:e.name,className:"h-9 w-9 rounded-lg"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(tj.CardTitle,{className:"text-base",children:e.name}),(0,s.jsx)(_.Badge,{variant:"outline",className:"text-xs",children:R("models.modelsCount",{count:O})})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:t?R("models.langbotModelsDescription"):(0,s.jsxs)(s.Fragment,{children:[e.base_url,e.base_url&&e.api_keys?.length>0&&" · ",e.api_keys?.length>0&&((B=e.api_keys[0])?B.length<=8?"****":`${B.slice(0,4)}...${B.slice(-4)}`:"")]})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-2",children:[t&&"space"!==i&&(0,s.jsxs)(k.Button,{variant:"outline",size:"sm",onClick:e=>{e.stopPropagation(),v()},children:[(0,s.jsx)(e3,{className:"h-4 w-4 mr-1"}),R("models.loginWithSpace")]}),t&&"space"===i&&null!==r&&(0,s.jsxs)("div",{className:"flex items-center gap-1 border rounded-md px-2 h-8 text-sm mr-2",children:[(0,s.jsxs)("span",{children:[(r/5e3).toFixed(2)," ",R("models.credits")]}),(0,s.jsx)(k.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:e=>{e.stopPropagation(),window.open(`${u.systemInfo.cloud_service_url}/profile?tab=billing`,"_blank")},children:(0,s.jsx)(Q.Plus,{className:"h-3 w-3"})})]}),!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(k.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:e=>{e.stopPropagation(),j()},children:(0,s.jsx)(e7.Settings,{className:"h-4 w-4"})}),E&&(0,s.jsxs)(N.Popover,{open:V,onOpenChange:$,children:[(0,s.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,s.jsx)(k.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:e=>{e.stopPropagation()},children:(0,s.jsx)(Y,{className:"h-4 w-4 text-destructive"})})}),(0,s.jsx)(N.PopoverContent,{className:"w-64",align:"end",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm",children:R("models.deleteProviderConfirmation")}),(0,s.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,s.jsx)(k.Button,{variant:"outline",size:"sm",onClick:()=>$(!1),children:R("common.cancel")}),(0,s.jsx)(k.Button,{variant:"destructive",size:"sm",onClick:()=>{f(),$(!1)},children:R("common.delete")})]})]})})]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[O>0?(0,s.jsxs)(tp,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground cursor-pointer",children:[a?(0,s.jsx)(e5.ChevronDown,{className:"h-3 w-3"}):(0,s.jsx)(e4.ChevronRight,{className:"h-3 w-3"}),(0,s.jsx)("span",{children:R(a?"models.collapseModels":"models.expandModels")})]}):(0,s.jsx)("div",{}),!t&&(0,s.jsx)(e2,{isOpen:d===e.uuid,onOpen:b,onClose:C,onAddModel:w,onTestModel:D,isSubmitting:H,isTesting:I,testResult:z,onResetTestResult:F})]})]}),(0,s.jsx)(tg,{children:(0,s.jsx)(tj.CardContent,{className:"px-4 mt-2",children:l?(0,s.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:[R("common.loading"),"..."]}):o?(0,s.jsxs)("div",{className:"space-y-2",children:[o.llm.map(e=>(0,s.jsx)(eQ,{model:e,modelType:"llm",isLangBotModels:t,editModelPopoverOpen:c,deleteConfirmOpen:p,onOpenEditModel:y,onCloseEditModel:S,onOpenDeleteConfirm:M,onCloseDeleteConfirm:P,onDeleteModel:()=>T(e.uuid,"llm"),onUpdateModel:(t,s,a)=>L(e.uuid,"llm",t,s,a),onTestModel:(e,t,s)=>D(e,"llm",t,s),isSubmitting:H,isTesting:I,testResult:z,onResetTestResult:F},e.uuid)),o.embedding.map(e=>(0,s.jsx)(eQ,{model:e,modelType:"embedding",isLangBotModels:t,editModelPopoverOpen:c,deleteConfirmOpen:p,onOpenEditModel:y,onCloseEditModel:S,onOpenDeleteConfirm:M,onCloseDeleteConfirm:P,onDeleteModel:()=>T(e.uuid,"embedding"),onUpdateModel:(t,s,a)=>L(e.uuid,"embedding",t,s,a),onTestModel:(e,t,s)=>D(e,"embedding",t,s),isSubmitting:H,isTesting:I,testResult:z,onResetTestResult:F},e.uuid)),0===o.llm.length&&0===o.embedding.length&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:R("models.noModels")})]}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:R("models.noModels")})})})]})})}let tv="space-chat-completions";function tb(e){let t={};return e.forEach(e=>{e.key.trim()&&("number"===e.type?t[e.key]=Number(e.value):"boolean"===e.type?t[e.key]="true"===e.value:t[e.key]=e.value)}),t}function tC({open:e,onOpenChange:t}){let{t:a}=(0,x.useTranslation)(),[l,o]=(0,n.useState)([]),[i,r]=(0,n.useState)("local"),[d,c]=(0,n.useState)(null),[m,p]=(0,n.useState)(new Set),[g,j]=(0,n.useState)({}),[f,v]=(0,n.useState)(new Set),[b,C]=(0,n.useState)(!1),[w,y]=(0,n.useState)(null),[N,S]=(0,n.useState)(null),[_,P]=(0,n.useState)(null),[T,D]=(0,n.useState)(null),[H,I]=(0,n.useState)(!1),[z,F]=(0,n.useState)(!1),[B,R]=(0,n.useState)(null),[V,$]=(0,n.useState)(!1),E=u.systemInfo.disable_models_service?void 0:l.find(e=>e.requester===tv),O=l.filter(e=>e.requester!==tv);async function A(){try{let e=await h.httpClient.getUserInfo();if(r(e.account_type),"space"===e.account_type){let e=await h.httpClient.getSpaceCredits();c(e.credits)}}catch{r("local")}}async function q(){try{let e=await h.httpClient.getModelProviders();o(e.providers),$(!0)}catch(e){console.error("Failed to load providers",e),L.toast.error(a("models.loadError"))}}async function U(e,t=!1){if(!f.has(e)){t||v(t=>new Set(t).add(e));try{let[t,s]=await Promise.all([h.httpClient.getProviderLLMModels(e),h.httpClient.getProviderEmbeddingModels(e)]);j(a=>({...a,[e]:{llm:t.models,embedding:s.models}}))}catch(e){console.error("Failed to load models",e)}finally{t||v(t=>{let s=new Set(t);return s.delete(e),s})}}}async function Z(e){try{await h.httpClient.deleteModelProvider(e),L.toast.success(a("models.providerDeleted")),q()}catch(e){L.toast.error(a("models.providerDeleteError")+e.message)}}async function K(){try{let e=localStorage.getItem("token");if(!e)return void L.toast.error(a("common.error"));let t=window.location.origin,s=`${t}/auth/space/callback?mode=bind`,l=await h.httpClient.getSpaceAuthorizeUrl(s,e);window.location.href=l.authorize_url}catch{L.toast.error(a("common.spaceLoginFailed"))}}async function W(e,t,s,l,n){if(!s.trim())return void L.toast.error(a("models.modelNameRequired"));I(!0);try{let a=tb(n);"llm"===t?await h.httpClient.createProviderLLMModel({name:s,provider_uuid:e,abilities:l,extra_args:a}):await h.httpClient.createProviderEmbeddingModel({name:s,provider_uuid:e,extra_args:a}),S(null),U(e,!0),q()}catch(e){L.toast.error(a("models.createError")+e.message)}finally{I(!1)}}async function G(e,t,s,l,n,o){if(!l.trim())return void L.toast.error(a("models.modelNameRequired"));I(!0);try{let a=tb(o);"llm"===s?await h.httpClient.updateProviderLLMModel(t,{name:l,provider_uuid:e,abilities:n,extra_args:a}):await h.httpClient.updateProviderEmbeddingModel(t,{name:l,provider_uuid:e,extra_args:a}),P(null),U(e,!0),q()}catch(e){L.toast.error(a("models.saveError")+e.message)}finally{I(!1)}}async function J(e,t,s){try{"llm"===s?await h.httpClient.deleteProviderLLMModel(t):await h.httpClient.deleteProviderEmbeddingModel(t),L.toast.success(a("models.deleteSuccess")),U(e,!0),q()}catch(e){L.toast.error(a("models.deleteError")+e.message)}}async function X(e,t,s,n,o){F(!0),R(null);let i=Date.now();try{let a=tb(o),r=l.find(t=>t.uuid===e),d={requester:r?.requester||"",base_url:r?.base_url||"",api_keys:r?.api_keys||[]};"llm"===s?await h.httpClient.testLLMModel("_",{uuid:"",name:t,provider_uuid:"",provider:d,abilities:n,extra_args:a}):await h.httpClient.testEmbeddingModel("_",{uuid:"",name:t,provider_uuid:"",provider:d,extra_args:a});let c=Date.now()-i;R({success:!0,duration:c})}catch(e){console.error("Failed to test model",e),L.toast.error(a("models.testError")+": "+e.msg),R(null)}finally{F(!1)}}function Y(e,t=!1){return(0,s.jsx)(tf,{provider:e,isLangBotModels:t,isExpanded:m.has(e.uuid),isLoading:f.has(e.uuid),models:g[e.uuid],accountType:i,spaceCredits:d,addModelPopoverOpen:N,editModelPopoverOpen:_,deleteConfirmOpen:T,onToggle:()=>{var t;return t=e.uuid,void p(e=>{let s=new Set(e);return s.has(t)?s.delete(t):(s.add(t),g[t]||U(t)),s})},onEditProvider:()=>{y(e.uuid),C(!0)},onDeleteProvider:()=>Z(e.uuid),onSpaceLogin:K,onOpenAddModel:()=>S(e.uuid),onCloseAddModel:()=>S(null),onAddModel:(t,s,a,l)=>W(e.uuid,t,s,a,l),onOpenEditModel:e=>P(e),onCloseEditModel:()=>P(null),onUpdateModel:(t,s,a,l,n)=>G(e.uuid,t,s,a,l,n),onOpenDeleteConfirm:e=>D(e),onCloseDeleteConfirm:()=>D(null),onDeleteModel:(t,s)=>J(e.uuid,t,s),onTestModel:(t,s,a,l)=>X(e.uuid,t,s,a,l),isSubmitting:H,isTesting:z,testResult:B,onResetTestResult:()=>R(null)},e.uuid)}return(0,n.useEffect)(()=>{e&&(A(),q())},[e]),(0,n.useEffect)(()=>{V&&E&&0===O.length&&!m.has(E.uuid)&&(p(new Set([E.uuid])),g[E.uuid]||U(E.uuid))},[V,l]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M.Dialog,{open:e,onOpenChange:e=>{(e||!b)&&t(e)},children:(0,s.jsxs)(M.DialogContent,{className:"overflow-hidden p-0 h-[80vh] flex flex-col !max-w-[37rem]",children:[(0,s.jsx)(M.DialogHeader,{className:"px-6 pt-6 pb-0 flex-shrink-0",children:(0,s.jsx)(M.DialogTitle,{children:a("models.title")})}),(0,s.jsxs)("div",{className:"flex-1 overflow-auto px-6 pb-6 mt-0",children:[E&&Y(E,!0),(0,s.jsxs)("div",{className:"mb-3 flex justify-between items-center sticky top-0 bg-background py-2 z-10",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:0===O.length?a(u.systemInfo.disable_models_service?"models.addProviderHintSimple":"models.addProviderHint"):a("models.providerCount",{count:O.length})}),(0,s.jsxs)(k.Button,{size:"sm",variant:"outline",onClick:function(){y(null),C(!0)},children:[(0,s.jsx)(Q.Plus,{className:"h-4 w-4 mr-1"}),a("models.addProvider")]})]}),0===O.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,s.jsx)(eO,{className:"h-12 w-12 mb-3 opacity-50"}),(0,s.jsx)("p",{className:"text-sm",children:a("models.noProviders")})]}):O.map(e=>Y(e))]})]})}),(0,s.jsx)(M.Dialog,{open:b,onOpenChange:C,children:(0,s.jsxs)(M.DialogContent,{className:"w-[600px] p-6",children:[(0,s.jsx)(M.DialogHeader,{children:(0,s.jsx)(M.DialogTitle,{children:w?a("models.editProvider"):a("models.addProvider")})}),(0,s.jsx)(eU,{providerId:w||void 0,onFormSubmit:function(){C(!1),q(),m.forEach(e=>U(e))},onFormCancel:()=>C(!1)})]})})]})}function tw({onSelectedChangeAction:e}){let t=(0,r.useRouter)(),a=(0,r.usePathname)(),o=(0,r.useSearchParams)();(0,n.useEffect)(()=>{var t=a;if("home"===t.split("/")[1]&&c.find(e=>e.route===t)){let s=c.find(e=>e.route===t);s&&(f(s),e(s))}},[a]),(0,n.useEffect)(()=>{"showModelSettings"===o.get("action")&&W(!0),"showAccountSettings"===o.get("action")&&I(!0),"showApiIntegrationSettings"===o.get("action")&&F(!0)},[o]);let[d,f]=(0,n.useState)(),{theme:L,setTheme:M}=(0,y.useTheme)(),{t:P}=(0,x.useTranslation)(),[T,D]=(0,n.useState)(!1),[H,I]=(0,n.useState)(!1),[z,F]=(0,n.useState)(!1),[B,R]=(0,n.useState)(!1),[V,$]=(0,n.useState)(null),[E,O]=(0,n.useState)(null),[A,q]=(0,n.useState)(!1),[U,Z]=(0,n.useState)(!1),[K,W]=(0,n.useState)(!1),[J,X]=(0,n.useState)("");function Y(e){if(W(e),e){let e=new URLSearchParams(o.toString());e.set("action","showModelSettings"),t.replace(`${a}?${e.toString()}`,{scroll:!1})}else{let e=new URLSearchParams(o.toString());e.delete("action");let s=e.toString()?`${a}?${e.toString()}`:a;t.replace(s,{scroll:!1})}}function Q(e){if(I(e),e){let e=new URLSearchParams(o.toString());e.set("action","showAccountSettings"),t.replace(`${a}?${e.toString()}`,{scroll:!1})}else{let e=new URLSearchParams(o.toString());e.delete("action");let s=e.toString()?`${a}?${e.toString()}`:a;t.replace(s,{scroll:!1})}}function ee(s){var a;f(s),a=s,t.push(`${a.route}`),e(s)}return(0,n.useEffect)(()=>{let e;(e=c.find(e=>e.route===a))?ee(e):ee(c[0]),localStorage.getItem("token")||(localStorage.setItem("token","test-token"),localStorage.setItem("userEmail","test@example.com"));let t=localStorage.getItem("userEmail");t?X(t):h.httpClient.getUserInfo().then(e=>{X(e.user),localStorage.setItem("userEmail",e.user)}).catch(()=>{}),(0,u.getCloudServiceClientSync)().get("/api/v1/dist/info/repo").then(e=>{$(e.repo.stargazers_count)}).catch(e=>{console.error("Failed to fetch GitHub star count:",e)}),(0,u.getCloudServiceClientSync)().getLangBotReleases().then(e=>{if(e&&e.length>0){let t=e.find(e=>!e.prerelease&&!e.draft)||e[0];O(t);let s=u.systemInfo?.version;s&&t.tag_name&&q(function(e,t){let s=e.replace(/^v/,""),a=t.replace(/^v/,""),l=s.split(".").map(e=>parseInt(e,10)||0),n=a.split(".").map(e=>parseInt(e,10)||0),o=Math.max(l.length,n.length);for(let e=0;e<o;e++){let t=l[e]||0,s=n[e]||0;if(t>s)return!0;if(t<s)break}return!1}(t.tag_name,s))}}).catch(e=>{console.error("Failed to fetch releases:",e)})},[]),(0,s.jsxs)("div",{className:`${l.default.sidebarContainer}`,children:[(0,s.jsxs)("div",{className:`${l.default.sidebarTopContainer}`,children:[(0,s.jsxs)("div",{className:`${l.default.langbotIconContainer}`,children:[(0,s.jsx)("img",{className:`${l.default.langbotIcon}`,src:m.default.src,alt:"langbot-icon"}),(0,s.jsxs)("div",{className:`${l.default.langbotTextContainer}`,children:[(0,s.jsx)("div",{className:`${l.default.langbotText}`,children:"LangBot"}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("div",{className:`${l.default.langbotVersion}`,children:u.systemInfo?.version}),A&&(0,s.jsx)(_.Badge,{onClick:()=>Z(!0),className:"bg-red-500 hover:bg-red-600 text-white text-[0.6rem] px-1.5 py-0 h-4 cursor-pointer",children:P("plugins.new")})]})]})]}),(0,s.jsx)("div",{className:l.default.sidebarItemsContainer,children:c.map(e=>(0,s.jsx)("div",{onClick:()=>{ee(e)},children:(0,s.jsx)(i,{onClick:()=>{},isSelected:void 0!==d&&d.id===e.id,icon:e.icon,name:e.name})},e.id))})]}),(0,s.jsxs)("div",{className:`${l.default.sidebarBottomContainer}`,children:[null!==V&&(0,s.jsx)("div",{onClick:()=>{window.open("https://github.com/langbot-app/LangBot","_blank")},className:"flex justify-center cursor-pointer p-2 rounded-lg transition-colors",children:(0,s.jsxs)(_.Badge,{variant:"outline",className:"hover:bg-secondary/50 px-3 py-1.5 text-sm font-medium transition-colors border-border relative overflow-hidden group",children:[(0,s.jsx)("svg",{className:"w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.42 2.865 8.17 6.839 9.49.5.092.682-.217.682-.482 0-.237-.008-.866-.013-1.7-2.782.604-3.369-1.34-3.369-1.34-.454-1.156-1.11-1.464-1.11-1.464-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.831.092-.646.35-1.086.636-1.336-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.743 0 .267.18.578.688.48C19.138 20.167 22 16.418 22 12c0-5.523-4.477-10-10-10z"})}),(0,s.jsx)("div",{className:"absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-white/20 to-transparent group-hover:translate-x-full transition-transform duration-1000 ease-out"}),V.toLocaleString()]})}),(0,s.jsx)(i,{onClick:()=>Y(!0),isSelected:!1,icon:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M10.6144 17.7956C10.277 18.5682 9.20776 18.5682 8.8704 17.7956L7.99275 15.7854C7.21171 13.9966 5.80589 12.5726 4.0523 11.7942L1.63658 10.7219C.868536 10.381.868537 9.26368 1.63658 8.92276L3.97685 7.88394C5.77553 7.08552 7.20657 5.60881 7.97427 3.75892L8.8633 1.61673C9.19319.821767 10.2916.821765 10.6215 1.61673L11.5105 3.75894C12.2782 5.60881 13.7092 7.08552 15.5079 7.88394L17.8482 8.92276C18.6162 9.26368 18.6162 10.381 17.8482 10.7219L15.4325 11.7942C13.6789 12.5726 12.2731 13.9966 11.492 15.7854L10.6144 17.7956ZM4.53956 9.82234C6.8254 10.837 8.68402 12.5048 9.74238 14.7996 10.8008 12.5048 12.6594 10.837 14.9452 9.82234 12.6321 8.79557 10.7676 7.04647 9.74239 4.71088 8.71719 7.04648 6.85267 8.79557 4.53956 9.82234ZM19.4014 22.6899 19.6482 22.1242C20.0882 21.1156 20.8807 20.3125 21.8695 19.8732L22.6299 19.5353C23.0412 19.3526 23.0412 18.7549 22.6299 18.5722L21.9121 18.2532C20.8978 17.8026 20.0911 16.9698 19.6586 15.9269L19.4052 15.3156C19.2285 14.8896 18.6395 14.8896 18.4628 15.3156L18.2094 15.9269C17.777 16.9698 16.9703 17.8026 15.956 18.2532L15.2381 18.5722C14.8269 18.7549 14.8269 19.3526 15.2381 19.5353L15.9985 19.8732C16.9874 20.3125 17.7798 21.1156 18.2198 22.1242L18.4667 22.6899C18.6473 23.104 19.2207 23.104 19.4014 22.6899ZM18.3745 19.0469 18.937 18.4883 19.4878 19.0469 18.937 19.5898 18.3745 19.0469Z"})}),name:P("models.title")}),(0,s.jsxs)(N.Popover,{open:T,onOpenChange:e=>{(e||!B)&&D(e)},children:[(0,s.jsx)(N.PopoverTrigger,{children:(0,s.jsx)(i,{onClick:()=>{},isSelected:!1,icon:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 3C10.9 3 10 3.9 10 5C10 6.1 10.9 7 12 7C13.1 7 14 6.1 14 5C14 3.9 13.1 3 12 3ZM12 17C10.9 17 10 17.9 10 19C10 20.1 10.9 21 12 21C13.1 21 14 20.1 14 19C14 17.9 13.1 17 12 17ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z"})}),name:P("common.accountOptions")})}),(0,s.jsxs)(N.PopoverContent,{side:"right",align:"end",className:"w-auto p-2 flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-accent cursor-pointer",onClick:()=>{Q(!0),D(!1)},children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-medium",children:J?J.charAt(0).toUpperCase():"U"}),(0,s.jsx)("span",{className:"text-sm truncate max-w-[180px]",children:J||P("account.settings")})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(S.LanguageSelector,{triggerClassName:"flex-1",onOpenChange:R}),(0,s.jsxs)(k.Button,{variant:"outline",size:"icon",onClick:()=>M("light"===L?"dark":"dark"===L?"system":"light"),className:"h-9 w-9 shrink-0",children:["light"===L&&(0,s.jsx)(g.Sun,{className:"h-[1.2rem] w-[1.2rem]"}),"dark"===L&&(0,s.jsx)(p.Moon,{className:"h-[1.2rem] w-[1.2rem]"}),"system"===L&&(0,s.jsx)(j.Monitor,{className:"h-[1.2rem] w-[1.2rem]"})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)(k.Button,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>{F(!0),D(!1)},children:[(0,s.jsx)(w,{className:"w-4 h-4 mr-2"}),P("common.apiIntegration")]}),(0,s.jsxs)(k.Button,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>{let e=localStorage.getItem("langbot_language");"zh-Hans"===e||"zh-Hant"===e?window.open("https://docs.langbot.app/zh/insight/guide.html","_blank"):window.open("https://docs.langbot.app/en/insight/guide.html","_blank"),D(!1)},children:[(0,s.jsx)(v,{className:"w-4 h-4 mr-2"}),P("common.helpDocs")]}),(0,s.jsxs)(k.Button,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>{window.open("https://github.com/langbot-app/LangBot/issues","_blank"),D(!1)},children:[(0,s.jsx)(b,{className:"w-4 h-4 mr-2"}),P("common.featureRequest")]}),(0,s.jsxs)(k.Button,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>void(localStorage.removeItem("token"),localStorage.removeItem("userEmail"),window.location.href="/login"),children:[(0,s.jsx)(C,{className:"w-4 h-4 mr-2"}),P("common.logout")]})]})]})]})]}),(0,s.jsx)(G,{open:H,onOpenChange:Q}),(0,s.jsx)(ez,{open:z,onOpenChange:F}),(0,s.jsx)(eE,{open:U,onOpenChange:Z,release:E}),(0,s.jsx)(tC,{open:K,onOpenChange:Y})]})}var ty=e.i(14119);function tN({title:e,subtitle:t,helpLink:a}){return(0,s.jsxs)("div",{className:`${ty.default.titleBarContainer}`,children:[(0,s.jsx)("div",{className:`${ty.default.titleText}`,children:e}),(0,s.jsxs)("div",{className:`${ty.default.subtitleText}`,children:[t,(0,s.jsx)("span",{className:`${ty.default.helpLink}`,children:(0,s.jsx)("div",{onClick:()=>{window.open((0,eq.extractI18nObject)(a),"_blank")},className:"cursor-pointer",children:(0,s.jsx)("svg",{className:"w-[1rem] h-[1rem]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM13 13.3551V14H11V12.5C11 11.9477 11.4477 11.5 12 11.5C12.8284 11.5 13.5 10.8284 13.5 10C13.5 9.17157 12.8284 8.5 12 8.5C11.2723 8.5 10.6656 9.01823 10.5288 9.70577L8.56731 9.31346C8.88637 7.70919 10.302 6.5 12 6.5C13.933 6.5 15.5 8.067 15.5 10C15.5 11.5855 14.4457 12.9248 13 13.3551Z"})})})})]})]})}function tk({children:e}){let[t,l]=(0,n.useState)(""),[o,i]=(0,n.useState)(""),[r,d]=(0,n.useState)({en_US:"",zh_Hans:""});(0,n.useEffect)(()=>{u.userInfo||(0,u.initializeUserInfo)()},[]);let c=(0,n.useCallback)(e=>{l(e.name),i(e.description),d(e.helpLink)},[]),m=(0,n.useMemo)(()=>e,[e]);return(0,s.jsxs)("div",{className:a.default.homeLayoutContainer,children:[(0,s.jsx)("aside",{className:a.default.sidebar,children:(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{}),children:(0,s.jsx)(tw,{onSelectedChangeAction:c})})}),(0,s.jsxs)("div",{className:a.default.main,children:[(0,s.jsx)(tN,{title:t,subtitle:o,helpLink:r}),(0,s.jsx)("main",{className:a.default.mainContent,children:m})]})]})}e.s(["default",()=>tk],64934)}]);