@alwith/module-chat 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as a}from"react/jsx-runtime";import{useEffect as w,useMemo as F,useState as N}from"react";import{Button as y}from"../ui/button.js";import{Checkbox as S}from"../ui/checkbox.js";import{Dialog as C,DialogContent as D,DialogDescription as j,DialogFooter as q,DialogHeader as E,DialogTitle as P}from"../ui/dialog.js";import{Field as G,FieldDescription as p,FieldGroup as I,FieldLabel as K,FieldLegend as x,FieldSet as b}from"../ui/field.js";import{Input as L}from"../ui/input.js";import{Label as V}from"../ui/label.js";import{RadioGroup as _,RadioGroupItem as B}from"../ui/radio-group.js";import{Switch as T}from"../ui/switch.js";import{Textarea as H}from"../ui/textarea.js";import{isArrayProperty as A,isBooleanProperty as O,isNumberProperty as M,isStringProperty as R}from"@alwith/api";function z(n){if(!R(n))return null;if(n.oneOf&&n.oneOf.length>0)return n.oneOf.map((e)=>({value:e.const,label:e.title??e.const,...e.description?{description:e.description}:{}}));if(n.enum&&n.enum.length>0)return n.enum.map((e)=>({value:e,label:e}));return null}function J(n){let e=n,t=e._meta?.alwith?.options;if(Array.isArray(t)&&Array.isArray(e.enum))return t.map((r)=>({value:r.const,label:r.title,...r.description?{description:r.description}:{}}));if(Array.isArray(e.enum))return e.enum.map((r)=>({value:String(r),label:String(r)}));if(Array.isArray(e.oneOf))return e.oneOf.map((r)=>({value:r.const,label:r.title,...r.description?{description:r.description}:{}}));return null}function Q(n){let e=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([t,r])=>({key:t,property:r,title:r.title??t,description:r.description??null,required:e.has(t),options:z(r),multiOptions:A(r)?J(r.items):null}))}function v(n){let e={};for(let t of n){let r=t.property.default;if(r!==void 0&&r!==null)e[t.key]=r;else if(t.options)e[t.key]=t.options[0].value;else if(O(t.property))e[t.key]=!1;else if(A(t.property))e[t.key]=[]}return e}function U(n,e){if(n.multiOptions)return Array.isArray(e)&&e.length>0;if(!n.required)return!0;return e!==void 0&&e!==""&&!(Array.isArray(e)&&e.length===0)}function k({id:n,label:e,description:t,control:r}){return a("div",{className:"hover:bg-muted/40 flex items-center gap-2 rounded-sm px-1.5 py-1",children:[r,a(V,{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[i("div",{className:"text-foreground text-sm",children:e}),t&&i("div",{className:"text-muted-foreground text-xs",children:t})]})]})}function W({id:n,field:e,value:t,onChange:r}){if(e.multiOptions){let l=new Set(Array.isArray(t)?t:[]);return a(b,{children:[i(x,{variant:"label",children:e.title}),e.description&&i(p,{children:e.description}),i("div",{className:"flex flex-col gap-1",children:e.multiOptions.map((s)=>{let c=`${n}:${s.value}`;return i(k,{id:c,...s,control:i(S,{id:c,checked:l.has(s.value),onCheckedChange:(d)=>{let u=new Set(l);if(d)u.add(s.value);else u.delete(s.value);r([...u])}})},s.value)})})]})}if(e.options)return a(b,{children:[i(x,{variant:"label",children:e.title}),e.description&&i(p,{children:e.description}),i(_,{value:typeof t==="string"?t:"",onValueChange:(l)=>r(String(l)),className:"flex flex-col gap-1",children:e.options.map((l)=>{let s=`${n}:${l.value}`;return i(k,{id:s,...l,control:i(B,{value:l.value,id:s})},l.value)})})]});return a(G,{children:[i(K,{htmlFor:n,children:e.title}),O(e.property)?i(T,{id:n,checked:t===!0,onCheckedChange:(l)=>r(l)}):M(e.property)?i(L,{id:n,type:"number",required:e.required,value:typeof t==="number"?t:"",onChange:(l)=>r(l.target.value===""?void 0:Number(l.target.value))}):i(H,{id:n,rows:2,required:e.required,value:typeof t==="string"?t:"",onChange:(l)=>r(l.target.value)}),e.description&&i(p,{children:e.description})]})}function ce({requestId:n,schema:e,message:t,total:r,t:l,onRespond:s}){let c=F(()=>Q(e),[e]),[d,u]=N(()=>v(c));w(()=>u(v(c)),[n,c]);let h=c.every((o)=>U(o,d[o.key])),g=()=>{if(!h)return;let o={};for(let[f,m]of Object.entries(d))if(m!==void 0)o[f]=m;s({action:"accept",content:o})};return i(C,{open:!0,onOpenChange:(o)=>!o&&s({action:"cancel"}),children:a(D,{className:"flex max-h-[80vh] flex-col gap-4 sm:max-w-lg",onKeyDown:(o)=>{if(o.key==="Enter"&&(o.metaKey||o.ctrlKey))o.preventDefault(),g()},children:[a(E,{children:[a("div",{className:"flex items-center justify-between gap-2 pe-8",children:[i(P,{children:e.title??l("approval.needed")}),r>1&&i("span",{className:"text-muted-foreground shrink-0 text-xs",children:`1 / ${r}`})]}),i(j,{children:t})]}),i("div",{className:"min-h-0 flex-1 overflow-y-auto",children:i(I,{children:c.map((o)=>i(W,{id:`${n}:${o.key}`,field:o,value:d[o.key],onChange:(f)=>u((m)=>({...m,[o.key]:f}))},o.key))})}),a(q,{children:[i(y,{variant:"ghost",onClick:()=>s({action:"decline"}),children:l("actions.decline")}),i(y,{disabled:!h,onClick:g,children:l("actions.submit")})]})]})})}export{ce as SchemaElicitationForm,Q as elicitationFields,v as initialValues,U as isAnswered};
|
|
@@ -29,6 +29,8 @@ export type TextInputContext = {
|
|
|
29
29
|
value: string;
|
|
30
30
|
setInput: (v: string) => void;
|
|
31
31
|
clear: () => void;
|
|
32
|
+
getRevision?: () => number;
|
|
33
|
+
clearSubmitted?: () => void;
|
|
32
34
|
};
|
|
33
35
|
export type PromptInputControllerProps = {
|
|
34
36
|
textInput: TextInputContext;
|
|
@@ -37,12 +39,22 @@ export type PromptInputControllerProps = {
|
|
|
37
39
|
};
|
|
38
40
|
export declare const PromptInputSubmitContext: import("react").Context<((text: string) => void) | null>;
|
|
39
41
|
export declare function usePromptInputSubmit(): ((text: string) => void) | null;
|
|
42
|
+
export type PromptSubmitResult = {
|
|
43
|
+
status: "accepted";
|
|
44
|
+
} | {
|
|
45
|
+
status: "blocked";
|
|
46
|
+
reason: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const PromptInputSubmissionContext: import("react").Context<(() => Promise<PromptSubmitResult>) | null>;
|
|
49
|
+
export declare function usePromptInputSubmission(): (() => Promise<PromptSubmitResult>) | null;
|
|
40
50
|
export declare const ProviderAttachmentsContext: import("react").Context<AttachmentsContext | null>;
|
|
41
51
|
export declare function usePromptInputController(): PromptInputControllerProps;
|
|
42
52
|
export declare const useOptionalPromptInputController: () => PromptInputControllerProps | null;
|
|
43
53
|
export declare function useProviderAttachments(): AttachmentsContext;
|
|
44
54
|
export type PromptInputProviderProps = PropsWithChildren<{
|
|
45
55
|
initialInput?: string;
|
|
56
|
+
revision?: number;
|
|
57
|
+
onSubmittedClear?: () => void;
|
|
46
58
|
attachmentPolicy?: AttachmentPolicy;
|
|
47
59
|
onRemoveAttachment?: () => void;
|
|
48
60
|
value?: string;
|
|
@@ -54,6 +66,6 @@ export type PromptInputProviderProps = PropsWithChildren<{
|
|
|
54
66
|
id: string;
|
|
55
67
|
})[]) => void;
|
|
56
68
|
}>;
|
|
57
|
-
export declare function PromptInputProvider({ initialInput: initialTextInput, onRemoveAttachment, attachmentPolicy, value, onValueChange, attachments: attachmentsControlled, onAttachmentsChange, children }: PromptInputProviderProps): import("react").JSX.Element;
|
|
69
|
+
export declare function PromptInputProvider({ initialInput: initialTextInput, revision, onSubmittedClear, onRemoveAttachment, attachmentPolicy, value, onValueChange, attachments: attachmentsControlled, onAttachmentsChange, children }: PromptInputProviderProps): import("react").JSX.Element;
|
|
58
70
|
export declare const LocalAttachmentsContext: import("react").Context<AttachmentsContext | null>;
|
|
59
71
|
export declare function usePromptInputAttachments(): AttachmentsContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as z}from"react/jsx-runtime";import{createContext as m,useCallback as n,useContext as u,useEffect as X,useMemo as D,useRef as v,useState as B}from"react";var w=m(null),Y=m(null);function rt(){return u(Y)}var Z=m(null);function ot(){return u(Z)}var A=m(null);function ut(){let r=u(w);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");return r}var st=()=>u(w);function it(){let r=u(A);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");return r}var V=()=>u(A);function ct({initialInput:r="",revision:p,onSubmittedClear:s,onRemoveAttachment:L,attachmentPolicy:a,value:g,onValueChange:j,attachments:h,onAttachmentsChange:W,children:G}){let y=n((t)=>{if(t.type)return t.type;let e=(t.name||"").toLowerCase();if(e.endsWith(".png"))return"image/png";if(e.endsWith(".jpg")||e.endsWith(".jpeg"))return"image/jpeg";if(e.endsWith(".webp"))return"image/webp";if(e.endsWith(".gif"))return"image/gif";if(e.endsWith(".bmp"))return"image/bmp";if(e.endsWith(".svg"))return"image/svg+xml";return""},[]),T=g!==void 0,[H,J]=B(r),l=g!==void 0?g:H,o=v({value:l,external:p,revision:0});if(o.current.value!==l||o.current.external!==p)o.current={value:l,external:p,revision:o.current.revision+1};let C=n(()=>o.current.revision,[]),x=n((t)=>{if(o.current.value=t,o.current.revision++,T)j?.(t);else J(t)},[T,j]),b=n(()=>x(""),[x]),I=h!==void 0,[K,N]=B([]),P=h!==void 0?h:K,R=v(P);R.current=P;let i=n((t)=>{let e=typeof t==="function"?t(R.current):t;if(I)W?.(e);else N(e)},[I,W]),O=v(null),k=v(()=>{}),F=n((t)=>{let e=Array.from(t);if(e.length===0)return;i((f)=>{let d=a===void 0?e:a.uniqueFiles(e,f);return f.concat(d.map((c)=>{let q=a?.sourcePath(c);return{id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(c),mediaType:y(c),filename:c.name,size:c.size,lastModified:c.lastModified,...q===void 0?{}:{sourcePath:q}}}))})},[a,y,i]),E=n((t)=>{i((e)=>{let f=e.find((d)=>d.id===t);if(f?.url)URL.revokeObjectURL(f.url);return e.filter((d)=>d.id!==t)}),L?.()},[L,i]),M=n(()=>{i((t)=>{for(let e of t)if(e.url)URL.revokeObjectURL(e.url);return[]})},[i]);X(()=>{if(I)return;return()=>{for(let t of R.current)if(t.url)URL.revokeObjectURL(t.url)}},[I]);let S=n(()=>{k.current?.()},[]),U=D(()=>({files:P,add:F,remove:E,clear:M,openFileDialog:S,fileInputRef:O}),[P,F,E,M,S]),_=n((t,e)=>{O.current=t.current,k.current=e},[]),Q=D(()=>({textInput:{value:l,setInput:x,clear:b,getRevision:C,clearSubmitted:s===void 0?b:s},attachments:U,__registerFileInput:_}),[l,x,b,C,s,U,_]);return z(w.Provider,{value:Q,children:z(A.Provider,{value:U,children:G})})}var tt=m(null);function pt(){let r=V(),p=u(tt),s=r??p;if(!s)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s}export{tt as LocalAttachmentsContext,ct as PromptInputProvider,Z as PromptInputSubmissionContext,Y as PromptInputSubmitContext,A as ProviderAttachmentsContext,st as useOptionalPromptInputController,pt as usePromptInputAttachments,ut as usePromptInputController,ot as usePromptInputSubmission,rt as usePromptInputSubmit,it as useProviderAttachments};
|
|
@@ -13,6 +13,8 @@ export type PromptInputProps = Omit<HTMLAttributes<HTMLFormElement>, "onSubmit"
|
|
|
13
13
|
attachmentPolicy?: AttachmentPolicy;
|
|
14
14
|
onCommand?: (text: string) => boolean;
|
|
15
15
|
onSubmitError: (error: unknown) => void;
|
|
16
|
+
canSubmit?: () => true | string;
|
|
17
|
+
onSubmitAsync?: (message: PromptInputMessage) => Promise<void>;
|
|
16
18
|
accept?: string;
|
|
17
19
|
multiple?: boolean;
|
|
18
20
|
globalDrop?: boolean;
|
|
@@ -25,7 +27,7 @@ export type PromptInputProps = Omit<HTMLAttributes<HTMLFormElement>, "onSubmit"
|
|
|
25
27
|
}) => void;
|
|
26
28
|
onSubmit: (message: PromptInputMessage, event: FormEvent<HTMLFormElement>) => void | Promise<void>;
|
|
27
29
|
};
|
|
28
|
-
export declare const PromptInput: ({ className, bashMode, attachmentPolicy, onCommand, onSubmitError, accept, multiple, globalDrop, syncHiddenInput, maxFiles, maxFileSize, onError, onSubmit, children, ...props }: PromptInputProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const PromptInput: ({ className, bashMode, attachmentPolicy, onCommand, onSubmitError, canSubmit, onSubmitAsync, accept, multiple, globalDrop, syncHiddenInput, maxFiles, maxFileSize, onError, onSubmit, children, ...props }: PromptInputProps) => import("react").JSX.Element;
|
|
29
31
|
export type PromptInputBodyProps = HTMLAttributes<HTMLDivElement>;
|
|
30
32
|
export declare function PromptInputBody({ className, ...props }: PromptInputBodyProps): import("react").JSX.Element;
|
|
31
33
|
export type PromptInputHeaderProps = Omit<ComponentProps<typeof InputGroupAddon>, "align">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as
|
|
1
|
+
import{jsx as o,jsxs as me}from"react/jsx-runtime";import{ArrowUpIcon as pe,Loader2Icon as ge,SquareIcon as he,XIcon as be}from"lucide-react";import{Children as V,useCallback as v,useEffect as z,useMemo as ve,useRef as _,useState as xe}from"react";import{flushSync as Ie}from"react-dom";import{cn as x}from"cn";import{InputGroup as ye,InputGroupAddon as Y,InputGroupButton as Z}from"../ui/input-group.js";import{exceedsImageLimit as Le,MAX_TOTAL_IMAGE_MB as we}from"../lib/limits.js";import{preparePromptFiles as Te}from"../lib/prepare-prompt-files.js";import{LocalAttachmentsContext as ze,PromptInputSubmitContext as _e,PromptInputSubmissionContext as ke,ProviderAttachmentsContext as Ae,useOptionalPromptInputController as Pe}from"./prompt-input-context.js";import{MAX_TOTAL_IMAGE_MB as Je}from"../lib/limits.js";var Fe=({className:c,bashMode:l=!1,attachmentPolicy:I,onCommand:m,onSubmitError:y,canSubmit:p,onSubmitAsync:g,accept:k,multiple:ee,globalDrop:A,syncHiddenInput:D,maxFiles:S,maxFileSize:j,onError:h,onSubmit:te,children:re,...ne})=>{let s=Pe(),a=!!s,se=l&&a&&s.textInput.value.startsWith("!"),L=_(null),P=_(null),M=_(!1),[ie,U]=xe([]),d=a?s.attachments.files:ie,F=_(d);F.current=d;let oe=v(()=>{L.current?.click()},[]),O=v((e)=>{if(!k||k.trim()==="")return!0;return k.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[k]),B=v((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),ae=v((e)=>{let r=Array.from(e),t=r.filter((i)=>O(i));if(r.length&&t.length===0){h?.({code:"accept",message:"No files match the accepted types."});return}let n=(i)=>j?i.size<=j:!0,f=t.filter(n);if(t.length>0&&f.length===0){h?.({code:"max_file_size",message:"All files exceed the maximum size."});return}U((i)=>{let b=I?I.uniqueFiles(f,i):f,u=typeof S==="number"?Math.max(0,S-i.length):void 0,N=typeof u==="number"?b.slice(0,u):b;if(typeof u==="number"&&b.length>u)h?.({code:"max_files",message:"Too many files. Some were not added."});let K=[];for(let T of N){let Q=I?.sourcePath(T);K.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(T),mediaType:B(T),filename:T.name,size:T.size,lastModified:T.lastModified,...Q===void 0?{}:{sourcePath:Q}})}return i.concat(K)})},[I,B,O,S,j,h]),ue=v((e)=>U((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),ce=v(()=>U((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),q=a?s.attachments.add:ae,w=v((e)=>{let r=Array.from(e),t=r.filter((f)=>!(f.type??"").toLowerCase().startsWith("image/"));if(t.length>0){h?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((f,i)=>f+i.size,0);if(n>0){let f=d.filter((i)=>(i.mediaType??"").toLowerCase().startsWith("image/")).reduce((i,b)=>i+(b.size??0),0);if(Le(f,n)){h?.({code:"max_total_size",message:`Total image size must not exceed ${we}MB.`});return}}q(r)},[d,q,h]),E=a?s.attachments.remove:ue,W=a?s.attachments.clear:ce,G=a?s.attachments.openFileDialog:oe;z(()=>{if(!a)return;s.__registerFileInput(L,()=>L.current?.click())},[a,s]),z(()=>{if(D&&L.current&&d.length===0)L.current.value=""},[d,D]),z(()=>{let e=P.current;if(!e)return;if(A)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)w(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[w,A]),z(()=>{if(!A)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)w(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[w,A]),z(()=>()=>{if(!a){for(let e of F.current)if(e.url)URL.revokeObjectURL(e.url)}},[a]);let le=(e)=>{if(e.currentTarget.files)w(e.currentTarget.files);e.currentTarget.value=""},X=ve(()=>({files:d.map((e)=>({...e,id:e.id})),add:w,remove:E,clear:W,openFileDialog:G,fileInputRef:L}),[d,w,E,W,G]),R=_({controller:s,files:d,canSubmit:p});R.current={controller:s,files:d,canSubmit:p};let C=_(!0);z(()=>(C.current=!0,()=>{C.current=!1}),[]);let H=async(e)=>{let r=p===void 0?!0:p();if(r!==!0)return{status:"blocked",reason:r};if(M.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=P.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=a?s.textInput.value:String(new FormData(t).get("message")??""),f=s?.textInput.getRevision?.(),i=d,b=()=>{if(!C.current)return;let u=R.current;if(u.files!==i)return;if(a){if(f===void 0||u.controller===null||u.controller.textInput.getRevision?.()!==f)return;if(u.controller.textInput.clearSubmitted===void 0)u.controller.textInput.clear();else u.controller.textInput.clearSubmitted()}else if(String(new FormData(t).get("message")??"")===n)t.reset();W()};M.current=!0;try{if(m?.(n.trim()))return b(),{status:"accepted"};let u=await Te(i),N=R.current.canSubmit===void 0?!0:R.current.canSubmit();if(N!==!0)return{status:"blocked",reason:N};if(!C.current)return{status:"blocked",reason:"form_unmounted"};if(u.rejectedCount>0)h?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:u.files});else if(e!==null)await te({text:n,files:u.files},e);return b(),{status:"accepted"}}finally{M.current=!1}},fe=(e)=>{e.preventDefault(),H(e).catch(y)},de=v((e)=>{if(!e.trim())return;if(a&&s)Ie(()=>{s.textInput.setInput(e)});P.current?.requestSubmit()},[s,a]),J=o(ke.Provider,{value:()=>H(null),children:me(_e.Provider,{value:de,children:[o("input",{accept:k,"aria-label":"Upload files",className:"hidden",multiple:ee,onChange:le,ref:L,title:"Upload files",type:"file"}),o("form",{className:x("w-full",c),onSubmit:fe,ref:P,"data-tour":"chat-input",...ne,children:o(ye,{className:x("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",se&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:re})})]})});return a?o(Ae.Provider,{value:X,children:J}):o(ze.Provider,{value:X,children:J})};function Oe({className:c,...l}){return o("div",{className:x("flex w-full min-w-0 flex-row items-end gap-2",c),...l})}function Be({className:c,...l}){return o(Y,{align:"block-end",className:x("order-first flex-wrap gap-1 p-2 pb-1.5",c),...l})}function qe({className:c,...l}){return o(Y,{align:"block-end",className:x("mt-3.5 justify-between gap-1 p-0",c),...l})}function Ee({className:c,...l}){return o("div",{className:x("flex items-center gap-1",c),...l})}var Ge=({variant:c="ghost",className:l,size:I,collapsed:m=!1,...y})=>{let p=m||V.count(y.children)<=1?"icon-xs":"xs";return o(Z,{className:x("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(m||V.count(y.children)<=1)&&"size-7",l),size:p,type:"button",variant:c,...y})},Xe=({className:c,variant:l="ghost",size:I="icon-xs",status:m,children:y,...p})=>{let g=o(pe,{className:"size-4"});if(m==="submitted")g=o(ge,{className:"size-4 animate-spin"});else if(m==="streaming")g=o(he,{className:"size-3 fill-current"});else if(m==="error")g=o(be,{className:"size-4"});return o(Z,{"aria-label":"Submit",className:x("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",c),size:I,type:"submit",variant:l,...p,children:y??g})};export{Je as MAX_TOTAL_IMAGE_MB,Fe as PromptInput,Oe as PromptInputBody,Ge as PromptInputButton,qe as PromptInputFooter,Be as PromptInputHeader,Xe as PromptInputSubmit,Ee as PromptInputTools};
|