@collective-intelligence/ui-react 0.3.9 → 0.4.1
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.
package/README.md
CHANGED
|
@@ -145,7 +145,8 @@ client. The AI React package composes them with the chat state.
|
|
|
145
145
|
`allow_always`; `pendingDecision` holds the buttons.
|
|
146
146
|
- `ChatAnswerFeedback`: thumbs up and down for an answer. `value` is the
|
|
147
147
|
current `positive` or `negative` rating; a second press calls `onClear`.
|
|
148
|
-
Thumbs down asks for
|
|
148
|
+
Thumbs down asks for a required note in a dialog before `onSubmit`;
|
|
149
|
+
submit stays disabled while the note is blank. Thumbs up sends no note.
|
|
149
150
|
`pending` holds the buttons.
|
|
150
151
|
- `ChatAttachmentChip`: one file. `mode="draft"` takes `onRemove`;
|
|
151
152
|
`mode="stored"` takes an optional `onDownload` (no callback, no download
|
package/dist/chat.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { KeyboardEvent as KeyboardEvent$1, ReactNode } from 'react';
|
|
|
5
5
|
import { Components } from 'react-markdown';
|
|
6
6
|
|
|
7
7
|
export type ChatAnswerFeedbackSentiment = "negative" | "positive";
|
|
8
|
-
/** A rating to save; `note` is
|
|
8
|
+
/** A rating to save; `note` is the non-blank note of a negative rating. */
|
|
9
9
|
export interface ChatAnswerFeedbackInput {
|
|
10
10
|
note: string | null;
|
|
11
11
|
sentiment: ChatAnswerFeedbackSentiment;
|
|
@@ -15,7 +15,7 @@ export interface ChatAnswerFeedbackLabels {
|
|
|
15
15
|
/** Accessible name of the rating buttons. */
|
|
16
16
|
readonly group: string;
|
|
17
17
|
readonly negative: string;
|
|
18
|
-
/** Accessible name and placeholder of the note input. */
|
|
18
|
+
/** Accessible name and placeholder of the note input; say it is required. */
|
|
19
19
|
readonly note: string;
|
|
20
20
|
readonly noteDescription: string;
|
|
21
21
|
readonly noteTitle: string;
|
|
@@ -37,8 +37,9 @@ export interface ChatAnswerFeedbackProps {
|
|
|
37
37
|
value?: ChatAnswerFeedbackSentiment | null | undefined;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Thumbs up and down for an answer. Thumbs
|
|
41
|
-
* first
|
|
40
|
+
* Thumbs up and down for an answer. Thumbs up rates without a note. Thumbs
|
|
41
|
+
* down asks for a required note first: submit stays disabled while the note
|
|
42
|
+
* is blank. A second press clears the rating.
|
|
42
43
|
*/
|
|
43
44
|
export declare const ChatAnswerFeedback: ({ className, error, labels, onClear, onSubmit, pending, value }: ChatAnswerFeedbackProps) => React$1.JSX.Element;
|
|
44
45
|
/** The state of an approval request. */
|
package/dist/chat.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import"./index-64r6cav3.js";import"./index-dg126t3v.js";import{a}from"./index-r2snvwyb.js";import{N,ao,O,Xo,V,sr,_,q,g,I}from"./index-sd38wa4w.js";import{Q,nr,ar}from"./index-2twj52t7.js";import{T}from"./index-r5ds1mtq.js";import{Vr,Pt}from"./index-fnk7gsdd.js";import{fr,Dt,mo,ho,qe,pr,go,je,vo,mr,xo,bo,yo,Co}from"./index-m0v264jr.js";import{H,ve,Wt,It,Xe}from"./index-2yf6mq9g.js";import{b}from"./index-ecvn2gnv.js";import{L}from"./index-rgbg5bsy.js";import{v}from"./index-tcwzyy71.js";import"./index-0gzm7bb9.js";import{e}from"./index-qbwndfn2.js";import{useState as Ne}from"react";import{jsx as D,jsxs as j,Fragment as He}from"react/jsx-runtime";var Ce=({active:t,disabled:n,label:o,onClick:r,sentiment:s})=>{let i=s==="positive"?bo:xo;return D(a,{"aria-label":o,"aria-pressed":t,disabled:n,className:e("h-7 min-w-7 px-2 text-base",t&&(s==="positive"?"border-(--success) text-(--success)":"border-(--danger) text-(--danger)")),onClick:r,size:"sm",type:"button",variant:"ghost",children:D(i,{"aria-hidden":"true",className:e("size-4",t&&"fill-current")})})},Qe=({labels:t,onCancel:n,onSubmit:o})=>{let[r,s]=Ne("");return j(He,{children:[D(Q,{"aria-label":t.note,autoFocus:!0,onChange:(i)=>{s(i.target.value)},placeholder:t.note,value:r}),j(sr,{children:[D(a,{onClick:n,type:"button",variant:"outline",children:t.cancel}),D(a,{onClick:()=>{o(r.trim()===""?null:r.trim())},type:"button",children:t.submit})]})]})},_e=({className:t,error:n,labels:o,onClear:r,onSubmit:s,pending:i=!1,value:d})=>{let[p,u]=Ne(!1);return j("div",{className:e("flex flex-wrap items-center gap-2 text-xs text-muted-foreground",t),"data-part":"answer-feedback",children:[j("fieldset",{"aria-busy":i,"aria-label":o.group,className:"flex items-center gap-1",children:[D(Ce,{active:d==="positive",disabled:i,label:o.positive,onClick:()=>{if(d==="positive"){r();return}s({note:null,sentiment:"positive"})},sentiment:"positive"}),D(Ce,{active:d==="negative",disabled:i,label:o.negative,onClick:()=>{if(d==="negative"){r();return}u(!0)},sentiment:"negative"})]}),i?D("span",{children:o.saving}):null,n===void 0||n===null?null:D("span",{className:"text-destructive",role:"alert",children:n}),D(N,{onOpenChange:u,open:p,children:j(O,{children:[j(V,{children:[D(_,{children:o.noteTitle}),D(q,{children:o.noteDescription})]}),D(Qe,{labels:o,onCancel:()=>{u(!1)},onSubmit:(x)=>{s({note:x,sentiment:"negative"}),u(!1)}})]})})]})};import{useId as ye,useState as se}from"react";import{jsx as c,jsxs as R}from"react/jsx-runtime";var Ue=new Set(["continuation_failed","reconciliation_required"]),Ke=({status:t})=>c("div",{className:"mt-0.5 rounded-md border border-border bg-muted/40 p-1.5",children:(()=>{if(t==="approved")return c(H,{className:"size-4 text-emerald-600"});if(t==="pending")return c(pr,{className:"size-4 text-muted-foreground"});return c(Dt,{className:"size-4 text-destructive"})})()}),Ge=({label:t,outcome:n})=>R("output",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3 text-sm font-medium text-foreground",children:[Ue.has(n)?c(ve,{className:"size-4 shrink-0 text-destructive"}):c(H,{className:"size-4 shrink-0 text-emerald-600"}),t]}),re=[],$e=({onApprove:t,onReject:n,outcome:o,status:r})=>{if(r!=="pending"||o!==void 0)return"closed";return t===void 0&&n===void 0?"read_only":"decide"},Ve={closed:null,decide:"decideHint",read_only:"readOnlyHint"},We=({className:t,decisions:n=re,labels:o,meta:r=re,resolution:s,steps:i=re})=>{if(r.length===0&&i.length===0&&n.length===0&&s===void 0)return null;return R("div",{className:e("mt-3 grid gap-2 text-xs text-muted-foreground",t),children:[r.length===0?null:c("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:r.map((d,p)=>c("span",{children:d},p))}),i.length===0?null:c("ul",{"aria-label":o.steps,className:"grid gap-1",children:i.map((d)=>R("li",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"truncate",children:d.label}),c("span",{className:"shrink-0",children:o.stepProgress(d.approved,d.required)})]},d.id))}),n.length===0?null:c("ul",{"aria-label":o.decisions,className:"grid gap-1 border-t border-border pt-2",children:n.map((d)=>c("li",{children:d.label},d.id))}),s===void 0?null:c("p",{className:"border-t border-border pt-2",children:s})]})},ie=500,Je=({labels:t,onCancel:n,onReject:o,pending:r})=>{let s=ye(),[i,d]=se(""),p=i.trim();return R("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[c(I,{htmlFor:s,children:t.rejectReason}),c(Q,{autoFocus:!0,disabled:r,id:s,maxLength:ie,onChange:(u)=>{d(u.target.value)},placeholder:t.rejectReasonPlaceholder,value:i}),R("div",{className:"flex items-center justify-between gap-2",children:[R("span",{className:"text-xs text-muted-foreground",children:[i.length,"/",ie]}),R("div",{className:"flex gap-2",children:[c(a,{disabled:r,onClick:n,size:"sm",type:"button",variant:"ghost",children:t.cancel}),R(a,{disabled:r||p==="",onClick:()=>{o(p)},size:"sm",type:"button",variant:"destructive",children:[r?c(b,{className:"size-3.5 animate-spin"}):null,t.confirmReject]})]})]})]})},Ye=({labels:t,onApprove:n,onReject:o,pendingAction:r})=>{let s=ye(),[i,d]=se(""),[p,u]=se(!1),x=r!==void 0;if(p&&o!==void 0)return c(Je,{labels:t,onCancel:()=>{u(!1)},onReject:o,pending:r==="reject"});return R("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[n===void 0?null:R("div",{className:"grid gap-1.5",children:[c(I,{className:"text-xs",htmlFor:s,children:t.comment}),c(g,{disabled:x,id:s,maxLength:ie,onChange:(h)=>{d(h.target.value)},placeholder:t.commentPlaceholder,value:i})]}),R("div",{className:"flex gap-2",children:[n===void 0?null:R(a,{disabled:x,onClick:()=>{n(i.trim()===""?null:i.trim())},size:"sm",type:"button",children:[r==="approve"?c(b,{className:"size-3.5 animate-spin"}):c(H,{className:"size-3.5"}),r==="approve"?t.approving:t.approve]}),o===void 0?null:R(a,{disabled:x,onClick:()=>{u(!0)},size:"sm",type:"button",variant:"outline",children:[c(Dt,{className:"size-3.5"}),t.reject]})]})]})},Ze=({children:t,className:n,classNames:o,decisions:r,error:s,labels:i,meta:d,onApprove:p,onReject:u,outcome:x,pendingAction:h,resolution:k,status:C,steps:M,summary:J})=>{let z=$e({onApprove:p,onReject:u,outcome:x,status:C}),Y=Ve[z],Z=Y===null?void 0:i[Y];return R("section",{"aria-label":i.title,className:e("rounded-md border border-border bg-background p-3 text-sm",n),"data-part":"approval-card","data-status":C,children:[R("div",{className:e("flex items-start gap-3",o?.header),children:[c(Ke,{status:C}),R("div",{className:"min-w-0 flex-1",children:[R("div",{className:"flex flex-wrap items-center gap-2",children:[c("p",{className:"font-medium text-foreground",children:i.title}),c(T,{variant:z==="decide"?"default":"outline",children:i.statuses[C]}),z==="read_only"?c(T,{variant:"secondary",children:i.readOnly}):null]}),Z===void 0?null:c("p",{className:"mt-1 text-muted-foreground",children:Z}),J===void 0?null:c("div",{className:"mt-1 break-words text-foreground",children:J}),c(We,{className:o?.details,decisions:r,labels:i,meta:d,resolution:k,steps:M})]})]}),t,z==="decide"?c("div",{className:o?.actions,children:c(Ye,{labels:i,onApprove:p,onReject:u,pendingAction:h})}):null,s===void 0||s===null?null:c("p",{className:"mt-2 text-destructive",role:"alert",children:s}),x===void 0?null:c(Ge,{label:i.outcomes[x],outcome:x})]})};import{jsx as y,jsxs as U,Fragment as nt}from"react/jsx-runtime";var et=({labels:t,name:n,onDownload:o,pending:r})=>U("button",{"aria-label":t.downloadFile(n),className:"inline-flex items-center gap-1 rounded-sm px-1 text-(--accent) hover:text-(--accent-hover) focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60",disabled:r,onClick:o,type:"button",children:[r?y(b,{className:"size-3.5 animate-spin"}):y(Wt,{className:"size-3.5"}),y("span",{children:r?t.downloading:t.download})]}),tt=({description:t,label:n,name:o,url:r})=>U(N,{children:[y(ao,{asChild:!0,children:y("button",{"aria-label":n,className:"shrink-0 overflow-hidden rounded-sm focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:y("img",{alt:"",className:"size-7 object-cover",src:r})})}),y(ao,{asChild:!0,children:y("button",{className:"max-w-[220px] truncate text-left hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:o})}),U(O,{size:"xl",children:[U(V,{children:[y(_,{children:o}),y(q,{children:t})]}),y(Xo,{children:y("img",{alt:o,className:"max-h-[70vh] w-full rounded-md object-contain",src:r})})]})]}),at=(t)=>{let{className:n,detail:o,labels:r,name:s,previewUrl:i}=t;return U("span",{className:e("inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted/50 px-2 py-1 text-xs text-foreground",n),"data-mode":t.mode,"data-part":"attachment-chip",children:[i===void 0?U(nt,{children:[y(je,{className:"size-3.5 shrink-0 text-muted-foreground"}),y("span",{className:"max-w-[220px] truncate",children:s})]}):y(tt,{description:r.previewDescription,label:r.preview(s),name:s,url:i}),o===void 0?null:y("span",{className:"text-muted-foreground",children:o}),t.mode==="draft"?y("button",{"aria-label":r.remove(s),className:"rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",onClick:t.onRemove,type:"button",children:y(L,{className:"size-3.5"})}):null,t.mode==="stored"&&t.onDownload!==void 0?y(et,{labels:r,name:s,onDownload:t.onDownload,pending:t.pending??!1}):null,t.mode==="stored"&&t.error!==void 0&&t.error!==null?y("span",{className:"text-destructive",role:"alert",children:t.error}):null]})};import{jsx as we,jsxs as ke}from"react/jsx-runtime";var ot=(t,n,o)=>{if(n>0)return` · ${t.messages(n)}`;if(o>0)return` · ${t.runs(o)}`;return""},rt=({className:t,labels:n,messageCount:o=0,runCount:r=0})=>ke("div",{className:e("flex items-center gap-3 text-xs text-muted-foreground",t),"data-part":"compaction-marker",children:[we("hr",{"aria-label":n.compacted,className:"h-px flex-1 border-0 bg-border"}),ke("span",{className:"shrink-0 rounded-md border border-border bg-background px-2 py-1",children:[n.compacted,ot(n,o,r)]}),we("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]});import{useState as st}from"react";import{jsx as P,jsxs as ee}from"react/jsx-runtime";var de=(t)=>[...t.dataTransfer.types].includes("Files"),it=({state:t})=>{if(t==="idle")return P(ho,{className:"size-4"});return P(b,{className:"size-4 animate-spin"})},Re=({className:t,label:n,onStop:o,stopping:r})=>P(a,{"aria-busy":r||void 0,"aria-label":n,className:e("size-8 shrink-0 rounded-md bg-destructive text-destructive-foreground hover:bg-destructive/90",t),disabled:r,onClick:o,size:"icon",type:"button",children:r?P(b,{className:"size-4 animate-spin"}):P("span",{className:"size-3 rounded-[2px] bg-current"})}),dt=({canSubmit:t,labels:n,onStop:o,sendClassName:r,showStop:s,state:i,stopping:d,submit:p,trailing:u})=>{let x=s&&o!==void 0,h=!x&&i==="running"&&o!==void 0;return ee("div",{className:"flex shrink-0 items-center gap-1.5",children:[x?P(Re,{className:void 0,label:n.stop,onStop:o,stopping:d}):null,u,h?P(Re,{className:r,label:n.stop,onStop:o,stopping:d}):P(a,{"aria-label":i==="idle"?n.send:n.submitting,className:e("size-8 shrink-0 rounded-md bg-foreground text-background hover:bg-foreground/90",r),disabled:!t,onClick:p,size:"icon",type:"button",children:P(it,{state:i})})]})},lt=({attachments:t,className:n,classNames:o,disabled:r=!1,footer:s,labels:i,leading:d,notice:p,onFilesAdd:u,onInputKeyDown:x,onStop:h,onSubmit:k,onValueChange:C,placeholder:M,showStop:J=!1,state:z="idle",stopping:Y=!1,suggestions:Z,trailing:Ie,value:ue})=>{let[ge,oe]=st(!1),fe=z==="idle"&&!r&&ue.trim()!=="",be=()=>{if(fe)k()},xe=(f)=>{if(u!==void 0&&f.length>0)u([...f])},Oe=u===void 0?{}:{onDragEnter:(f)=>{if(de(f))f.preventDefault(),oe(!0)},onDragLeave:(f)=>{let{relatedTarget:he}=f;if(!(he instanceof Node)||!f.currentTarget.contains(he))oe(!1)},onDragOver:(f)=>{if(de(f))f.preventDefault()},onDrop:(f)=>{if(de(f))f.preventDefault(),oe(!1),xe(f.dataTransfer.files)}};return ee("div",{className:e("w-full",n),"data-part":"composer",children:[p===void 0?null:P("div",{className:"mb-2",children:p}),ee("div",{className:e("relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-colors dark:border-border/80 dark:bg-black dark:shadow-none",ge&&"border-primary/70 bg-primary/5 ring-2 ring-primary/20",o?.frame),"data-part":"composer-frame",...Oe,children:[ge?P("div",{className:"pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-xl border border-primary/40 bg-background/80 text-sm font-medium text-foreground backdrop-blur-sm",children:i.drop}):null,t===void 0?null:P("div",{className:"flex flex-wrap gap-2 border-b border-border px-3 py-2",children:t}),P(Q,{"aria-label":i.input,className:e("max-h-44 min-h-20 resize-none border-0 bg-transparent px-5 py-4 text-base text-foreground shadow-none placeholder:text-muted-foreground focus-visible:ring-0 dark:bg-transparent",o?.input),disabled:r,onChange:(f)=>{C(f.target.value)},onKeyDown:(f)=>{if(x?.(f),f.defaultPrevented||f.key!=="Enter"||f.shiftKey||f.nativeEvent.isComposing)return;f.preventDefault(),be()},onPaste:(f)=>{if(u!==void 0&&f.clipboardData.files.length>0)f.preventDefault(),xe(f.clipboardData.files)},placeholder:M,value:ue}),Z,ee("div",{className:e("flex min-h-14 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-t border-border/80 bg-muted/30 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-950",o?.toolbar),children:[P("div",{className:"flex min-w-0 flex-1 items-center gap-1 text-muted-foreground",children:d}),P(dt,{canSubmit:fe,labels:i,onStop:h,sendClassName:o?.send,showStop:J,state:z,stopping:Y,submit:be,trailing:Ie})]})]}),s]})};import{jsx as pt}from"react/jsx-runtime";var ct=(t)=>Number.isFinite(t)?Math.round(Math.min(1,Math.max(0,t))*100):0,mt=({className:t,label:n,ratio:o})=>{let r=ct(o);return pt(Vr,{"aria-valuenow":r,className:t,"data-part":"context-usage-ring",label:n,role:"meter",value:r})};import ut from"react-markdown";import gt from"remark-gfm";import{jsx as W}from"react/jsx-runtime";var ft=({children:t,href:n})=>W("a",{href:n,rel:"noreferrer",target:"_blank",children:t}),bt=({children:t,...n})=>W("div",{className:"my-4 max-w-full overflow-x-auto",children:W("table",{...n,className:"w-max min-w-full",children:t})}),Pe={a:ft,table:bt},xt=[gt],ht=({className:t,components:n,content:o})=>W("div",{className:e("prose prose-sm min-w-0 max-w-none break-words text-[15px] leading-7 text-foreground dark:prose-invert prose-headings:font-semibold prose-pre:bg-muted prose-th:text-left",t),"data-part":"markdown",children:W(ut,{components:n===void 0?Pe:{...Pe,...n},remarkPlugins:xt,children:o})});import{jsx as B,jsxs as te}from"react/jsx-runtime";var vt=6,Ct=({className:t,classNames:n,events:o,labels:r,memoryDisabled:s=!1,saved:i,used:d})=>{if(o.length===0)return null;return te("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3 text-sm",t),"data-part":"memory-evidence",children:[te("div",{className:e("flex flex-wrap items-center justify-between gap-2",n?.header),children:[B("div",{className:"font-semibold",children:r.title}),te("div",{className:"flex flex-wrap gap-1.5",children:[d>0?B(T,{className:"rounded-md",variant:"secondary",children:r.used(d)}):null,i>0?B(T,{className:"rounded-md",variant:"secondary",children:r.saved(i)}):null,s?B(T,{className:"rounded-md",variant:"secondary",children:r.disabled}):null]})]}),B("ul",{className:e("mt-2 space-y-1.5",n?.events),children:o.slice(0,vt).map((p)=>te("li",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[B("span",{className:"font-medium text-foreground",children:p.label}),(p.details??[]).map((u,x)=>B("span",{children:u},x))]},p.id))})]})};import{jsx as K,jsxs as le}from"react/jsx-runtime";var Se={assistant:{className:"bg-accent text-accent-foreground",icon:K(qe,{className:"size-5"})},user:{className:"bg-primary text-primary-foreground",icon:K(yo,{className:"size-5"})}},Nt=({author:t,avatar:n,children:o,className:r,classNames:s,sender:i,timestamp:d})=>le("article",{className:e("grid grid-cols-[36px_minmax(0,1fr)] gap-3",r),"data-part":"message","data-sender":i,children:[K("div",{"aria-hidden":"true",className:e("grid size-9 place-items-center overflow-hidden rounded-full",n===void 0&&Se[i].className,s?.avatar),children:n??Se[i].icon}),le("div",{className:"min-w-0 text-sm text-foreground",children:[le("div",{className:e("mb-1.5 flex flex-wrap items-center gap-2",s?.header),children:[K("span",{className:e("font-semibold",s?.author),children:t}),d===void 0?null:K("span",{className:e("text-xs text-muted-foreground",s?.timestamp),children:d})]}),K("div",{className:e("flex flex-col gap-3",s?.body),children:o})]})]});import{jsx as E,jsxs as G}from"react/jsx-runtime";var ce=({className:t,decision:n,label:o,onDecide:r,pendingDecision:s,variant:i="default"})=>G(a,{className:t,disabled:s!==void 0,onClick:()=>{r(n)},type:"button",variant:i,children:[s===n?E(b,{className:"size-4 animate-spin"}):null,o]}),yt=({className:t,classNames:n,description:o,error:r,labels:s,name:i,onDecide:d,pendingDecision:p})=>E("section",{"aria-label":s.region(i),className:e("rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",t),"data-part":"permission-prompt",children:G("div",{className:"flex items-start gap-3",children:[E("div",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md bg-(--bg-accent-soft) text-(--accent)",children:E(mr,{className:"size-4"})}),G("div",{className:"@container/permission min-w-0 flex-1 space-y-3",children:[G("div",{children:[E("h2",{className:e("break-words text-base font-semibold text-foreground",n?.title),children:s.title(i)}),s.description===void 0?null:E("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:s.description})]}),o===void 0||o===null?null:E("p",{className:e("rounded-md border border-border bg-muted/50 px-3 py-2 text-sm leading-6 text-muted-foreground",n?.description),children:o}),r===void 0||r===null?null:E("p",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm leading-6 text-destructive",role:"alert",children:r}),G("div",{className:e("flex flex-col gap-2 @2xl/permission:flex-row @2xl/permission:items-center",n?.actions),children:[E(ce,{className:"w-full @2xl/permission:w-auto",decision:"deny",label:s.deny,onDecide:d,pendingDecision:p,variant:"outline"}),G("div",{className:"flex flex-col gap-2 @md/permission:flex-row @2xl/permission:ml-auto @2xl/permission:justify-end",children:[E(ce,{className:"w-full @md/permission:w-auto",decision:"allow_this_conversation",label:s.allowThisConversation,onDecide:d,pendingDecision:p}),E(ce,{className:"w-full @md/permission:w-auto",decision:"allow_always",label:s.allowAlways,onDecide:d,pendingDecision:p})]})]})]})]})});import{useState as wt}from"react";import{jsx as A,jsxs as X}from"react/jsx-runtime";var kt={approval:pr,command:mo,compaction:H,file:je,model:qe,permission:mr,request:H,run:H,skill:qe,step:H,tool:Co},Rt=({step:t})=>{if(t.status==="active")return A(b,{className:"size-4 animate-spin"});let n=kt[t.kind];return A(n,{className:"size-4"})},St=({className:t,classNames:n,defaultOpen:o=!1,onOpenChange:r,open:s,steps:i,summary:d})=>{let[p,u]=wt(o),x=s??p;if(i.length===0)return null;return X("details",{className:e("group ml-12 text-sm text-muted-foreground",t),"data-part":"processing-steps",onToggle:(h)=>{let k=h.currentTarget.open;if(k!==x)u(k),r?.(k)},open:x,children:[X("summary",{className:e("flex w-fit cursor-pointer list-none items-center gap-1.5 font-medium text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",n?.summary),children:[A("span",{children:d}),A(v,{className:"size-4 transition-transform group-open:rotate-180"})]}),x?A("ol",{className:e("mt-4",n?.list),children:i.map((h,k)=>X("li",{className:e("grid grid-cols-[32px_minmax(0,1fr)] gap-3",n?.step),"data-status":h.status,children:[X("div",{className:"relative flex justify-center",children:[A("span",{className:"mt-0.5 grid size-6 place-items-center rounded-md border border-border bg-background text-muted-foreground",children:A(Rt,{step:h})}),k<i.length-1?A("span",{className:"absolute top-8 bottom-0 w-px bg-border"}):null]}),A("div",{className:"min-w-0 pb-5",children:X("div",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[A("span",{className:e("break-words text-base",h.status==="active"?"text-foreground":"text-muted-foreground"),children:h.label}),h.detail===void 0?null:A("span",{className:"rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:h.detail})]})})]},h.id))}):null]})};import{useId as Te,useState as ae}from"react";import{jsx as m,jsxs as S,Fragment as Ft}from"react/jsx-runtime";var me="other",De=(t)=>`option:${t}`,Ee=({description:t,id:n,label:o,value:r})=>S("div",{className:"flex items-start gap-2",children:[m(ar,{className:"mt-0.5",id:n,value:r}),S("div",{className:"grid gap-0.5",children:[m(I,{htmlFor:n,children:o}),t===void 0?null:m("span",{className:"text-xs text-muted-foreground",children:t})]})]}),Et=({disabled:t,labels:n,onRespond:o,options:r,withText:s})=>{let i=Te(),[d,p]=ae(null),[u,x]=ae(""),h=(C)=>r.find((M)=>De(M.id)===C),k=(()=>{if(d===me)return u.trim()===""?null:{action:"answer",text:u.trim()};let C=d===null?void 0:h(d);return C===void 0?null:{action:"answer",optionId:C.id}})();return S(Ft,{children:[S(nr,{className:"grid gap-2",disabled:t,onValueChange:(C)=>{p(C);let M=h(C);if(!s&&M!==void 0)o({action:"answer",optionId:M.id})},value:d??"",children:[r.map((C,M)=>m(Ee,{description:C.description,id:`${i}-${M}`,label:C.label,value:De(C.id)},C.id)),s?m(Ee,{id:`${i}-other`,label:n.otherOption,value:me}):null]}),s?S("div",{className:"flex gap-2",children:[m(g,{"aria-label":n.otherAnswer,disabled:t||d!==me,onChange:(C)=>{x(C.target.value)},value:u}),m(a,{disabled:t||k===null,onClick:()=>{if(k!==null)o(k)},type:"button",children:n.continue})]}):null]})},At=({disabled:t,labels:n,onRespond:o})=>{let[r,s]=ae("");return S("div",{className:"grid gap-2",children:[m(Q,{"aria-label":n.textAnswer,disabled:t,onChange:(i)=>{s(i.target.value)},placeholder:n.textPlaceholder,value:r}),m(a,{className:"justify-self-start",disabled:t||r.trim()==="",onClick:()=>{o({action:"answer",text:r.trim()})},type:"button",children:n.answer})]})},Lt=({disabled:t,labels:n,onRespond:o})=>{let r=Te(),[s,i]=ae("");return S("div",{className:"grid gap-2",children:[m(a,{className:"justify-self-start",disabled:t,onClick:()=>{o({action:"approve"})},type:"button",children:t?n.responding:n.approve}),m(I,{htmlFor:r,children:n.reviseLabel}),S("div",{className:"flex gap-2",children:[m(g,{disabled:t,id:r,onChange:(d)=>{i(d.target.value)},value:s}),m(a,{disabled:t||s.trim()==="",onClick:()=>{o({action:"revise",text:s.trim()})},type:"button",variant:"outline",children:n.revise})]})]})},Ae=({error:t})=>t===void 0||t===null?null:m("p",{className:"text-destructive",role:"alert",children:t}),Le=({meta:t})=>t.length===0?null:m("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:t.map((n,o)=>m("span",{children:n},o))}),Tt=({className:t,label:n,preview:o})=>o===void 0||o===null?null:S("div",{className:e("grid gap-2 rounded-md border border-border bg-muted/30 p-3",t),children:[m("p",{className:"font-semibold",children:n}),m("div",{className:"break-words",children:o})]}),Mt=(t)=>t!=="pending"&&t!=="responding",zt=({className:t,classNames:n,labels:o,outcome:r,prompt:s,status:i})=>S("section",{className:e("grid gap-2 rounded-lg border border-border bg-muted/30 p-4 text-sm",t),"data-part":"question-card","data-status":i,children:[m("div",{className:e("break-words",n?.prompt),children:s}),S("p",{className:"flex items-center gap-2 font-medium",children:[i==="completed"?m(H,{className:"size-4 shrink-0 text-emerald-600"}):m(Dt,{className:"size-4 shrink-0 text-destructive"}),o[i]]}),r===void 0||r===null?null:m("output",{className:"text-muted-foreground",children:r})]}),Bt=(t)=>{let{className:n,classNames:o,error:r,labels:s,meta:i=[],onRespond:d,outcome:p,preview:u,prompt:x,status:h}=t;if(Mt(h))return m(zt,{className:n,classNames:o,labels:s,outcome:p,prompt:x,status:h});let k=h==="responding",C=m(Tt,{className:o?.preview,label:s.preview,preview:u});if(t.mode==="confirm")return S("section",{className:e("grid gap-3 rounded-lg border border-border bg-muted/30 p-4 text-sm",n),"data-part":"question-card","data-status":h,children:[S("div",{children:[m("p",{className:"text-xs font-semibold tracking-wide text-muted-foreground uppercase",children:s.confirmTitle}),s.confirmHint===void 0?null:m("p",{className:"text-xs text-muted-foreground",children:s.confirmHint})]}),m("div",{className:e("break-words font-semibold",o?.prompt),children:x}),m(Le,{meta:i}),C,m(Lt,{disabled:k,labels:s,onRespond:d}),m(Ae,{error:r})]});return S("section",{className:e("grid gap-3 rounded-lg border border-border p-4 text-sm",n),"data-part":"question-card","data-status":h,children:[C,m("div",{className:e("break-words",o?.prompt),children:x}),m(Le,{meta:i}),t.mode==="choice"||t.mode==="choice_or_text"?m(Et,{disabled:k,labels:s,onRespond:d,options:t.options,withText:t.mode==="choice_or_text"}):null,t.mode==="text"?m(At,{disabled:k,labels:s,onRespond:d}):null,m(Ae,{error:r})]})};import{jsx as F,jsxs as ne,Fragment as _t}from"react/jsx-runtime";var Ot={danger:"text-destructive",neutral:"text-muted-foreground",primary:"text-primary",success:"text-emerald-600",warning:"text-amber-600"},Qt=({className:t,classNames:n,detail:o,label:r,labels:s,tone:i})=>ne("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3",t),"data-part":"run-status","data-tone":i,children:[ne("div",{className:"flex min-w-0 items-center gap-2",children:[F(qe,{className:"size-4 shrink-0 text-muted-foreground"}),F("span",{className:e("truncate font-semibold",n?.title),children:s.title})]}),ne("div",{className:e("mt-1.5 flex flex-wrap items-center gap-2 text-sm",n?.status),children:[F(Pt,{size:"md",tone:i}),F("span",{className:"text-muted-foreground",children:s.status}),F("span",{className:Ot[i],children:r}),o===void 0||o===null?null:ne(_t,{children:[F("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"·"}),F("span",{className:"font-mono text-xs text-muted-foreground",children:o})]})]})]});import{useState as Me}from"react";import{jsx as l,jsxs as w}from"react/jsx-runtime";var jt=5,Ht=4,Ut={custom:je,evidence:je,json:fr,links:Xe,sources:vo,summary:fr,table:go,text:fr,warnings:ve},Kt=(t)=>{try{let{protocol:n}=new URL(t);return n==="http:"||n==="https:"?t:null}catch{return null}},ze=({children:t,url:n})=>{let o=Kt(n);if(o===null)return l("span",{className:"break-words font-medium",children:t});return w("a",{className:"inline-flex max-w-full items-center gap-1 break-all font-medium text-primary hover:text-(--accent-hover)",href:o,rel:"noreferrer",target:"_blank",children:[l("span",{className:"min-w-0 break-words",children:t}),l(It,{className:"size-3 shrink-0"})]})},Be=({meta:t})=>t===void 0||t.length===0?null:l("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:t.map((n,o)=>l("span",{children:n},o))}),pe=({excerpt:t})=>t===void 0?null:l("p",{className:"mt-1 break-words text-xs leading-5 text-muted-foreground",children:t}),Fe=({hidden:t,label:n,onShow:o})=>t>0?w("button",{className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:text-(--accent-hover)",onClick:o,type:"button",children:[n(t),l(v,{className:"size-3"})]}):null,qt=({groups:t,note:n})=>w("div",{className:"flex flex-col gap-3",children:[t.map((o)=>w("section",{className:"flex flex-col gap-2",children:[l("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o.label}),l("ol",{className:"flex flex-col gap-2",children:o.items.map((r)=>w("li",{className:"rounded-md border border-border bg-background/70 p-2.5",children:[w("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[w("div",{className:"min-w-0",children:[l("div",{className:"font-medium",children:r.title}),l(pe,{excerpt:r.excerpt})]}),r.action]}),l(Be,{meta:r.meta})]},r.id))})]},o.id)),n===void 0?null:l("p",{className:"text-xs text-muted-foreground",children:n})]}),Gt=({columns:t,labels:n,rows:o})=>{let[r,s]=Me(!1),i=r?o:o.slice(0,jt);return w("div",{className:"flex flex-col items-start gap-2",children:[l("div",{className:"w-full max-w-full overflow-x-auto",children:w("table",{className:"w-full min-w-[520px] table-fixed border-collapse text-left text-xs",children:[l("thead",{children:l("tr",{className:"border-b border-border",children:t.map((d)=>l("th",{className:"w-[180px] px-2 py-2 font-semibold text-muted-foreground",title:d.description,children:d.label},d.key))})}),l("tbody",{children:i.map((d)=>l("tr",{className:"border-b border-border/70 last:border-0",children:t.map((p)=>l("td",{className:"px-2 py-2 align-top break-words",children:d.cells[p.key]},p.key))},d.id))})]})}),l(Fe,{hidden:o.length-i.length,label:n.showMore,onShow:()=>{s(!0)}})]})},$t=({labels:t,sources:n})=>{let[o,r]=Me(!1),s=o?n:n.slice(0,Ht);return w("div",{className:"flex flex-col items-start gap-2",children:[l("ol",{className:"flex w-full flex-col gap-2",children:s.map((i)=>w("li",{className:"rounded-md border border-border bg-background/70 p-2",children:[w("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[w("div",{className:"min-w-0",children:[i.url===void 0?l("span",{className:"font-medium",children:i.title}):l(ze,{url:i.url,children:i.title}),l(pe,{excerpt:i.excerpt})]}),i.rank===void 0?null:l("span",{className:"shrink-0 text-xs text-muted-foreground",children:i.rank})]}),l(Be,{meta:i.meta})]},i.id))}),l(Fe,{hidden:n.length-s.length,label:t.showMore,onShow:()=>{r(!0)}})]})},Vt=(t)=>{switch(t.kind){case"custom":return!1;case"evidence":return t.groups.every((n)=>n.items.length===0);case"json":return t.json==="";case"links":return t.links.length===0;case"sources":return t.sources.length===0;case"summary":return t.items.length===0;case"table":return t.columns.length===0||t.rows.length===0;case"text":return t.text==="";case"warnings":return t.warnings.length===0;default:return t}},Xt=({labels:t,part:n})=>{if(Vt(n))return l("p",{className:"text-xs text-muted-foreground",children:t.empty});switch(n.kind){case"custom":return n.content;case"evidence":return l(qt,{groups:n.groups,note:n.note});case"json":return l("pre",{className:"max-h-[280px] overflow-auto rounded-md bg-background p-2 text-xs leading-5 text-foreground",children:n.json});case"links":return l("ul",{className:"grid gap-2",children:n.links.map((o)=>w("li",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l(ze,{url:o.url,children:o.label}),l(pe,{excerpt:o.description})]},o.id))});case"sources":return l($t,{labels:t,sources:n.sources});case"summary":return l("dl",{className:"grid gap-2 @lg/chat:grid-cols-2",children:n.items.map((o)=>w("div",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),l("dd",{className:"mt-1 break-words text-sm",children:o.value}),o.description===void 0?null:l("dd",{className:"mt-1 text-xs text-muted-foreground",children:o.description})]},o.id))});case"table":return l(Gt,{columns:n.columns,labels:t,rows:n.rows});case"text":return l("p",{className:"whitespace-pre-wrap break-words text-sm leading-6",children:n.text});case"warnings":return l("ul",{className:"flex flex-col gap-2",children:n.warnings.map((o)=>w("li",{className:"flex min-w-0 gap-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-2 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[l(ve,{className:"mt-0.5 size-3.5 shrink-0"}),l("span",{className:"break-words text-xs",children:o.message})]},o.id))});default:return n}},Jt=({part:t})=>{if(t.kind==="custom"&&t.icon!==void 0)return t.icon;let n=Ut[t.kind];return l(n,{className:"size-4"})},Yt=({className:t,classNames:n,labels:o,parts:r})=>r.length===0?null:l("div",{className:e("flex flex-col gap-3",t),"data-part":"tool-evidence",children:r.map((s)=>w("section",{className:e("overflow-hidden rounded-md border border-border bg-muted/20",n?.part),"data-kind":s.kind,children:[w("div",{className:e("flex min-w-0 items-start gap-2 border-b border-border px-3 py-2",n?.header),children:[l("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:l(Jt,{part:s})}),w("div",{className:"min-w-0",children:[l("h3",{className:"truncate text-sm font-medium",children:s.title}),s.description===void 0?null:l("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:s.description})]})]}),l("div",{className:e("min-w-0 p-3",n?.body),children:l(Xt,{labels:o,part:s})})]},s.id))});export{_e as ChatAnswerFeedback,Ze as ChatApprovalCard,at as ChatAttachmentChip,rt as ChatCompactionMarker,lt as ChatComposerShell,mt as ChatContextUsageRing,ht as ChatMarkdown,Ct as ChatMemoryEvidence,Nt as ChatMessage,yt as ChatPermissionPrompt,St as ChatProcessingSteps,Bt as ChatQuestionCard,Qt as ChatRunStatus,Yt as ChatToolEvidence};
|
|
2
|
+
import"./index-64r6cav3.js";import"./index-dg126t3v.js";import{a}from"./index-r2snvwyb.js";import{N,ao,O,Xo,V,sr,_,q,g,I}from"./index-sd38wa4w.js";import{Q,nr,ar}from"./index-2twj52t7.js";import{T}from"./index-r5ds1mtq.js";import{Vr,Pt}from"./index-fnk7gsdd.js";import{fr,Dt,mo,ho,qe,pr,go,je,vo,mr,xo,bo,yo,Co}from"./index-m0v264jr.js";import{H,ve,Wt,It,Xe}from"./index-2yf6mq9g.js";import{b}from"./index-ecvn2gnv.js";import{L}from"./index-rgbg5bsy.js";import{v}from"./index-tcwzyy71.js";import"./index-0gzm7bb9.js";import{e}from"./index-qbwndfn2.js";import{useState as Ne}from"react";import{jsx as D,jsxs as j,Fragment as He}from"react/jsx-runtime";var Ce=({active:t,disabled:n,label:o,onClick:r,sentiment:s})=>{let i=s==="positive"?bo:xo;return D(a,{"aria-label":o,"aria-pressed":t,disabled:n,className:e("h-7 min-w-7 px-2 text-base",t&&(s==="positive"?"border-(--success) text-(--success)":"border-(--danger) text-(--danger)")),onClick:r,size:"sm",type:"button",variant:"ghost",children:D(i,{"aria-hidden":"true",className:e("size-4",t&&"fill-current")})})},Qe=({labels:t,onCancel:n,onSubmit:o})=>{let[r,s]=Ne(""),i=r.trim();return j(He,{children:[D(Q,{"aria-label":t.note,autoFocus:!0,onChange:(d)=>{s(d.target.value)},placeholder:t.note,required:!0,value:r}),j(sr,{children:[D(a,{onClick:n,type:"button",variant:"outline",children:t.cancel}),D(a,{disabled:i==="",onClick:()=>{o(i)},type:"button",children:t.submit})]})]})},_e=({className:t,error:n,labels:o,onClear:r,onSubmit:s,pending:i=!1,value:d})=>{let[p,u]=Ne(!1);return j("div",{className:e("flex flex-wrap items-center gap-2 text-xs text-muted-foreground",t),"data-part":"answer-feedback",children:[j("fieldset",{"aria-busy":i,"aria-label":o.group,className:"flex items-center gap-1",children:[D(Ce,{active:d==="positive",disabled:i,label:o.positive,onClick:()=>{if(d==="positive"){r();return}s({note:null,sentiment:"positive"})},sentiment:"positive"}),D(Ce,{active:d==="negative",disabled:i,label:o.negative,onClick:()=>{if(d==="negative"){r();return}u(!0)},sentiment:"negative"})]}),i?D("span",{children:o.saving}):null,n===void 0||n===null?null:D("span",{className:"text-destructive",role:"alert",children:n}),D(N,{onOpenChange:u,open:p,children:j(O,{children:[j(V,{children:[D(_,{children:o.noteTitle}),D(q,{children:o.noteDescription})]}),D(Qe,{labels:o,onCancel:()=>{u(!1)},onSubmit:(x)=>{s({note:x,sentiment:"negative"}),u(!1)}})]})})]})};import{useId as ye,useState as se}from"react";import{jsx as c,jsxs as R}from"react/jsx-runtime";var Ue=new Set(["continuation_failed","reconciliation_required"]),Ke=({status:t})=>c("div",{className:"mt-0.5 rounded-md border border-border bg-muted/40 p-1.5",children:(()=>{if(t==="approved")return c(H,{className:"size-4 text-emerald-600"});if(t==="pending")return c(pr,{className:"size-4 text-muted-foreground"});return c(Dt,{className:"size-4 text-destructive"})})()}),Ge=({label:t,outcome:n})=>R("output",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3 text-sm font-medium text-foreground",children:[Ue.has(n)?c(ve,{className:"size-4 shrink-0 text-destructive"}):c(H,{className:"size-4 shrink-0 text-emerald-600"}),t]}),re=[],$e=({onApprove:t,onReject:n,outcome:o,status:r})=>{if(r!=="pending"||o!==void 0)return"closed";return t===void 0&&n===void 0?"read_only":"decide"},Ve={closed:null,decide:"decideHint",read_only:"readOnlyHint"},We=({className:t,decisions:n=re,labels:o,meta:r=re,resolution:s,steps:i=re})=>{if(r.length===0&&i.length===0&&n.length===0&&s===void 0)return null;return R("div",{className:e("mt-3 grid gap-2 text-xs text-muted-foreground",t),children:[r.length===0?null:c("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:r.map((d,p)=>c("span",{children:d},p))}),i.length===0?null:c("ul",{"aria-label":o.steps,className:"grid gap-1",children:i.map((d)=>R("li",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"truncate",children:d.label}),c("span",{className:"shrink-0",children:o.stepProgress(d.approved,d.required)})]},d.id))}),n.length===0?null:c("ul",{"aria-label":o.decisions,className:"grid gap-1 border-t border-border pt-2",children:n.map((d)=>c("li",{children:d.label},d.id))}),s===void 0?null:c("p",{className:"border-t border-border pt-2",children:s})]})},ie=500,Je=({labels:t,onCancel:n,onReject:o,pending:r})=>{let s=ye(),[i,d]=se(""),p=i.trim();return R("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[c(I,{htmlFor:s,children:t.rejectReason}),c(Q,{autoFocus:!0,disabled:r,id:s,maxLength:ie,onChange:(u)=>{d(u.target.value)},placeholder:t.rejectReasonPlaceholder,value:i}),R("div",{className:"flex items-center justify-between gap-2",children:[R("span",{className:"text-xs text-muted-foreground",children:[i.length,"/",ie]}),R("div",{className:"flex gap-2",children:[c(a,{disabled:r,onClick:n,size:"sm",type:"button",variant:"ghost",children:t.cancel}),R(a,{disabled:r||p==="",onClick:()=>{o(p)},size:"sm",type:"button",variant:"destructive",children:[r?c(b,{className:"size-3.5 animate-spin"}):null,t.confirmReject]})]})]})]})},Ye=({labels:t,onApprove:n,onReject:o,pendingAction:r})=>{let s=ye(),[i,d]=se(""),[p,u]=se(!1),x=r!==void 0;if(p&&o!==void 0)return c(Je,{labels:t,onCancel:()=>{u(!1)},onReject:o,pending:r==="reject"});return R("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[n===void 0?null:R("div",{className:"grid gap-1.5",children:[c(I,{className:"text-xs",htmlFor:s,children:t.comment}),c(g,{disabled:x,id:s,maxLength:ie,onChange:(h)=>{d(h.target.value)},placeholder:t.commentPlaceholder,value:i})]}),R("div",{className:"flex gap-2",children:[n===void 0?null:R(a,{disabled:x,onClick:()=>{n(i.trim()===""?null:i.trim())},size:"sm",type:"button",children:[r==="approve"?c(b,{className:"size-3.5 animate-spin"}):c(H,{className:"size-3.5"}),r==="approve"?t.approving:t.approve]}),o===void 0?null:R(a,{disabled:x,onClick:()=>{u(!0)},size:"sm",type:"button",variant:"outline",children:[c(Dt,{className:"size-3.5"}),t.reject]})]})]})},Ze=({children:t,className:n,classNames:o,decisions:r,error:s,labels:i,meta:d,onApprove:p,onReject:u,outcome:x,pendingAction:h,resolution:k,status:C,steps:M,summary:J})=>{let z=$e({onApprove:p,onReject:u,outcome:x,status:C}),Y=Ve[z],Z=Y===null?void 0:i[Y];return R("section",{"aria-label":i.title,className:e("rounded-md border border-border bg-background p-3 text-sm",n),"data-part":"approval-card","data-status":C,children:[R("div",{className:e("flex items-start gap-3",o?.header),children:[c(Ke,{status:C}),R("div",{className:"min-w-0 flex-1",children:[R("div",{className:"flex flex-wrap items-center gap-2",children:[c("p",{className:"font-medium text-foreground",children:i.title}),c(T,{variant:z==="decide"?"default":"outline",children:i.statuses[C]}),z==="read_only"?c(T,{variant:"secondary",children:i.readOnly}):null]}),Z===void 0?null:c("p",{className:"mt-1 text-muted-foreground",children:Z}),J===void 0?null:c("div",{className:"mt-1 break-words text-foreground",children:J}),c(We,{className:o?.details,decisions:r,labels:i,meta:d,resolution:k,steps:M})]})]}),t,z==="decide"?c("div",{className:o?.actions,children:c(Ye,{labels:i,onApprove:p,onReject:u,pendingAction:h})}):null,s===void 0||s===null?null:c("p",{className:"mt-2 text-destructive",role:"alert",children:s}),x===void 0?null:c(Ge,{label:i.outcomes[x],outcome:x})]})};import{jsx as y,jsxs as U,Fragment as nt}from"react/jsx-runtime";var et=({labels:t,name:n,onDownload:o,pending:r})=>U("button",{"aria-label":t.downloadFile(n),className:"inline-flex items-center gap-1 rounded-sm px-1 text-(--accent) hover:text-(--accent-hover) focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60",disabled:r,onClick:o,type:"button",children:[r?y(b,{className:"size-3.5 animate-spin"}):y(Wt,{className:"size-3.5"}),y("span",{children:r?t.downloading:t.download})]}),tt=({description:t,label:n,name:o,url:r})=>U(N,{children:[y(ao,{asChild:!0,children:y("button",{"aria-label":n,className:"shrink-0 overflow-hidden rounded-sm focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:y("img",{alt:"",className:"size-7 object-cover",src:r})})}),y(ao,{asChild:!0,children:y("button",{className:"max-w-[220px] truncate text-left hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:o})}),U(O,{size:"xl",children:[U(V,{children:[y(_,{children:o}),y(q,{children:t})]}),y(Xo,{children:y("img",{alt:o,className:"max-h-[70vh] w-full rounded-md object-contain",src:r})})]})]}),at=(t)=>{let{className:n,detail:o,labels:r,name:s,previewUrl:i}=t;return U("span",{className:e("inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted/50 px-2 py-1 text-xs text-foreground",n),"data-mode":t.mode,"data-part":"attachment-chip",children:[i===void 0?U(nt,{children:[y(je,{className:"size-3.5 shrink-0 text-muted-foreground"}),y("span",{className:"max-w-[220px] truncate",children:s})]}):y(tt,{description:r.previewDescription,label:r.preview(s),name:s,url:i}),o===void 0?null:y("span",{className:"text-muted-foreground",children:o}),t.mode==="draft"?y("button",{"aria-label":r.remove(s),className:"rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",onClick:t.onRemove,type:"button",children:y(L,{className:"size-3.5"})}):null,t.mode==="stored"&&t.onDownload!==void 0?y(et,{labels:r,name:s,onDownload:t.onDownload,pending:t.pending??!1}):null,t.mode==="stored"&&t.error!==void 0&&t.error!==null?y("span",{className:"text-destructive",role:"alert",children:t.error}):null]})};import{jsx as we,jsxs as ke}from"react/jsx-runtime";var ot=(t,n,o)=>{if(n>0)return` · ${t.messages(n)}`;if(o>0)return` · ${t.runs(o)}`;return""},rt=({className:t,labels:n,messageCount:o=0,runCount:r=0})=>ke("div",{className:e("flex items-center gap-3 text-xs text-muted-foreground",t),"data-part":"compaction-marker",children:[we("hr",{"aria-label":n.compacted,className:"h-px flex-1 border-0 bg-border"}),ke("span",{className:"shrink-0 rounded-md border border-border bg-background px-2 py-1",children:[n.compacted,ot(n,o,r)]}),we("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]});import{useState as st}from"react";import{jsx as P,jsxs as ee}from"react/jsx-runtime";var de=(t)=>[...t.dataTransfer.types].includes("Files"),it=({state:t})=>{if(t==="idle")return P(ho,{className:"size-4"});return P(b,{className:"size-4 animate-spin"})},Re=({className:t,label:n,onStop:o,stopping:r})=>P(a,{"aria-busy":r||void 0,"aria-label":n,className:e("size-8 shrink-0 rounded-md bg-destructive text-destructive-foreground hover:bg-destructive/90",t),disabled:r,onClick:o,size:"icon",type:"button",children:r?P(b,{className:"size-4 animate-spin"}):P("span",{className:"size-3 rounded-[2px] bg-current"})}),dt=({canSubmit:t,labels:n,onStop:o,sendClassName:r,showStop:s,state:i,stopping:d,submit:p,trailing:u})=>{let x=s&&o!==void 0,h=!x&&i==="running"&&o!==void 0;return ee("div",{className:"flex shrink-0 items-center gap-1.5",children:[x?P(Re,{className:void 0,label:n.stop,onStop:o,stopping:d}):null,u,h?P(Re,{className:r,label:n.stop,onStop:o,stopping:d}):P(a,{"aria-label":i==="idle"?n.send:n.submitting,className:e("size-8 shrink-0 rounded-md bg-foreground text-background hover:bg-foreground/90",r),disabled:!t,onClick:p,size:"icon",type:"button",children:P(it,{state:i})})]})},lt=({attachments:t,className:n,classNames:o,disabled:r=!1,footer:s,labels:i,leading:d,notice:p,onFilesAdd:u,onInputKeyDown:x,onStop:h,onSubmit:k,onValueChange:C,placeholder:M,showStop:J=!1,state:z="idle",stopping:Y=!1,suggestions:Z,trailing:Ie,value:ue})=>{let[ge,oe]=st(!1),fe=z==="idle"&&!r&&ue.trim()!=="",be=()=>{if(fe)k()},xe=(f)=>{if(u!==void 0&&f.length>0)u([...f])},Oe=u===void 0?{}:{onDragEnter:(f)=>{if(de(f))f.preventDefault(),oe(!0)},onDragLeave:(f)=>{let{relatedTarget:he}=f;if(!(he instanceof Node)||!f.currentTarget.contains(he))oe(!1)},onDragOver:(f)=>{if(de(f))f.preventDefault()},onDrop:(f)=>{if(de(f))f.preventDefault(),oe(!1),xe(f.dataTransfer.files)}};return ee("div",{className:e("w-full",n),"data-part":"composer",children:[p===void 0?null:P("div",{className:"mb-2",children:p}),ee("div",{className:e("relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-colors dark:border-border/80 dark:bg-black dark:shadow-none",ge&&"border-primary/70 bg-primary/5 ring-2 ring-primary/20",o?.frame),"data-part":"composer-frame",...Oe,children:[ge?P("div",{className:"pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-xl border border-primary/40 bg-background/80 text-sm font-medium text-foreground backdrop-blur-sm",children:i.drop}):null,t===void 0?null:P("div",{className:"flex flex-wrap gap-2 border-b border-border px-3 py-2",children:t}),P(Q,{"aria-label":i.input,className:e("max-h-44 min-h-20 resize-none border-0 bg-transparent px-5 py-4 text-base text-foreground shadow-none placeholder:text-muted-foreground focus-visible:ring-0 dark:bg-transparent",o?.input),disabled:r,onChange:(f)=>{C(f.target.value)},onKeyDown:(f)=>{if(x?.(f),f.defaultPrevented||f.key!=="Enter"||f.shiftKey||f.nativeEvent.isComposing)return;f.preventDefault(),be()},onPaste:(f)=>{if(u!==void 0&&f.clipboardData.files.length>0)f.preventDefault(),xe(f.clipboardData.files)},placeholder:M,value:ue}),Z,ee("div",{className:e("flex min-h-14 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-t border-border/80 bg-muted/30 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-950",o?.toolbar),children:[P("div",{className:"flex min-w-0 flex-1 items-center gap-1 text-muted-foreground",children:d}),P(dt,{canSubmit:fe,labels:i,onStop:h,sendClassName:o?.send,showStop:J,state:z,stopping:Y,submit:be,trailing:Ie})]})]}),s]})};import{jsx as pt}from"react/jsx-runtime";var ct=(t)=>Number.isFinite(t)?Math.round(Math.min(1,Math.max(0,t))*100):0,mt=({className:t,label:n,ratio:o})=>{let r=ct(o);return pt(Vr,{"aria-valuenow":r,className:t,"data-part":"context-usage-ring",label:n,role:"meter",value:r})};import ut from"react-markdown";import gt from"remark-gfm";import{jsx as W}from"react/jsx-runtime";var ft=({children:t,href:n})=>W("a",{href:n,rel:"noreferrer",target:"_blank",children:t}),bt=({children:t,...n})=>W("div",{className:"my-4 max-w-full overflow-x-auto",children:W("table",{...n,className:"w-max min-w-full",children:t})}),Pe={a:ft,table:bt},xt=[gt],ht=({className:t,components:n,content:o})=>W("div",{className:e("prose prose-sm min-w-0 max-w-none break-words text-[15px] leading-7 text-foreground dark:prose-invert prose-headings:font-semibold prose-pre:bg-muted prose-th:text-left",t),"data-part":"markdown",children:W(ut,{components:n===void 0?Pe:{...Pe,...n},remarkPlugins:xt,children:o})});import{jsx as B,jsxs as te}from"react/jsx-runtime";var vt=6,Ct=({className:t,classNames:n,events:o,labels:r,memoryDisabled:s=!1,saved:i,used:d})=>{if(o.length===0)return null;return te("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3 text-sm",t),"data-part":"memory-evidence",children:[te("div",{className:e("flex flex-wrap items-center justify-between gap-2",n?.header),children:[B("div",{className:"font-semibold",children:r.title}),te("div",{className:"flex flex-wrap gap-1.5",children:[d>0?B(T,{className:"rounded-md",variant:"secondary",children:r.used(d)}):null,i>0?B(T,{className:"rounded-md",variant:"secondary",children:r.saved(i)}):null,s?B(T,{className:"rounded-md",variant:"secondary",children:r.disabled}):null]})]}),B("ul",{className:e("mt-2 space-y-1.5",n?.events),children:o.slice(0,vt).map((p)=>te("li",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[B("span",{className:"font-medium text-foreground",children:p.label}),(p.details??[]).map((u,x)=>B("span",{children:u},x))]},p.id))})]})};import{jsx as K,jsxs as le}from"react/jsx-runtime";var Se={assistant:{className:"bg-accent text-accent-foreground",icon:K(qe,{className:"size-5"})},user:{className:"bg-primary text-primary-foreground",icon:K(yo,{className:"size-5"})}},Nt=({author:t,avatar:n,children:o,className:r,classNames:s,sender:i,timestamp:d})=>le("article",{className:e("grid grid-cols-[36px_minmax(0,1fr)] gap-3",r),"data-part":"message","data-sender":i,children:[K("div",{"aria-hidden":"true",className:e("grid size-9 place-items-center overflow-hidden rounded-full",n===void 0&&Se[i].className,s?.avatar),children:n??Se[i].icon}),le("div",{className:"min-w-0 text-sm text-foreground",children:[le("div",{className:e("mb-1.5 flex flex-wrap items-center gap-2",s?.header),children:[K("span",{className:e("font-semibold",s?.author),children:t}),d===void 0?null:K("span",{className:e("text-xs text-muted-foreground",s?.timestamp),children:d})]}),K("div",{className:e("flex flex-col gap-3",s?.body),children:o})]})]});import{jsx as E,jsxs as G}from"react/jsx-runtime";var ce=({className:t,decision:n,label:o,onDecide:r,pendingDecision:s,variant:i="default"})=>G(a,{className:t,disabled:s!==void 0,onClick:()=>{r(n)},type:"button",variant:i,children:[s===n?E(b,{className:"size-4 animate-spin"}):null,o]}),yt=({className:t,classNames:n,description:o,error:r,labels:s,name:i,onDecide:d,pendingDecision:p})=>E("section",{"aria-label":s.region(i),className:e("rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",t),"data-part":"permission-prompt",children:G("div",{className:"flex items-start gap-3",children:[E("div",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md bg-(--bg-accent-soft) text-(--accent)",children:E(mr,{className:"size-4"})}),G("div",{className:"@container/permission min-w-0 flex-1 space-y-3",children:[G("div",{children:[E("h2",{className:e("break-words text-base font-semibold text-foreground",n?.title),children:s.title(i)}),s.description===void 0?null:E("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:s.description})]}),o===void 0||o===null?null:E("p",{className:e("rounded-md border border-border bg-muted/50 px-3 py-2 text-sm leading-6 text-muted-foreground",n?.description),children:o}),r===void 0||r===null?null:E("p",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm leading-6 text-destructive",role:"alert",children:r}),G("div",{className:e("flex flex-col gap-2 @2xl/permission:flex-row @2xl/permission:items-center",n?.actions),children:[E(ce,{className:"w-full @2xl/permission:w-auto",decision:"deny",label:s.deny,onDecide:d,pendingDecision:p,variant:"outline"}),G("div",{className:"flex flex-col gap-2 @md/permission:flex-row @2xl/permission:ml-auto @2xl/permission:justify-end",children:[E(ce,{className:"w-full @md/permission:w-auto",decision:"allow_this_conversation",label:s.allowThisConversation,onDecide:d,pendingDecision:p}),E(ce,{className:"w-full @md/permission:w-auto",decision:"allow_always",label:s.allowAlways,onDecide:d,pendingDecision:p})]})]})]})]})});import{useState as wt}from"react";import{jsx as A,jsxs as X}from"react/jsx-runtime";var kt={approval:pr,command:mo,compaction:H,file:je,model:qe,permission:mr,request:H,run:H,skill:qe,step:H,tool:Co},Rt=({step:t})=>{if(t.status==="active")return A(b,{className:"size-4 animate-spin"});let n=kt[t.kind];return A(n,{className:"size-4"})},St=({className:t,classNames:n,defaultOpen:o=!1,onOpenChange:r,open:s,steps:i,summary:d})=>{let[p,u]=wt(o),x=s??p;if(i.length===0)return null;return X("details",{className:e("group ml-12 text-sm text-muted-foreground",t),"data-part":"processing-steps",onToggle:(h)=>{let k=h.currentTarget.open;if(k!==x)u(k),r?.(k)},open:x,children:[X("summary",{className:e("flex w-fit cursor-pointer list-none items-center gap-1.5 font-medium text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",n?.summary),children:[A("span",{children:d}),A(v,{className:"size-4 transition-transform group-open:rotate-180"})]}),x?A("ol",{className:e("mt-4",n?.list),children:i.map((h,k)=>X("li",{className:e("grid grid-cols-[32px_minmax(0,1fr)] gap-3",n?.step),"data-status":h.status,children:[X("div",{className:"relative flex justify-center",children:[A("span",{className:"mt-0.5 grid size-6 place-items-center rounded-md border border-border bg-background text-muted-foreground",children:A(Rt,{step:h})}),k<i.length-1?A("span",{className:"absolute top-8 bottom-0 w-px bg-border"}):null]}),A("div",{className:"min-w-0 pb-5",children:X("div",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[A("span",{className:e("break-words text-base",h.status==="active"?"text-foreground":"text-muted-foreground"),children:h.label}),h.detail===void 0?null:A("span",{className:"rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:h.detail})]})})]},h.id))}):null]})};import{useId as Te,useState as ae}from"react";import{jsx as m,jsxs as S,Fragment as Ft}from"react/jsx-runtime";var me="other",De=(t)=>`option:${t}`,Ee=({description:t,id:n,label:o,value:r})=>S("div",{className:"flex items-start gap-2",children:[m(ar,{className:"mt-0.5",id:n,value:r}),S("div",{className:"grid gap-0.5",children:[m(I,{htmlFor:n,children:o}),t===void 0?null:m("span",{className:"text-xs text-muted-foreground",children:t})]})]}),Et=({disabled:t,labels:n,onRespond:o,options:r,withText:s})=>{let i=Te(),[d,p]=ae(null),[u,x]=ae(""),h=(C)=>r.find((M)=>De(M.id)===C),k=(()=>{if(d===me)return u.trim()===""?null:{action:"answer",text:u.trim()};let C=d===null?void 0:h(d);return C===void 0?null:{action:"answer",optionId:C.id}})();return S(Ft,{children:[S(nr,{className:"grid gap-2",disabled:t,onValueChange:(C)=>{p(C);let M=h(C);if(!s&&M!==void 0)o({action:"answer",optionId:M.id})},value:d??"",children:[r.map((C,M)=>m(Ee,{description:C.description,id:`${i}-${M}`,label:C.label,value:De(C.id)},C.id)),s?m(Ee,{id:`${i}-other`,label:n.otherOption,value:me}):null]}),s?S("div",{className:"flex gap-2",children:[m(g,{"aria-label":n.otherAnswer,disabled:t||d!==me,onChange:(C)=>{x(C.target.value)},value:u}),m(a,{disabled:t||k===null,onClick:()=>{if(k!==null)o(k)},type:"button",children:n.continue})]}):null]})},At=({disabled:t,labels:n,onRespond:o})=>{let[r,s]=ae("");return S("div",{className:"grid gap-2",children:[m(Q,{"aria-label":n.textAnswer,disabled:t,onChange:(i)=>{s(i.target.value)},placeholder:n.textPlaceholder,value:r}),m(a,{className:"justify-self-start",disabled:t||r.trim()==="",onClick:()=>{o({action:"answer",text:r.trim()})},type:"button",children:n.answer})]})},Lt=({disabled:t,labels:n,onRespond:o})=>{let r=Te(),[s,i]=ae("");return S("div",{className:"grid gap-2",children:[m(a,{className:"justify-self-start",disabled:t,onClick:()=>{o({action:"approve"})},type:"button",children:t?n.responding:n.approve}),m(I,{htmlFor:r,children:n.reviseLabel}),S("div",{className:"flex gap-2",children:[m(g,{disabled:t,id:r,onChange:(d)=>{i(d.target.value)},value:s}),m(a,{disabled:t||s.trim()==="",onClick:()=>{o({action:"revise",text:s.trim()})},type:"button",variant:"outline",children:n.revise})]})]})},Ae=({error:t})=>t===void 0||t===null?null:m("p",{className:"text-destructive",role:"alert",children:t}),Le=({meta:t})=>t.length===0?null:m("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:t.map((n,o)=>m("span",{children:n},o))}),Tt=({className:t,label:n,preview:o})=>o===void 0||o===null?null:S("div",{className:e("grid gap-2 rounded-md border border-border bg-muted/30 p-3",t),children:[m("p",{className:"font-semibold",children:n}),m("div",{className:"break-words",children:o})]}),Mt=(t)=>t!=="pending"&&t!=="responding",zt=({className:t,classNames:n,labels:o,outcome:r,prompt:s,status:i})=>S("section",{className:e("grid gap-2 rounded-lg border border-border bg-muted/30 p-4 text-sm",t),"data-part":"question-card","data-status":i,children:[m("div",{className:e("break-words",n?.prompt),children:s}),S("p",{className:"flex items-center gap-2 font-medium",children:[i==="completed"?m(H,{className:"size-4 shrink-0 text-emerald-600"}):m(Dt,{className:"size-4 shrink-0 text-destructive"}),o[i]]}),r===void 0||r===null?null:m("output",{className:"text-muted-foreground",children:r})]}),Bt=(t)=>{let{className:n,classNames:o,error:r,labels:s,meta:i=[],onRespond:d,outcome:p,preview:u,prompt:x,status:h}=t;if(Mt(h))return m(zt,{className:n,classNames:o,labels:s,outcome:p,prompt:x,status:h});let k=h==="responding",C=m(Tt,{className:o?.preview,label:s.preview,preview:u});if(t.mode==="confirm")return S("section",{className:e("grid gap-3 rounded-lg border border-border bg-muted/30 p-4 text-sm",n),"data-part":"question-card","data-status":h,children:[S("div",{children:[m("p",{className:"text-xs font-semibold tracking-wide text-muted-foreground uppercase",children:s.confirmTitle}),s.confirmHint===void 0?null:m("p",{className:"text-xs text-muted-foreground",children:s.confirmHint})]}),m("div",{className:e("break-words font-semibold",o?.prompt),children:x}),m(Le,{meta:i}),C,m(Lt,{disabled:k,labels:s,onRespond:d}),m(Ae,{error:r})]});return S("section",{className:e("grid gap-3 rounded-lg border border-border p-4 text-sm",n),"data-part":"question-card","data-status":h,children:[C,m("div",{className:e("break-words",o?.prompt),children:x}),m(Le,{meta:i}),t.mode==="choice"||t.mode==="choice_or_text"?m(Et,{disabled:k,labels:s,onRespond:d,options:t.options,withText:t.mode==="choice_or_text"}):null,t.mode==="text"?m(At,{disabled:k,labels:s,onRespond:d}):null,m(Ae,{error:r})]})};import{jsx as F,jsxs as ne,Fragment as _t}from"react/jsx-runtime";var Ot={danger:"text-destructive",neutral:"text-muted-foreground",primary:"text-primary",success:"text-emerald-600",warning:"text-amber-600"},Qt=({className:t,classNames:n,detail:o,label:r,labels:s,tone:i})=>ne("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3",t),"data-part":"run-status","data-tone":i,children:[ne("div",{className:"flex min-w-0 items-center gap-2",children:[F(qe,{className:"size-4 shrink-0 text-muted-foreground"}),F("span",{className:e("truncate font-semibold",n?.title),children:s.title})]}),ne("div",{className:e("mt-1.5 flex flex-wrap items-center gap-2 text-sm",n?.status),children:[F(Pt,{size:"md",tone:i}),F("span",{className:"text-muted-foreground",children:s.status}),F("span",{className:Ot[i],children:r}),o===void 0||o===null?null:ne(_t,{children:[F("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"·"}),F("span",{className:"font-mono text-xs text-muted-foreground",children:o})]})]})]});import{useState as Me}from"react";import{jsx as l,jsxs as w}from"react/jsx-runtime";var jt=5,Ht=4,Ut={custom:je,evidence:je,json:fr,links:Xe,sources:vo,summary:fr,table:go,text:fr,warnings:ve},qt=(t)=>{try{let{protocol:n}=new URL(t);return n==="http:"||n==="https:"?t:null}catch{return null}},ze=({children:t,url:n})=>{let o=qt(n);if(o===null)return l("span",{className:"break-words font-medium",children:t});return w("a",{className:"inline-flex max-w-full items-center gap-1 break-all font-medium text-primary hover:text-(--accent-hover)",href:o,rel:"noreferrer",target:"_blank",children:[l("span",{className:"min-w-0 break-words",children:t}),l(It,{className:"size-3 shrink-0"})]})},Be=({meta:t})=>t===void 0||t.length===0?null:l("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:t.map((n,o)=>l("span",{children:n},o))}),pe=({excerpt:t})=>t===void 0?null:l("p",{className:"mt-1 break-words text-xs leading-5 text-muted-foreground",children:t}),Fe=({hidden:t,label:n,onShow:o})=>t>0?w("button",{className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:text-(--accent-hover)",onClick:o,type:"button",children:[n(t),l(v,{className:"size-3"})]}):null,Kt=({groups:t,note:n})=>w("div",{className:"flex flex-col gap-3",children:[t.map((o)=>w("section",{className:"flex flex-col gap-2",children:[l("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o.label}),l("ol",{className:"flex flex-col gap-2",children:o.items.map((r)=>w("li",{className:"rounded-md border border-border bg-background/70 p-2.5",children:[w("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[w("div",{className:"min-w-0",children:[l("div",{className:"font-medium",children:r.title}),l(pe,{excerpt:r.excerpt})]}),r.action]}),l(Be,{meta:r.meta})]},r.id))})]},o.id)),n===void 0?null:l("p",{className:"text-xs text-muted-foreground",children:n})]}),Gt=({columns:t,labels:n,rows:o})=>{let[r,s]=Me(!1),i=r?o:o.slice(0,jt);return w("div",{className:"flex flex-col items-start gap-2",children:[l("div",{className:"w-full max-w-full overflow-x-auto",children:w("table",{className:"w-full min-w-[520px] table-fixed border-collapse text-left text-xs",children:[l("thead",{children:l("tr",{className:"border-b border-border",children:t.map((d)=>l("th",{className:"w-[180px] px-2 py-2 font-semibold text-muted-foreground",title:d.description,children:d.label},d.key))})}),l("tbody",{children:i.map((d)=>l("tr",{className:"border-b border-border/70 last:border-0",children:t.map((p)=>l("td",{className:"px-2 py-2 align-top break-words",children:d.cells[p.key]},p.key))},d.id))})]})}),l(Fe,{hidden:o.length-i.length,label:n.showMore,onShow:()=>{s(!0)}})]})},$t=({labels:t,sources:n})=>{let[o,r]=Me(!1),s=o?n:n.slice(0,Ht);return w("div",{className:"flex flex-col items-start gap-2",children:[l("ol",{className:"flex w-full flex-col gap-2",children:s.map((i)=>w("li",{className:"rounded-md border border-border bg-background/70 p-2",children:[w("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[w("div",{className:"min-w-0",children:[i.url===void 0?l("span",{className:"font-medium",children:i.title}):l(ze,{url:i.url,children:i.title}),l(pe,{excerpt:i.excerpt})]}),i.rank===void 0?null:l("span",{className:"shrink-0 text-xs text-muted-foreground",children:i.rank})]}),l(Be,{meta:i.meta})]},i.id))}),l(Fe,{hidden:n.length-s.length,label:t.showMore,onShow:()=>{r(!0)}})]})},Vt=(t)=>{switch(t.kind){case"custom":return!1;case"evidence":return t.groups.every((n)=>n.items.length===0);case"json":return t.json==="";case"links":return t.links.length===0;case"sources":return t.sources.length===0;case"summary":return t.items.length===0;case"table":return t.columns.length===0||t.rows.length===0;case"text":return t.text==="";case"warnings":return t.warnings.length===0;default:return t}},Xt=({labels:t,part:n})=>{if(Vt(n))return l("p",{className:"text-xs text-muted-foreground",children:t.empty});switch(n.kind){case"custom":return n.content;case"evidence":return l(Kt,{groups:n.groups,note:n.note});case"json":return l("pre",{className:"max-h-[280px] overflow-auto rounded-md bg-background p-2 text-xs leading-5 text-foreground",children:n.json});case"links":return l("ul",{className:"grid gap-2",children:n.links.map((o)=>w("li",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l(ze,{url:o.url,children:o.label}),l(pe,{excerpt:o.description})]},o.id))});case"sources":return l($t,{labels:t,sources:n.sources});case"summary":return l("dl",{className:"grid gap-2 @lg/chat:grid-cols-2",children:n.items.map((o)=>w("div",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),l("dd",{className:"mt-1 break-words text-sm",children:o.value}),o.description===void 0?null:l("dd",{className:"mt-1 text-xs text-muted-foreground",children:o.description})]},o.id))});case"table":return l(Gt,{columns:n.columns,labels:t,rows:n.rows});case"text":return l("p",{className:"whitespace-pre-wrap break-words text-sm leading-6",children:n.text});case"warnings":return l("ul",{className:"flex flex-col gap-2",children:n.warnings.map((o)=>w("li",{className:"flex min-w-0 gap-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-2 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[l(ve,{className:"mt-0.5 size-3.5 shrink-0"}),l("span",{className:"break-words text-xs",children:o.message})]},o.id))});default:return n}},Jt=({part:t})=>{if(t.kind==="custom"&&t.icon!==void 0)return t.icon;let n=Ut[t.kind];return l(n,{className:"size-4"})},Yt=({className:t,classNames:n,labels:o,parts:r})=>r.length===0?null:l("div",{className:e("flex flex-col gap-3",t),"data-part":"tool-evidence",children:r.map((s)=>w("section",{className:e("overflow-hidden rounded-md border border-border bg-muted/20",n?.part),"data-kind":s.kind,children:[w("div",{className:e("flex min-w-0 items-start gap-2 border-b border-border px-3 py-2",n?.header),children:[l("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:l(Jt,{part:s})}),w("div",{className:"min-w-0",children:[l("h3",{className:"truncate text-sm font-medium",children:s.title}),s.description===void 0?null:l("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:s.description})]})]}),l("div",{className:e("min-w-0 p-3",n?.body),children:l(Xt,{labels:o,part:s})})]},s.id))});export{_e as ChatAnswerFeedback,Ze as ChatApprovalCard,at as ChatAttachmentChip,rt as ChatCompactionMarker,lt as ChatComposerShell,mt as ChatContextUsageRing,ht as ChatMarkdown,Ct as ChatMemoryEvidence,Nt as ChatMessage,yt as ChatPermissionPrompt,St as ChatProcessingSteps,Bt as ChatQuestionCard,Qt as ChatRunStatus,Yt as ChatToolEvidence};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{vn,Hn}from"../../../../index-zmwpsfzp.js";import{e}from"../../../../index-qbwndfn2.js";Hn(import.meta.url,["
|
|
2
|
+
import{vn,Hn}from"../../../../index-zmwpsfzp.js";import{e}from"../../../../index-qbwndfn2.js";Hn(import.meta.url,["ws46amqa","dtzc3f2q","zmwpsfzp","qbwndfn2"],[["./index.js",2,3],["../../../../hls.light-dtzc3f2q.js"],["../../../../index-zmwpsfzp.js"],["../../../../index-qbwndfn2.js"]],0);
|
|
3
3
|
import{useEffect as h,useRef as H}from"react";var E=["application/vnd.apple.mpegurl","application/x-mpegurl"];var w={fetch:async(t,n)=>await globalThis.fetch(t,n),loadHls:async()=>{let{default:t}=await (vn("dtzc3f2q"),import("../../../../hls.light-dtzc3f2q.js"));return t}},b=(t)=>{let n=new URL(t,document.baseURI),r=n.pathname.indexOf("/media/");if(r===-1)return;return{origin:n.origin,pathPrefix:n.pathname.slice(0,r+7),url:n}},f=(t,n)=>{let r=new URL(n,t.url);return r.origin===t.origin&&r.pathname.startsWith(t.pathPrefix)},u=(t)=>{let n=new URL(t.url);return n.searchParams.set("stream","hls"),n.href},m=(t)=>{let n=t.headers.get("content-type")?.toLowerCase()??"";return t.ok&&E.some((r)=>n.startsWith(r))},y=async(t)=>{try{await t.body?.cancel()}catch{}},L=async(t)=>{try{await t.play()}catch{}},g=(t,n,r,s)=>{let{signal:i,video:o}=n,a=!1,l,c=(d)=>{l=new t(d),l.on(t.Events.ERROR,(D,p)=>{if(a||p.details!==t.ErrorDetails.FRAG_LOAD_ERROR||p.response?.code!==403)return;a=!0;let S=!o.paused,v=o.currentTime;if(l.destroy(),c({startPosition:v,xhrSetup:s}),S)L(o)}),l.loadSource(r),l.attachMedia(o)};c({xhrSetup:s}),i.addEventListener("abort",()=>l.destroy(),{once:!0})},M=(t,n)=>async(r,s)=>{if(!f(t,s))return;let i=await n();if(r.readyState===r.UNSENT)r.open("GET",s,!0);for(let[o,a]of Object.entries(i))r.setRequestHeader(o,a)},P=(t)=>(n,r)=>{n.withCredentials=f(t,r)},T=async(t,n,r,s)=>{let i=async(l)=>{let c=await s.fetch(l,{credentials:"omit",headers:await n(),signal:t.signal});return y(c),t.signal.throwIfAborted(),c},o=u(r),a=await i(o);if(m(a)){let l=await s.loadHls();if(t.signal.throwIfAborted(),l.isSupported()){g(l,t,o,M(r,n));return}a=await i(t.src)}t.video.src=a.ok?a.url:t.src},x=async(t,n,r)=>{let s=u(n),i=await r.fetch(s,{credentials:"include",redirect:"manual",signal:t.signal});if(y(i),t.signal.throwIfAborted(),m(i)){let o=await r.loadHls();if(t.signal.throwIfAborted(),o.isSupported()){g(o,t,s,P(n));return}if(t.video.canPlayType("application/vnd.apple.mpegurl")!==""){t.video.src=s;return}}t.video.src=t.src},R=async(t,n=w)=>{let{requestHeaders:r,signal:s,src:i,video:o}=t;try{let a=b(i);if(a===void 0){o.src=i;return}await(r===void 0?x(t,a,n):T(t,r,a,n))}catch{if(!s.aborted)o.src=i}};import{jsx as A}from"react/jsx-runtime";var O=({src:t,requestHeaders:n,className:r,classes:s,...i})=>{let o=H(null),a=H(n),l=n!==void 0;return h(()=>{a.current=n},[n]),h(()=>{let c=o.current;if(c===null)return;let d=new AbortController;return R({requestHeaders:l?async()=>await a.current?.()??{}:void 0,signal:d.signal,src:t,video:c}),()=>d.abort()},[t,l]),A("video",{ref:o,className:e("block w-full",s?.root,r),...i})},C=O;export{C as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Public React primitives, design-system components, icons, illustrations, and utilities for Collective Intelligence applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -235,5 +235,5 @@
|
|
|
235
235
|
"vite": "^8.0.0",
|
|
236
236
|
"vitest": "4.1.10"
|
|
237
237
|
},
|
|
238
|
-
"gitHead": "
|
|
238
|
+
"gitHead": "1aea8fbbdc15de6ed86458def4327d8b799d0473"
|
|
239
239
|
}
|