mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-16 15:30:59 +00:00
1 line
36 KiB
JavaScript
1 line
36 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,71654,96476,28332,e=>{"use strict";var t,a=e.i(60498),n=e.i(57728),r=e.i(16585),s=e.i(19309),l=e.i(64339),i=((t={}).INT="integer",t.FLOAT="float",t.BOOLEAN="boolean",t.STRING="string",t.TEXT="text",t.STRING_ARRAY="array[string]",t.FILE="file",t.FILE_ARRAY="array[file]",t.SELECT="select",t.LLM_MODEL_SELECTOR="llm-model-selector",t.PROMPT_EDITOR="prompt-editor",t.UNKNOWN="unknown",t.KNOWLEDGE_BASE_SELECTOR="knowledge-base-selector",t.KNOWLEDGE_BASE_MULTI_SELECTOR="knowledge-base-multi-selector",t.PLUGIN_SELECTOR="plugin-selector",t.BOT_SELECTOR="bot-selector",t);e.s(["DynamicFormItemType",()=>i],96476);var o=e.i(87980),d=e.i(47977),c=e.i(13781),u=e.i(74035),p=e.i(49311),h=e.i(15742),m=e.i(50098);e.i(26128);var x=e.i(91830),f=e.i(11607),g=e.i(14407);function b({className:e,...t}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,g.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var v=e.i(81817),j=e.i(88274),w=e.i(74110),y=e.i(63737),C=e.i(54944),N=e.i(7377),E=e.i(53397);function S({config:e,field:t,onFileUploaded:n}){let[r,s]=(0,p.useState)([]),[l,g]=(0,p.useState)([]),[S,k]=(0,p.useState)([]),[_,T]=(0,p.useState)([]),[L,V]=(0,p.useState)(!1),[H,R]=(0,p.useState)(!1),[O,I]=(0,p.useState)([]),[M,B]=(0,p.useState)(null),{t:P}=(0,x.useTranslation)(),z=async e=>{if(e.size>0xa00000)return m.toast.error(P("plugins.fileUpload.tooLarge")),null;try{V(!0);let t=await h.httpClient.uploadPluginConfigFile(e);return m.toast.success(P("plugins.fileUpload.success")),n?.(t.file_key),{file_key:t.file_key,mimetype:e.type}}catch(e){return m.toast.error(P("plugins.fileUpload.failed")+": "+e.message),null}finally{V(!1)}};switch((0,p.useEffect)(()=>{e.type===i.LLM_MODEL_SELECTOR&&h.httpClient.getProviderLLMModels().then(e=>{let t=e.models;(h.systemInfo.disable_models_service||h.userInfo?.account_type!=="space")&&(t=t.filter(e=>e.provider?.requester!=="space-chat-completions")),s(t)}).catch(e=>{m.toast.error("Failed to get LLM model list: "+e.msg)})},[e.type]),(0,p.useEffect)(()=>{(e.type===i.KNOWLEDGE_BASE_SELECTOR||e.type===i.KNOWLEDGE_BASE_MULTI_SELECTOR)&&(h.httpClient.getKnowledgeBases().then(e=>{g(e.bases)}).catch(e=>{m.toast.error("Failed to get knowledge base list: "+e.msg)}),h.httpClient.getPluginSystemStatus().then(e=>{B(e)}).catch(e=>{console.error("Failed to get plugin system status:",e)}))},[e.type]),(0,p.useEffect)(()=>{(e.type===i.KNOWLEDGE_BASE_SELECTOR||e.type===i.KNOWLEDGE_BASE_MULTI_SELECTOR)&&M?.is_enable&&M?.is_connected&&h.httpClient.getExternalKnowledgeBases().then(e=>{k(e.bases)}).catch(e=>{console.error("Failed to get external knowledge base list:",e)})},[e.type,M]),(0,p.useEffect)(()=>{e.type===i.BOT_SELECTOR&&h.httpClient.getBots().then(e=>{T(e.bots)}).catch(e=>{m.toast.error("Failed to get bot list: "+e.msg)})},[e.type]),e.type){case i.INT:case i.FLOAT:return(0,a.jsx)(o.Input,{type:"number",...t,onChange:e=>t.onChange(Number(e.target.value))});case i.STRING:return(0,a.jsx)(o.Input,{...t});case i.TEXT:return(0,a.jsx)(b,{...t,className:"min-h-[120px]"});case i.BOOLEAN:return(0,a.jsx)(c.Switch,{checked:t.value,onCheckedChange:t.onChange});case i.STRING_ARRAY:return(0,a.jsxs)("div",{className:"space-y-2",children:[t.value.map((e,n)=>(0,a.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,a.jsx)(o.Input,{className:"w-[200px]",value:e,onChange:e=>{let a=[...t.value];a[n]=e.target.value,t.onChange(a)}}),(0,a.jsx)("button",{type:"button",className:"p-2 hover:bg-gray-100 rounded",onClick:()=>{let e=t.value.filter((e,t)=>t!==n);t.onChange(e)},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5 text-red-500",children:(0,a.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]},n)),(0,a.jsx)(u.Button,{type:"button",variant:"outline",onClick:()=>{t.onChange([...t.value,""])},children:P("common.add")})]});case i.SELECT:return(0,a.jsxs)(d.Select,{value:t.value,onValueChange:t.onChange,children:[(0,a.jsx)(d.SelectTrigger,{className:"bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,a.jsx)(d.SelectValue,{placeholder:P("common.select")})}),(0,a.jsx)(d.SelectContent,{children:(0,a.jsx)(d.SelectGroup,{children:e.options?.map(e=>(0,a.jsx)(d.SelectItem,{value:e.name,children:(0,f.extractI18nObject)(e.label)},e.name))})})]});case i.LLM_MODEL_SELECTOR:let D=r.reduce((e,t)=>{let a=t.provider?.name||t.provider?.requester||"Unknown";return e[a]||(e[a]=[]),e[a].push(t),e},{});return(0,a.jsxs)(d.Select,{value:t.value,onValueChange:t.onChange,children:[(0,a.jsx)(d.SelectTrigger,{className:"bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,a.jsx)(d.SelectValue,{placeholder:P("models.selectModel")})}),(0,a.jsx)(d.SelectContent,{children:Object.entries(D).map(([e,t])=>(0,a.jsxs)(d.SelectGroup,{children:[(0,a.jsx)(d.SelectLabel,{children:e}),t.map(e=>(0,a.jsx)(d.SelectItem,{value:e.uuid,children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[e.name,e.abilities?.includes("vision")&&(0,a.jsx)(N.Eye,{className:"h-3 w-3 text-muted-foreground"}),e.abilities?.includes("func_call")&&(0,a.jsx)(E.Wrench,{className:"h-3 w-3 text-muted-foreground"})]})},e.uuid))]},e))})]});case i.KNOWLEDGE_BASE_SELECTOR:return(0,a.jsxs)(d.Select,{value:t.value,onValueChange:t.onChange,children:[(0,a.jsx)(d.SelectTrigger,{className:"bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,a.jsx)(d.SelectValue,{placeholder:P("knowledge.selectKnowledgeBase")})}),(0,a.jsxs)(d.SelectContent,{children:[(0,a.jsx)(d.SelectGroup,{children:(0,a.jsx)(d.SelectItem,{value:"__none__",children:P("knowledge.empty")})}),l.length>0&&(0,a.jsxs)(d.SelectGroup,{children:[(0,a.jsx)(d.SelectLabel,{children:P("knowledge.builtIn")}),l.map(e=>(0,a.jsx)(d.SelectItem,{value:e.uuid??"",children:e.name},e.uuid))]}),S.length>0&&(0,a.jsxs)(d.SelectGroup,{children:[(0,a.jsx)(d.SelectLabel,{children:P("knowledge.external")}),S.map(e=>(0,a.jsx)(d.SelectItem,{value:e.uuid??"",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("img",{src:h.httpClient.getPluginIconURL(e.plugin_author,e.plugin_name),alt:"plugin icon",className:"w-4 h-4 rounded-[8%] flex-shrink-0"}),(0,a.jsx)("span",{children:e.name})]})},e.uuid))]})]})]});case i.KNOWLEDGE_BASE_MULTI_SELECTOR:return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"space-y-2",children:t.value&&t.value.length>0?(0,a.jsx)("div",{className:"space-y-2",children:t.value.map(e=>{let n=l.find(t=>t.uuid===e),r=S.find(t=>t.uuid===e),s=n||r;return s?(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border p-3 hover:bg-accent",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[r&&(0,a.jsx)("img",{src:h.httpClient.getPluginIconURL(r.plugin_author,r.plugin_name),alt:"plugin icon",className:"w-8 h-8 rounded-[8%] flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"font-medium",children:s.name}),s.description&&(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:s.description})]})]}),(0,a.jsx)(u.Button,{type:"button",variant:"ghost",size:"icon",onClick:()=>{let a=t.value.filter(t=>t!==e);t.onChange(a)},children:(0,a.jsx)(C.X,{className:"h-4 w-4"})})]},e):null})}):(0,a.jsx)("div",{className:"flex h-32 items-center justify-center rounded-lg border-2 border-dashed border-border",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:P("knowledge.noKnowledgeBaseSelected")})})}),(0,a.jsxs)(u.Button,{type:"button",onClick:()=>{I(t.value||[]),R(!0)},variant:"outline",className:"w-full",children:[(0,a.jsx)(y.Plus,{className:"mr-2 h-4 w-4"}),P("knowledge.addKnowledgeBase")]}),(0,a.jsx)(j.Dialog,{open:H,onOpenChange:R,children:(0,a.jsxs)(j.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[(0,a.jsx)(j.DialogHeader,{children:(0,a.jsx)(j.DialogTitle,{children:P("knowledge.selectKnowledgeBases")})}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-4 pr-2",children:[l.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-muted-foreground px-2",children:P("knowledge.builtIn")}),l.map(e=>{let t=O.includes(e.uuid??"");return(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border p-3 hover:bg-accent cursor-pointer",onClick:()=>{let t=e.uuid??"";I(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},children:[(0,a.jsx)(w.Checkbox,{checked:t,"aria-label":`Select ${e.name}`}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"font-medium",children:e.name}),e.description&&(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:e.description})]})]},e.uuid)})]}),S.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-muted-foreground px-2",children:P("knowledge.external")}),S.map(e=>{let t=O.includes(e.uuid??"");return(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border p-3 hover:bg-accent cursor-pointer",onClick:()=>{let t=e.uuid??"";I(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},children:[(0,a.jsx)(w.Checkbox,{checked:t,"aria-label":`Select ${e.name}`}),(0,a.jsx)("img",{src:h.httpClient.getPluginIconURL(e.plugin_author,e.plugin_name),alt:"plugin icon",className:"w-8 h-8 rounded-[8%] flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"font-medium",children:e.name}),e.description&&(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:e.description})]})]},e.uuid)})]})]}),(0,a.jsxs)(j.DialogFooter,{children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:()=>R(!1),children:P("common.cancel")}),(0,a.jsx)(u.Button,{onClick:()=>{t.onChange(O),R(!1)},children:P("common.confirm")})]})]})})]});case i.BOT_SELECTOR:return(0,a.jsxs)(d.Select,{value:t.value,onValueChange:t.onChange,children:[(0,a.jsx)(d.SelectTrigger,{className:"bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,a.jsx)(d.SelectValue,{placeholder:P("bots.selectBot")})}),(0,a.jsx)(d.SelectContent,{children:(0,a.jsx)(d.SelectGroup,{children:_.map(e=>(0,a.jsx)(d.SelectItem,{value:e.uuid??"",children:e.name},e.uuid))})})]});case i.PROMPT_EDITOR:return(0,a.jsxs)("div",{className:"space-y-2",children:[t.value.map((e,n)=>(0,a.jsxs)("div",{className:"flex gap-2 items-center",children:[0===n?(0,a.jsx)("div",{className:"w-[120px] px-3 py-2 border rounded bg-gray-50 dark:bg-[#2a292e] text-gray-500 dark:text-white dark:border-gray-600",children:"system"}):(0,a.jsxs)(d.Select,{value:e.role,onValueChange:e=>{let a=[...t.value];a[n]={...a[n],role:e},t.onChange(a)},children:[(0,a.jsx)(d.SelectTrigger,{className:"w-[120px] bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,a.jsx)(d.SelectValue,{})}),(0,a.jsx)(d.SelectContent,{children:(0,a.jsxs)(d.SelectGroup,{children:[(0,a.jsx)(d.SelectItem,{value:"user",children:"user"}),(0,a.jsx)(d.SelectItem,{value:"assistant",children:"assistant"})]})})]}),(0,a.jsx)(b,{className:"w-[300px]",value:e.content,onChange:e=>{let a=[...t.value];a[n]={...a[n],content:e.target.value},t.onChange(a)}}),0!==n&&(0,a.jsx)("button",{type:"button",className:"p-2 hover:bg-gray-100 rounded",onClick:()=>{let e=t.value.filter((e,t)=>t!==n);t.onChange(e)},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5 text-red-500",children:(0,a.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]},n)),(0,a.jsx)(u.Button,{type:"button",variant:"outline",onClick:()=>{t.onChange([...t.value,{role:"user",content:""}])},children:P("common.addRound")})]});case i.FILE:return(0,a.jsx)("div",{className:"space-y-2",children:t.value&&t.value.file_key?(0,a.jsx)(v.Card,{className:"py-3 max-w-full overflow-hidden bg-gray-900",children:(0,a.jsxs)(v.CardContent,{className:"flex items-center gap-3 p-0 px-4 min-w-0",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,a.jsx)("div",{className:"text-sm font-medium truncate",title:t.value.file_key,children:t.value.file_key}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:t.value.mimetype})]}),(0,a.jsx)(u.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-shrink-0 h-8 w-8 p-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),t.onChange(null)},title:P("common.delete"),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4 text-destructive",children:(0,a.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]})}):(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:"file",accept:e.accept,disabled:L,onChange:async e=>{let a=e.target.files?.[0];if(a){let e=await z(a);e&&t.onChange(e)}e.target.value=""},className:"hidden",id:`file-input-${e.name}`}),(0,a.jsxs)(u.Button,{type:"button",variant:"outline",size:"sm",disabled:L,onClick:()=>document.getElementById(`file-input-${e.name}`)?.click(),children:[(0,a.jsx)("svg",{className:"w-4 h-4 mr-2",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,a.jsx)("path",{d:"M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z"})}),L?P("plugins.fileUpload.uploading"):P("plugins.fileUpload.chooseFile")]})]})});case i.FILE_ARRAY:return(0,a.jsxs)("div",{className:"space-y-2",children:[t.value?.map((e,n)=>(0,a.jsx)(v.Card,{className:"py-3 max-w-full overflow-hidden bg-gray-900",children:(0,a.jsxs)(v.CardContent,{className:"flex items-center gap-3 p-0 px-4 min-w-0",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,a.jsx)("div",{className:"text-sm font-medium truncate",title:e.file_key,children:e.file_key}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.mimetype})]}),(0,a.jsx)(u.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-shrink-0 h-8 w-8 p-0",onClick:e=>{e.preventDefault(),e.stopPropagation();let a=t.value.filter((e,t)=>t!==n);t.onChange(a)},title:P("common.delete"),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4 text-destructive",children:(0,a.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]})},n)),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:"file",accept:e.accept,disabled:L,onChange:async e=>{let a=e.target.files?.[0];if(a){let e=await z(a);e&&t.onChange([...t.value||[],e])}e.target.value=""},className:"hidden",id:`file-array-input-${e.name}`}),(0,a.jsxs)(u.Button,{type:"button",variant:"outline",size:"sm",disabled:L,onClick:()=>document.getElementById(`file-array-input-${e.name}`)?.click(),children:[(0,a.jsx)("svg",{className:"w-4 h-4 mr-2",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,a.jsx)("path",{d:"M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z"})}),L?P("plugins.fileUpload.uploading"):P("plugins.fileUpload.addFile")]})]})]});default:return(0,a.jsx)(o.Input,{...t})}}function k({itemConfigList:e,onSubmit:t,initialValues:i,onFileUploaded:o}){let d=(0,p.useRef)(!0),c=(0,p.useRef)(i),u=s.z.object(e.reduce((e,t)=>{let a;switch(t.type){case"integer":case"float":a=s.z.number();break;case"boolean":a=s.z.boolean();break;case"string":case"select":case"llm-model-selector":case"knowledge-base-selector":case"bot-selector":default:a=s.z.string();break;case"array[string]":case"knowledge-base-multi-selector":a=s.z.array(s.z.string());break;case"prompt-editor":a=s.z.array(s.z.object({content:s.z.string(),role:s.z.string()}))}return t.required&&(a instanceof s.z.ZodString||a instanceof s.z.ZodArray)&&(a=a.min(1,{message:"此字段为必填项"})),{...e,[t.name]:a}},{})),h=(0,n.useForm)({resolver:(0,r.zodResolver)(u),defaultValues:e.reduce((e,t)=>{let a=i?.[t.name]??t.default;return{...e,[t.name]:a}},{})});(0,p.useEffect)(()=>{if(d.current){d.current=!1,c.current=i;return}let t=JSON.stringify(c.current)!==JSON.stringify(i);i&&t&&(Object.entries(e.reduce((e,t)=>(e[t.name]=i[t.name]??t.default,e),{})).forEach(([e,t])=>{h.setValue(e,t)}),c.current=i)},[i,h,e]);let m=(0,p.useRef)(t);return m.current=t,(0,p.useEffect)(()=>{let t=h.getValues(),a=e.reduce((e,a)=>(e[a.name]=t[a.name]??a.default,e),{});m.current?.(a);let n=h.watch(()=>{let t=h.getValues(),a=e.reduce((e,a)=>(e[a.name]=t[a.name]??a.default,e),{});m.current?.(a)});return()=>n.unsubscribe()},[h,e]),(0,a.jsx)(l.Form,{...h,children:(0,a.jsx)("div",{className:"space-y-4",children:e.map(e=>(0,a.jsx)(l.FormField,{control:h.control,name:e.name,render:({field:t})=>(0,a.jsxs)(l.FormItem,{children:[(0,a.jsxs)(l.FormLabel,{children:[(0,f.extractI18nObject)(e.label)," ",e.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(l.FormControl,{children:(0,a.jsx)(S,{config:e,field:t,onFileUploaded:o})}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:(0,f.extractI18nObject)(e.description)}),(0,a.jsx)(l.FormMessage,{})]})},e.id))})})}e.s(["default",()=>S],28332),e.s(["default",()=>k],71654)},74664,e=>{e.v({cardContainer:"createCartComponent-module__mFGHBq__cardContainer",createCardContainer:"createCartComponent-module__mFGHBq__createCardContainer"})},57717,41235,8557,e=>{"use strict";let t;var a=e.i(60498),n=e.i(74664);function r({height:e,plusSize:t,onClick:r,width:s="100%"}){return(0,a.jsx)("div",{className:`${n.default.cardContainer} ${n.default.createCardContainer} `,style:{width:`${s}`,height:`${e}`,fontSize:`${t}px`},onClick:r,children:"+"})}e.s(["default",()=>r],57717);var s=e.i(49311),l=e.i(45855),i=e.i(63686);(0,e.i(83227).default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var o=e.i(14407);e.i(74035),e.i(87980),e.i(2147);var d=e.i(34216),c=e.i(72857);function u({...e}){return(0,a.jsx)(d.Root,{"data-slot":"sheet",...e})}function p({...e}){return(0,a.jsx)(d.Portal,{"data-slot":"sheet-portal",...e})}function h({className:e,...t}){return(0,a.jsx)(d.Overlay,{"data-slot":"sheet-overlay",className:(0,o.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function m({className:e,children:t,side:n="right",...r}){return(0,a.jsxs)(p,{children:[(0,a.jsx)(h,{}),(0,a.jsxs)(d.Content,{"data-slot":"sheet-content",className:(0,o.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===n&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===n&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===n&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===n&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...r,children:[t,(0,a.jsxs)(d.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,a.jsx)(c.XIcon,{className:"size-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function x({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sheet-header",className:(0,o.cn)("flex flex-col gap-1.5 p-4",e),...t})}function f({className:e,...t}){return(0,a.jsx)(d.Title,{"data-slot":"sheet-title",className:(0,o.cn)("text-foreground font-semibold",e),...t})}function g({className:e,...t}){return(0,a.jsx)(d.Description,{"data-slot":"sheet-description",className:(0,o.cn)("text-muted-foreground text-sm",e),...t})}function b({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"skeleton",className:(0,o.cn)("bg-accent animate-pulse rounded-md",e),...t})}e.s(["Skeleton",()=>b],41235);var v=e.i(15822),j=e.i(30479),w=e.i(67658),y=e.i(14830),C=e.i(21619),N=e.i(61258),E=e.i(53537),S=e.i(33036),k=e.i(4372),_=Symbol("radix.slottable"),T=e.i(60677),L=e.i(59715),[V,H]=(0,w.createContextScope)("Tooltip",[N.createPopperScope]),R=(0,N.createPopperScope)(),O="TooltipProvider",I="tooltip.open",[M,B]=V(O),P=e=>{let{__scopeTooltip:t,delayDuration:n=700,skipDelayDuration:r=300,disableHoverableContent:l=!1,children:i}=e,o=s.useRef(!0),d=s.useRef(!1),c=s.useRef(0);return s.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,a.jsx)(M,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:s.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:d,onPointerInTransitChange:s.useCallback(e=>{d.current=e},[]),disableHoverableContent:l,children:i})};P.displayName=O;var z="Tooltip",[D,F]=V(z),A=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:l,onOpenChange:i,disableHoverableContent:o,delayDuration:d}=e,c=B(z,e.__scopeTooltip),u=R(t),[p,h]=s.useState(null),m=(0,C.useId)(),x=s.useRef(0),f=o??c.disableHoverableContent,g=d??c.delayDuration,b=s.useRef(!1),[v,j]=(0,T.useControllableState)({prop:r,defaultProp:l??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(I))):c.onClose(),i?.(e)},caller:z}),w=s.useMemo(()=>v?b.current?"delayed-open":"instant-open":"closed",[v]),y=s.useCallback(()=>{window.clearTimeout(x.current),x.current=0,b.current=!1,j(!0)},[j]),E=s.useCallback(()=>{window.clearTimeout(x.current),x.current=0,j(!1)},[j]),S=s.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{b.current=!0,j(!0),x.current=0},g)},[g,j]);return s.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),(0,a.jsx)(N.Root,{...u,children:(0,a.jsx)(D,{scope:t,contentId:m,open:v,stateAttribute:w,trigger:p,onTriggerChange:h,onTriggerEnter:s.useCallback(()=>{c.isOpenDelayedRef.current?S():y()},[c.isOpenDelayedRef,S,y]),onTriggerLeave:s.useCallback(()=>{f?E():(window.clearTimeout(x.current),x.current=0)},[E,f]),onOpen:y,onClose:E,disableHoverableContent:f,children:n})})};A.displayName=z;var G="TooltipTrigger",U=s.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,l=F(G,n),i=B(G,n),o=R(n),d=s.useRef(null),c=(0,j.useComposedRefs)(t,d,l.onTriggerChange),u=s.useRef(!1),p=s.useRef(!1),h=s.useCallback(()=>u.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,a.jsx)(N.Anchor,{asChild:!0,...o,children:(0,a.jsx)(k.Primitive.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...r,ref:c,onPointerMove:(0,v.composeEventHandlers)(e.onPointerMove,e=>{"touch"!==e.pointerType&&(p.current||i.isPointerInTransitRef.current||(l.onTriggerEnter(),p.current=!0))}),onPointerLeave:(0,v.composeEventHandlers)(e.onPointerLeave,()=>{l.onTriggerLeave(),p.current=!1}),onPointerDown:(0,v.composeEventHandlers)(e.onPointerDown,()=>{l.open&&l.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:(0,v.composeEventHandlers)(e.onFocus,()=>{u.current||l.onOpen()}),onBlur:(0,v.composeEventHandlers)(e.onBlur,l.onClose),onClick:(0,v.composeEventHandlers)(e.onClick,l.onClose)})})});U.displayName=G;var Z="TooltipPortal",[K,W]=V(Z,{forceMount:void 0}),$=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:s}=e,l=F(Z,t);return(0,a.jsx)(K,{scope:t,forceMount:n,children:(0,a.jsx)(S.Presence,{present:n||l.open,children:(0,a.jsx)(E.Portal,{asChild:!0,container:s,children:r})})})};$.displayName=Z;var q="TooltipContent",X=s.forwardRef((e,t)=>{let n=W(q,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...l}=e,i=F(q,e.__scopeTooltip);return(0,a.jsx)(S.Presence,{present:r||i.open,children:i.disableHoverableContent?(0,a.jsx)(et,{side:s,...l,ref:t}):(0,a.jsx)(Y,{side:s,...l,ref:t})})}),Y=s.forwardRef((e,t)=>{let n=F(q,e.__scopeTooltip),r=B(q,e.__scopeTooltip),l=s.useRef(null),i=(0,j.useComposedRefs)(t,l),[o,d]=s.useState(null),{trigger:c,onClose:u}=n,p=l.current,{onPointerInTransitChange:h}=r,m=s.useCallback(()=>{d(null),h(!1)},[h]),x=s.useCallback((e,t)=>{let a,n=e.currentTarget,r={x:e.clientX,y:e.clientY},s=function(e,t){let a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(a,n,r,s)){case s:return"left";case r:return"right";case a:return"top";case n:return"bottom";default:throw Error("unreachable")}}(r,n.getBoundingClientRect());d(((a=[...function(e,t,a=5){let n=[];switch(t){case"top":n.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":n.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":n.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":n.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a})}return n}(r,s),...function(e){let{top:t,right:a,bottom:n,left:r}=e;return[{x:r,y:t},{x:a,y:t},{x:a,y:n},{x:r,y:n}]}(t.getBoundingClientRect())].slice()).sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:1*!!(e.y>t.y)),function(e){if(e.length<=1)return e.slice();let t=[];for(let a=0;a<e.length;a++){let n=e[a];for(;t.length>=2;){let e=t[t.length-1],a=t[t.length-2];if((e.x-a.x)*(n.y-a.y)>=(e.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();let a=[];for(let t=e.length-1;t>=0;t--){let n=e[t];for(;a.length>=2;){let e=a[a.length-1],t=a[a.length-2];if((e.x-t.x)*(n.y-t.y)>=(e.y-t.y)*(n.x-t.x))a.pop();else break}a.push(n)}return(a.pop(),1===t.length&&1===a.length&&t[0].x===a[0].x&&t[0].y===a[0].y)?t:t.concat(a)}(a))),h(!0)},[h]);return s.useEffect(()=>()=>m(),[m]),s.useEffect(()=>{if(c&&p){let e=e=>x(e,p),t=e=>x(e,c);return c.addEventListener("pointerleave",e),p.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),p.removeEventListener("pointerleave",t)}}},[c,p,x,m]),s.useEffect(()=>{if(o){let e=e=>{let t=e.target,a={x:e.clientX,y:e.clientY},n=c?.contains(t)||p?.contains(t),r=!function(e,t){let{x:a,y:n}=e,r=!1;for(let e=0,s=t.length-1;e<t.length;s=e++){let l=t[e],i=t[s],o=l.x,d=l.y,c=i.x,u=i.y;d>n!=u>n&&a<(c-o)*(n-d)/(u-d)+o&&(r=!r)}return r}(a,o);n?m():r&&(m(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,p,o,u,m]),(0,a.jsx)(et,{...e,ref:i})}),[J,Q]=V(z,{isInside:!1}),ee=((t=({children:e})=>(0,a.jsx)(a.Fragment,{children:e})).displayName="TooltipContent.Slottable",t.__radixId=_,t),et=s.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":l,onEscapeKeyDown:i,onPointerDownOutside:o,...d}=e,c=F(q,n),u=R(n),{onClose:p}=c;return s.useEffect(()=>(document.addEventListener(I,p),()=>document.removeEventListener(I,p)),[p]),s.useEffect(()=>{if(c.trigger){let e=e=>{let t=e.target;t?.contains(c.trigger)&&p()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,p]),(0,a.jsx)(y.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:(0,a.jsxs)(N.Content,{"data-state":c.stateAttribute,...u,...d,ref:t,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,a.jsx)(ee,{children:r}),(0,a.jsx)(J,{scope:n,isInside:!0,children:(0,a.jsx)(L.Root,{id:c.contentId,role:"tooltip",children:l||r})})]})})});X.displayName=q;var ea="TooltipArrow",en=s.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,s=R(n);return Q(ea,n).isInside?null:(0,a.jsx)(N.Arrow,{...s,...r,ref:t})});function er({delayDuration:e=0,...t}){return(0,a.jsx)(P,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function es({...e}){return(0,a.jsx)(er,{children:(0,a.jsx)(A,{"data-slot":"tooltip",...e})})}function el({...e}){return(0,a.jsx)(U,{"data-slot":"tooltip-trigger",...e})}function ei({className:e,sideOffset:t=0,children:n,...r}){return(0,a.jsx)($,{children:(0,a.jsxs)(X,{"data-slot":"tooltip-content",sideOffset:t,className:(0,o.cn)("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,(0,a.jsx)(en,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}en.displayName=ea;let eo=s.createContext(null);function ed(){let e=s.useContext(eo);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function ec({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:l,children:i,...d}){let c=function(){let[e,t]=s.useState(void 0);return s.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),a=()=>{t(window.innerWidth<768)};return e.addEventListener("change",a),t(window.innerWidth<768),()=>e.removeEventListener("change",a)},[]),!!e}(),[u,p]=s.useState(!1),[h,m]=s.useState(e),x=t??h,f=s.useCallback(e=>{let t="function"==typeof e?e(x):e;n?n(t):m(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[n,x]),g=s.useCallback(()=>c?p(e=>!e):f(e=>!e),[c,f,p]);s.useEffect(()=>{let e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);let b=x?"expanded":"collapsed",v=s.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:c,openMobile:u,setOpenMobile:p,toggleSidebar:g}),[b,x,f,c,u,p,g]);return(0,a.jsx)(eo.Provider,{value:v,children:(0,a.jsx)(er,{delayDuration:0,children:(0,a.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...l},className:(0,o.cn)("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",r),...d,children:i})})})}function eu({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:s,...l}){let{isMobile:i,state:d,openMobile:c,setOpenMobile:p}=ed();return"none"===n?(0,a.jsx)("div",{"data-slot":"sidebar",className:(0,o.cn)("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",r),...l,children:s}):i?(0,a.jsx)(u,{open:c,onOpenChange:p,...l,children:(0,a.jsxs)(m,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:e,children:[(0,a.jsxs)(x,{className:"sr-only",children:[(0,a.jsx)(f,{children:"Sidebar"}),(0,a.jsx)(g,{children:"Displays the mobile sidebar."})]}),(0,a.jsx)("div",{className:"flex h-full w-full flex-col",children:s})]})}):(0,a.jsxs)("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":"collapsed"===d?n:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[(0,a.jsx)("div",{"data-slot":"sidebar-gap",className:(0,o.cn)("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,a.jsx)("div",{"data-slot":"sidebar-container",className:(0,o.cn)("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...l,children:(0,a.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:s})})]})}function ep({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:(0,o.cn)("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function eh({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:(0,o.cn)("relative flex w-full min-w-0 flex-col p-2",e),...t})}function em({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:(0,o.cn)("w-full text-sm",e),...t})}function ex({className:e,...t}){return(0,a.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:(0,o.cn)("flex w-full min-w-0 flex-col gap-1",e),...t})}function ef({className:e,...t}){return(0,a.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:(0,o.cn)("group/menu-item relative",e),...t})}let eg=(0,i.cva)("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function eb({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:s,className:i,...d}){let c=e?l.Slot:"button",{isMobile:u,state:p}=ed(),h=(0,a.jsx)(c,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":t,className:(0,o.cn)(eg({variant:n,size:r}),i),...d});return s?("string"==typeof s&&(s={children:s}),(0,a.jsxs)(es,{children:[(0,a.jsx)(el,{asChild:!0,children:h}),(0,a.jsx)(ei,{side:"right",align:"center",hidden:"collapsed"!==p||u,...s})]})):h}e.s(["Sidebar",()=>eu,"SidebarContent",()=>ep,"SidebarGroup",()=>eh,"SidebarGroupContent",()=>em,"SidebarMenu",()=>ex,"SidebarMenuButton",()=>eb,"SidebarMenuItem",()=>ef,"SidebarProvider",()=>ec],8557)}]); |