@inf-monkeys-tech/monkeys-design 2.0.146 → 2.0.147
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/dist/components/agent-workbench/index.js +1 -1
- package/dist/components/agent-workbench/index.js.map +1 -1
- package/dist/components/agent-workbench/index.mjs +1 -1
- package/dist/components/agent-workbench/index.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive)
|
|
|
53
53
|
var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
|
|
54
54
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
55
55
|
|
|
56
|
-
var enUS={locale:"en-US",messages:{pagination:{navigation:"Pagination",first:"First",previous:"Previous",next:"Next",last:"Last",page:({page,pageCount})=>`Page ${page} of ${pageCount}`,currentPage:({page,pageCount})=>`Page ${page} of ${pageCount}, current page`,emptyResults:"0 results",range:({start,end,total})=>`${start}-${end} of ${total}`,selected:({count})=>`${count} selected`,pageSize:"Items per page",loadBatchSize:"Items per load",perLoad:"Items per load",jumpToPage:"Jump to page",pages:"pages",clickToJump:"Click to jump to a page"},dialog:{close:"Close dialog"},dropdownMenu:{actions:"Actions"},loading:{spinner:"Loading"},layout:{resizePanels:"Resize panels",expandPanel:"Expand",collapsePanel:"Collapse",movePanel:"Move",moveBefore:"Move earlier",moveAfter:"Move later"},steps:{label:"Progress",current:"Current",completed:"Completed",error:"Error",disabled:"Disabled"},numberInput:{increment:"Increase value",decrement:"Decrease value"},passwordInput:{showPassword:"Show password",hidePassword:"Hide password"},multiSelect:{placeholder:"Select options",empty:"No options",removeOption:({value})=>`Remove ${value}`},table:{dragColumn:({columnId})=>`Drag column ${columnId}`,resizeColumn:({columnId})=>`Resize column ${columnId}`,sortColumn:({columnId})=>columnId?`Sort column ${columnId}`:"Sort column",loadingRow:"Loading table row"},toolbar:{theme:{label:"Appearance",toggle:"Toggle theme",auto:"Auto",light:"Light",dark:"Dark"},language:{label:"Language",switch:"Switch language"}},toast:{errorTitle:"Error",warningTitle:"Warning",defaultErrorDescription:"Something went wrong.",defaultWarningDescription:"Please check and try again."},dataExplorer:{viewTree:{actions:"More actions",expand:"Expand",collapse:"Collapse",loading:"Loading...",empty:"No views",error:"Unable to load views"}},workbench:{relationshipGraph:{zoomOut:"Zoom out",zoomIn:"Zoom in",zoomToFit:"Fit graph",minimap:"Graph overview"},collection:{label:"Collection",loading:"Loading items",empty:"No items",loadError:"Unable to load items",refreshError:"Unable to refresh items",retry:"Retry",loadingMore:"Loading more items",permission:"You do not have permission to view this content",offline:"You appear to be offline",requestAccess:"Request access"},interactiveTable:{columnActions:"Column actions",freezeColumn:"Freeze to left",freezeEndColumn:"Freeze to right",unfreezeColumn:"Unfreeze from left",unfreezeEndColumn:"Unfreeze from right",unfreezeAllColumns:"Unfreeze all columns",resetColumnWidth:"Reset column width",frozenColumnTitle:"Frozen column"}},agentWorkbench:{label:"Session activity",reasoning:"Reasoning",plan:"Plan",taskNoDetail:"No additional details",modes:{chat:"Chat",work:"Work"},composer:{send:"Send message",stop:"Stop generating",queue:"Queue message",attach:"Add photos or files",voice:"Start voice input",webSearch:"Web search",chatMode:"Chat mode",model:"Model",reasoning:"Reasoning effort",permissions:"Permissions",removeAttachment:"Remove attachment",editQueued:"Edit queued message",deleteQueued:"Delete queued message",moveUp:"Move message up",moveDown:"Move message down",queued:"Queued messages",uploading:"Uploading",uploadFailed:"Upload failed",retryAttachment:"Retry attachment upload",noModels:"No models available",message:"Message",attachmentOnly:"Attachment",reasoningOptions:{low:"Low",medium:"Medium",high:"High",xhigh:"Extra high"},permissionOptions:{"approval-required":"Approval required","auto-approve":"Auto approve","full-access":"Full access"}},quickStart:{label:"Quick start",back:"Back",addFile:"Add file"},tool:{input:"Input",output:"Output",status:{pending:"Pending",running:"Running",completed:"Completed",failed:"Error",denied:"Denied"}},approval:{approve:"Approve",reject:"Reject",approved:"Approved",rejected:"Rejected"},artifact:{pending:"Preparing",ready:"Ready",failed:"Failed",open:({name})=>`Open ${name}`},run:{stopping:"Stopping...",stoppedAfter:({duration})=>`You stopped after ${duration}`},process:{running:"Working",queued:"Queued",waitingApproval:"Waiting for approval",failed:"Failed",stopped:"Stopped",processed:"Processed",processedFor:({duration})=>`Worked for ${duration}`,completedCount:({completed,total})=>`${completed}/${total} completed`},artifactWorkspace:{outputs:"Outputs",sources:"Sources",viewAll:"View all",toggleSummary:"Toggle files",tabs:"Open files",closeTab:({name})=>`Close ${name}`,closeWorkspace:"Close workspace",download:({name})=>`Download ${name}`,openExternal:({name})=>`Open ${name} in a new window`,loading:"Loading preview...",failed:"Preview unavailable",retry:"Try again"},usage:{label:"Context usage",context:({used,total})=>`${used} / ${total} tokens`},navigation:{search:"Search agents and sessions",searchSessions:"Search sessions",searchShortcut:"Focus search",clearSearch:"Clear search",tabsLabel:"Agent workbench navigation",agents:"Agents",sessions:"Sessions",newAgent:"New Agent",newSession:"New Session",capabilities:"Capabilities & Extensions",settings:"Agent Settings",allAgents:"All Agents",recentSessions:"Recent Sessions",chat:"Chat",work:"Work",chats:"Chats",builtIn:"Built-in",noDescription:"No description",loading:"Loading...",emptyAgents:"No agents yet",emptySessions:"No sessions yet",noResults:"No matching results",retry:"Retry",pin:"Pin",unpin:"Unpin",rename:"Rename",delete:"Delete",actions:"Actions",save:"Save",cancel:"Cancel",running:"Running",completed:"Completed",failed:"Failed",contextUsage:({percent})=>`${percent}% context used`},details:{title:"Task details",description:"Summary and workspace activity",duration:"Duration",updated:"Updated",model:"Model",mode:"Mode",permissions:"Permissions",tokenUsage:"Token usage",summary:"Summary",summaryEmpty:"No summary is available yet.",summaryFailed:"The summary could not be generated.",highlights:"Highlights",pendingItems:"Pending items",tabs:{label:"Task detail views",summary:"Summary",workspace:"Workspace"},status:{queued:"Queued",running:"Running",waiting_approval:"Waiting for approval",stopping:"Stopping",stopped:"Stopped",completed:"Completed",failed:"Failed"},state:{loading:{title:"Loading task details",description:"Restoring the latest session activity."},empty:{title:"No task selected",description:"Select a task to inspect its details."},error:{title:"Unable to load task details",description:"Try again after the session is available."}},actions:{close:"Close task details",copySummary:"Copy summary",retry:"Retry",retrySummary:"Retry summary",resume:"Resume",continueInNewTask:"Continue in new task",editAndRerun:"Edit and rerun",export:"Export"},workspace:{diffs:"Code changes",files:"Files",terminals:"Terminals",tests:"Tests",artifacts:"Artifacts",exitCode:({code})=>`Exit code ${code}`,diffStatus:{added:"Added",modified:"Modified",deleted:"Deleted",renamed:"Renamed"},fileOperation:{upsert:"Updated",delete:"Deleted"}}}}}};function mergeMonkeysLocaleMessages(base,override){return base;}var defaultMonkeysLocale={locale:enUS.locale,messages:mergeMonkeysLocaleMessages(enUS.messages)};var EMPTY_ENVIRONMENT=Object.freeze({});var EMPTY_PORTAL=Object.freeze({});var MONKEYS_PROVIDER_CONTEXTS_KEY=Symbol.for("@inf-monkeys-tech/monkeys-design/provider-context@1");function createMonkeysProviderContexts(){return Object.freeze({locale:React5.createContext({...defaultMonkeysLocale,provided:false}),theme:React5.createContext({provided:false}),direction:React5.createContext({provided:false}),environment:React5.createContext({provided:false,environment:EMPTY_ENVIRONMENT,portal:EMPTY_PORTAL})})}function getMonkeysProviderContexts(){const host2=globalThis;const existing=host2[MONKEYS_PROVIDER_CONTEXTS_KEY];if(existing)return existing;const contexts=createMonkeysProviderContexts();Object.defineProperty(host2,MONKEYS_PROVIDER_CONTEXTS_KEY,{value:contexts,enumerable:false,configurable:false,writable:false});return contexts}var providerContexts=getMonkeysProviderContexts();var MonkeysLocaleContext=providerContexts.locale;var MonkeysThemeContext=providerContexts.theme;var MonkeysDirectionContext=providerContexts.direction;providerContexts.environment;function useMonkeysLocale(){try{const context=React5.useContext(MonkeysLocaleContext);return context??{...defaultMonkeysLocale,provided:false}}catch{return {...defaultMonkeysLocale,provided:false}}}function useMonkeysLocaleMessages(){return React5.useContext(MonkeysLocaleContext).messages}function useMonkeysComponentAttributes(){const locale=React5.useContext(MonkeysLocaleContext);const theme=React5.useContext(MonkeysThemeContext);const direction=React5.useContext(MonkeysDirectionContext);const providerActive=locale.provided||theme.provided||direction.provided;return React5.useMemo(()=>providerActive?{dir:direction.direction,"data-monkeys-direction":direction.direction,"data-monkeys-locale":locale.locale,"data-monkeys-theme":theme.themeId,"data-monkeys-theme-mode":theme.resolvedTheme?.colorMode}:{},[direction.direction,locale.locale,providerActive,theme.resolvedTheme?.colorMode,theme.themeId])}function cn(...parts){return tailwindMerge.twMerge(parts.filter(Boolean).join(" "))}var key=Symbol.for("@inf-monkeys-tech/monkeys-design/bento-depth@1");var host=globalThis;var BentoDepth=host[key]??(host[key]=React5.createContext(0));function useBentoDepth(){return React5.useContext(BentoDepth)}function BentoDepthProvider({children,depth}){return jsxRuntime.jsx(BentoDepth.Provider,{value:depth,children})}function BentoScope({children}){return jsxRuntime.jsx(BentoDepthProvider,{depth:0,children})}var overlaySurfaceRoleClassNames={menu:"monkeys-overlay-surface--menu bg-menu-surface text-popover-foreground",dialog:"monkeys-overlay-surface--dialog bg-dialog-surface text-foreground"};function getOverlaySurfaceClassName(role,options={}){return ["monkeys-overlay-surface",overlaySurfaceRoleClassNames[role],options.rounded===false?void 0:"monkeys-overlay-surface--rounded"].filter(Boolean).join(" ")}function cn2(...inputs){return inputs.filter(Boolean).join(" ")}var DEFAULT_APPEARANCE={variant:"default",density:"default"};var AgentWorkbenchAppearanceContext=React5.createContext(DEFAULT_APPEARANCE);function resolveAgentWorkbenchAppearance(inherited,options={}){const variant=options.variant??inherited.variant;return {variant,density:options.density??(options.variant==="trend"?"compact":inherited.density)}}function useAgentWorkbenchAppearance(options={}){return resolveAgentWorkbenchAppearance(React5.useContext(AgentWorkbenchAppearanceContext),options)}function AgentWorkbenchAppearanceProvider({children,variant,density}){const inherited=React5.useContext(AgentWorkbenchAppearanceContext);const appearance=React5.useMemo(()=>resolveAgentWorkbenchAppearance(inherited,{variant,density}),[density,inherited,variant]);return jsxRuntime.jsx(AgentWorkbenchAppearanceContext.Provider,{value:appearance,children})}var SURFACE_CLASSES={page:"bg-background text-foreground",panel:"bg-card text-card-foreground",elevated:"border border-border bg-popover text-popover-foreground shadow-sm",subtle:"bg-muted/40 text-foreground",overlay:"border border-border bg-popover text-popover-foreground shadow-lg"};var AgentWorkbenchSurface=React5.forwardRef(function AgentWorkbenchSurface2({level="panel",variant,density,className,children,...props},ref){const appearance=useAgentWorkbenchAppearance({variant,density});return jsxRuntime.jsx("div",{...props,ref,"data-agent-workbench-surface":level,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,className:cn2(SURFACE_CLASSES[level],className),children})});var useAutosizeTextArea=({textAreaRef,triggerAutoSize,maxHeight=Number.MAX_SAFE_INTEGER,minHeight=0})=>{const[init,setInit]=React5__namespace.useState(true);React5__namespace.useEffect(()=>{const offsetBorder=2;if(textAreaRef){if(init){textAreaRef.style.minHeight=`${minHeight+offsetBorder}px`;if(maxHeight>minHeight){textAreaRef.style.maxHeight=`${maxHeight}px`;}setInit(false);}textAreaRef.style.height=`${minHeight+offsetBorder}px`;const scrollHeight=textAreaRef.scrollHeight;if(scrollHeight>maxHeight){textAreaRef.style.height=`${maxHeight}px`;}else {textAreaRef.style.height=`${scrollHeight+offsetBorder}px`;}}},[textAreaRef,triggerAutoSize]);};var AutosizeTextarea=React5__namespace.forwardRef(({maxHeight=Number.MAX_SAFE_INTEGER,minHeight=52,className,onChange,value,onKeyDown,onSubmit,onCompositionStart:propsOnCompositionStart,onCompositionEnd:propsOnCompositionEnd,...props},ref)=>{const textAreaRef=React5__namespace.useRef(null);const[triggerAutoSize,setTriggerAutoSize]=React5__namespace.useState("");const[isComposing,setIsComposing]=React5__namespace.useState(false);const[compositionValue,setCompositionValue]=React5__namespace.useState("");useAutosizeTextArea({textAreaRef:textAreaRef.current,triggerAutoSize,maxHeight,minHeight});React5.useImperativeHandle(ref,()=>({textArea:textAreaRef.current,focus:()=>textAreaRef.current?.focus(),maxHeight,minHeight}));React5__namespace.useEffect(()=>{setTriggerAutoSize(value);},[props?.defaultValue,value]);const handleKeyDown=React5__namespace.useCallback(e=>{if(e.key==="ArrowUp"&&triggerAutoSize.length<=0&&!(e.metaKey||e.altKey||e.ctrlKey)){e.preventDefault();return}if(onSubmit){const shouldSubmit=e.key==="Enter"&&e.keyCode!==229&&!e.nativeEvent.isComposing&&!isComposing&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey;if(shouldSubmit){e.preventDefault();onSubmit(e);}}onKeyDown?.(e);},[isComposing,onKeyDown,onSubmit,triggerAutoSize.length]);return jsxRuntime.jsx("textarea",{...props,onKeyDown:handleKeyDown,value:typeof value!=="undefined"?isComposing?compositionValue:value??"":void 0,ref:textAreaRef,className:cn("flex w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",className),onCompositionStart:e=>{setIsComposing(true);setCompositionValue(e.currentTarget.value);propsOnCompositionStart?.(e);},onCompositionEnd:e=>{setIsComposing(false);const finalValue=e.currentTarget.value;setCompositionValue(finalValue);setTriggerAutoSize(finalValue);onChange?.(e);propsOnCompositionEnd?.(e);},onChange:e=>{if(e.nativeEvent.isComposing){setCompositionValue(e.target.value);setTriggerAutoSize(e.target.value);return}setTriggerAutoSize(e.target.value);onChange?.(e);}})});AutosizeTextarea.displayName="AutosizeTextarea";var AccordionItem=React5__namespace.forwardRef(({className,style,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Item,{ref,className:cn("border-b",className),style:{borderColor:"var(--monkeys-component-accordion-item-border-color, hsl(var(--border)))",...style},...props}));AccordionItem.displayName="AccordionItem";var AccordionTrigger=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Header,{className:"flex",children:jsxRuntime.jsxs(AccordionPrimitive__namespace.Trigger,{ref,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",className),...props,children:[children,jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));AccordionTrigger.displayName="AccordionTrigger";var AccordionContent=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Content,{ref,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...props,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",className),children})}));AccordionContent.displayName="AccordionContent";var Checkbox=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(CheckboxPrimitive__namespace.Root,{ref,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",className),...props,children:jsxRuntime.jsx(CheckboxPrimitive__namespace.Indicator,{className:"flex items-center justify-center text-current",children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}));Checkbox.displayName="Checkbox";var buttonVariants=classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_[data-slot=icon]]:text-[inherit] [&_[data-slot=icon]_*]:!text-[inherit] [&_[data-slot=icon]_svg]:!stroke-current [&_[data-slot=icon]_svg_*]:!stroke-current [&_[data-slot=end-icon]]:text-[inherit] [&_[data-slot=end-icon]_*]:!text-[inherit] [&_[data-slot=end-icon]_svg]:!stroke-current [&_[data-slot=end-icon]_svg_*]:!stroke-current [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-control-surface shadow-sm ring-offset-control-surface hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-sm px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}});var Button=React5__namespace.forwardRef(({className,variant,size,asChild=false,...props},ref)=>{const Component=asChild?reactSlot.Slot:"button";return jsxRuntime.jsx(Component,{ref,className:buttonVariants({variant,size,className}),...props})});Button.displayName="Button";var ScrollArea=React5__namespace.forwardRef(({className,children,viewportClassName,viewportRef,onViewportScroll,scrollbar=true,scrollbarOrientation="vertical",scrollBarDisabled=false,type,...props},ref)=>{const bentoDepth=useBentoDepth();return jsxRuntime.jsxs(ScrollAreaPrimitive__namespace.Root,{ref,type:type??(bentoDepth>0?"auto":void 0),className:cn("group relative overflow-hidden",scrollBarDisabled&&"no-scrollbar",className),...props,children:[jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Viewport,{ref:viewportRef,onScroll:onViewportScroll,className:cn("h-full w-full rounded-[inherit]",viewportClassName),children}),scrollbar?jsxRuntime.jsx(ScrollBar,{orientation:scrollbarOrientation,className:cn(scrollBarDisabled&&"size-0 p-0")}):null,jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner,{})]})});ScrollArea.displayName="ScrollArea";var ScrollBar=React5__namespace.forwardRef(({className,orientation="vertical",...props},ref)=>jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,{ref,"data-monkeys-scrollbar":"",orientation,className:cn("flex touch-none select-none opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 data-[state=visible]:opacity-100",orientation==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-px",orientation==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-px",className),...props,children:jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ScrollBar.displayName="ScrollBar";var Switch=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SwitchPrimitive__namespace.Root,{ref,className:cn("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",className),...props,children:jsxRuntime.jsx(SwitchPrimitive__namespace.Thumb,{className:"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"})}));Switch.displayName="Switch";var Tabs=React5__namespace.forwardRef(({variant="default",...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.Root,{ref,"data-variant":variant,...props}));Tabs.displayName="Tabs";var TabsList=React5__namespace.forwardRef(({className,gap,style,...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.List,{ref,className:cn("inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",className),style:{gap,...style},...props}));TabsList.displayName="TabsList";var TabsTrigger=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.Trigger,{ref,className:cn("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",className),...props}));TabsTrigger.displayName="TabsTrigger";var TabsContent=React5__namespace.forwardRef(({className,...props},ref)=>{const depth=useBentoDepth();return jsxRuntime.jsx(TabsPrimitive__namespace.Content,{ref,className:cn("mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",depth>0&&"gap-[var(--monkeys-bento-gap)]",className),...props})});TabsContent.displayName="TabsContent";var TooltipContent=React5__namespace.forwardRef(({className,sideOffset=4,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(TooltipPrimitive__namespace.Portal,{children:jsxRuntime.jsx(TooltipPrimitive__namespace.Content,{...componentAttributes,...props,ref,sideOffset,"data-monkeys-component":"tooltip","data-slot":"content","data-surface":"menu",className:cn("z-50 overflow-hidden border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",getOverlaySurfaceClassName("menu"),className)})})});TooltipContent.displayName="TooltipContent";var Input=React5__namespace.forwardRef(({className,appearance="standard",type,...props},ref)=>jsxRuntime.jsx("input",{ref,type,className:cn("flex w-full border border-input bg-control-surface px-3 text-foreground ring-offset-control-surface transition-[border-color,background-color,color,box-shadow] file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",appearance==="compact"?"h-9 rounded-md py-1 text-sm shadow-sm":"h-10 rounded-md py-2 text-sm shadow-sm",appearance==="shadow"&&"rounded-lg shadow-sm shadow-black/[0.02] dark:border-white/10 dark:bg-white/[0.04] dark:shadow-none",className),...props}));Input.displayName="Input";var Textarea=React5__namespace.forwardRef(({className,appearance="standard",...props},ref)=>jsxRuntime.jsx("textarea",{ref,className:cn("flex w-full border border-input bg-control-surface px-3 py-2 text-foreground ring-offset-control-surface placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",appearance==="compact"?"min-h-[60px] rounded-md text-sm shadow-sm":"min-h-[80px] rounded-md text-sm",appearance==="shadow"&&"rounded-lg shadow-sm shadow-black/[0.02] dark:border-white/10 dark:bg-white/[0.04] dark:shadow-none",className),...props}));Textarea.displayName="Textarea";function InputGroup({className,...props}){return jsxRuntime.jsx("div",{"data-slot":"input-group",role:"group",className:cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-hidden transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",className),...props})}var inputGroupAddonVariants=classVarianceAuthority.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function InputGroupAddon({className,align="inline-start",...props}){return jsxRuntime.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":align,className:cn(inputGroupAddonVariants({align}),className),onClick:e=>{if(e.target.closest("button")){return}e.currentTarget.parentElement?.querySelector("input")?.focus();},...props})}var inputGroupButtonVariants=classVarianceAuthority.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function InputGroupButton({className,type="button",variant="ghost",size="xs",...props}){return jsxRuntime.jsx(Button,{type,"data-size":size,variant,className:cn(inputGroupButtonVariants({size}),className),...props})}var InputGroupInput=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(Input,{ref,"data-slot":"input-group-control",className:cn("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",className),...props}));InputGroupInput.displayName="InputGroupInput";var InputGroupTextarea=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(Textarea,{ref,"data-slot":"input-group-control",className:cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",className),...props}));InputGroupTextarea.displayName="InputGroupTextarea";var menuItemClassName="relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";var menuContentClassName=`z-50 min-w-[8rem] overflow-hidden border p-1 ${getOverlaySurfaceClassName("menu")} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`;var DropdownMenu2=DropdownMenuPrimitive__namespace.Root;var DropdownMenuTrigger=DropdownMenuPrimitive__namespace.Trigger;var DropdownMenuSubTrigger=React5__namespace.forwardRef(({className,inset,children,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.SubTrigger,{ref,className:cn(menuItemClassName,"data-[state=open]:bg-accent",inset&&"pl-8",className),...props,children:[children,jsxRuntime.jsx(lucideReact.ChevronRight,{"aria-hidden":"true",className:"ml-auto"})]}));DropdownMenuSubTrigger.displayName="DropdownMenuSubTrigger";var DropdownMenuSubContent=React5__namespace.forwardRef(({className,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DropdownMenuPrimitive__namespace.SubContent,{...componentAttributes,...props,ref,"data-monkeys-component":"dropdown-menu","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,className)})});DropdownMenuSubContent.displayName="DropdownMenuSubContent";var DropdownMenuContent=React5__namespace.forwardRef(({className,sideOffset=4,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal,{children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Content,{...componentAttributes,...props,ref,sideOffset,"data-monkeys-component":"dropdown-menu","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,className)})})});DropdownMenuContent.displayName="DropdownMenuContent";var DropdownMenuItem=React5__namespace.forwardRef(({className,inset,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Item,{ref,className:cn(menuItemClassName,inset&&"pl-8",className),...props}));DropdownMenuItem.displayName="DropdownMenuItem";var DropdownMenuCheckboxItem=React5__namespace.forwardRef(({className,children,checked,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.CheckboxItem,{ref,className:cn(menuItemClassName,"pl-8",className),checked,...props,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}),children]}));DropdownMenuCheckboxItem.displayName="DropdownMenuCheckboxItem";var DropdownMenuRadioItem=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.RadioItem,{ref,className:cn(menuItemClassName,"pl-8",className),...props,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Circle,{"aria-hidden":"true",className:"h-2 w-2 fill-current"})})}),children]}));DropdownMenuRadioItem.displayName="DropdownMenuRadioItem";var DropdownMenuLabel=React5__namespace.forwardRef(({className,inset,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Label,{ref,className:cn("px-2 py-1.5 text-sm font-semibold",inset&&"pl-8",className),...props}));DropdownMenuLabel.displayName="DropdownMenuLabel";var DropdownMenuSeparator=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Separator,{ref,className:cn("-mx-1 my-1 h-px bg-muted",className),...props}));DropdownMenuSeparator.displayName="DropdownMenuSeparator";var Select=SelectPrimitive__namespace.Root;var SelectValue=SelectPrimitive__namespace.Value;var SelectTrigger=React5__namespace.forwardRef(({className,children,iconClassName,size="default",...props},ref)=>jsxRuntime.jsxs(SelectPrimitive__namespace.Trigger,{ref,className:cn("flex h-10 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-control-surface px-3 py-2 text-left text-sm text-foreground shadow-sm ring-offset-control-surface data-[placeholder]:text-muted-foreground focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 [&>span]:min-w-0 [&>span]:flex-1 [&>span]:text-left",size==="sm"&&"h-8 px-2 py-1 text-xs",className),...props,children:[children,jsxRuntime.jsx(SelectPrimitive__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:cn("h-4 w-4 opacity-50",iconClassName)})})]}));SelectTrigger.displayName="SelectTrigger";var SelectScrollUpButton=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.ScrollUpButton,{ref,className:cn("flex cursor-default items-center justify-center py-1",className),...props,children:jsxRuntime.jsx(lucideReact.ChevronUp,{"aria-hidden":"true",className:"h-4 w-4"})}));SelectScrollUpButton.displayName="SelectScrollUpButton";var SelectScrollDownButton=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.ScrollDownButton,{ref,className:cn("flex cursor-default items-center justify-center py-1",className),...props,children:jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:"h-4 w-4"})}));SelectScrollDownButton.displayName="SelectScrollDownButton";var SelectContent=React5__namespace.forwardRef(({className,children,position="popper",viewportClassName,disableTriggerViewportSizing=false,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(SelectPrimitive__namespace.Portal,{children:jsxRuntime.jsxs(SelectPrimitive__namespace.Content,{...componentAttributes,...props,ref,position,"data-monkeys-component":"select","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,"relative max-h-[var(--radix-select-content-available-height)] overflow-y-auto overflow-x-hidden",position==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",className),children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(SelectPrimitive__namespace.Viewport,{className:cn("p-1",position==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]",position==="popper"&&!disableTriggerViewportSizing&&"h-[var(--radix-select-trigger-height)]",viewportClassName),children}),jsxRuntime.jsx(SelectScrollDownButton,{})]})})});SelectContent.displayName="SelectContent";var SelectLabel=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.Label,{ref,className:cn("px-2 py-1.5 text-sm font-semibold",className),...props}));SelectLabel.displayName="SelectLabel";var SelectItem=React5__namespace.forwardRef(({className,children,indicatorClassName,itemText,hideIndicator=false,...props},ref)=>jsxRuntime.jsxs(SelectPrimitive__namespace.Item,{ref,className:cn(menuItemClassName,"w-full",hideIndicator?"px-2":"pl-8 pr-2",className),...props,children:[!hideIndicator?jsxRuntime.jsx("span",{className:cn("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",indicatorClassName),children:jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}):null,itemText?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SelectPrimitive__namespace.ItemText,{asChild:true,children:jsxRuntime.jsx("span",{className:"sr-only",children:itemText})}),children]}):jsxRuntime.jsx(SelectPrimitive__namespace.ItemText,{children})]}));SelectItem.displayName="SelectItem";var SelectSeparator=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.Separator,{ref,className:cn("-mx-1 my-1 h-px bg-muted",className),...props}));SelectSeparator.displayName="SelectSeparator";var Sheet=DialogPrimitive__namespace.Root;var SheetPortal=DialogPrimitive__namespace.Portal;var SheetOverlay=React5__namespace.forwardRef(({className,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DialogPrimitive__namespace.Overlay,{...componentAttributes,...props,ref,"data-monkeys-component":"sheet","data-slot":"overlay","data-monkeys-overlay":true,className:cn("theme-overlay-backdrop fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",className)})});SheetOverlay.displayName="SheetOverlay";var sideClassNames={top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm"};var SheetContent=React5__namespace.forwardRef(({side="right",className,children,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsxs(SheetPortal,{children:[jsxRuntime.jsx(SheetOverlay,{}),jsxRuntime.jsxs(DialogPrimitive__namespace.Content,{...componentAttributes,...props,ref,"data-monkeys-component":"sheet","data-slot":"content","data-surface":"dialog","data-monkeys-dialog-content":true,className:cn("fixed z-50 gap-4 p-6 transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",getOverlaySurfaceClassName("dialog",{rounded:false}),sideClassNames[side],className),children:[jsxRuntime.jsxs(DialogPrimitive__namespace.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-dialog-surface transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[jsxRuntime.jsx("svg",{"aria-hidden":"true",className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),jsxRuntime.jsx("span",{className:"sr-only",children:"Close"})]}),jsxRuntime.jsx(BentoScope,{children})]})]})});SheetContent.displayName="SheetContent";var SheetTitle=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DialogPrimitive__namespace.Title,{ref,className:cn("text-lg font-semibold text-foreground",className),...props}));SheetTitle.displayName="SheetTitle";var SheetDescription=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DialogPrimitive__namespace.Description,{ref,className:cn("text-sm text-muted-foreground",className),...props}));SheetDescription.displayName="SheetDescription";function ComposerSelect({value,label,placeholder,options,className,onValueChange}){const selectedOption=options.find(option=>option.value===value);return jsxRuntime.jsxs(Select,{value:value||void 0,disabled:options.length===0,onValueChange,children:[jsxRuntime.jsx(SelectTrigger,{size:"sm","aria-label":label,className:cn2("shrink bg-background font-medium",className),children:jsxRuntime.jsx(SelectValue,{placeholder,children:selectedOption?.label})}),jsxRuntime.jsx(SelectContent,{disableTriggerViewportSizing:true,children:options.map(option=>jsxRuntime.jsx(SelectItem,{value:option.value,disabled:option.disabled,children:option.label},option.value))})]})}var EMPTY_COMPOSER_VIEW_MODEL={contract:"AgentWorkbenchComposerViewModel",value:"",status:"idle",mode:"chat",attachments:[],queuedDrafts:[],inputActions:[],model:{options:[]},webSearchEnabled:false,capabilities:{attachments:false,voiceInput:false,webSearch:false,modelSelection:false,reasoning:false,permissions:false,queue:false,stop:false}};function modelOptionValue(option){return `${option.mode}:${option.id}`}function AgentWorkbenchComposer({viewModel=EMPTY_COMPOSER_VIEW_MODEL,disabled=false,modeSelectionEnabled=false,modeFilteringEnabled=false,variant,density,className,classNames,onIntent:emitIntent}){const current=React5.useRef({disabled,emitIntent});current.current={disabled,emitIntent};const onIntent=intent=>{if(!current.current.disabled)current.current.emitIntent?.(intent);};const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const iconButtonClass=cn2(compact?"size-7":"size-8","shrink-0 p-0 text-muted-foreground");const messages=useMonkeysLocaleMessages().agentWorkbench;const fileInputRef=React5.useRef(null);const surfaceRef=React5.useRef(null);const[editingDraftId,setEditingDraftId]=React5.useState();const[editingText,setEditingText]=React5.useState("");const[isNarrow,setIsNarrow]=React5.useState(false);const narrowBreakpoint=modeSelectionEnabled?900:704;const isBusy=viewModel.status==="loading"||viewModel.status==="streaming"||viewModel.status==="stopping";const isStopping=viewModel.status==="stopping";const isUploading=viewModel.attachments.some(attachment=>attachment.status==="uploading");const canSubmit=!disabled&&!isStopping&&!isUploading&&(viewModel.value.trim().length>0||viewModel.attachments.some(item=>item.status==="ready"));const showSubmitButton=!isBusy||canSubmit;const filterModelsByMode=modeSelectionEnabled||modeFilteringEnabled;const visibleModelOptions=React5.useMemo(()=>filterModelsByMode?viewModel.model.options.filter(option=>option.mode===viewModel.mode):viewModel.model.options,[filterModelsByMode,viewModel.mode,viewModel.model.options]);const selectedModelValue=React5.useMemo(()=>{const selected=visibleModelOptions.find(option=>option.id===viewModel.model.selectedId&&option.mode===viewModel.mode);return selected?modelOptionValue(selected):visibleModelOptions[0]?modelOptionValue(visibleModelOptions[0]):""},[viewModel.mode,viewModel.model.selectedId,visibleModelOptions]);const inputActions=viewModel.inputActions||[];const selectedInputActionId=viewModel.selectedInputActionId;React5.useEffect(()=>{const surface=surfaceRef.current;if(!surface)return void 0;const updateLayout=()=>setIsNarrow(surface.getBoundingClientRect().width<=narrowBreakpoint);updateLayout();window.addEventListener("resize",updateLayout);if(typeof ResizeObserver==="undefined"){const interval=window.setInterval(updateLayout,250);return ()=>{window.clearInterval(interval);window.removeEventListener("resize",updateLayout);}}const observer=new ResizeObserver(updateLayout);observer.observe(surface);return ()=>{observer.disconnect();window.removeEventListener("resize",updateLayout);}},[narrowBreakpoint]);const submit=()=>{if(canSubmit)onIntent?.({type:"submit"});};return jsxRuntime.jsx("fieldset",{disabled,className:"min-w-0 border-0 p-0",children:jsxRuntime.jsxs("form",{"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":viewModel.status,className:cn2("agent-workbench-composer flex min-w-0 w-full flex-col",compact?"gap-1.5":"gap-2",className,classNames?.root),"aria-label":messages.composer.message,onSubmit:event=>{event.preventDefault();submit();},children:[viewModel.capabilities.queue&&viewModel.queuedDrafts.length>0?jsxRuntime.jsx("section",{"aria-label":messages.composer.queued,className:cn2("min-w-0 max-w-full rounded-md border border-border bg-muted/40 p-2",classNames?.queue),children:jsxRuntime.jsx("ol",{className:"space-y-1.5",children:viewModel.queuedDrafts.map((draft,index)=>jsxRuntime.jsxs("li",{className:"flex min-h-9 min-w-0 max-w-full items-center gap-2 overflow-hidden rounded-md bg-background px-2 py-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"w-5 shrink-0 text-center text-xs text-muted-foreground",children:index+1}),editingDraftId===draft.id?jsxRuntime.jsx(Input,{autoFocus:true,value:editingText,"aria-label":messages.composer.editQueued,appearance:"compact",className:"h-8 min-w-0 flex-1 px-2 py-1",onChange:event=>setEditingText(event.target.value),onBlur:()=>{if(editingText.trim())onIntent?.({type:"edit-queued-draft",draftId:draft.id,text:editingText});setEditingDraftId(void 0);},onKeyDown:event=>{if(event.key==="Escape")setEditingDraftId(void 0);if(event.key==="Enter"&&editingText.trim()){event.preventDefault();onIntent?.({type:"edit-queued-draft",draftId:draft.id,text:editingText});setEditingDraftId(void 0);}}}):jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:draft.text||messages.composer.attachmentOnly}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.moveUp,disabled:index===0,onClick:()=>onIntent?.({type:"move-queued-draft",draftId:draft.id,direction:"up"}),children:jsxRuntime.jsx(lucideReact.ArrowUp,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.moveDown,disabled:index===viewModel.queuedDrafts.length-1,onClick:()=>onIntent?.({type:"move-queued-draft",draftId:draft.id,direction:"down"}),children:jsxRuntime.jsx(lucideReact.ArrowDown,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.editQueued,onClick:()=>{setEditingDraftId(draft.id);setEditingText(draft.text);},children:jsxRuntime.jsx(lucideReact.Pencil,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:cn2(iconButtonClass,"text-destructive-text hover:text-destructive-text"),"aria-label":messages.composer.deleteQueued,onClick:()=>onIntent?.({type:"delete-queued-draft",draftId:draft.id}),children:jsxRuntime.jsx(lucideReact.Trash2,{className:"size-3.5"})})]})]},draft.id))})}):null,jsxRuntime.jsxs("div",{ref:surfaceRef,"data-agent-workbench-surface":"elevated",className:cn2("agent-workbench-composer__surface min-w-0 max-w-full rounded-[var(--radius)] border border-input bg-popover text-popover-foreground shadow-sm transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",compact?"p-2.5":"p-3"),children:[viewModel.attachments.length>0?jsxRuntime.jsx("div",{"data-agent-workbench-composer-attachments":true,className:cn2("mb-2 flex max-w-full gap-2 overflow-x-auto overscroll-x-contain pb-1",classNames?.attachments),children:viewModel.attachments.map(attachment=>{const isAttachmentError=attachment.status==="error";const isAttachmentUploading=attachment.status==="uploading";return jsxRuntime.jsxs("div",{role:isAttachmentError?"alert":void 0,className:cn2("flex h-14 min-w-48 max-w-64 shrink-0 items-center gap-2 rounded-md border bg-muted/45 p-1.5",isAttachmentError?"border-destructive/50 bg-destructive/5":"border-border"),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded bg-muted",children:attachment.previewUrl&&attachment.mediaType?.startsWith("image/")?jsxRuntime.jsx("img",{src:attachment.previewUrl,alt:"",className:"size-full object-cover"}):attachment.mediaType?.startsWith("image/")?jsxRuntime.jsx(lucideReact.Image,{className:"size-5 text-muted-foreground"}):jsxRuntime.jsx(lucideReact.File,{className:"size-5 text-muted-foreground"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-xs font-medium text-foreground",title:attachment.name,children:attachment.name}),jsxRuntime.jsxs("span",{className:cn2("mt-0.5 flex items-center gap-1 text-[11px]",isAttachmentError?"text-destructive-text":"text-muted-foreground"),children:[isAttachmentUploading?jsxRuntime.jsx(lucideReact.LoaderCircle,{className:"size-3 animate-spin","aria-hidden":"true"}):null,isAttachmentError?jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-3","aria-hidden":"true"}):null,isAttachmentUploading?messages.composer.uploading:isAttachmentError?messages.composer.uploadFailed:attachment.mediaType||messages.composer.attachmentOnly]})]}),jsxRuntime.jsxs("span",{className:"flex shrink-0 items-center gap-0.5",children:[isAttachmentError?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"!size-7 min-w-7 shrink-0 p-0 text-destructive-text hover:text-destructive-text","aria-label":`${messages.composer.retryAttachment}: ${attachment.name}`,onClick:()=>onIntent?.({type:"retry-attachment",attachmentId:attachment.id}),children:jsxRuntime.jsx(lucideReact.RotateCcw,{className:"size-3.5"})}):null,jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"!size-7 min-w-7 shrink-0 p-0 text-muted-foreground hover:text-foreground","aria-label":`${messages.composer.removeAttachment}: ${attachment.name}`,onClick:()=>onIntent?.({type:"remove-attachment",attachmentId:attachment.id}),children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5"})})]})]},attachment.id)})}):null,jsxRuntime.jsx(AutosizeTextarea,{value:viewModel.value,minHeight:compact?44:54,maxHeight:256,"aria-label":messages.composer.message,placeholder:viewModel.placeholder,className:cn2("min-w-0 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent px-0 py-0 text-sm leading-relaxed text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",classNames?.textarea),onChange:event=>onIntent?.({type:"change-value",value:event.target.value}),onKeyDown:event=>{if(event.key==="Enter"&&!event.shiftKey&&!event.nativeEvent.isComposing){event.preventDefault();submit();}}}),jsxRuntime.jsxs("div",{className:cn2("agent-workbench-composer__toolbar mt-2 flex min-w-0 max-w-full items-center",compact?"min-h-7 gap-1.5":"min-h-8 gap-2",isNarrow?"flex-wrap":"flex-nowrap",classNames?.toolbar),children:[jsxRuntime.jsxs("div",{"data-agent-workbench-composer-controls":true,className:cn2("agent-workbench-composer__controls flex min-w-0 max-w-full flex-1 items-center gap-1.5",isNarrow?"w-full flex-wrap":"flex-nowrap overflow-x-auto overscroll-x-contain pb-1"),children:[viewModel.capabilities.attachments?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.attach,onClick:()=>fileInputRef.current?.click(),children:jsxRuntime.jsx(lucideReact.Paperclip,{className:"size-4"})}),jsxRuntime.jsx("input",{ref:fileInputRef,type:"file",className:"hidden",multiple:true,onChange:event=>{const files=Array.from(event.target.files||[]);if(files.length>0)onIntent?.({type:"request-attachments",files});event.target.value="";}})]}):null,inputActions.length>0?jsxRuntime.jsxs(Tabs,{value:selectedInputActionId,onValueChange:actionId=>onIntent?.({type:"select-input-action",actionId}),children:[jsxRuntime.jsx(TabsList,{className:cn2("shrink-0 gap-0.5 rounded-md bg-muted/60 p-0.5",compact?"h-7":"h-8"),children:inputActions.map(action=>{const ActionIcon=action.icon==="image"?lucideReact.Image:lucideReact.FileText;return jsxRuntime.jsxs(TabsTrigger,{value:action.id,className:cn2("min-w-0 gap-1.5 px-2.5 text-xs text-foreground/75 shadow-none hover:text-foreground data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",compact?"h-6":"h-7"),children:[action.icon?jsxRuntime.jsx(ActionIcon,{className:"size-3.5"}):null,jsxRuntime.jsx("span",{className:"max-w-32 truncate",children:action.label})]},action.id)})}),inputActions.map(action=>jsxRuntime.jsx(TabsContent,{value:action.id,className:"hidden"},action.id))]}):null,viewModel.capabilities.voiceInput?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.voice,onClick:()=>onIntent?.({type:"request-voice-input"}),children:jsxRuntime.jsx(lucideReact.Mic,{className:"size-4"})}):null,viewModel.capabilities.webSearch?jsxRuntime.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap px-1 text-xs font-medium text-foreground",children:[messages.composer.webSearch,jsxRuntime.jsx(Switch,{checked:viewModel.webSearchEnabled,onCheckedChange:enabled=>onIntent?.({type:"toggle-web-search",enabled})})]}):null,modeSelectionEnabled?jsxRuntime.jsxs(Tabs,{value:viewModel.mode,onValueChange:mode=>onIntent?.({type:"change-mode",mode}),children:[jsxRuntime.jsx(TabsList,{"aria-label":messages.composer.chatMode,className:cn2("shrink-0 gap-0.5 rounded-md bg-muted/60 p-0.5",compact?"h-7":"h-8"),children:["chat","work"].map(mode=>jsxRuntime.jsx(TabsTrigger,{value:mode,className:cn2("min-w-0 px-2.5 text-xs text-foreground/75 shadow-none hover:text-foreground data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",compact?"h-6":"h-7"),children:messages.modes[mode]},mode))}),["chat","work"].map(mode=>jsxRuntime.jsx(TabsContent,{value:mode,className:"hidden"},mode))]}):null,viewModel.capabilities.modelSelection?jsxRuntime.jsx(ComposerSelect,{value:selectedModelValue,label:messages.composer.model,placeholder:messages.composer.noModels,className:"w-48 min-w-36",options:visibleModelOptions.map(option=>({value:modelOptionValue(option),label:`${option.label} \xB7 ${messages.modes[option.mode]}`,disabled:option.disabled})),onValueChange:value=>{const option=visibleModelOptions.find(item=>modelOptionValue(item)===value);if(option)onIntent?.({type:"select-model",modelId:option.id,mode:option.mode});}}):null,viewModel.capabilities.reasoning&&viewModel.reasoning?jsxRuntime.jsx(ComposerSelect,{value:viewModel.reasoning.value,label:messages.composer.reasoning,className:"w-32 min-w-24",options:viewModel.reasoning.options.map(value=>({value,label:messages.composer.reasoningOptions[value]})),onValueChange:value=>onIntent?.({type:"change-reasoning",value})}):null,viewModel.capabilities.permissions&&viewModel.permissionProfile?jsxRuntime.jsx(ComposerSelect,{value:viewModel.permissionProfile,label:messages.composer.permissions,className:"w-40 min-w-32",options:["approval-required","auto-approve","full-access"].map(value=>({value,label:messages.composer.permissionOptions[value]})),onValueChange:value=>onIntent?.({type:"change-permission",value})}):null]}),jsxRuntime.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[showSubmitButton?jsxRuntime.jsx(Button,{type:"submit",size:"icon",className:cn2(iconButtonClass,"bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground disabled:bg-primary/40 disabled:!opacity-100"),"aria-label":isBusy&&viewModel.capabilities.queue?messages.composer.queue:messages.composer.send,disabled:!canSubmit,children:jsxRuntime.jsx(lucideReact.Send,{className:"size-4 !text-white [&_path]:!stroke-white"})}):null,isBusy&&!canSubmit&&viewModel.capabilities.stop?jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"icon",className:iconButtonClass,"aria-label":isStopping?messages.run.stopping:messages.composer.stop,disabled:isStopping,onClick:()=>onIntent?.({type:"stop"}),children:jsxRuntime.jsx(lucideReact.Square,{className:"size-3 fill-current"})}):null]})]})]}),viewModel.status==="error"&&viewModel.error?jsxRuntime.jsx("p",{role:"alert",className:"text-sm text-destructive-text",children:viewModel.error}):null]})})}var ICONS={sparkles:lucideReact.Sparkles,palette:lucideReact.Palette,search:lucideReact.Search,"file-text":lucideReact.FileText,code:lucideReact.Code2,"shopping-bag":lucideReact.ShoppingBag};var QUICK_START_CATEGORY_ID="__quick-start__";function TemplateVisual({template}){const Icon2=ICONS[template.icon||"sparkles"];if(template.coverImageUrl){return jsxRuntime.jsx("img",{src:template.coverImageUrl,alt:"",className:"size-full bg-muted object-contain"})}return jsxRuntime.jsx("span",{className:"flex size-full items-center justify-center bg-gradient-to-br from-primary/5 via-muted/50 to-primary/15",children:jsxRuntime.jsx("span",{className:"flex size-14 items-center justify-center rounded-2xl border border-primary/10 bg-background/85 text-primary shadow-sm",children:jsxRuntime.jsx(Icon2,{className:"size-7","aria-hidden":"true"})})})}function AgentWorkbenchQuickStart({viewModel,className,onIntent}){const messages=useMonkeysLocaleMessages().agentWorkbench.quickStart;const fileInputRef=React5.useRef(null);const[activeCategoryId,setActiveCategoryId]=React5.useState();const[activeSectionId,setActiveSectionId]=React5.useState();const[pendingTemplate,setPendingTemplate]=React5.useState();const categories=React5.useMemo(()=>viewModel.categories.map(category=>({...category,sections:category.sections.map(section=>({...section,templates:section.templates.filter(template=>!template.modes||template.modes.includes(viewModel.mode))})).filter(section=>section.templates.length>0)})).filter(category=>category.sections.length>0),[viewModel.categories,viewModel.mode]);const quickStartCategory=React5.useMemo(()=>{const templates=categories.flatMap(category=>category.sections.filter(section=>section.id==="quick-start")).map(section=>section.templates).flat().filter((template,index,allTemplates)=>allTemplates.findIndex(item=>item.id===template.id)===index);if(templates.length===0)return void 0;return {id:QUICK_START_CATEGORY_ID,label:messages.label,icon:"sparkles",sections:[{id:"quick-start",label:messages.label,templates}]}},[categories,messages.label]);const activeCategory=activeCategoryId===QUICK_START_CATEGORY_ID?quickStartCategory:categories.find(category=>category.id===activeCategoryId);const activeSection=activeCategory?.sections.find(section=>section.id===activeSectionId)||activeCategory?.sections[0];const usesCompactList=activeSection?.templates.length?activeSection.templates.every(template=>!template.coverImageUrl):false;React5.useEffect(()=>{if(activeCategoryId&&activeCategoryId!==QUICK_START_CATEGORY_ID&&!categories.some(category=>category.id===activeCategoryId)){setActiveCategoryId(void 0);setActiveSectionId(void 0);}if(activeCategoryId===QUICK_START_CATEGORY_ID&&!quickStartCategory){setActiveCategoryId(void 0);setActiveSectionId(void 0);}},[activeCategoryId,categories,quickStartCategory]);if(categories.length===0)return null;const selectCategory=category=>{setActiveCategoryId(category.id);setActiveSectionId(category.sections[0]?.id);onIntent?.({type:"change-category",categoryId:category.id});};const selectQuickStart=()=>{if(!quickStartCategory)return;setActiveCategoryId(QUICK_START_CATEGORY_ID);setActiveSectionId(quickStartCategory.sections[0]?.id);onIntent?.({type:"change-category"});};const selectSection=sectionId=>{if(!activeCategory)return;setActiveSectionId(sectionId);onIntent?.({type:"change-section",categoryId:activeCategory.id,sectionId});};const selectTemplate=template=>{if(viewModel.disabled)return;if(template.action!=="upload"){onIntent?.({type:"select-template",templateId:template.id,prompt:template.prompt});return}const input=fileInputRef.current;if(!input)return;input.accept=template.accept||"*/*";input.multiple=template.multiple===true;setPendingTemplate(template);input.click();};return jsxRuntime.jsxs("section",{className:cn2("agent-workbench-quick-start min-w-0 max-w-full",className),"aria-label":messages.label,children:[jsxRuntime.jsx("input",{ref:fileInputRef,type:"file",className:"hidden",onChange:event=>{const files=Array.from(event.target.files||[]);if(pendingTemplate&&files.length>0){onIntent?.({type:"select-template",templateId:pendingTemplate.id,prompt:pendingTemplate.prompt,files:pendingTemplate.multiple?files:files.slice(0,1)});}setPendingTemplate(void 0);event.target.value="";}}),!activeCategory?jsxRuntime.jsxs("div",{className:"flex max-w-full items-center justify-center gap-2 overflow-x-auto px-1 pb-1",children:[quickStartCategory?jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-10 shrink-0 items-center gap-2 rounded-full border border-border bg-background px-4 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring","aria-pressed":activeCategoryId===QUICK_START_CATEGORY_ID,onClick:selectQuickStart,children:[jsxRuntime.jsx(lucideReact.Sparkles,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),messages.label]}):null,categories.map(category=>{const Icon2=ICONS[category.icon||"sparkles"];return jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-10 shrink-0 items-center gap-2 rounded-full border border-border bg-background px-4 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>selectCategory(category),children:[jsxRuntime.jsx(Icon2,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),category.label]},category.id)})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 max-w-full items-center gap-1 overflow-x-auto pb-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{setActiveCategoryId(void 0);setActiveSectionId(void 0);onIntent?.({type:"change-category"});},children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4","aria-hidden":"true"}),messages.back]}),activeCategory.sections.map((section,index)=>jsxRuntime.jsx("button",{type:"button","aria-pressed":activeSection?.id===section.id,className:cn2("h-9 shrink-0 rounded-full px-4 text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",activeSection?.id===section.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>selectSection(section.id),children:activeCategory.id!==QUICK_START_CATEGORY_ID&&index===0?activeCategory.label:section.label},section.id))]}),jsxRuntime.jsx("div",{"data-quick-start-layout":usesCompactList?"list":"cards",className:cn2("grid",usesCompactList?"grid-cols-1 gap-0":"grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3"),children:activeSection?.templates.map(template=>jsxRuntime.jsxs("button",{type:"button",disabled:viewModel.disabled,"data-quick-start-template-id":template.id,className:cn2("group min-w-0 overflow-hidden text-left transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",usesCompactList?"flex min-h-14 items-center rounded-none border-x-0 border-t-0 bg-transparent shadow-none hover:border-border hover:bg-muted/40 last:border-b-0":"rounded-xl border border-border bg-background hover:border-primary/30 hover:bg-muted/20"),onClick:()=>selectTemplate(template),children:[jsxRuntime.jsxs("span",{className:cn2(usesCompactList?"min-w-0 flex-1 px-2 py-2.5":"block px-4 pb-3 pt-4"),children:[jsxRuntime.jsxs("span",{className:cn2("flex items-center gap-2 text-sm text-foreground",usesCompactList?"font-medium":"font-semibold"),children:[template.title,template.action==="upload"?jsxRuntime.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Upload,{className:"size-3","aria-hidden":"true"}),messages.addFile]}):null]}),template.description?jsxRuntime.jsx("span",{className:cn2("line-clamp-2 block text-xs leading-4 text-muted-foreground",usesCompactList?"mt-0.5 min-h-0 text-muted-foreground/75":"mt-1 min-h-8"),children:template.description}):null]}),usesCompactList?jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"mr-2 size-4 shrink-0 text-muted-foreground/45","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:cn2("block overflow-hidden",template.coverImageUrl?"aspect-[5/2]":"h-28"),children:jsxRuntime.jsx(TemplateVisual,{template})})]},template.id))})]})]})}var AgentWorkbenchSidebarContainer=React5.forwardRef(function AgentWorkbenchSidebarContainer2({children,header,search,primaryAction,actions,groups,footer,className,classNames,bodyProps,bodyScrollable=true,status="ready",variant,density,loadingState,emptyState,errorState,...props},ref){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const hasToolbar=search!==void 0||primaryAction!==void 0||actions!==void 0;const statusContent=status==="loading"?loadingState:status==="empty"?emptyState:status==="error"?errorState:children;return jsxRuntime.jsxs("nav",{ref,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":status,className:cn2("flex h-full min-h-0 flex-col bg-card text-card-foreground",classNames?.root,className),...props,children:[header!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.header),children:header}):null,hasToolbar?jsxRuntime.jsxs("div",{className:cn2("shrink-0",compact?"space-y-2 px-3 pb-2 pt-3":"space-y-3 px-4 pb-2 pt-4",classNames?.search),children:[search,primaryAction!==void 0?jsxRuntime.jsx("div",{className:cn2(classNames?.primaryAction),children:primaryAction}):null,actions!==void 0?jsxRuntime.jsx("div",{className:cn2("flex min-w-0 items-center gap-2",classNames?.actions),children:actions}):null]}):null,jsxRuntime.jsx("div",{"data-agent-workbench-scroll-region":bodyScrollable?"":void 0,...bodyProps,tabIndex:bodyProps?.tabIndex??(bodyScrollable?0:void 0),className:cn2("min-h-0 flex-1",compact?"px-3 pb-3":"px-4 pb-4",bodyScrollable&&"overflow-x-hidden overflow-y-auto overscroll-contain",classNames?.body),children:statusContent}),groups!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.groups),children:groups}):null,footer!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.footer),children:footer}):null]})});AgentWorkbenchSidebarContainer.displayName="AgentWorkbenchSidebarContainer";function AgentWorkbenchSidebarSearch({value,label,placeholder=label,className,variant="default",onChange}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const searchRef=React5.useRef(null);React5.useEffect(()=>{const handleShortcut=event=>{if(!(event.ctrlKey||event.metaKey)||event.key.toLocaleLowerCase()!=="k")return;event.preventDefault();searchRef.current?.focus();searchRef.current?.select();};window.addEventListener("keydown",handleShortcut);return ()=>window.removeEventListener("keydown",handleShortcut)},[]);return jsxRuntime.jsxs(InputGroup,{className:cn2(variant==="trend"?"h-12 rounded-[var(--radius)] border-border bg-card text-foreground":"h-10 rounded-lg bg-card",className),children:[jsxRuntime.jsx(InputGroupAddon,{children:jsxRuntime.jsx(lucideReact.Search,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx(InputGroupInput,{ref:searchRef,type:"search",value,"aria-label":label,placeholder,className:"min-w-0 [&::-webkit-search-cancel-button]:hidden",onChange:event=>onChange(event.target.value),onKeyDown:event=>{if(event.key!=="Escape")return;onChange("");event.currentTarget.blur();}}),value?jsxRuntime.jsx(InputGroupAddon,{align:"inline-end",children:jsxRuntime.jsx(InputGroupButton,{size:"icon-xs","aria-label":messages.clearSearch,onClick:()=>onChange(""),children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5","aria-hidden":"true"})})}):jsxRuntime.jsx(InputGroupAddon,{align:"inline-end",children:jsxRuntime.jsx("kbd",{className:"border border-border px-1.5 py-0.5 text-[10px]",children:"Ctrl K"})})]})}function AgentWorkbenchSidebarNewSessionButton({label,className,variant="default",onClick}){return jsxRuntime.jsxs(Button,{type:"button",variant:variant==="trend"?"default":"ghost",className:cn2(variant==="trend"?"h-11 w-full justify-center gap-2 rounded-[var(--radius)] border border-primary/60 bg-primary px-3 font-semibold text-primary-foreground hover:bg-primary/90":"h-9 w-full justify-start gap-2 px-3 text-sm",className),onClick,children:[jsxRuntime.jsx(lucideReact.SquarePen,{className:"size-4","aria-hidden":"true"}),label]})}function SessionAvatar({item}){const[failed,setFailed]=React5.useState(false);if(item.thumbnailUrl&&!failed){return jsxRuntime.jsx("img",{src:item.thumbnailUrl,alt:"",className:"size-full object-cover",loading:"lazy",onError:()=>setFailed(true)})}return jsxRuntime.jsx(lucideReact.Image,{className:"size-5","aria-hidden":"true"})}function SessionMeta({item}){const{locale}=useMonkeysLocale();const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;return jsxRuntime.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 truncate text-xs text-foreground/80",children:new Intl.DateTimeFormat(locale,{dateStyle:"medium",timeStyle:"short"}).format(new Date(item.updatedAt))}),item.mode?jsxRuntime.jsx("span",{className:cn2("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",item.mode==="work"?"bg-primary/10 text-primary":"bg-muted text-foreground"),children:item.mode==="work"?messages.work:messages.chat}):null]})}function StatusIndicator({status}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;if(status==="running"){return jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin text-primary","aria-label":messages.running})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-primary","aria-label":messages.completed})}if(status==="error"){return jsxRuntime.jsx(lucideReact.AlertCircle,{className:"size-4 text-destructive-text","aria-label":messages.failed})}return null}function AgentWorkbenchSessionList({sessions,selectedSessionId,status="ready",error,query="",emptyLabel,noResultsLabel,retryLabel,groupByMode=false,showHeading=false,variant="default",className,itemClassName,capabilities,onSelect,onTogglePin,onRename,onDelete,onRetry}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const renameInputRef=React5.useRef(null);const[editingSessionId,setEditingSessionId]=React5.useState();const[editingTitle,setEditingTitle]=React5.useState("");React5.useEffect(()=>{if(!editingSessionId)return;renameInputRef.current?.focus();renameInputRef.current?.select();},[editingSessionId]);const cancelRename=()=>{setEditingSessionId(void 0);setEditingTitle("");};const saveRename=item=>{const title=editingTitle.trim();if(title&&title!==item.title)onRename?.(item.id,title);cancelRename();};if(status==="loading"&&sessions.length===0){return jsxRuntime.jsx("div",{className:"space-y-2 px-1 py-3",role:"status","aria-label":messages.loading,children:Array.from({length:4},(_,index)=>jsxRuntime.jsx("div",{"aria-hidden":"true",className:cn2("animate-pulse rounded-[var(--radius)] bg-muted/70",variant==="trend"?"h-10":"h-14")},index))})}if(status==="error"){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 px-3 py-8 text-center",children:[jsxRuntime.jsx("p",{className:"max-w-full break-words text-sm text-muted-foreground",role:"alert",children:error}),onRetry?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"gap-1.5 px-0 text-sm text-primary hover:text-primary",onClick:onRetry,children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-3.5","aria-hidden":"true"}),retryLabel??messages.retry]}):null]})}if(sessions.length===0){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:query?noResultsLabel:emptyLabel})}const renderTrendItems=items=>jsxRuntime.jsx("div",{className:"space-y-3",children:items.map(item=>jsxRuntime.jsxs("div",{"aria-current":item.id===selectedSessionId?"page":void 0,"data-agent-session-status":item.status??"idle","aria-busy":item.status==="running"?"true":void 0,className:"group flex h-10 w-full min-w-0 items-center rounded-[var(--radius)] border border-transparent bg-muted/60 text-foreground transition hover:bg-muted focus-within:border-ring focus-within:ring-2 focus-within:ring-ring aria-[current=page]:border-primary aria-[current=page]:bg-primary/10",children:[jsxRuntime.jsx("button",{type:"button",title:item.title,className:"h-full min-w-0 flex-1 truncate px-3 text-left text-sm font-semibold",onClick:()=>onSelect(item.id),children:item.title}),capabilities?.delete?jsxRuntime.jsx("span",{"data-agent-workbench-item-actions":true,className:"mr-1 shrink-0 opacity-0 transition-opacity group-aria-[current=page]:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100",onClick:event=>event.stopPropagation(),onKeyDown:event=>event.stopPropagation(),children:jsxRuntime.jsxs(DropdownMenu2,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":messages.actions,className:"size-8 text-muted-foreground",children:jsxRuntime.jsx(lucideReact.Ellipsis,{className:"size-4","aria-hidden":"true"})})}),jsxRuntime.jsx(DropdownMenuContent,{align:"end",children:jsxRuntime.jsxs(DropdownMenuItem,{className:"text-destructive-text",onSelect:()=>onDelete?.(item.id),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"mr-2 size-4","aria-hidden":"true"}),messages.delete]})})]})}):null]},item.id))});const renderItems=items=>jsxRuntime.jsx("div",{className:"space-y-1",children:items.map(item=>{const percent=item.contextUsage&&item.contextUsage.maxTokens>0?Math.min(100,Math.round(item.contextUsage.usedTokens/item.contextUsage.maxTokens*100)):void 0;return jsxRuntime.jsxs("div",{"aria-current":item.id===selectedSessionId?"page":void 0,className:cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",itemClassName),children:[editingSessionId===item.id?jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(SessionAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx(Input,{ref:renameInputRef,value:editingTitle,"aria-label":messages.rename,appearance:"compact",className:"h-6 w-full border-primary px-1.5 text-sm font-medium",onChange:event=>setEditingTitle(event.target.value),onClick:event=>event.stopPropagation(),onBlur:()=>saveRename(item),onKeyDown:event=>{event.stopPropagation();if(event.key==="Enter"){event.preventDefault();saveRename(item);}else if(event.key==="Escape"){event.preventDefault();cancelRename();}}}),jsxRuntime.jsx(SessionMeta,{item})]})]}):jsxRuntime.jsxs("button",{type:"button",title:item.title,className:"flex min-w-0 flex-1 items-center gap-3 text-left",onClick:()=>onSelect(item.id),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(SessionAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-sm font-medium",children:item.title}),jsxRuntime.jsx(SessionMeta,{item})]})]}),jsxRuntime.jsxs("span",{"data-agent-workbench-item-actions":true,className:"flex shrink-0 items-center gap-1",children:[percent!==void 0&&item.status==="idle"?jsxRuntime.jsxs("span",{className:"text-xs text-foreground","aria-label":messages.contextUsage({percent}),children:[percent,"%"]}):jsxRuntime.jsx(StatusIndicator,{status:item.status}),capabilities?.pin?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":item.pinned?messages.unpin:messages.pin,className:cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100",item.pinned&&"text-primary opacity-100"),onClick:event=>{event.stopPropagation();onTogglePin?.(item.id,!item.pinned);},children:jsxRuntime.jsx(lucideReact.Pin,{className:cn2("size-4",item.pinned&&"fill-current")})}):null,capabilities?.rename||capabilities?.delete?jsxRuntime.jsx("span",{onClick:event=>event.stopPropagation(),onKeyDown:event=>event.stopPropagation(),children:jsxRuntime.jsxs(DropdownMenu2,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8","aria-label":messages.actions,children:jsxRuntime.jsx(lucideReact.Ellipsis,{className:"size-4","aria-hidden":"true"})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[capabilities.rename?jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>{setEditingSessionId(item.id);setEditingTitle(item.title);},children:[jsxRuntime.jsx(lucideReact.Pencil,{className:"mr-2 size-4","aria-hidden":"true"}),messages.rename]}):null,capabilities.delete?jsxRuntime.jsxs(DropdownMenuItem,{className:"text-destructive-text",onSelect:()=>onDelete?.(item.id),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"mr-2 size-4","aria-hidden":"true"}),messages.delete]}):null]})]})}):null]})]},item.id)})});return jsxRuntime.jsxs("div",{className:cn2("space-y-2",className),children:[showHeading&&!groupByMode?jsxRuntime.jsx("h3",{className:"mb-2 px-3 text-xs font-medium text-muted-foreground",children:messages.recentSessions}):null,variant==="trend"?renderTrendItems(sessions):groupByMode?[{id:"chatbot",label:messages.chats,icon:lucideReact.MessageSquare,items:sessions.filter(item=>item.mode!=="work")},{id:"agent",label:messages.agents,icon:lucideReact.Bot,items:sessions.filter(item=>item.mode==="work")}].map(({id,label,icon:Icon2,items})=>jsxRuntime.jsxs("details",{open:true,"aria-label":label,children:[jsxRuntime.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 rounded-md px-3 text-sm font-semibold hover:bg-muted",children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 truncate",children:label})]}),renderItems(items)]},id)):renderItems(sessions)]})}var EMPTY_NAVIGATION_VIEW_MODEL={contract:"AgentWorkbenchNavigationViewModel",activeTab:"sessions",searchQuery:"",agents:{status:"loading",items:[]},sessions:{status:"loading",items:[]},capabilities:{createAgent:false,createSession:false,manageCapabilities:false,manageAgentSettings:false,pinAgents:false,pinSessions:false,renameSessions:false,deleteSessions:false}};function ItemAvatar({item}){const[failed,setFailed]=React5.useState(false);if(item.iconUrl&&!failed){return jsxRuntime.jsx("img",{src:item.iconUrl,alt:"",className:"size-full object-cover",onError:()=>setFailed(true)})}const initial=item.name.trim().charAt(0).toLocaleUpperCase();return initial?jsxRuntime.jsx("span",{className:"text-sm font-semibold",children:initial}):jsxRuntime.jsx(lucideReact.Bot,{className:"size-4"})}function CollectionState({status,empty,noResults,hasItems,query,error,onRetry}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;if(status==="loading"&&!hasItems){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:messages.loading})}if(status==="error"){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 px-3 py-8 text-center",children:[jsxRuntime.jsx("p",{className:"max-w-full break-words text-sm text-muted-foreground",role:"alert",children:error}),jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"gap-1.5 px-0 text-sm text-primary hover:text-primary",onClick:onRetry,children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-3.5","aria-hidden":"true"}),messages.retry]})]})}if(!hasItems){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:query?noResults:empty})}return null}function AgentWorkbenchSidebar({viewModel=EMPTY_NAVIGATION_VIEW_MODEL,navigationMode,config,header,headerActions,footer,className,classNames,onIntent}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const resolvedConfig=React5.useMemo(()=>monkeys.resolveAgentWorkbenchSidebarConfig(config),[config]);const visibleSections=React5.useMemo(()=>new Set(resolvedConfig.visibleSections),[resolvedConfig.visibleSections]);const sessionsOnly=navigationMode==="sessions-only"||navigationMode===void 0&&resolvedConfig.navigationMode!=="default";const showAgents=visibleSections.has("agents")&&!sessionsOnly;const showSessions=visibleSections.has("sessions");const query=viewModel.searchQuery.trim().toLocaleLowerCase();const agents=React5.useMemo(()=>viewModel.agents.items.filter(item=>!query||`${item.name} ${item.description??""}`.toLocaleLowerCase().includes(query)),[query,viewModel.agents.items]);const sessions=React5.useMemo(()=>viewModel.sessions.items.filter(item=>!query||item.title.toLocaleLowerCase().includes(query)),[query,viewModel.sessions.items]);return jsxRuntime.jsx(Tabs,{value:sessionsOnly||!showAgents?"sessions":viewModel.activeTab,onValueChange:value=>{if(!sessionsOnly&&(value==="agents"||value==="sessions"))onIntent?.({type:"change-tab",tab:value});},className:"h-full min-h-0",children:jsxRuntime.jsxs(AgentWorkbenchSidebarContainer,{"data-sidebar-width-percent":resolvedConfig.widthPercent,"aria-label":messages.tabsLabel,header:visibleSections.has("header")?header:void 0,search:visibleSections.has("search")?jsxRuntime.jsx(AgentWorkbenchSidebarSearch,{value:viewModel.searchQuery,label:sessionsOnly?messages.searchSessions:messages.search,className:classNames?.search,onChange:query2=>onIntent?.({type:"change-search",query:query2})}):void 0,actions:showAgents&&showSessions||headerActions?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[showAgents&&showSessions?jsxRuntime.jsxs(TabsList,{className:cn2("grid min-w-0 flex-1 grid-cols-2 text-foreground",classNames?.tabs),"aria-label":messages.tabsLabel,children:[jsxRuntime.jsx(TabsTrigger,{value:"agents",children:messages.agents}),jsxRuntime.jsx(TabsTrigger,{value:"sessions",children:messages.sessions})]}):null,headerActions?jsxRuntime.jsx("div",{className:"flex shrink-0 items-center",children:headerActions}):null]}):void 0,footer:visibleSections.has("footer")&&(!sessionsOnly&&viewModel.capabilities.manageAgentSettings||footer)?jsxRuntime.jsxs("div",{className:cn2("border-t border-border p-4",classNames?.footer),children:[!sessionsOnly&&viewModel.capabilities.manageAgentSettings?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"h-10 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"open-agent-settings"}),children:[jsxRuntime.jsx(lucideReact.Settings,{className:"size-4","aria-hidden":"true"}),messages.settings]}):null,footer]}):void 0,bodyScrollable:false,className,classNames:{root:classNames?.root,body:"flex min-h-0 flex-1 flex-col p-0"},children:[showAgents?jsxRuntime.jsxs(TabsContent,{value:"agents","data-agent-workbench-scroll-region":true,className:cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",classNames?.body),children:[viewModel.capabilities.createAgent?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"create-agent"}),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"size-4","aria-hidden":"true"}),messages.newAgent]}):null,jsxRuntime.jsx("h3",{className:"mb-2 px-3 text-xs font-medium text-muted-foreground",children:messages.allAgents}),jsxRuntime.jsx(CollectionState,{status:viewModel.agents.status,empty:messages.emptyAgents,noResults:messages.noResults,hasItems:agents.length>0,query,error:viewModel.agents.error,onRetry:()=>onIntent?.({type:"retry-agents"})}),jsxRuntime.jsx("div",{className:"space-y-1",children:agents.map(item=>jsxRuntime.jsxs("div",{"aria-current":item.id===viewModel.selectedAgentItem?"page":void 0,className:cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",classNames?.item),children:[jsxRuntime.jsxs("button",{type:"button",title:item.name,className:"flex min-w-0 flex-1 items-center gap-3 text-left",onClick:()=>onIntent?.({type:"select-agent",itemId:item.id}),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(ItemAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-sm font-medium",children:item.name}),jsxRuntime.jsx("span",{className:"block truncate text-xs text-foreground/80",children:item.description||messages.noDescription})]})]}),item.builtIn?jsxRuntime.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-1 text-[10px] text-foreground",children:messages.builtIn}):null,viewModel.capabilities.pinAgents?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":item.pinned?messages.unpin:messages.pin,className:cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100",item.pinned&&"text-primary opacity-100"),onClick:event=>{event.stopPropagation();onIntent?.({type:"toggle-agent-pin",itemId:item.id,pinned:!item.pinned});},onKeyDown:event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();event.stopPropagation();onIntent?.({type:"toggle-agent-pin",itemId:item.id,pinned:!item.pinned});}},children:jsxRuntime.jsx(lucideReact.Pin,{className:cn2("size-4",item.pinned&&"fill-current",item.pinPending&&"animate-pulse")})}):null]},item.id))})]}):null,showSessions?jsxRuntime.jsxs(TabsContent,{value:"sessions","data-agent-workbench-scroll-region":true,className:cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",classNames?.body),children:[visibleSections.has("new-session")&&viewModel.capabilities.createSession?jsxRuntime.jsx(AgentWorkbenchSidebarNewSessionButton,{label:messages.newSession,onClick:()=>onIntent?.({type:"create-session"})}):null,!sessionsOnly&&viewModel.capabilities.manageCapabilities?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"open-capabilities"}),children:[jsxRuntime.jsx(lucideReact.Blocks,{className:"size-4","aria-hidden":"true"}),messages.capabilities]}):null,jsxRuntime.jsx(AgentWorkbenchSessionList,{sessions,selectedSessionId:viewModel.selectedSessionItem,status:viewModel.sessions.status,error:viewModel.sessions.error,query,emptyLabel:messages.emptySessions,noResultsLabel:messages.noResults,groupByMode:sessionsOnly,showHeading:!sessionsOnly,itemClassName:classNames?.item,capabilities:{pin:viewModel.capabilities.pinSessions,rename:viewModel.capabilities.renameSessions,delete:viewModel.capabilities.deleteSessions},onSelect:sessionId=>onIntent?.({type:"select-session",sessionId}),onTogglePin:(sessionId,pinned)=>onIntent?.({type:"toggle-session-pin",sessionId,pinned}),onRename:(sessionId,title)=>onIntent?.({type:"rename-session",sessionId,title}),onDelete:sessionId=>onIntent?.({type:"delete-session",sessionId}),onRetry:()=>onIntent?.({type:"retry-sessions"})})]}):null]})})}function AgentWorkbenchExploreCardMedia({item,src=item.imageUrl,className,onError}){if(!src)return null;const variant=item.mediaVariant??"cover";const isLogo=variant==="logo";const showLabel=variant==="cover-with-label";const treatmentClass=item.mediaTreatment==="monochrome-light"?"brightness-0 invert":item.mediaTreatment==="invert"?"invert":"";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:cn2(isLogo?"flex size-full items-center justify-center bg-[hsl(var(--monkeys-color-media-surface))] p-5":"block size-full",className),children:jsxRuntime.jsx("img",{src,alt:"",className:cn2("transition-transform duration-300 group-hover:scale-[1.03]",isLogo?"max-h-full max-w-full object-contain":"size-full object-cover",treatmentClass),onError})}),showLabel?jsxRuntime.jsxs("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-8 text-[hsl(var(--monkeys-color-media-foreground))]",style:{backgroundImage:"linear-gradient(to top, hsl(var(--monkeys-color-media-overlay) / 0.8), hsl(var(--monkeys-color-media-overlay) / 0.3), transparent)"},children:[jsxRuntime.jsx("span",{className:"block text-base font-semibold leading-tight",children:item.title}),item.subtitle?jsxRuntime.jsx("span",{className:"mt-0.5 block text-[11px] leading-tight opacity-75",children:item.subtitle}):null]}):null]})}function AgentWorkbenchExploreSidebar({sessions,groups:configuredGroups,config,labels,selectedSessionId,searchQuery="",loading=false,error,showDraftSession=!selectedSessionId,deleteSessions=false,variant="default",defaultGroupId,header,footer,className,renderItemMedia,onIntent}){const resolvedConfig=React5.useMemo(()=>monkeys.resolveAgentWorkbenchSidebarConfig(config),[config]);const visibleSections=React5.useMemo(()=>new Set(resolvedConfig.visibleSections),[resolvedConfig.visibleSections]);const groups=configuredGroups?.length?configuredGroups:resolvedConfig.groups;const resolvedDefaultGroupId=defaultGroupId??resolvedConfig.defaultGroupId;const[activeGroupId,setActiveGroupId]=React5.useState(resolvedDefaultGroupId??groups[0]?.id??"");const activeGroup=groups.find(group=>group.id===activeGroupId)??groups[0];const normalizedQuery=searchQuery.trim().toLocaleLowerCase();const draftVisible=showDraftSession&&(!normalizedQuery||labels.draftSession.toLocaleLowerCase().includes(normalizedQuery));const filteredSessions=React5.useMemo(()=>sessions.filter(session=>!normalizedQuery||session.title.toLocaleLowerCase().includes(normalizedQuery)),[normalizedQuery,sessions]);React5.useEffect(()=>{if(groups.some(group=>group.id===activeGroupId))return;setActiveGroupId(resolvedDefaultGroupId??groups[0]?.id??"");},[activeGroupId,groups,resolvedDefaultGroupId]);const changeGroup=groupId=>{setActiveGroupId(groupId);onIntent?.({type:"change-group",groupId});};const groupNavigation=visibleSections.has("groups")&&activeGroup?jsxRuntime.jsx("div",{className:"border-t border-border px-4 pb-4 pt-3",children:jsxRuntime.jsxs(Tabs,{value:activeGroup.id,onValueChange:changeGroup,children:[jsxRuntime.jsx(TabsList,{className:"grid h-10 w-full rounded-[var(--radius)] bg-muted p-0.5 text-foreground",style:{gridTemplateColumns:`repeat(${groups.length}, minmax(0, 1fr))`},children:groups.map(group=>jsxRuntime.jsx(TabsTrigger,{value:group.id,className:"rounded-md text-sm font-semibold text-foreground data-[state=active]:border data-[state=active]:border-border data-[state=active]:bg-background",children:group.label},group.id))}),groups.map(group=>jsxRuntime.jsx(TabsContent,{value:group.id,className:"mt-3",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:group.items.map(item=>jsxRuntime.jsx("button",{type:"button","aria-label":item.title,className:"group relative aspect-[1.27] overflow-hidden rounded-[var(--radius)] border border-border bg-card text-left transition hover:border-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",style:Number.isFinite(group.itemAspectRatio)&&Number(group.itemAspectRatio)>0?{aspectRatio:group.itemAspectRatio}:void 0,onClick:()=>onIntent?.({type:"select-item",groupId:group.id,item}),children:renderItemMedia?.(item,group)??jsxRuntime.jsx(AgentWorkbenchExploreCardMedia,{item})},item.id))})},group.id))]})}):void 0;return jsxRuntime.jsx(AgentWorkbenchSidebarContainer,{"data-sidebar-style":"explore","data-sidebar-width-percent":resolvedConfig.widthPercent,"aria-label":labels.navigation,variant,density:variant==="trend"?"compact":void 0,header:visibleSections.has("header")?header:void 0,search:visibleSections.has("search")?jsxRuntime.jsx(AgentWorkbenchSidebarSearch,{value:searchQuery,label:labels.search,variant,onChange:query=>onIntent?.({type:"change-search",query})}):void 0,primaryAction:visibleSections.has("new-session")?jsxRuntime.jsx(AgentWorkbenchSidebarNewSessionButton,{label:labels.newSession,variant,onClick:()=>onIntent?.({type:"create-session"})}):void 0,groups:groupNavigation,footer:visibleSections.has("footer")?footer:void 0,bodyProps:{"data-agent-workbench-session-scroll-region":""},className,classNames:{body:"min-h-[160px] flex-[0_1_280px]"},children:visibleSections.has("sessions")?jsxRuntime.jsxs("div",{className:"space-y-2",children:[draftVisible?jsxRuntime.jsx("button",{type:"button","aria-current":"page",className:"block h-10 w-full min-w-0 truncate rounded-[var(--radius)] border border-primary bg-primary/10 px-3 text-left text-sm font-semibold text-foreground",onClick:()=>onIntent?.({type:"create-session"}),children:labels.draftSession}):null,filteredSessions.length>0||!draftVisible||loading||error?jsxRuntime.jsx(AgentWorkbenchSessionList,{sessions:filteredSessions,selectedSessionId,status:error?"error":loading?"loading":"ready",error,query:normalizedQuery,emptyLabel:labels.emptySessions,noResultsLabel:labels.noResults,retryLabel:labels.retry,groupByMode:resolvedConfig.navigationMode!=="default",variant,capabilities:{delete:deleteSessions},onSelect:sessionId=>onIntent?.({type:"select-session",sessionId}),onDelete:sessionId=>onIntent?.({type:"delete-session",sessionId}),onRetry:labels.retry?()=>onIntent?.({type:"retry-sessions"}):void 0}):null]}):null})}var EVENT_CAPABILITIES={reasoning:"reasoning",plan:"plan",task:"tasks",tool:"tools",approval:"approval",artifact:"artifacts",usage:"usage"};function projectRun(events){const statuses=events.filter(event=>event.eventType==="status");const run=statuses.at(-1);if(!run)return void 0;if(run.payload.status!=="stopped"||run.payload.durationMs!==void 0)return run;const runStatuses=run.runId?statuses.filter(event=>event.runId===run.runId&&event.sequence<=run.sequence):statuses.filter(event=>event.sequence<=run.sequence);let previousStoppedIndex=-1;for(let index=runStatuses.length-1;index>=0;index-=1){const event=runStatuses[index];if(event.sequence<run.sequence&&event.payload.status==="stopped"){previousStoppedIndex=index;break}}const started=runStatuses.slice(previousStoppedIndex+1).reverse().find(event=>event.payload.status==="running"||event.payload.status==="queued");const startedAt=started?.payload.startedAt??started?.occurredAt;const stoppedAt=run.payload.stoppedAt??run.occurredAt;if(!startedAt||!stoppedAt)return run;const durationMs=Date.parse(stoppedAt)-Date.parse(startedAt);return Number.isFinite(durationMs)&&durationMs>=0?{...run,resolvedDurationMs:durationMs}:run}function isVisible(event,capabilities){const capability=EVENT_CAPABILITIES[event.eventType];return capability?capabilities[capability]===true:true}function latestBy(events,eventType,key2){const latest=new Map;for(const event of events){if(event.eventType!==eventType)continue;const typedEvent=event;latest.set(key2(typedEvent),typedEvent);}return [...latest.values()].sort((left,right)=>left.sequence-right.sequence)}function createAgentWorkbenchActivityModel(viewModel){const visibleEvents=viewModel.events.filter(event=>isVisible(event,viewModel.snapshot.capabilities));return {mode:viewModel.snapshot.mode,status:viewModel.status,reasoning:latestBy(visibleEvents,"reasoning",event=>event.payload.reasoningId),plans:latestBy(visibleEvents,"plan",event=>event.payload.planId),tasks:latestBy(visibleEvents,"task",event=>event.payload.taskId),tools:latestBy(visibleEvents,"tool",event=>event.payload.toolCallId),approvals:latestBy(visibleEvents,"approval",event=>event.payload.approvalId),artifacts:latestBy(visibleEvents,"artifact",event=>event.payload.artifactId),usage:[...visibleEvents].reverse().find(event=>event.eventType==="usage"),run:projectRun(visibleEvents)}}function JsonValue({value}){if(value===void 0)return null;const content=typeof value==="string"?value:JSON.stringify(value,null,2);return jsxRuntime.jsx("pre",{className:"max-h-48 max-w-full overflow-auto overscroll-contain whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs text-foreground [overflow-wrap:anywhere]",tabIndex:0,children:content})}function AgentWorkbenchApproval({approval,className,onDecision}){const messages=useMonkeysLocaleMessages().agentWorkbench.approval;const requested=approval.status==="requested";const approved=approval.status==="approved";return jsxRuntime.jsx("article",{className:cn2("min-w-0 overflow-hidden rounded-lg border border-border bg-card p-3 text-card-foreground",className),"data-agent-approval-status":approval.status,children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[requested?jsxRuntime.jsx(lucideReact.Clock3,{className:"mt-0.5 size-4 shrink-0 text-warning-foreground","aria-hidden":"true"}):approved?jsxRuntime.jsx(lucideReact.Check,{className:"mt-0.5 size-4 shrink-0 text-success","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.X,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("h3",{className:"break-words text-sm font-medium",children:approval.title}),approval.description?jsxRuntime.jsx("p",{tabIndex:0,className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words text-sm text-muted-foreground [overflow-wrap:anywhere]",children:approval.description}):null,approval.requestedAction!==void 0?jsxRuntime.jsx("div",{className:"mt-3 min-w-0",children:jsxRuntime.jsx(JsonValue,{value:approval.requestedAction})}):null,requested?jsxRuntime.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[jsxRuntime.jsx(Button,{type:"button",size:"sm",className:"h-auto px-3 py-1.5 text-sm",disabled:!onDecision,onClick:()=>onDecision?.({approvalId:approval.approvalId,approved:true}),children:messages.approve}),jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto px-3 py-1.5 text-sm",disabled:!onDecision,onClick:()=>onDecision?.({approvalId:approval.approvalId,approved:false}),children:messages.reject})]}):jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:approved?messages.approved:messages.rejected})]})]})})}function JsonValue2({value,className}){if(value===void 0)return null;const content=typeof value==="string"?value:JSON.stringify(value,null,2);return jsxRuntime.jsx("pre",{tabIndex:0,className:cn2("max-h-64 max-w-full overflow-auto overscroll-contain whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs text-foreground [overflow-wrap:anywhere]",className),children:content})}function ToolStatus({status}){useMonkeysLocaleMessages().agentWorkbench.tool.status;const commonClassName="size-3.5 shrink-0";if(status==="pending"){return jsxRuntime.jsx(lucideReact.Clock3,{className:commonClassName,"aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Loader2,{className:cn2(commonClassName,"animate-spin"),"aria-hidden":"true"})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:cn2(commonClassName,"text-primary"),"aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.XCircle,{className:cn2(commonClassName,"text-destructive-text"),"aria-hidden":"true"})}function AgentWorkbenchTool({event,expanded,defaultExpanded=event.payload.status==="failed",className,classNames,onExpandedChange}){const messages=useMonkeysLocaleMessages().agentWorkbench.tool;const[uncontrolledExpanded,setUncontrolledExpanded]=React5.useState(defaultExpanded);const isControlled=expanded!==void 0;const isExpanded=expanded??uncontrolledExpanded;const status=event.payload.status;const setExpanded=nextExpanded=>{if(!isControlled)setUncontrolledExpanded(nextExpanded);onExpandedChange?.(nextExpanded);};return jsxRuntime.jsxs("details",{open:isExpanded,className:cn2("group min-w-0 overflow-hidden rounded-lg border border-border bg-card text-card-foreground",classNames?.root,className),"data-tool-status":status,children:[jsxRuntime.jsxs("summary",{className:cn2("flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",classNames?.trigger),onClick:event2=>{event2.preventDefault();setExpanded(!isExpanded);},children:[jsxRuntime.jsx(lucideReact.TerminalSquare,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:event.payload.toolName}),jsxRuntime.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground",children:[jsxRuntime.jsx(ToolStatus,{status}),messages.status[status]]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:cn2("min-w-0 space-y-3 border-t border-border px-3 py-3 text-sm",classNames?.content),children:[event.payload.input!==void 0?jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:messages.input}),jsxRuntime.jsx(JsonValue2,{value:event.payload.input,className:classNames?.input})]}):null,event.payload.output!==void 0?jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:messages.output}),jsxRuntime.jsx(JsonValue2,{value:event.payload.output,className:classNames?.output})]}):null,event.payload.error?jsxRuntime.jsx("p",{tabIndex:0,className:"max-h-32 overflow-auto whitespace-pre-wrap break-words text-sm text-destructive-text [overflow-wrap:anywhere]",role:"alert",children:event.payload.error}):null]})]})}function ArtifactDownloadButton({artifact,label,onDownload}){const busy=React5.useRef(false);const[downloading,setDownloading]=React5.useState(false);return jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":label,title:label,disabled:downloading,className:"text-muted-foreground hover:text-foreground",onClick:async event=>{event.preventDefault();event.stopPropagation();if(busy.current)return;busy.current=true;setDownloading(true);try{await onDownload(artifact);}finally{busy.current=false;setDownloading(false);}},children:downloading?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Download,{className:"size-4","aria-hidden":"true"})})}function ActivityDetails({icon:Icon2,title,open,streaming,className,triggerClassName,contentClassName,children}){return jsxRuntime.jsxs("details",{className:cn2("group min-w-0 overflow-hidden rounded-lg border border-border bg-card text-card-foreground",className),open,children:[jsxRuntime.jsxs("summary",{className:cn2("flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",triggerClassName),children:[streaming?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsx("div",{className:cn2("min-w-0 border-t border-border px-3 py-3 text-sm",contentClassName),children})]})}function StatusIcon({status}){if(status==="completed"||status==="passed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-success","aria-hidden":"true"})}if(status==="failed"){return jsxRuntime.jsx(lucideReact.XCircle,{className:"size-4 text-destructive-text","aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 animate-pulse text-warning-foreground","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}function formatDuration(durationMs){if(durationMs<1e3)return "<1s";const totalSeconds=Math.floor(durationMs/1e3);const minutes=Math.floor(totalSeconds/60);const seconds=totalSeconds%60;return minutes>0?`${minutes}m ${seconds}s`:`${seconds}s`}function RunStatus({event}){const messages=useMonkeysLocaleMessages().agentWorkbench;const status=event.payload.status;if(status!=="stopping"&&status!=="stopped")return null;return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status",children:[status==="stopping"?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.CircleStop,{className:"size-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:status==="stopping"?messages.run.stopping:messages.run.stoppedAfter({duration:formatDuration(event.payload.durationMs??event.resolvedDurationMs??0)})})]})}function AgentWorkbenchActivity({viewModel,ariaLabel,hiddenToolCallIds,hideReasoning=false,hideStoppedRun=false,className,classNames,onApprovalDecision,onArtifactOpen,onArtifactDownload}){const messages=useMonkeysLocaleMessages().agentWorkbench;if(!viewModel)return null;const activity=createAgentWorkbenchActivityModel(viewModel);const reasoning=hideReasoning?[]:activity.reasoning;const tools=activity.tools.filter(event=>!hiddenToolCallIds?.has(event.payload.toolCallId));const approvals=activity.approvals.filter(event=>!event.payload.toolCallId||!hiddenToolCallIds?.has(event.payload.toolCallId));const usage=activity.usage?.payload;const contextWindow=typeof usage?.contextWindow==="number"&&usage.contextWindow>0?usage.contextWindow:void 0;const showRun=activity.run?.payload.status==="stopping"||activity.run?.payload.status==="stopped"&&!hideStoppedRun;const hasActivity=reasoning.length>0||activity.plans.length>0||activity.tasks.length>0||tools.length>0||approvals.length>0||activity.artifacts.length>0||showRun||contextWindow!==void 0;if(!hasActivity)return null;return jsxRuntime.jsxs("section",{className:cn2("space-y-3",classNames?.root,className),"aria-label":ariaLabel??messages.label,"data-agent-workbench-mode":activity.mode,"data-agent-workbench-status":activity.status,children:[reasoning.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:messages.reasoning,open:event.payload.status==="streaming",streaming:event.payload.status==="streaming",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsx("div",{tabIndex:0,className:"max-h-64 overflow-auto whitespace-pre-wrap break-words text-muted-foreground [overflow-wrap:anywhere]",children:event.payload.text})},event.payload.reasoningId)),activity.plans.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:event.payload.title||messages.plan,open:event.payload.status==="running",streaming:event.payload.status==="running",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsx("ol",{className:"space-y-2",children:event.payload.steps.map(step=>jsxRuntime.jsxs("li",{className:"flex min-w-0 items-start gap-2",children:[jsxRuntime.jsx(StatusIcon,{status:step.status}),jsxRuntime.jsx("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:step.title})]},step.id))})},event.payload.planId)),activity.tasks.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:event.payload.title,open:event.payload.status==="running",streaming:event.payload.status==="running",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(StatusIcon,{status:event.payload.status}),jsxRuntime.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-muted-foreground [overflow-wrap:anywhere]",children:event.payload.detail||messages.taskNoDetail})]})},event.payload.taskId)),tools.map(event=>jsxRuntime.jsx(AgentWorkbenchTool,{event,defaultExpanded:event.payload.status==="failed",classNames:{root:classNames?.item,trigger:classNames?.trigger,content:classNames?.content}},event.payload.toolCallId)),approvals.map(event=>{return jsxRuntime.jsx(AgentWorkbenchApproval,{approval:event.payload,className:classNames?.approval,onDecision:onApprovalDecision},event.payload.approvalId)}),activity.artifacts.map(event=>{const canOpen=Boolean(event.payload.url&&onArtifactOpen);return jsxRuntime.jsxs("article",{className:cn2("flex items-center gap-3 rounded-lg border border-border bg-card p-3 text-card-foreground",classNames?.artifact),children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"truncate text-sm font-medium",children:event.payload.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:messages.artifact[event.payload.status]})]}),event.payload.url?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground","aria-label":messages.artifact.open({name:event.payload.name}),title:messages.artifact.open({name:event.payload.name}),disabled:!canOpen,onClick:click=>{click.preventDefault();click.stopPropagation();if(!event.payload.url)return;onArtifactOpen?.({artifactId:event.payload.artifactId,name:event.payload.name,url:event.payload.url});},children:jsxRuntime.jsx(lucideReact.PanelRightOpen,{className:"size-4","aria-hidden":"true"})}):null,event.payload.url&&event.payload.status==="ready"&&onArtifactDownload?jsxRuntime.jsx(ArtifactDownloadButton,{artifact:{artifactId:event.payload.artifactId,name:event.payload.name,url:event.payload.url},label:messages.artifactWorkspace.download({name:event.payload.name}),onDownload:onArtifactDownload}):null]},event.payload.artifactId)}),showRun&&activity.run?jsxRuntime.jsx(RunStatus,{event:activity.run}):null,usage&&contextWindow!==void 0?jsxRuntime.jsx("div",{className:cn2("flex justify-end",classNames?.usage),"aria-label":messages.usage.label,children:jsxRuntime.jsx("span",{className:"rounded-full border border-border bg-muted px-2.5 py-1 text-xs text-foreground",children:messages.usage.context({used:usage.contextTokens??usage.totalTokens??0,total:contextWindow})})}):null]})}var WORKSPACE_CAPABILITIES={diff:"diff","workspace-file":"workspaceFiles",terminal:"terminal","test-result":"testResults",artifact:"artifacts"};function latestBy2(events,eventType,key2){const latest=new Map;for(const event of events){if(event.eventType!==eventType)continue;const typedEvent=event;latest.set(key2(typedEvent),typedEvent);}return [...latest.values()].sort((left,right)=>left.sequence-right.sequence)}function projectTerminals(events){const terminals=new Map;for(const event of events){const current=terminals.get(event.payload.terminalId)??{terminalId:event.payload.terminalId,stdin:"",stdout:"",stderr:"",status:"",sequence:event.sequence};const stream=event.payload.stream;terminals.set(event.payload.terminalId,{...current,...stream==="status"?{status:event.payload.chunk}:{[stream]:`${current[stream]}${event.payload.chunk}`},...event.payload.exitCode===void 0?{}:{exitCode:event.payload.exitCode},sequence:event.sequence});}return [...terminals.values()].sort((left,right)=>left.sequence-right.sequence)}function createAgentWorkbenchDetailsModel(viewModel){const capabilities=viewModel.snapshot.capabilities;const workspaceEvents=viewModel.events.filter(event=>{const capability=WORKSPACE_CAPABILITIES[event.eventType];return capability?capabilities[capability]===true:false});const run=[...viewModel.events].reverse().find(event=>event.eventType==="status");const currentRunId=run?.runId;const summary=[...viewModel.events].reverse().find(event=>event.eventType==="summary"&&capabilities.summary===true&&(!currentRunId||event.runId===currentRunId));return {mode:viewModel.snapshot.mode,modelId:viewModel.snapshot.modelId,permissionProfile:viewModel.snapshot.permissionProfile,status:viewModel.status,sessionId:viewModel.sessionId,capabilities,resumable:capabilities.resume===true&&viewModel.resumable,summary,error:[...viewModel.events].reverse().find(event=>event.eventType==="error"),run,usage:capabilities.usage?[...viewModel.events].reverse().find(event=>event.eventType==="usage"):void 0,workspace:{diffs:latestBy2(workspaceEvents,"diff",event=>event.payload.path),files:latestBy2(workspaceEvents,"workspace-file",event=>event.payload.path),terminals:projectTerminals(workspaceEvents.filter(event=>event.eventType==="terminal")),tests:latestBy2(workspaceEvents,"test-result",event=>event.payload.testId),artifacts:latestBy2(workspaceEvents,"artifact",event=>event.payload.artifactId)}}}function formatDuration2(durationMs){if(durationMs===void 0)return "-";const seconds=Math.max(0,Math.round(durationMs/1e3));if(seconds<60)return `${seconds}s`;return `${Math.floor(seconds/60)}m ${seconds%60}s`}function formatDate(value,locale){if(!value)return "-";const date=new Date(value);if(Number.isNaN(date.getTime()))return "-";return new Intl.DateTimeFormat(locale,{dateStyle:"medium",timeStyle:"short"}).format(date)}function Count({value}){return jsxRuntime.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-semibold text-foreground",children:value})}function DetailsSection({title,count,icon:Icon2,className,children}){if(count===0)return null;return jsxRuntime.jsxs("details",{className:cn2("group rounded-lg border border-border bg-card text-card-foreground",className),open:true,children:[jsxRuntime.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",children:[jsxRuntime.jsx(Icon2,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:title}),jsxRuntime.jsx(Count,{value:count}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsx("div",{className:"border-t border-border p-3",children})]})}function StatusIcon2({status}){if(status==="completed"||status==="passed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-primary","aria-hidden":"true"})}if(status==="failed"){return jsxRuntime.jsx(lucideReact.XCircle,{className:"size-4 text-destructive-text","aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 animate-pulse","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}function StateContent({state}){const messages=useMonkeysLocaleMessages().agentWorkbench.details;const error=state==="error";return jsxRuntime.jsxs("div",{className:"flex min-h-48 flex-col items-center justify-center gap-2 px-6 text-center",role:error?"alert":state==="loading"?"status":void 0,"aria-busy":state==="loading"||void 0,children:[state==="loading"?jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-5 animate-spin text-muted-foreground","aria-hidden":"true"}):error?jsxRuntime.jsx(lucideReact.AlertCircle,{className:"size-5 text-destructive-text","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("div",{className:"text-sm font-medium",children:messages.state[state].title}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:messages.state[state].description})]})}function SummaryPanel({model,onIntent}){const workbenchMessages=useMonkeysLocaleMessages().agentWorkbench;const messages=workbenchMessages.details;const locale=useMonkeysLocale().locale;const summary=model.summary;const run=model.run?.payload;const error=model.error;const retryable=model.status==="failed"&&error?.payload.retryable;const canResume=model.resumable&&["stopped","completed","failed"].includes(model.status);const canContinueInNewTask=model.capabilities.threadForking;const canEditAndRerun=model.capabilities.editAndRerun;const tokenUsage=model.usage?.payload.totalTokens??(model.usage?.payload.inputTokens!==void 0||model.usage?.payload.outputTokens!==void 0?(model.usage.payload.inputTokens??0)+(model.usage.payload.outputTokens??0):void 0);return jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("section",{className:"rounded-lg border border-border bg-muted/40 p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(StatusIcon2,{status:model.status}),jsxRuntime.jsx("span",{className:"text-sm font-semibold",children:messages.status[model.status]})]}),jsxRuntime.jsxs("dl",{className:"mt-3 grid grid-cols-2 gap-3 text-xs",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.duration}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:formatDuration2(run?.durationMs)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.updated}),jsxRuntime.jsx("dd",{className:"mt-0.5 truncate font-medium",children:formatDate(run?.stoppedAt??run?.completedAt??run?.failedAt,locale)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.model}),jsxRuntime.jsx("dd",{className:"mt-0.5 truncate font-medium",children:model.modelId})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.mode}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:workbenchMessages.modes[model.mode]})]}),model.permissionProfile?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.permissions}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:workbenchMessages.composer.permissionOptions[model.permissionProfile]})]}):null,tokenUsage!==void 0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.tokenUsage}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:new Intl.NumberFormat(locale).format(tokenUsage)})]}):null]}),error?jsxRuntime.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/5 p-2.5 text-sm text-destructive-text",role:"alert",children:error.payload.message}):null,retryable||canResume?jsxRuntime.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[retryable?jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"retry",eventId:error.eventId}),children:messages.actions.retry}):null,canResume?jsxRuntime.jsx(Button,{type:"button",size:"sm",className:"h-auto px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"resume",sessionId:model.sessionId}),children:messages.actions.resume}):null]}):null]}),jsxRuntime.jsxs("section",{className:"flex flex-wrap gap-2 rounded-lg border border-border bg-card p-3 text-card-foreground",children:[canContinueInNewTask?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"continue-in-new-task",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.GitFork,{className:"size-3.5","aria-hidden":"true"}),messages.actions.continueInNewTask]}):null,canEditAndRerun?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"edit-and-rerun",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.PencilLine,{className:"size-3.5","aria-hidden":"true"}),messages.actions.editAndRerun]}):null,jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"export",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.Download,{className:"size-3.5","aria-hidden":"true"}),messages.actions.export]})]}),jsxRuntime.jsxs("section",{className:"rounded-lg border border-border bg-card p-3 text-card-foreground",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:messages.summary}),summary?.payload.text?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-foreground","aria-label":messages.actions.copySummary,disabled:!onIntent,onClick:()=>onIntent?.({type:"copy-summary",summaryId:summary.payload.summaryId,text:summary.payload.text}),children:jsxRuntime.jsx(lucideReact.Copy,{className:"size-4","aria-hidden":"true"})}):null]}),summary?.payload.status==="failed"?jsxRuntime.jsxs("div",{className:"mt-3 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive-text",role:"alert",children:messages.summaryFailed}),jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"retry-summary",eventId:summary.eventId}),children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"size-3.5","aria-hidden":"true"}),messages.actions.retrySummary]})]}):summary?.payload.text?jsxRuntime.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[jsxRuntime.jsx("p",{className:"whitespace-pre-wrap text-muted-foreground",children:summary.payload.text}),summary.payload.highlights.length>0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium",children:messages.highlights}),jsxRuntime.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 text-muted-foreground",children:summary.payload.highlights.map(item=>jsxRuntime.jsx("li",{children:item},item))})]}):null,summary.payload.pendingItems.length>0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium",children:messages.pendingItems}),jsxRuntime.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 text-muted-foreground",children:summary.payload.pendingItems.map(item=>jsxRuntime.jsx("li",{children:item},item))})]}):null]}):jsxRuntime.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:messages.summaryEmpty})]})]})}function WorkspacePanel({model,sectionClassName,codeClassName}){const messages=useMonkeysLocaleMessages().agentWorkbench.details.workspace;const workspace=model.workspace;return jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(DetailsSection,{title:messages.diffs,count:workspace.diffs.length,icon:lucideReact.FileCode2,className:sectionClassName,children:jsxRuntime.jsx("div",{className:"space-y-3",children:workspace.diffs.map(event=>jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[jsxRuntime.jsx("span",{className:"truncate font-medium",children:event.payload.path}),jsxRuntime.jsx("span",{className:"shrink-0 text-muted-foreground",children:messages.diffStatus[event.payload.status]})]}),event.payload.patch?jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:event.payload.patch}):null]},event.payload.path))})}),jsxRuntime.jsx(DetailsSection,{title:messages.files,count:workspace.files.length,icon:lucideReact.Files,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.files.map(event=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.path}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:messages.fileOperation[event.payload.operation]})]},event.payload.path))})}),jsxRuntime.jsx(DetailsSection,{title:messages.terminals,count:workspace.terminals.length,icon:lucideReact.TerminalSquare,className:sectionClassName,children:jsxRuntime.jsx("div",{className:"space-y-3",children:workspace.terminals.map(terminal=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex justify-between gap-2 text-xs font-medium",children:[jsxRuntime.jsx("span",{children:terminal.terminalId}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:terminal.exitCode===void 0?terminal.status:messages.exitCode({code:terminal.exitCode})})]}),jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:[terminal.stdin,terminal.stdout,terminal.stderr].filter(Boolean).join("\n")})]},terminal.terminalId))})}),jsxRuntime.jsx(DetailsSection,{title:messages.tests,count:workspace.tests.length,icon:lucideReact.TestTube2,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.tests.map(event=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(StatusIcon2,{status:event.payload.status}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.name}),event.payload.durationMs===void 0?null:jsxRuntime.jsx("span",{className:"text-muted-foreground",children:formatDuration2(event.payload.durationMs)})]}),event.payload.output?jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-48 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:event.payload.output}):null]},event.payload.testId))})}),jsxRuntime.jsx(DetailsSection,{title:messages.artifacts,count:workspace.artifacts.length,icon:lucideReact.FileOutput,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.artifacts.map(event=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.name}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:event.payload.kind})]},event.payload.artifactId))})})]})}function AgentWorkbenchTaskDetails({viewModel,state="ready",activeTab="summary",className,classNames,onActiveTabChange,onIntent,onExport,onCopySummary,onRetry,onRetrySummary}){const dispatch=onIntent||onExport||onCopySummary||onRetry||onRetrySummary?intent=>{if(intent.type==="export"&&onExport)return onExport(intent);if(intent.type==="copy-summary"&&onCopySummary)return onCopySummary(intent);if(intent.type==="retry"&&onRetry)return onRetry(intent);if(intent.type==="retry-summary"&&onRetrySummary)return onRetrySummary(intent);onIntent?.(intent);}:void 0;const messages=useMonkeysLocaleMessages().agentWorkbench.details;if(state!=="ready"){return jsxRuntime.jsx("aside",{className:cn2("flex h-full min-h-0 flex-col border-l border-border bg-background",classNames?.root,className),children:jsxRuntime.jsx(StateContent,{state})})}if(!viewModel){return jsxRuntime.jsx("aside",{className:cn2("flex h-full min-h-0 flex-col border-l border-border bg-background",classNames?.root,className),children:jsxRuntime.jsx(StateContent,{state:"empty"})})}const model=createAgentWorkbenchDetailsModel(viewModel);const workspaceCount=Object.values(model.workspace).reduce((total,items)=>total+items.length,0);const workspaceAvailable=workspaceCount>0;const resolvedTab=activeTab==="workspace"&&!workspaceAvailable?"summary":activeTab;const tabs=[{id:"summary",label:messages.tabs.summary,count:model.summary?1:0},...workspaceAvailable?[{id:"workspace",label:messages.tabs.workspace,count:workspaceCount}]:[]];return jsxRuntime.jsxs("aside",{className:cn2("flex h-full min-h-0 min-w-0 flex-col border-l border-border bg-background text-foreground",classNames?.root,className),"data-agent-workbench-mode":model.mode,children:[jsxRuntime.jsxs("header",{className:cn2("flex shrink-0 items-center gap-2 border-b border-border px-4 py-3",classNames?.header),children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("h2",{className:"truncate text-sm font-semibold",children:messages.title}),jsxRuntime.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:messages.description})]}),onIntent?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground","aria-label":messages.actions.close,onClick:()=>onIntent({type:"close"}),children:jsxRuntime.jsx(lucideReact.X,{className:"size-4","aria-hidden":"true"})}):null]}),jsxRuntime.jsxs(Tabs,{value:resolvedTab,className:"flex min-h-0 flex-1 flex-col",onValueChange:tab=>onActiveTabChange?.(tab),children:[jsxRuntime.jsx(TabsList,{"aria-label":messages.tabs.label,className:cn2("flex h-auto shrink-0 gap-1 rounded-none border-b border-border bg-transparent px-3 py-2",classNames?.tabs),children:tabs.map(tab=>jsxRuntime.jsxs(TabsTrigger,{value:tab.id,className:"min-w-0 flex-1 gap-1 px-2 py-1.5 text-xs shadow-none data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",children:[jsxRuntime.jsx("span",{className:"truncate",children:tab.label}),jsxRuntime.jsx(Count,{value:tab.count})]},tab.id))}),jsxRuntime.jsx(TabsContent,{value:"summary",className:cn2("mt-0 min-h-0 flex-1 overflow-y-auto p-3",classNames?.body),children:jsxRuntime.jsx(SummaryPanel,{model,onIntent:dispatch})}),workspaceAvailable?jsxRuntime.jsx(TabsContent,{value:"workspace",className:cn2("mt-0 min-h-0 flex-1 overflow-y-auto p-3",classNames?.body),children:jsxRuntime.jsx(WorkspacePanel,{model,sectionClassName:classNames?.section,codeClassName:classNames?.code})}):null]})]})}var AgentWorkbenchMessage=React5.forwardRef(function AgentWorkbenchMessage2({role,className,...messageProps},ref){return jsxRuntime.jsx("div",{...messageProps,ref,"data-agent-message-role":role,className:cn2("group flex w-full max-w-[95%] min-w-0 flex-col gap-2",role==="user"?"is-user ml-auto justify-end":"is-assistant",role==="system"&&"mx-auto items-center text-center",className)})});var AgentWorkbenchMessageContent=React5.forwardRef(function AgentWorkbenchMessageContent2({children,className,tabIndex=0,...contentProps},ref){return jsxRuntime.jsx("div",{...contentProps,ref,tabIndex,className:cn2("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-x-auto overflow-y-hidden break-words text-sm [overflow-wrap:anywhere]","[&_a]:max-w-full [&_a]:break-all [&_code]:max-w-full [&_code]:break-words","[&_pre]:w-max [&_pre]:min-w-full [&_pre]:whitespace-pre [&_pre_code]:break-normal","[&_table]:w-max [&_table]:min-w-full [&_table]:whitespace-nowrap","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",className),children})});var AgentWorkbenchMessageActions=React5.forwardRef(function AgentWorkbenchMessageActions2({children,className,...actionsProps},ref){return jsxRuntime.jsx("div",{...actionsProps,ref,className:cn2("flex min-w-0 items-center gap-1",className),children})});var AgentWorkbenchMessageAction=React5.forwardRef(function AgentWorkbenchMessageAction2({children,label,tooltip,className,disabled=false,type="button",...buttonProps},ref){return jsxRuntime.jsx("button",{...buttonProps,ref,type,"aria-label":label,title:tooltip,disabled,className:cn2("inline-flex size-8 shrink-0 items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground shadow-none transition-colors","hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",className),children})});function materializeMessages(events){const messages=new Map;for(const event of events){if(event.eventType!=="message")continue;const current=messages.get(event.payload.messageId);const parts=event.payload.operation==="replace"?event.payload.parts:[...current?.parts??[],...event.payload.parts];messages.set(event.payload.messageId,{id:event.payload.messageId,role:event.payload.role,parts,sequence:event.sequence});}return [...messages.values()]}function logicalActivityKey(event){switch(event.eventType){case "reasoning":return `reasoning:${event.payload.reasoningId}`;case "plan":return `plan:${event.payload.planId}`;case "task":return `task:${event.payload.taskId}`;case "tool":return `tool:${event.payload.toolCallId}`;case "approval":return `approval:${event.payload.approvalId}`;case "artifact":return `artifact:${event.payload.artifactId}`;case "usage":return "usage";case "status":return "status";default:return void 0}}function createThreadEntries(viewModel){const messages=materializeMessages(viewModel.events).map(message=>({type:"message",sequence:message.sequence,message}));const activity=new Map;for(const event of viewModel.events){const key2=logicalActivityKey(event);if(key2)activity.set(key2,event);}return [...messages,...viewModel.events.filter(event=>event.eventType==="error").map(event=>({type:"error",sequence:event.sequence,event})),...[...activity.values()].map(event=>({type:"activity",sequence:event.sequence,event}))].sort((left,right)=>left.sequence-right.sequence)}function partText(part){if(typeof part==="string")return part;if(!part||typeof part!=="object"||Array.isArray(part))return String(part??"");const record=part;if(typeof record.text==="string")return record.text;if(typeof record.name==="string")return record.name;return JSON.stringify(record,null,2)}function DefaultMessageContent({message}){const content=message.parts.map(partText).filter(Boolean).join("");return jsxRuntime.jsx("div",{className:"whitespace-pre-wrap break-words",children:content})}function singleEventViewModel(viewModel,event){return {...viewModel,events:[event],lastSequence:event.sequence}}function AgentWorkbenchThread({viewModel,loading=false,emptyTitle,emptyDescription,autoScroll=true,className,classNames,renderMessageContent,onApprovalDecision,onArtifactOpen}){const messages=useMonkeysLocaleMessages().agentWorkbench;const resolvedEmptyTitle=emptyTitle??messages.navigation.emptySessions;const scrollRef=React5.useRef(null);const entries=React5.useMemo(()=>viewModel?createThreadEntries(viewModel):[],[viewModel]);React5.useEffect(()=>{if(!autoScroll||!viewModel)return;const element=scrollRef.current;if(element)element.scrollTop=element.scrollHeight;},[autoScroll,viewModel?.lastSequence,viewModel?.sessionId]);return jsxRuntime.jsx("div",{ref:scrollRef,role:"log","aria-label":messages.label,className:cn2("min-h-0 flex-1 overflow-y-auto bg-background",classNames?.root,className),children:loading&&entries.length===0?jsxRuntime.jsxs("div",{className:cn2("flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground",classNames?.loading),role:"status",children:[jsxRuntime.jsx("span",{className:"size-4 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.navigation.loading})]}):entries.length===0?jsxRuntime.jsxs("div",{className:cn2("flex min-h-48 flex-col items-center justify-center px-6 text-center",classNames?.empty),children:[jsxRuntime.jsx("h2",{className:"text-base font-semibold text-foreground",children:resolvedEmptyTitle}),emptyDescription?jsxRuntime.jsx("p",{className:"mt-1 max-w-lg text-sm text-muted-foreground",children:emptyDescription}):null]}):jsxRuntime.jsx("div",{className:cn2("mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 sm:px-6",classNames?.list),children:entries.map(entry=>{if(entry.type==="error"){return jsxRuntime.jsx("div",{role:"alert",className:cn2("rounded-lg border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive-text",classNames?.activity),children:entry.event.payload.message},`error:${entry.event.eventId}`)}if(entry.type==="activity"){return jsxRuntime.jsx(AgentWorkbenchActivity,{viewModel:singleEventViewModel(viewModel,entry.event),ariaLabel:`${messages.label} ${entry.sequence+1}`,className:classNames?.activity,onApprovalDecision,onArtifactOpen},`activity:${entry.event.eventId}`)}const{message}=entry;const isUser=message.role==="user";const isSystem=message.role==="system";if(isSystem){return jsxRuntime.jsx("div",{className:cn2("text-center text-xs text-muted-foreground",classNames?.message),children:renderMessageContent?.(message)??jsxRuntime.jsx(DefaultMessageContent,{message})},message.id)}return jsxRuntime.jsxs(AgentWorkbenchMessage,{role:message.role,className:cn2("flex-row items-start gap-3",isUser&&"flex-row-reverse",classNames?.message),"data-message-role":message.role,children:[jsxRuntime.jsx("span",{className:cn2("flex size-8 shrink-0 items-center justify-center rounded-full",isUser?"bg-primary text-primary-foreground":"bg-muted text-foreground"),"aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-current"})}),jsxRuntime.jsx(AgentWorkbenchMessageContent,{className:cn2("max-w-[85%] rounded-2xl px-4 py-2.5 text-sm leading-6",!isUser&&"bg-card text-card-foreground",classNames?.messageContent),children:renderMessageContent?.(message)??jsxRuntime.jsx(DefaultMessageContent,{message})})]},message.id)})})})}var AgentWorkbenchThreadShell=React5.forwardRef(function AgentWorkbenchThreadShell2({children,title,headerActions,showHeader=Boolean(title||headerActions),variant,density,className,classNames,...shellProps},ref){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";return jsxRuntime.jsxs("section",{...shellProps,ref,"data-agent-thread-shell":"true","data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,className:cn2("flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground",classNames?.root,className),children:[showHeader?jsxRuntime.jsxs("div",{className:cn2("flex min-w-0 items-center justify-between border-b border-border",compact?"min-h-10 gap-2 px-3 py-1.5":"min-h-11 gap-3 px-4 py-2",classNames?.header),children:[jsxRuntime.jsx("h1",{className:cn2("min-w-0 flex-1 truncate font-normal text-foreground",compact?"text-base leading-5":"text-lg leading-6",classNames?.title),children:title}),headerActions?jsxRuntime.jsx("div",{className:cn2("flex min-w-0 shrink-0 items-center gap-0.5",classNames?.headerActions),children:headerActions}):null]}):null,jsxRuntime.jsx("div",{className:cn2("flex min-h-0 min-w-0 flex-1 flex-col",classNames?.body),children})]})});var AGENT_WORKBENCH_SHELL_BREAKPOINTS=Object.freeze({mobile:768,drawer:1200,compact:1440,lowHeight:768});function resolveAgentWorkbenchShellLayout(width,breakpoints=AGENT_WORKBENCH_SHELL_BREAKPOINTS){if(width<breakpoints.mobile)return "mobile";if(width<breakpoints.drawer)return "drawer";if(width<breakpoints.compact)return "compact";return "wide"}var OVERLAY_EVENT="monkeys-agent-workbench-overlay-open";function cssSize(value){return typeof value==="number"?`${value}px`:value}function clamp(value,min,max){return Math.min(Math.max(value,min),Math.max(min,max))}function initialMeasuredSize(){if(typeof window==="undefined")return {width:1440,height:900};return {width:window.visualViewport?.width??window.innerWidth,height:window.visualViewport?.height??window.innerHeight}}function readStoredWidths(storageKey){if(!storageKey||typeof window==="undefined")return {};try{const value=JSON.parse(window.localStorage.getItem(storageKey)??"{}");return typeof value==="object"&&value!==null?value:{}}catch{return {}}}function writeStoredWidths(storageKey,widths){if(!storageKey||typeof window==="undefined")return;window.localStorage.setItem(storageKey,JSON.stringify(widths));}function AgentWorkbenchShell({sidebar,children,details,sidebarOpen=true,sidebarDefaultOpen=true,detailsOpen=true,onDetailsOpenChange,sidebarWidth=280,detailsWidth=360,sidebarMinWidth=240,sidebarMaxWidth=400,detailsMinWidth=320,detailsMaxWidth=720,mainMinWidth=600,responsive=false,responsiveMeasurement="container",responsiveWidth,responsiveHeight,breakpoints=AGENT_WORKBENCH_SHELL_BREAKPOINTS,onLayoutChange,showResponsiveControls=true,overlayGroupId,resizable=false,widthStorageKey,onSidebarWidthChange,onDetailsWidthChange,labels,variant,density,className,classNames,style,...rootProps}){const appearance=useAgentWorkbenchAppearance({variant,density});const rootRef=React5.useRef(null);const sidebarReturnFocusRef=React5.useRef(null);const detailsReturnFocusRef=React5.useRef(null);const shellId=React5.useId();const[measuredSize,setMeasuredSize]=React5.useState(initialMeasuredSize);const storedWidths=React5.useMemo(()=>readStoredWidths(widthStorageKey),[widthStorageKey]);const[sidebarPixelWidth,setSidebarPixelWidth]=React5.useState(()=>typeof sidebarWidth==="number"?storedWidths.sidebar??sidebarWidth:280);const[detailsPixelWidth,setDetailsPixelWidth]=React5.useState(()=>typeof detailsWidth==="number"?storedWidths.details??detailsWidth:360);const[sidebarOverlayOpen,setSidebarOverlayOpen]=React5.useState(false);const[detailsOverlayOpen,setDetailsOverlayOpen]=React5.useState(false);const[sidebarExpanded,setSidebarExpanded]=React5.useState(sidebarDefaultOpen);const rememberReturnFocus=React5.useCallback((region,candidate=document.activeElement)=>{if(!(candidate instanceof HTMLElement)||candidate===document.body||candidate===document.documentElement){return}const targetRef=region==="sidebar"?sidebarReturnFocusRef:detailsReturnFocusRef;targetRef.current=candidate;},[]);const restoreReturnFocus=React5.useCallback(region=>{const targetRef=region==="sidebar"?sidebarReturnFocusRef:detailsReturnFocusRef;const target=targetRef.current;targetRef.current=null;if(!target?.isConnected)return;window.requestAnimationFrame(()=>{if(target.isConnected)target.focus();});},[]);React5.useEffect(()=>{if(typeof sidebarWidth==="number"){setSidebarPixelWidth(storedWidths.sidebar??sidebarWidth);}},[sidebarWidth,storedWidths.sidebar]);React5.useEffect(()=>setSidebarExpanded(sidebarDefaultOpen),[sidebarDefaultOpen]);React5.useEffect(()=>{if(typeof detailsWidth==="number"){setDetailsPixelWidth(storedWidths.details??detailsWidth);}},[detailsWidth,storedWidths.details]);React5.useEffect(()=>{if(!responsive)return void 0;const updateViewport=()=>{const viewport=initialMeasuredSize();setMeasuredSize({width:responsiveWidth??viewport.width,height:responsiveHeight??viewport.height});};if(responsiveMeasurement==="viewport"||responsiveWidth!==void 0||responsiveHeight!==void 0){updateViewport();if(responsiveWidth!==void 0&&responsiveHeight!==void 0){return void 0}window.addEventListener("resize",updateViewport);window.visualViewport?.addEventListener("resize",updateViewport);return ()=>{window.removeEventListener("resize",updateViewport);window.visualViewport?.removeEventListener("resize",updateViewport);}}const root=rootRef.current;if(!root)return void 0;const updateContainer=()=>{const rect=root.getBoundingClientRect();setMeasuredSize({width:rect.width,height:rect.height});};updateContainer();if(typeof ResizeObserver==="undefined"){window.addEventListener("resize",updateContainer);return ()=>window.removeEventListener("resize",updateContainer)}const observer=new ResizeObserver(updateContainer);observer.observe(root);return ()=>observer.disconnect()},[responsive,responsiveHeight,responsiveMeasurement,responsiveWidth]);const layout=responsive?resolveAgentWorkbenchShellLayout(responsiveWidth??measuredSize.width,breakpoints):"wide";const lowHeight=responsive&&(responsiveHeight??measuredSize.height)<=breakpoints.lowHeight;React5.useEffect(()=>onLayoutChange?.(layout),[layout,onLayoutChange]);const hasSidebar=sidebar!==void 0&&sidebarOpen;const hasDetails=details!==void 0&&detailsOpen;const sidebarUsesOverlay=layout==="drawer"||layout==="mobile";const inlineSidebar=hasSidebar&&sidebarExpanded&&!sidebarUsesOverlay;const inlineDetails=hasDetails&&layout==="wide";const resolvedSidebarMax=Math.max(sidebarMinWidth,Math.min(sidebarMaxWidth,layout==="compact"?320:sidebarMaxWidth,measuredSize.width-(inlineDetails?detailsPixelWidth:0)-mainMinWidth));const resolvedDetailsMax=Math.max(detailsMinWidth,Math.min(detailsMaxWidth,measuredSize.width-(inlineSidebar?sidebarPixelWidth:0)-mainMinWidth));const resolvedSidebarWidth=typeof sidebarWidth==="number"?clamp(sidebarPixelWidth,sidebarMinWidth,resolvedSidebarMax):sidebarWidth;const resolvedDetailsWidth=typeof detailsWidth==="number"?clamp(detailsPixelWidth,detailsMinWidth,resolvedDetailsMax):detailsWidth;const requestOverlay=React5.useCallback(region=>{if(!overlayGroupId||typeof window==="undefined")return;window.dispatchEvent(new CustomEvent(OVERLAY_EVENT,{detail:{groupId:overlayGroupId,ownerId:shellId,region}}));},[overlayGroupId,shellId]);React5.useEffect(()=>{if(!overlayGroupId||typeof window==="undefined")return void 0;const handleOverlayOpen=event=>{const detail=event.detail;if(detail?.groupId!==overlayGroupId||detail?.ownerId===shellId)return;setSidebarOverlayOpen(false);setDetailsOverlayOpen(open=>{if(open)onDetailsOpenChange?.(false);return false});};window.addEventListener(OVERLAY_EVENT,handleOverlayOpen);return ()=>window.removeEventListener(OVERLAY_EVENT,handleOverlayOpen)},[onDetailsOpenChange,overlayGroupId,shellId]);React5.useEffect(()=>{if(inlineSidebar||!hasSidebar)setSidebarOverlayOpen(false);},[hasSidebar,inlineSidebar]);React5.useEffect(()=>{if(inlineDetails||!hasDetails){setDetailsOverlayOpen(false);return}rememberReturnFocus("details");requestOverlay("details");setDetailsOverlayOpen(true);},[hasDetails,inlineDetails,rememberReturnFocus,requestOverlay]);const persistWidths=React5.useCallback((sidebarValue,detailsValue)=>{writeStoredWidths(widthStorageKey,{sidebar:sidebarValue,details:detailsValue});},[widthStorageKey]);const updateRegionWidth=React5.useCallback((region,value)=>{if(region==="sidebar"){const next2=clamp(value,sidebarMinWidth,resolvedSidebarMax);setSidebarPixelWidth(next2);onSidebarWidthChange?.(next2);return next2}const next=clamp(value,detailsMinWidth,resolvedDetailsMax);setDetailsPixelWidth(next);onDetailsWidthChange?.(next);return next},[detailsMinWidth,onDetailsWidthChange,onSidebarWidthChange,resolvedDetailsMax,resolvedSidebarMax,sidebarMinWidth]);const beginResize=React5.useCallback((region,event)=>{if(!resizable||event.button!==0)return;event.preventDefault();const startX=event.clientX;const startWidth=region==="sidebar"?sidebarPixelWidth:detailsPixelWidth;let latestWidth=startWidth;const previousCursor=document.body.style.cursor;const previousUserSelect=document.body.style.userSelect;document.body.style.cursor="col-resize";document.body.style.userSelect="none";const handleMove=pointerEvent=>{const delta=pointerEvent.clientX-startX;latestWidth=updateRegionWidth(region,startWidth+(region==="sidebar"?delta:-delta));};const handleUp=()=>{document.body.style.cursor=previousCursor;document.body.style.userSelect=previousUserSelect;window.removeEventListener("pointermove",handleMove);window.removeEventListener("pointerup",handleUp);persistWidths(region==="sidebar"?latestWidth:sidebarPixelWidth,region==="details"?latestWidth:detailsPixelWidth);};window.addEventListener("pointermove",handleMove);window.addEventListener("pointerup",handleUp,{once:true});},[detailsPixelWidth,persistWidths,resizable,sidebarPixelWidth,updateRegionWidth]);const resizeWithKeyboard=React5.useCallback((region,direction)=>{const current=region==="sidebar"?sidebarPixelWidth:detailsPixelWidth;const next=updateRegionWidth(region,current+direction*16);persistWidths(region==="sidebar"?next:sidebarPixelWidth,region==="details"?next:detailsPixelWidth);},[detailsPixelWidth,persistWidths,sidebarPixelWidth,updateRegionWidth]);const shellStyle={"--agent-workbench-sidebar-width":inlineSidebar?cssSize(resolvedSidebarWidth):"0px","--agent-workbench-details-width":inlineDetails?cssSize(resolvedDetailsWidth):"0px",gridTemplateColumns:inlineSidebar&&inlineDetails?"var(--agent-workbench-sidebar-width) minmax(0, 1fr) var(--agent-workbench-details-width)":inlineSidebar?"var(--agent-workbench-sidebar-width) minmax(0, 1fr)":inlineDetails?"minmax(0, 1fr) var(--agent-workbench-details-width)":"minmax(0, 1fr)",...style};const sidebarOverlay=hasSidebar&&sidebarUsesOverlay;const sidebarRestoreControl=hasSidebar&&!sidebarExpanded&&!sidebarUsesOverlay;const detailsOverlay=hasDetails&&!inlineDetails;const showControls=responsive&&showResponsiveControls&&(sidebarOverlay||sidebarRestoreControl||detailsOverlay);const mobilePanel=layout==="mobile";const controlSize=mobilePanel?"size-11":"size-9";const panelCloseClass=mobilePanel?"[&>button]:flex [&>button]:size-11 [&>button]:items-center [&>button]:justify-center":"";return jsxRuntime.jsxs("div",{...rootProps,ref:rootRef,role:rootProps.role??"region","aria-label":rootProps["aria-label"]??"Agent workbench","data-agent-workbench-shell":"true","data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-layout":layout,"data-agent-workbench-low-height":lowHeight?"true":"false","data-sidebar-open":hasSidebar?"true":"false","data-sidebar-expanded":sidebarExpanded?"true":"false","data-sidebar-presentation":inlineSidebar?"inline":sidebarOverlay?"overlay":"hidden","data-details-open":hasDetails?"true":"false","data-details-presentation":inlineDetails?"inline":detailsOverlay?"overlay":"hidden",className:cn2("relative grid size-full min-h-0 min-w-0 overflow-hidden bg-background text-foreground",classNames?.root,className),style:shellStyle,children:[inlineSidebar?jsxRuntime.jsx("div",{"data-agent-workbench-region":"sidebar",className:cn2("min-h-0 min-w-0 overflow-hidden border-r border-border bg-card text-card-foreground",classNames?.sidebar),children:sidebar}):null,jsxRuntime.jsxs("div",{"data-agent-workbench-region":"main",className:cn2("flex min-h-0 min-w-0 flex-col overflow-hidden bg-background",classNames?.main),children:[showControls?jsxRuntime.jsxs("div",{"data-agent-workbench-responsive-controls":"true",className:cn2("flex min-h-11 shrink-0 items-center gap-1 border-b border-border bg-background px-2",lowHeight&&"min-h-10",classNames?.controls),children:[sidebarOverlay||sidebarRestoreControl?jsxRuntime.jsx("button",{type:"button",className:cn2("inline-flex items-center justify-center rounded-[var(--radius)] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",controlSize),"aria-label":labels?.openSidebar??"Open navigation","aria-expanded":sidebarRestoreControl?sidebarExpanded:sidebarOverlayOpen,onClick:event=>{if(sidebarRestoreControl){setSidebarExpanded(true);return}rememberReturnFocus("sidebar",event.currentTarget);requestOverlay("sidebar");setSidebarOverlayOpen(true);},children:jsxRuntime.jsx(lucideReact.PanelLeft,{className:"size-5","aria-hidden":"true"})}):null,detailsOverlay&&details?jsxRuntime.jsx("button",{type:"button",className:cn2("ml-auto inline-flex items-center justify-center rounded-[var(--radius)] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",controlSize),"aria-label":labels?.openDetails??"Open details","aria-expanded":detailsOverlayOpen,onClick:event=>{rememberReturnFocus("details",event.currentTarget);requestOverlay("details");setDetailsOverlayOpen(true);},children:jsxRuntime.jsx(lucideReact.PanelRight,{className:"size-5","aria-hidden":"true"})}):null]}):null,jsxRuntime.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children})]}),inlineDetails?jsxRuntime.jsx("div",{"data-agent-workbench-region":"details",className:cn2("min-h-0 min-w-0 overflow-hidden border-l border-border bg-card text-card-foreground",classNames?.details),children:details}):null,resizable&&inlineSidebar&&typeof sidebarWidth==="number"?jsxRuntime.jsx("button",{type:"button",role:"separator","aria-orientation":"vertical","aria-label":labels?.resizeSidebar??"Resize navigation","aria-valuemin":sidebarMinWidth,"aria-valuemax":resolvedSidebarMax,"aria-valuenow":Number(resolvedSidebarWidth),className:cn2("absolute inset-y-0 z-20 w-2 -translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-border after:transition-colors hover:after:bg-primary focus-visible:after:w-0.5 focus-visible:after:bg-ring",classNames?.resizeHandle),style:{left:"var(--agent-workbench-sidebar-width)"},onPointerDown:event=>beginResize("sidebar",event),onKeyDown:event=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault();resizeWithKeyboard("sidebar",event.key==="ArrowRight"?1:-1);}}):null,resizable&&inlineDetails&&typeof detailsWidth==="number"?jsxRuntime.jsx("button",{type:"button",role:"separator","aria-orientation":"vertical","aria-label":labels?.resizeDetails??"Resize details","aria-valuemin":detailsMinWidth,"aria-valuemax":resolvedDetailsMax,"aria-valuenow":Number(resolvedDetailsWidth),className:cn2("absolute inset-y-0 right-[var(--agent-workbench-details-width)] z-20 w-2 translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-border after:transition-colors hover:after:bg-primary focus-visible:after:w-0.5 focus-visible:after:bg-ring",classNames?.resizeHandle),onPointerDown:event=>beginResize("details",event),onKeyDown:event=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault();resizeWithKeyboard("details",event.key==="ArrowLeft"?1:-1);}}):null,sidebarOverlay?jsxRuntime.jsx(Sheet,{open:sidebarOverlayOpen,onOpenChange:open=>{setSidebarOverlayOpen(open);if(!open)restoreReturnFocus("sidebar");},children:jsxRuntime.jsxs(SheetContent,{side:"left","aria-describedby":void 0,className:cn2("flex h-dvh flex-col gap-0 overflow-hidden bg-card p-0 text-card-foreground",mobilePanel?"inset-0 size-dvw !max-w-none border-0":"w-[min(360px,90vw)] !max-w-none",panelCloseClass,classNames?.sidebarOverlay),children:[jsxRuntime.jsx(SheetTitle,{className:"sr-only",children:labels?.sidebar??"Navigation"}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:sidebar})]})}):null,detailsOverlay?jsxRuntime.jsx(Sheet,{open:detailsOverlayOpen,onOpenChange:open=>{setDetailsOverlayOpen(open);if(!open){restoreReturnFocus("details");onDetailsOpenChange?.(false);}},children:jsxRuntime.jsxs(SheetContent,{side:"right","aria-describedby":void 0,className:cn2("flex h-dvh flex-col gap-0 overflow-hidden bg-card p-0 text-card-foreground",mobilePanel?"inset-0 size-dvw !max-w-none border-0":"w-[min(520px,92vw)] !max-w-none",panelCloseClass,classNames?.detailsOverlay),children:[jsxRuntime.jsx(SheetTitle,{className:"sr-only",children:labels?.details??"Details"}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:details})]})}):null]})}function formatDuration3(durationMs){const totalSeconds=Math.max(0,Math.floor(durationMs/1e3));const hours=Math.floor(totalSeconds/3600);const minutes=Math.floor(totalSeconds%3600/60);const seconds=totalSeconds%60;if(hours>0)return minutes>0?`${hours}h ${minutes}m`:`${hours}h`;if(minutes===0)return `${seconds}s`;return `${minutes}m ${seconds}s`}function isActive(status){return status==="queued"||status==="running"||status==="waiting_approval"}function AgentWorkbenchProcess({status,children,durationMs,completedCount,totalCount,open,defaultOpen,onOpenChange,className,contentClassName,label,title:processTitle,createdAt,showStatusIcon=true,variant,density}){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const messages=useMonkeysLocaleMessages().agentWorkbench;const controlled=open!==void 0;const[internalOpen,setInternalOpen]=React5.useState(defaultOpen??isActive(status));const userChangedOpen=React5.useRef(false);const previousStatus=React5.useRef(status);const resolvedOpen=controlled?open:internalOpen;React5.useEffect(()=>{if(controlled||userChangedOpen.current||previousStatus.current===status)return;previousStatus.current=status;setInternalOpen(isActive(status));},[controlled,status]);const handleOpenChange=nextOpen=>{userChangedOpen.current=true;if(!controlled)setInternalOpen(nextOpen);onOpenChange?.(nextOpen);};const duration=durationMs===void 0?void 0:formatDuration3(durationMs);const title=label??(status==="queued"?messages.process.queued:status==="waiting_approval"?messages.process.waitingApproval:status==="running"?messages.process.running:status==="failed"?messages.process.failed:status==="stopped"?messages.process.stopped:duration?messages.process.processedFor({duration}):messages.process.processed);const showCount=totalCount!==void 0&&totalCount>0;const displayTitle=processTitle??title;const parsedCreatedAt=createdAt?new Date(createdAt):void 0;const createdTime=parsedCreatedAt&&Number.isFinite(parsedCreatedAt.getTime())?parsedCreatedAt.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false}):void 0;const hasProcessDetails=processTitle!==void 0&&(createdTime!==void 0||label!==void 0);return jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Root,{open:resolvedOpen,onOpenChange:handleOpenChange,className:cn2("group/process w-full min-w-0",className),"data-agent-process-status":status,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"aria-busy":isActive(status)?"true":void 0,children:[jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Trigger,{className:cn2("flex w-full min-w-0 items-center gap-2 border-b border-border/70 text-left text-sm text-muted-foreground outline-hidden transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",compact?"min-h-8 py-1.5":"min-h-9 py-2"),children:[showStatusIcon?status==="running"||status==="queued"?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}):status==="waiting_approval"?jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 shrink-0 text-warning-foreground","aria-hidden":"true"}):status==="failed"?jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-4 shrink-0 text-destructive-text","aria-hidden":"true"}):status==="completed"?jsxRuntime.jsx(lucideReact.Check,{className:"size-4 shrink-0 text-success","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:hasProcessDetails?jsxRuntime.jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxRuntime.jsxs("span",{className:"flex min-w-0 items-center gap-2 truncate",children:[jsxRuntime.jsx("span",{className:"truncate",children:displayTitle}),createdTime?jsxRuntime.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/70",children:createdTime}):null]}),label?jsxRuntime.jsx("span",{className:"truncate text-xs text-muted-foreground/70",children:label}):null]}):title}),showCount?jsxRuntime.jsx("span",{className:"shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground",children:messages.process.completedCount({completed:completedCount??0,total:totalCount})}):null,jsxRuntime.jsx(lucideReact.ChevronRight,{className:"size-4 shrink-0 transition-transform group-data-[state=open]/process:rotate-90","aria-hidden":"true"})]}),jsxRuntime.jsx(CollapsiblePrimitive__namespace.Content,{className:cn2("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",contentClassName),children:jsxRuntime.jsx("div",{className:cn2("flex min-w-0 flex-col",compact?"gap-2 py-3":"gap-3 py-4"),children})})]})}var ACTION_ICONS={read:lucideReact.BookOpen,search:lucideReact.Search,tool:lucideReact.Wrench,command:lucideReact.TerminalSquare,file:lucideReact.FileText};function ActionStatusIcon({status}){if(status==="running"||status==="pending"){return jsxRuntime.jsx(lucideReact.Loader2,{className:"size-3.5 shrink-0 animate-spin","aria-hidden":"true"})}if(status==="failed"||status==="denied"){return jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-3.5 shrink-0 text-destructive-text","aria-hidden":"true"})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.Check,{className:"size-3.5 shrink-0","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-3.5 shrink-0","aria-hidden":"true"})}function AgentWorkbenchAction({summary,kind="tool",status="completed",children,open,defaultOpen=false,onOpenChange,icon,className,contentClassName}){const Icon2=icon??ACTION_ICONS[kind];const row=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:summary}),jsxRuntime.jsx(ActionStatusIcon,{status}),children?jsxRuntime.jsx(lucideReact.ChevronRight,{className:"size-3.5 shrink-0 transition-transform group-data-[state=open]/action:rotate-90","aria-hidden":"true"}):null]});if(!children){return jsxRuntime.jsx("div",{className:cn2("flex min-h-7 min-w-0 items-center gap-2 text-[13px] text-muted-foreground",className),"data-agent-action-status":status,children:row})}return jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Root,{open,defaultOpen,onOpenChange,className:cn2("group/action min-w-0",className),"data-agent-action-status":status,children:[jsxRuntime.jsx(CollapsiblePrimitive__namespace.Trigger,{className:"flex min-h-7 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground outline-hidden hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:row}),jsxRuntime.jsx(CollapsiblePrimitive__namespace.Content,{className:"overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",children:jsxRuntime.jsx("div",{className:cn2("ml-6 mt-2 min-w-0 border-l border-border pl-3",contentClassName),children})})]})}var ARTIFACT_ICONS={audio:lucideReact.Music2,file:lucideReact.File,html:lucideReact.FileCode2,image:lucideReact.FileImage,markdown:lucideReact.FileText,pdf:lucideReact.FileText,presentation:lucideReact.Presentation,video:lucideReact.Film,web:lucideReact.Globe2};function ArtifactThumbnail({artifact}){const[thumbnailFailed,setThumbnailFailed]=React5.useState(false);if(artifact.status==="loading"){return jsxRuntime.jsx("span",{className:"size-7 shrink-0 animate-pulse rounded bg-muted","aria-hidden":"true"})}if(artifact.status==="error"){return jsxRuntime.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded bg-destructive/10 text-destructive-text",children:jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"size-4","aria-hidden":"true"})})}if(artifact.thumbnailUrl&&!thumbnailFailed){return jsxRuntime.jsx("img",{src:artifact.thumbnailUrl,alt:"",loading:"lazy",className:"size-7 shrink-0 rounded object-cover",onError:()=>setThumbnailFailed(true)})}const Icon2=ARTIFACT_ICONS[artifact.kind];return jsxRuntime.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded bg-muted text-muted-foreground",children:jsxRuntime.jsx(Icon2,{className:"size-4","aria-hidden":"true"})})}function ArtifactGroup({title,artifacts,maxItems,onArtifactOpen}){return jsxRuntime.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[jsxRuntime.jsx("div",{role:"heading","aria-level":2,className:"text-sm font-medium text-muted-foreground",children:title}),artifacts.slice(0,maxItems).map(artifact=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"h-auto min-w-0 justify-start gap-2 px-0.5 py-0.5 text-left text-sm font-normal disabled:cursor-default",disabled:!onArtifactOpen||artifact.status==="loading",onClick:()=>onArtifactOpen?.(artifact),children:[jsxRuntime.jsx(ArtifactThumbnail,{artifact}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:artifact.name})]},artifact.id))]})}function AgentWorkbenchArtifactSummary({artifacts,open,defaultOpen=false,maxItemsPerGroup=3,showAll=false,className,contentClassName,onOpenChange,onArtifactOpen,onViewAll}){const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const outputs=artifacts.filter(artifact=>artifact.origin==="output");const sources=artifacts.filter(artifact=>artifact.origin==="source");if(artifacts.length===0)return null;return jsxRuntime.jsxs(PopoverPrimitive__namespace.Root,{open,defaultOpen,onOpenChange,children:[jsxRuntime.jsx(PopoverPrimitive__namespace.Trigger,{type:"button",className:cn2("flex size-9 items-center justify-center rounded-xl bg-muted text-muted-foreground outline-hidden transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:text-foreground",className),"aria-label":messages.toggleSummary,children:jsxRuntime.jsx(lucideReact.ListFilter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsxs(PopoverPrimitive__namespace.Content,{"aria-label":messages.toggleSummary,side:"bottom",align:"end",sideOffset:8,collisionPadding:12,className:cn2("z-50 w-[min(22rem,calc(100vw-1.5rem))] rounded-3xl border border-border bg-popover p-4 text-popover-foreground shadow-xl outline-hidden",contentClassName),children:[jsxRuntime.jsxs("div",{className:"flex max-h-[min(34rem,calc(100vh-5rem))] min-w-0 flex-col gap-4 overflow-y-auto",children:[outputs.length>0?jsxRuntime.jsx(ArtifactGroup,{title:messages.outputs,artifacts:outputs,maxItems:showAll?outputs.length:maxItemsPerGroup,onArtifactOpen}):null,outputs.length>0&&sources.length>0?jsxRuntime.jsx("div",{className:"h-px bg-border"}):null,sources.length>0?jsxRuntime.jsx(ArtifactGroup,{title:messages.sources,artifacts:sources,maxItems:showAll?sources.length:maxItemsPerGroup,onArtifactOpen}):null,onViewAll&&!showAll&&(outputs.length>maxItemsPerGroup||sources.length>maxItemsPerGroup)?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"min-h-8 gap-2 px-0 text-sm text-muted-foreground hover:text-foreground",onClick:onViewAll,children:[jsxRuntime.jsx(lucideReact.Link2,{className:"size-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.viewAll})]}):null]}),jsxRuntime.jsx(PopoverPrimitive__namespace.Arrow,{className:"fill-popover"})]})]})}var ARTIFACT_ICONS2={audio:lucideReact.Music2,file:lucideReact.File,html:lucideReact.FileCode2,image:lucideReact.FileImage,markdown:lucideReact.FileText,pdf:lucideReact.FileText,presentation:lucideReact.Presentation,video:lucideReact.Film,web:lucideReact.Globe2};function SortableArtifactTab({artifact,selected,onClose}){const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const Icon2=ARTIFACT_ICONS2[artifact.kind];const{attributes,listeners,setNodeRef,setActivatorNodeRef,transform,transition,isDragging}=sortable.useSortable({id:artifact.id});const{role:_sortableRole,tabIndex:_sortableTabIndex,...sortableA11y}=attributes;const setTabRef=node=>{setNodeRef(node);setActivatorNodeRef(node);};const handleMouseDown=event=>{if(event.button!==1)return;event.preventDefault();onClose();};const handleClick=event=>{if(!(event.target instanceof Element)||!event.target.closest("[data-close-artifact-tab]"))return;event.preventDefault();onClose();};const handleKeyDown=event=>{listeners?.onKeyDown?.(event);if(event.key!=="Delete"&&event.key!=="Backspace")return;event.preventDefault();onClose();};return jsxRuntime.jsxs(TabsPrimitive__namespace.Trigger,{ref:setTabRef,value:artifact.id,style:{transform:utilities.CSS.Transform.toString(transform),transition},className:cn2("group/tab relative flex h-9 max-w-56 shrink-0 items-center gap-2 rounded-lg pl-3 pr-8 text-sm outline-hidden focus-visible:ring-2 focus-visible:ring-ring",selected?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60",isDragging&&"opacity-60"),onMouseDown:handleMouseDown,onClick:handleClick,...sortableA11y,...listeners,onKeyDown:handleKeyDown,children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"truncate",children:artifact.name}),jsxRuntime.jsx("span",{className:"absolute right-1.5 flex size-6 items-center justify-center rounded-md opacity-0 hover:bg-muted group-focus/tab:opacity-100 group-hover/tab:opacity-100 data-[selected=true]:opacity-100","data-selected":selected,"data-close-artifact-tab":"",title:messages.closeTab({name:artifact.name}),"aria-hidden":"true",children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5","aria-hidden":"true"})})]})}function AgentWorkbenchArtifactWorkspace({artifacts,activeArtifactId,className,variant,density,renderArtifact,onIntent}){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const activeArtifact=artifacts.find(artifact=>artifact.id===activeArtifactId)??artifacts[0];const sensors=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:5}}),core.useSensor(core.KeyboardSensor,{coordinateGetter:sortable.sortableKeyboardCoordinates}));if(!activeArtifact)return null;const handleDragEnd=({active,over})=>{if(!over||active.id===over.id)return;onIntent?.({type:"reorder",artifactId:String(active.id),overArtifactId:String(over.id)});};const artifactContent=activeArtifact.status==="loading"?jsxRuntime.jsx("div",{className:"flex size-full min-h-48 items-center justify-center p-6 text-center",role:"status",children:jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col items-center gap-3 text-sm text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"size-5 animate-spin","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.loading})]})}):activeArtifact.status==="error"?jsxRuntime.jsx("div",{className:"flex size-full min-h-48 items-center justify-center p-6 text-center",role:"alert",children:jsxRuntime.jsxs("div",{className:"flex min-w-0 max-w-sm flex-col items-center gap-3",children:[jsxRuntime.jsx("span",{className:"flex size-10 items-center justify-center rounded-full bg-destructive/10 text-destructive-text",children:jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"size-5","aria-hidden":"true"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"break-words text-sm font-medium text-foreground [overflow-wrap:anywhere]",children:messages.failed}),activeArtifact.description?jsxRuntime.jsx("p",{className:"mt-1 max-h-24 overflow-auto whitespace-pre-wrap break-words text-sm text-muted-foreground [overflow-wrap:anywhere]",children:activeArtifact.description}):null]}),onIntent?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>onIntent({type:"retry",artifactId:activeArtifact.id}),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-4","aria-hidden":"true"}),messages.retry]}):null]})}):renderArtifact(activeArtifact);return jsxRuntime.jsxs(TabsPrimitive__namespace.Root,{value:activeArtifact.id,onValueChange:artifactId=>onIntent?.({type:"select",artifactId}),"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":activeArtifact.status,"data-agent-workbench-surface":"panel",className:cn2("flex size-full min-h-0 min-w-0 flex-col bg-card text-card-foreground",className),orientation:"horizontal",children:[jsxRuntime.jsxs("div",{className:cn2("relative z-10 flex shrink-0 items-center gap-2 border-b border-border bg-muted/40 px-2",compact?"h-10":"h-12"),children:[jsxRuntime.jsx(core.DndContext,{sensors,collisionDetection:core.closestCenter,onDragEnd:handleDragEnd,children:jsxRuntime.jsx(sortable.SortableContext,{items:artifacts.map(artifact=>artifact.id),strategy:sortable.horizontalListSortingStrategy,children:jsxRuntime.jsx(TabsPrimitive__namespace.List,{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","aria-label":messages.tabs,children:artifacts.map(artifact=>jsxRuntime.jsx(SortableArtifactTab,{artifact,selected:artifact.id===activeArtifact.id,onClose:()=>onIntent?.({type:"close",artifactId:artifact.id})},artifact.id))})})}),jsxRuntime.jsxs("div",{className:"relative z-20 flex shrink-0 items-center gap-2",children:[activeArtifact.url?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.download({name:activeArtifact.name}),onClick:()=>onIntent?.({type:"download",artifactId:activeArtifact.id}),children:jsxRuntime.jsx(lucideReact.Download,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.openExternal({name:activeArtifact.name}),onClick:()=>onIntent?.({type:"open-external",artifactId:activeArtifact.id}),children:jsxRuntime.jsx(lucideReact.ExternalLink,{className:"size-4","aria-hidden":"true"})})]}):null,jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.closeWorkspace,onClick:()=>onIntent?.({type:"close-workspace"}),children:jsxRuntime.jsx(lucideReact.PanelRightClose,{className:"size-4","aria-hidden":"true"})})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:artifacts.map(artifact=>jsxRuntime.jsx(TabsPrimitive__namespace.Content,{value:artifact.id,className:"size-full min-h-0 min-w-0 outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:artifact.id===activeArtifact.id?artifactContent:null},artifact.id))})]})}
|
|
56
|
+
var enUS={locale:"en-US",messages:{pagination:{navigation:"Pagination",first:"First",previous:"Previous",next:"Next",last:"Last",page:({page,pageCount})=>`Page ${page} of ${pageCount}`,currentPage:({page,pageCount})=>`Page ${page} of ${pageCount}, current page`,emptyResults:"0 results",range:({start,end,total})=>`${start}-${end} of ${total}`,selected:({count})=>`${count} selected`,pageSize:"Items per page",loadBatchSize:"Items per load",perLoad:"Items per load",jumpToPage:"Jump to page",pages:"pages",clickToJump:"Click to jump to a page"},dialog:{close:"Close dialog"},dropdownMenu:{actions:"Actions"},loading:{spinner:"Loading"},layout:{resizePanels:"Resize panels",expandPanel:"Expand",collapsePanel:"Collapse",movePanel:"Move",moveBefore:"Move earlier",moveAfter:"Move later"},steps:{label:"Progress",current:"Current",completed:"Completed",error:"Error",disabled:"Disabled"},numberInput:{increment:"Increase value",decrement:"Decrease value"},passwordInput:{showPassword:"Show password",hidePassword:"Hide password"},multiSelect:{placeholder:"Select options",empty:"No options",removeOption:({value})=>`Remove ${value}`},table:{dragColumn:({columnId})=>`Drag column ${columnId}`,resizeColumn:({columnId})=>`Resize column ${columnId}`,sortColumn:({columnId})=>columnId?`Sort column ${columnId}`:"Sort column",loadingRow:"Loading table row"},toolbar:{theme:{label:"Appearance",toggle:"Toggle theme",auto:"Auto",light:"Light",dark:"Dark"},language:{label:"Language",switch:"Switch language"}},toast:{errorTitle:"Error",warningTitle:"Warning",defaultErrorDescription:"Something went wrong.",defaultWarningDescription:"Please check and try again."},dataExplorer:{viewTree:{actions:"More actions",expand:"Expand",collapse:"Collapse",loading:"Loading...",empty:"No views",error:"Unable to load views"}},workbench:{relationshipGraph:{zoomOut:"Zoom out",zoomIn:"Zoom in",zoomToFit:"Fit graph",minimap:"Graph overview"},collection:{label:"Collection",loading:"Loading items",empty:"No items",loadError:"Unable to load items",refreshError:"Unable to refresh items",retry:"Retry",loadingMore:"Loading more items",permission:"You do not have permission to view this content",offline:"You appear to be offline",requestAccess:"Request access"},interactiveTable:{columnActions:"Column actions",freezeColumn:"Freeze to left",freezeEndColumn:"Freeze to right",unfreezeColumn:"Unfreeze from left",unfreezeEndColumn:"Unfreeze from right",unfreezeAllColumns:"Unfreeze all columns",resetColumnWidth:"Reset column width",frozenColumnTitle:"Frozen column"}},agentWorkbench:{label:"Session activity",reasoning:"Reasoning",plan:"Plan",taskNoDetail:"No additional details",modes:{chat:"Chat",work:"Work"},composer:{send:"Send message",stop:"Stop generating",queue:"Queue message",attach:"Add photos or files",voice:"Start voice input",webSearch:"Web search",chatMode:"Chat mode",model:"Model",reasoning:"Reasoning effort",permissions:"Permissions",removeAttachment:"Remove attachment",editQueued:"Edit queued message",deleteQueued:"Delete queued message",moveUp:"Move message up",moveDown:"Move message down",queued:"Queued messages",uploading:"Uploading",uploadFailed:"Upload failed",retryAttachment:"Retry attachment upload",noModels:"No models available",message:"Message",attachmentOnly:"Attachment",reasoningOptions:{low:"Low",medium:"Medium",high:"High",xhigh:"Extra high"},permissionOptions:{"approval-required":"Approval required","auto-approve":"Auto approve","full-access":"Full access"}},quickStart:{label:"Quick start",back:"Back",addFile:"Add file"},tool:{input:"Input",output:"Output",status:{pending:"Pending",running:"Running",completed:"Completed",failed:"Error",denied:"Denied"}},approval:{approve:"Approve",reject:"Reject",approved:"Approved",rejected:"Rejected"},artifact:{pending:"Preparing",ready:"Ready",failed:"Failed",open:({name})=>`Open ${name}`},run:{stopping:"Stopping...",stoppedAfter:({duration})=>`You stopped after ${duration}`},process:{running:"Working",queued:"Queued",waitingApproval:"Waiting for approval",failed:"Failed",stopped:"Stopped",processed:"Processed",processedFor:({duration})=>`Worked for ${duration}`,completedCount:({completed,total})=>`${completed}/${total} completed`},artifactWorkspace:{outputs:"Outputs",sources:"Sources",viewAll:"View all",toggleSummary:"Toggle files",tabs:"Open files",closeTab:({name})=>`Close ${name}`,closeWorkspace:"Close workspace",download:({name})=>`Download ${name}`,openExternal:({name})=>`Open ${name} in a new window`,loading:"Loading preview...",failed:"Preview unavailable",retry:"Try again"},usage:{label:"Context usage",context:({used,total})=>`${used} / ${total} tokens`},navigation:{search:"Search agents and sessions",searchSessions:"Search sessions",searchShortcut:"Focus search",clearSearch:"Clear search",tabsLabel:"Agent workbench navigation",agents:"Agents",sessions:"Sessions",newAgent:"New Agent",newSession:"New Session",capabilities:"Capabilities & Extensions",settings:"Agent Settings",allAgents:"All Agents",recentSessions:"Recent Sessions",chat:"Chat",work:"Work",chats:"Chats",builtIn:"Built-in",noDescription:"No description",loading:"Loading...",emptyAgents:"No agents yet",emptySessions:"No sessions yet",noResults:"No matching results",retry:"Retry",pin:"Pin",unpin:"Unpin",rename:"Rename",delete:"Delete",actions:"Actions",save:"Save",cancel:"Cancel",running:"Running",completed:"Completed",failed:"Failed",contextUsage:({percent})=>`${percent}% context used`},details:{title:"Task details",description:"Summary and workspace activity",duration:"Duration",updated:"Updated",model:"Model",mode:"Mode",permissions:"Permissions",tokenUsage:"Token usage",summary:"Summary",summaryEmpty:"No summary is available yet.",summaryFailed:"The summary could not be generated.",highlights:"Highlights",pendingItems:"Pending items",tabs:{label:"Task detail views",summary:"Summary",workspace:"Workspace"},status:{queued:"Queued",running:"Running",waiting_approval:"Waiting for approval",stopping:"Stopping",stopped:"Stopped",completed:"Completed",failed:"Failed"},state:{loading:{title:"Loading task details",description:"Restoring the latest session activity."},empty:{title:"No task selected",description:"Select a task to inspect its details."},error:{title:"Unable to load task details",description:"Try again after the session is available."}},actions:{close:"Close task details",copySummary:"Copy summary",retry:"Retry",retrySummary:"Retry summary",resume:"Resume",continueInNewTask:"Continue in new task",editAndRerun:"Edit and rerun",export:"Export"},workspace:{diffs:"Code changes",files:"Files",terminals:"Terminals",tests:"Tests",artifacts:"Artifacts",exitCode:({code})=>`Exit code ${code}`,diffStatus:{added:"Added",modified:"Modified",deleted:"Deleted",renamed:"Renamed"},fileOperation:{upsert:"Updated",delete:"Deleted"}}}}}};function mergeMonkeysLocaleMessages(base,override){return base;}var defaultMonkeysLocale={locale:enUS.locale,messages:mergeMonkeysLocaleMessages(enUS.messages)};var EMPTY_ENVIRONMENT=Object.freeze({});var EMPTY_PORTAL=Object.freeze({});var MONKEYS_PROVIDER_CONTEXTS_KEY=Symbol.for("@inf-monkeys-tech/monkeys-design/provider-context@1");function createMonkeysProviderContexts(){return Object.freeze({locale:React5.createContext({...defaultMonkeysLocale,provided:false}),theme:React5.createContext({provided:false}),direction:React5.createContext({provided:false}),environment:React5.createContext({provided:false,environment:EMPTY_ENVIRONMENT,portal:EMPTY_PORTAL})})}function getMonkeysProviderContexts(){const host2=globalThis;const existing=host2[MONKEYS_PROVIDER_CONTEXTS_KEY];if(existing)return existing;const contexts=createMonkeysProviderContexts();Object.defineProperty(host2,MONKEYS_PROVIDER_CONTEXTS_KEY,{value:contexts,enumerable:false,configurable:false,writable:false});return contexts}var providerContexts=getMonkeysProviderContexts();var MonkeysLocaleContext=providerContexts.locale;var MonkeysThemeContext=providerContexts.theme;var MonkeysDirectionContext=providerContexts.direction;providerContexts.environment;function useMonkeysLocale(){try{const context=React5.useContext(MonkeysLocaleContext);return context??{...defaultMonkeysLocale,provided:false}}catch{return {...defaultMonkeysLocale,provided:false}}}function useMonkeysLocaleMessages(){return React5.useContext(MonkeysLocaleContext).messages}function useMonkeysComponentAttributes(){const locale=React5.useContext(MonkeysLocaleContext);const theme=React5.useContext(MonkeysThemeContext);const direction=React5.useContext(MonkeysDirectionContext);const providerActive=locale.provided||theme.provided||direction.provided;return React5.useMemo(()=>providerActive?{dir:direction.direction,"data-monkeys-direction":direction.direction,"data-monkeys-locale":locale.locale,"data-monkeys-theme":theme.themeId,"data-monkeys-theme-mode":theme.resolvedTheme?.colorMode}:{},[direction.direction,locale.locale,providerActive,theme.resolvedTheme?.colorMode,theme.themeId])}function cn(...parts){return tailwindMerge.twMerge(parts.filter(Boolean).join(" "))}var key=Symbol.for("@inf-monkeys-tech/monkeys-design/bento-depth@1");var host=globalThis;var BentoDepth=host[key]??(host[key]=React5.createContext(0));function useBentoDepth(){return React5.useContext(BentoDepth)}function BentoDepthProvider({children,depth}){return jsxRuntime.jsx(BentoDepth.Provider,{value:depth,children})}function BentoScope({children}){return jsxRuntime.jsx(BentoDepthProvider,{depth:0,children})}var overlaySurfaceRoleClassNames={menu:"monkeys-overlay-surface--menu bg-menu-surface text-popover-foreground",dialog:"monkeys-overlay-surface--dialog bg-dialog-surface text-foreground"};function getOverlaySurfaceClassName(role,options={}){return ["monkeys-overlay-surface",overlaySurfaceRoleClassNames[role],options.rounded===false?void 0:"monkeys-overlay-surface--rounded"].filter(Boolean).join(" ")}function cn2(...inputs){return inputs.filter(Boolean).join(" ")}var DEFAULT_APPEARANCE={variant:"default",density:"default"};var AgentWorkbenchAppearanceContext=React5.createContext(DEFAULT_APPEARANCE);function resolveAgentWorkbenchAppearance(inherited,options={}){const variant=options.variant??inherited.variant;return {variant,density:options.density??(options.variant==="trend"?"compact":inherited.density)}}function useAgentWorkbenchAppearance(options={}){return resolveAgentWorkbenchAppearance(React5.useContext(AgentWorkbenchAppearanceContext),options)}function AgentWorkbenchAppearanceProvider({children,variant,density}){const inherited=React5.useContext(AgentWorkbenchAppearanceContext);const appearance=React5.useMemo(()=>resolveAgentWorkbenchAppearance(inherited,{variant,density}),[density,inherited,variant]);return jsxRuntime.jsx(AgentWorkbenchAppearanceContext.Provider,{value:appearance,children})}var SURFACE_CLASSES={page:"bg-background text-foreground",panel:"bg-card text-card-foreground",elevated:"border border-border bg-popover text-popover-foreground shadow-sm",subtle:"bg-muted/40 text-foreground",overlay:"border border-border bg-popover text-popover-foreground shadow-lg"};var AgentWorkbenchSurface=React5.forwardRef(function AgentWorkbenchSurface2({level="panel",variant,density,className,children,...props},ref){const appearance=useAgentWorkbenchAppearance({variant,density});return jsxRuntime.jsx("div",{...props,ref,"data-agent-workbench-surface":level,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,className:cn2(SURFACE_CLASSES[level],className),children})});var useAutosizeTextArea=({textAreaRef,triggerAutoSize,maxHeight=Number.MAX_SAFE_INTEGER,minHeight=0})=>{const[init,setInit]=React5__namespace.useState(true);React5__namespace.useEffect(()=>{const offsetBorder=2;if(textAreaRef){if(init){textAreaRef.style.minHeight=`${minHeight+offsetBorder}px`;if(maxHeight>minHeight){textAreaRef.style.maxHeight=`${maxHeight}px`;}setInit(false);}textAreaRef.style.height=`${minHeight+offsetBorder}px`;const scrollHeight=textAreaRef.scrollHeight;if(scrollHeight>maxHeight){textAreaRef.style.height=`${maxHeight}px`;}else {textAreaRef.style.height=`${scrollHeight+offsetBorder}px`;}}},[textAreaRef,triggerAutoSize]);};var AutosizeTextarea=React5__namespace.forwardRef(({maxHeight=Number.MAX_SAFE_INTEGER,minHeight=52,className,onChange,value,onKeyDown,onSubmit,onCompositionStart:propsOnCompositionStart,onCompositionEnd:propsOnCompositionEnd,...props},ref)=>{const textAreaRef=React5__namespace.useRef(null);const[triggerAutoSize,setTriggerAutoSize]=React5__namespace.useState("");const[isComposing,setIsComposing]=React5__namespace.useState(false);const[compositionValue,setCompositionValue]=React5__namespace.useState("");useAutosizeTextArea({textAreaRef:textAreaRef.current,triggerAutoSize,maxHeight,minHeight});React5.useImperativeHandle(ref,()=>({textArea:textAreaRef.current,focus:()=>textAreaRef.current?.focus(),maxHeight,minHeight}));React5__namespace.useEffect(()=>{setTriggerAutoSize(value);},[props?.defaultValue,value]);const handleKeyDown=React5__namespace.useCallback(e=>{if(e.key==="ArrowUp"&&triggerAutoSize.length<=0&&!(e.metaKey||e.altKey||e.ctrlKey)){e.preventDefault();return}if(onSubmit){const shouldSubmit=e.key==="Enter"&&e.keyCode!==229&&!e.nativeEvent.isComposing&&!isComposing&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey;if(shouldSubmit){e.preventDefault();onSubmit(e);}}onKeyDown?.(e);},[isComposing,onKeyDown,onSubmit,triggerAutoSize.length]);return jsxRuntime.jsx("textarea",{...props,onKeyDown:handleKeyDown,value:typeof value!=="undefined"?isComposing?compositionValue:value??"":void 0,ref:textAreaRef,className:cn("flex w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",className),onCompositionStart:e=>{setIsComposing(true);setCompositionValue(e.currentTarget.value);propsOnCompositionStart?.(e);},onCompositionEnd:e=>{setIsComposing(false);const finalValue=e.currentTarget.value;setCompositionValue(finalValue);setTriggerAutoSize(finalValue);onChange?.(e);propsOnCompositionEnd?.(e);},onChange:e=>{if(e.nativeEvent.isComposing){setCompositionValue(e.target.value);setTriggerAutoSize(e.target.value);return}setTriggerAutoSize(e.target.value);onChange?.(e);}})});AutosizeTextarea.displayName="AutosizeTextarea";var AccordionItem=React5__namespace.forwardRef(({className,style,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Item,{ref,className:cn("border-b",className),style:{borderColor:"var(--monkeys-component-accordion-item-border-color, hsl(var(--border)))",...style},...props}));AccordionItem.displayName="AccordionItem";var AccordionTrigger=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Header,{className:"flex",children:jsxRuntime.jsxs(AccordionPrimitive__namespace.Trigger,{ref,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",className),...props,children:[children,jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));AccordionTrigger.displayName="AccordionTrigger";var AccordionContent=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsx(AccordionPrimitive__namespace.Content,{ref,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...props,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",className),children})}));AccordionContent.displayName="AccordionContent";var Checkbox=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(CheckboxPrimitive__namespace.Root,{ref,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",className),...props,children:jsxRuntime.jsx(CheckboxPrimitive__namespace.Indicator,{className:"flex items-center justify-center text-current",children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}));Checkbox.displayName="Checkbox";var buttonVariants=classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_[data-slot=icon]]:text-[inherit] [&_[data-slot=icon]_*]:!text-[inherit] [&_[data-slot=icon]_svg]:!stroke-current [&_[data-slot=icon]_svg_*]:!stroke-current [&_[data-slot=end-icon]]:text-[inherit] [&_[data-slot=end-icon]_*]:!text-[inherit] [&_[data-slot=end-icon]_svg]:!stroke-current [&_[data-slot=end-icon]_svg_*]:!stroke-current [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-control-surface shadow-sm ring-offset-control-surface hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-sm px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}});var Button=React5__namespace.forwardRef(({className,variant,size,asChild=false,...props},ref)=>{const Component=asChild?reactSlot.Slot:"button";return jsxRuntime.jsx(Component,{ref,className:buttonVariants({variant,size,className}),...props})});Button.displayName="Button";var ScrollArea=React5__namespace.forwardRef(({className,children,viewportClassName,viewportRef,onViewportScroll,scrollbar=true,scrollbarOrientation="vertical",scrollBarDisabled=false,type,...props},ref)=>{const bentoDepth=useBentoDepth();return jsxRuntime.jsxs(ScrollAreaPrimitive__namespace.Root,{ref,type:type??(bentoDepth>0?"auto":void 0),className:cn("group relative overflow-hidden",scrollBarDisabled&&"no-scrollbar",className),...props,children:[jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Viewport,{ref:viewportRef,onScroll:onViewportScroll,className:cn("h-full w-full rounded-[inherit]",viewportClassName),children}),scrollbar?jsxRuntime.jsx(ScrollBar,{orientation:scrollbarOrientation,className:cn(scrollBarDisabled&&"size-0 p-0")}):null,jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner,{})]})});ScrollArea.displayName="ScrollArea";var ScrollBar=React5__namespace.forwardRef(({className,orientation="vertical",...props},ref)=>jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,{ref,"data-monkeys-scrollbar":"",orientation,className:cn("flex touch-none select-none opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 data-[state=visible]:opacity-100",orientation==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-px",orientation==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-px",className),...props,children:jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ScrollBar.displayName="ScrollBar";var Switch=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SwitchPrimitive__namespace.Root,{ref,className:cn("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",className),...props,children:jsxRuntime.jsx(SwitchPrimitive__namespace.Thumb,{className:"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"})}));Switch.displayName="Switch";var Tabs=React5__namespace.forwardRef(({variant="default",...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.Root,{ref,"data-variant":variant,...props}));Tabs.displayName="Tabs";var TabsList=React5__namespace.forwardRef(({className,gap,style,...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.List,{ref,className:cn("inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",className),style:{gap,...style},...props}));TabsList.displayName="TabsList";var TabsTrigger=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(TabsPrimitive__namespace.Trigger,{ref,className:cn("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",className),...props}));TabsTrigger.displayName="TabsTrigger";var TabsContent=React5__namespace.forwardRef(({className,...props},ref)=>{const depth=useBentoDepth();return jsxRuntime.jsx(TabsPrimitive__namespace.Content,{ref,className:cn("mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",depth>0&&"gap-[var(--monkeys-bento-gap)]",className),...props})});TabsContent.displayName="TabsContent";var TooltipContent=React5__namespace.forwardRef(({className,sideOffset=4,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(TooltipPrimitive__namespace.Portal,{children:jsxRuntime.jsx(TooltipPrimitive__namespace.Content,{...componentAttributes,...props,ref,sideOffset,"data-monkeys-component":"tooltip","data-slot":"content","data-surface":"menu",className:cn("z-50 overflow-hidden border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",getOverlaySurfaceClassName("menu"),className)})})});TooltipContent.displayName="TooltipContent";var Input=React5__namespace.forwardRef(({className,appearance="standard",type,...props},ref)=>jsxRuntime.jsx("input",{ref,type,className:cn("flex w-full border border-input bg-control-surface px-3 text-foreground ring-offset-control-surface transition-[border-color,background-color,color,box-shadow] file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",appearance==="compact"?"h-9 rounded-md py-1 text-sm shadow-sm":"h-10 rounded-md py-2 text-sm shadow-sm",appearance==="shadow"&&"rounded-lg shadow-sm shadow-black/[0.02] dark:border-white/10 dark:bg-white/[0.04] dark:shadow-none",className),...props}));Input.displayName="Input";var Textarea=React5__namespace.forwardRef(({className,appearance="standard",...props},ref)=>jsxRuntime.jsx("textarea",{ref,className:cn("flex w-full border border-input bg-control-surface px-3 py-2 text-foreground ring-offset-control-surface placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",appearance==="compact"?"min-h-[60px] rounded-md text-sm shadow-sm":"min-h-[80px] rounded-md text-sm",appearance==="shadow"&&"rounded-lg shadow-sm shadow-black/[0.02] dark:border-white/10 dark:bg-white/[0.04] dark:shadow-none",className),...props}));Textarea.displayName="Textarea";function InputGroup({className,...props}){return jsxRuntime.jsx("div",{"data-slot":"input-group",role:"group",className:cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-hidden transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",className),...props})}var inputGroupAddonVariants=classVarianceAuthority.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function InputGroupAddon({className,align="inline-start",...props}){return jsxRuntime.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":align,className:cn(inputGroupAddonVariants({align}),className),onClick:e=>{if(e.target.closest("button")){return}e.currentTarget.parentElement?.querySelector("input")?.focus();},...props})}var inputGroupButtonVariants=classVarianceAuthority.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function InputGroupButton({className,type="button",variant="ghost",size="xs",...props}){return jsxRuntime.jsx(Button,{type,"data-size":size,variant,className:cn(inputGroupButtonVariants({size}),className),...props})}var InputGroupInput=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(Input,{ref,"data-slot":"input-group-control",className:cn("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",className),...props}));InputGroupInput.displayName="InputGroupInput";var InputGroupTextarea=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(Textarea,{ref,"data-slot":"input-group-control",className:cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",className),...props}));InputGroupTextarea.displayName="InputGroupTextarea";var menuItemClassName="relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";var menuContentClassName=`z-50 min-w-[8rem] overflow-hidden border p-1 ${getOverlaySurfaceClassName("menu")} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`;var DropdownMenu2=DropdownMenuPrimitive__namespace.Root;var DropdownMenuTrigger=DropdownMenuPrimitive__namespace.Trigger;var DropdownMenuSubTrigger=React5__namespace.forwardRef(({className,inset,children,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.SubTrigger,{ref,className:cn(menuItemClassName,"data-[state=open]:bg-accent",inset&&"pl-8",className),...props,children:[children,jsxRuntime.jsx(lucideReact.ChevronRight,{"aria-hidden":"true",className:"ml-auto"})]}));DropdownMenuSubTrigger.displayName="DropdownMenuSubTrigger";var DropdownMenuSubContent=React5__namespace.forwardRef(({className,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DropdownMenuPrimitive__namespace.SubContent,{...componentAttributes,...props,ref,"data-monkeys-component":"dropdown-menu","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,className)})});DropdownMenuSubContent.displayName="DropdownMenuSubContent";var DropdownMenuContent=React5__namespace.forwardRef(({className,sideOffset=4,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal,{children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Content,{...componentAttributes,...props,ref,sideOffset,"data-monkeys-component":"dropdown-menu","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,className)})})});DropdownMenuContent.displayName="DropdownMenuContent";var DropdownMenuItem=React5__namespace.forwardRef(({className,inset,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Item,{ref,className:cn(menuItemClassName,inset&&"pl-8",className),...props}));DropdownMenuItem.displayName="DropdownMenuItem";var DropdownMenuCheckboxItem=React5__namespace.forwardRef(({className,children,checked,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.CheckboxItem,{ref,className:cn(menuItemClassName,"pl-8",className),checked,...props,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}),children]}));DropdownMenuCheckboxItem.displayName="DropdownMenuCheckboxItem";var DropdownMenuRadioItem=React5__namespace.forwardRef(({className,children,...props},ref)=>jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.RadioItem,{ref,className:cn(menuItemClassName,"pl-8",className),...props,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Circle,{"aria-hidden":"true",className:"h-2 w-2 fill-current"})})}),children]}));DropdownMenuRadioItem.displayName="DropdownMenuRadioItem";var DropdownMenuLabel=React5__namespace.forwardRef(({className,inset,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Label,{ref,className:cn("px-2 py-1.5 text-sm font-semibold",inset&&"pl-8",className),...props}));DropdownMenuLabel.displayName="DropdownMenuLabel";var DropdownMenuSeparator=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Separator,{ref,className:cn("-mx-1 my-1 h-px bg-muted",className),...props}));DropdownMenuSeparator.displayName="DropdownMenuSeparator";var Select=SelectPrimitive__namespace.Root;var SelectValue=SelectPrimitive__namespace.Value;var SelectTrigger=React5__namespace.forwardRef(({className,children,iconClassName,size="default",...props},ref)=>jsxRuntime.jsxs(SelectPrimitive__namespace.Trigger,{ref,className:cn("flex h-10 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-control-surface px-3 py-2 text-left text-sm text-foreground shadow-sm ring-offset-control-surface data-[placeholder]:text-muted-foreground focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 [&>span]:min-w-0 [&>span]:flex-1 [&>span]:text-left",size==="sm"&&"h-8 px-2 py-1 text-xs",className),...props,children:[children,jsxRuntime.jsx(SelectPrimitive__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:cn("h-4 w-4 opacity-50",iconClassName)})})]}));SelectTrigger.displayName="SelectTrigger";var SelectScrollUpButton=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.ScrollUpButton,{ref,className:cn("flex cursor-default items-center justify-center py-1",className),...props,children:jsxRuntime.jsx(lucideReact.ChevronUp,{"aria-hidden":"true",className:"h-4 w-4"})}));SelectScrollUpButton.displayName="SelectScrollUpButton";var SelectScrollDownButton=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.ScrollDownButton,{ref,className:cn("flex cursor-default items-center justify-center py-1",className),...props,children:jsxRuntime.jsx(lucideReact.ChevronDown,{"aria-hidden":"true",className:"h-4 w-4"})}));SelectScrollDownButton.displayName="SelectScrollDownButton";var SelectContent=React5__namespace.forwardRef(({className,children,position="popper",viewportClassName,disableTriggerViewportSizing=false,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(SelectPrimitive__namespace.Portal,{children:jsxRuntime.jsxs(SelectPrimitive__namespace.Content,{...componentAttributes,...props,ref,position,"data-monkeys-component":"select","data-slot":"content","data-surface":"menu",className:cn(menuContentClassName,"relative max-h-[var(--radix-select-content-available-height)] overflow-y-auto overflow-x-hidden",position==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",className),children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(SelectPrimitive__namespace.Viewport,{className:cn("p-1",position==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]",position==="popper"&&!disableTriggerViewportSizing&&"h-[var(--radix-select-trigger-height)]",viewportClassName),children}),jsxRuntime.jsx(SelectScrollDownButton,{})]})})});SelectContent.displayName="SelectContent";var SelectLabel=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.Label,{ref,className:cn("px-2 py-1.5 text-sm font-semibold",className),...props}));SelectLabel.displayName="SelectLabel";var SelectItem=React5__namespace.forwardRef(({className,children,indicatorClassName,itemText,hideIndicator=false,...props},ref)=>jsxRuntime.jsxs(SelectPrimitive__namespace.Item,{ref,className:cn(menuItemClassName,"w-full",hideIndicator?"px-2":"pl-8 pr-2",className),...props,children:[!hideIndicator?jsxRuntime.jsx("span",{className:cn("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",indicatorClassName),children:jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":"true",className:"h-4 w-4"})})}):null,itemText?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SelectPrimitive__namespace.ItemText,{asChild:true,children:jsxRuntime.jsx("span",{className:"sr-only",children:itemText})}),children]}):jsxRuntime.jsx(SelectPrimitive__namespace.ItemText,{children})]}));SelectItem.displayName="SelectItem";var SelectSeparator=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(SelectPrimitive__namespace.Separator,{ref,className:cn("-mx-1 my-1 h-px bg-muted",className),...props}));SelectSeparator.displayName="SelectSeparator";var Sheet=DialogPrimitive__namespace.Root;var SheetPortal=DialogPrimitive__namespace.Portal;var SheetOverlay=React5__namespace.forwardRef(({className,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsx(DialogPrimitive__namespace.Overlay,{...componentAttributes,...props,ref,"data-monkeys-component":"sheet","data-slot":"overlay","data-monkeys-overlay":true,className:cn("theme-overlay-backdrop fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",className)})});SheetOverlay.displayName="SheetOverlay";var sideClassNames={top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm"};var SheetContent=React5__namespace.forwardRef(({side="right",className,children,...props},ref)=>{const componentAttributes=useMonkeysComponentAttributes();return jsxRuntime.jsxs(SheetPortal,{children:[jsxRuntime.jsx(SheetOverlay,{}),jsxRuntime.jsxs(DialogPrimitive__namespace.Content,{...componentAttributes,...props,ref,"data-monkeys-component":"sheet","data-slot":"content","data-surface":"dialog","data-monkeys-dialog-content":true,className:cn("fixed z-50 gap-4 p-6 transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",getOverlaySurfaceClassName("dialog",{rounded:false}),sideClassNames[side],className),children:[jsxRuntime.jsxs(DialogPrimitive__namespace.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-dialog-surface transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[jsxRuntime.jsx("svg",{"aria-hidden":"true",className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),jsxRuntime.jsx("span",{className:"sr-only",children:"Close"})]}),jsxRuntime.jsx(BentoScope,{children})]})]})});SheetContent.displayName="SheetContent";var SheetTitle=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DialogPrimitive__namespace.Title,{ref,className:cn("text-lg font-semibold text-foreground",className),...props}));SheetTitle.displayName="SheetTitle";var SheetDescription=React5__namespace.forwardRef(({className,...props},ref)=>jsxRuntime.jsx(DialogPrimitive__namespace.Description,{ref,className:cn("text-sm text-muted-foreground",className),...props}));SheetDescription.displayName="SheetDescription";function ComposerSelect({value,label,placeholder,options,className,onValueChange}){const selectedOption=options.find(option=>option.value===value);return jsxRuntime.jsxs(Select,{value:value||void 0,disabled:options.length===0,onValueChange,children:[jsxRuntime.jsx(SelectTrigger,{size:"sm","aria-label":label,className:cn2("shrink bg-background font-medium",className),children:jsxRuntime.jsx(SelectValue,{placeholder,children:selectedOption?.label})}),jsxRuntime.jsx(SelectContent,{disableTriggerViewportSizing:true,children:options.map(option=>jsxRuntime.jsx(SelectItem,{value:option.value,disabled:option.disabled,children:option.label},option.value))})]})}var EMPTY_COMPOSER_VIEW_MODEL={contract:"AgentWorkbenchComposerViewModel",value:"",status:"idle",mode:"chat",attachments:[],queuedDrafts:[],inputActions:[],model:{options:[]},webSearchEnabled:false,capabilities:{attachments:false,voiceInput:false,webSearch:false,modelSelection:false,reasoning:false,permissions:false,queue:false,stop:false}};function modelOptionValue(option){return `${option.mode}:${option.id}`}function AgentWorkbenchComposer({viewModel=EMPTY_COMPOSER_VIEW_MODEL,disabled=false,modeSelectionEnabled=false,modeFilteringEnabled=false,variant,density,className,classNames,onIntent:emitIntent}){const current=React5.useRef({disabled,emitIntent});current.current={disabled,emitIntent};const onIntent=intent=>{if(!current.current.disabled)current.current.emitIntent?.(intent);};const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const iconButtonClass=cn2(compact?"size-7":"size-8","shrink-0 p-0 text-muted-foreground");const messages=useMonkeysLocaleMessages().agentWorkbench;const fileInputRef=React5.useRef(null);const surfaceRef=React5.useRef(null);const[editingDraftId,setEditingDraftId]=React5.useState();const[editingText,setEditingText]=React5.useState("");const[isNarrow,setIsNarrow]=React5.useState(false);const narrowBreakpoint=modeSelectionEnabled?900:704;const isBusy=viewModel.status==="loading"||viewModel.status==="streaming"||viewModel.status==="stopping";const isStopping=viewModel.status==="stopping";const isUploading=viewModel.attachments.some(attachment=>attachment.status==="uploading");const canSubmit=!disabled&&!isStopping&&!isUploading&&(viewModel.value.trim().length>0||viewModel.attachments.some(item=>item.status==="ready"));const showSubmitButton=!isBusy||canSubmit;const filterModelsByMode=modeSelectionEnabled||modeFilteringEnabled;const visibleModelOptions=React5.useMemo(()=>filterModelsByMode?viewModel.model.options.filter(option=>option.mode===viewModel.mode):viewModel.model.options,[filterModelsByMode,viewModel.mode,viewModel.model.options]);const selectedModelValue=React5.useMemo(()=>{const selected=visibleModelOptions.find(option=>option.id===viewModel.model.selectedId&&option.mode===viewModel.mode);return selected?modelOptionValue(selected):visibleModelOptions[0]?modelOptionValue(visibleModelOptions[0]):""},[viewModel.mode,viewModel.model.selectedId,visibleModelOptions]);const inputActions=viewModel.inputActions||[];const selectedInputActionId=viewModel.selectedInputActionId;React5.useEffect(()=>{const surface=surfaceRef.current;if(!surface)return void 0;const updateLayout=()=>setIsNarrow(surface.getBoundingClientRect().width<=narrowBreakpoint);updateLayout();window.addEventListener("resize",updateLayout);if(typeof ResizeObserver==="undefined"){const interval=window.setInterval(updateLayout,250);return ()=>{window.clearInterval(interval);window.removeEventListener("resize",updateLayout);}}const observer=new ResizeObserver(updateLayout);observer.observe(surface);return ()=>{observer.disconnect();window.removeEventListener("resize",updateLayout);}},[narrowBreakpoint]);const submit=()=>{if(canSubmit)onIntent?.({type:"submit"});};return jsxRuntime.jsx("fieldset",{disabled,className:"min-w-0 border-0 p-0",children:jsxRuntime.jsxs("form",{"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":viewModel.status,className:cn2("agent-workbench-composer flex min-w-0 w-full flex-col",compact?"gap-1.5":"gap-2",className,classNames?.root),"aria-label":messages.composer.message,onSubmit:event=>{event.preventDefault();submit();},children:[viewModel.capabilities.queue&&viewModel.queuedDrafts.length>0?jsxRuntime.jsx("section",{"aria-label":messages.composer.queued,className:cn2("min-w-0 max-w-full rounded-md border border-border bg-muted/40 p-2",classNames?.queue),children:jsxRuntime.jsx("ol",{className:"space-y-1.5",children:viewModel.queuedDrafts.map((draft,index)=>jsxRuntime.jsxs("li",{className:"flex min-h-9 min-w-0 max-w-full items-center gap-2 overflow-hidden rounded-md bg-background px-2 py-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"w-5 shrink-0 text-center text-xs text-muted-foreground",children:index+1}),editingDraftId===draft.id?jsxRuntime.jsx(Input,{autoFocus:true,value:editingText,"aria-label":messages.composer.editQueued,appearance:"compact",className:"h-8 min-w-0 flex-1 px-2 py-1",onChange:event=>setEditingText(event.target.value),onBlur:()=>{if(editingText.trim())onIntent?.({type:"edit-queued-draft",draftId:draft.id,text:editingText});setEditingDraftId(void 0);},onKeyDown:event=>{if(event.key==="Escape")setEditingDraftId(void 0);if(event.key==="Enter"&&editingText.trim()){event.preventDefault();onIntent?.({type:"edit-queued-draft",draftId:draft.id,text:editingText});setEditingDraftId(void 0);}}}):jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:draft.text||messages.composer.attachmentOnly}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.moveUp,disabled:index===0,onClick:()=>onIntent?.({type:"move-queued-draft",draftId:draft.id,direction:"up"}),children:jsxRuntime.jsx(lucideReact.ArrowUp,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.moveDown,disabled:index===viewModel.queuedDrafts.length-1,onClick:()=>onIntent?.({type:"move-queued-draft",draftId:draft.id,direction:"down"}),children:jsxRuntime.jsx(lucideReact.ArrowDown,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.editQueued,onClick:()=>{setEditingDraftId(draft.id);setEditingText(draft.text);},children:jsxRuntime.jsx(lucideReact.Pencil,{className:"size-3.5"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:cn2(iconButtonClass,"text-destructive-text hover:text-destructive-text"),"aria-label":messages.composer.deleteQueued,onClick:()=>onIntent?.({type:"delete-queued-draft",draftId:draft.id}),children:jsxRuntime.jsx(lucideReact.Trash2,{className:"size-3.5"})})]})]},draft.id))})}):null,jsxRuntime.jsxs("div",{ref:surfaceRef,"data-agent-workbench-surface":"elevated",className:cn2("agent-workbench-composer__surface min-w-0 max-w-full rounded-[var(--radius)] border border-input bg-popover text-popover-foreground shadow-sm transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",compact?"p-2.5":"p-3"),children:[viewModel.attachments.length>0?jsxRuntime.jsx("div",{"data-agent-workbench-composer-attachments":true,className:cn2("mb-2 flex max-w-full gap-2 overflow-x-auto overscroll-x-contain pb-1",classNames?.attachments),children:viewModel.attachments.map(attachment=>{const isAttachmentError=attachment.status==="error";const isAttachmentUploading=attachment.status==="uploading";return jsxRuntime.jsxs("div",{role:isAttachmentError?"alert":void 0,className:cn2("flex h-14 min-w-48 max-w-64 shrink-0 items-center gap-2 rounded-md border bg-muted/45 p-1.5",isAttachmentError?"border-destructive/50 bg-destructive/5":"border-border"),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded bg-muted",children:attachment.previewUrl&&attachment.mediaType?.startsWith("image/")?jsxRuntime.jsx("img",{src:attachment.previewUrl,alt:"",className:"size-full object-cover"}):attachment.mediaType?.startsWith("image/")?jsxRuntime.jsx(lucideReact.Image,{className:"size-5 text-muted-foreground"}):jsxRuntime.jsx(lucideReact.File,{className:"size-5 text-muted-foreground"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-xs font-medium text-foreground",title:attachment.name,children:attachment.name}),jsxRuntime.jsxs("span",{className:cn2("mt-0.5 flex items-center gap-1 text-[11px]",isAttachmentError?"text-destructive-text":"text-muted-foreground"),children:[isAttachmentUploading?jsxRuntime.jsx(lucideReact.LoaderCircle,{className:"size-3 animate-spin","aria-hidden":"true"}):null,isAttachmentError?jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-3","aria-hidden":"true"}):null,isAttachmentUploading?messages.composer.uploading:isAttachmentError?messages.composer.uploadFailed:attachment.mediaType||messages.composer.attachmentOnly]})]}),jsxRuntime.jsxs("span",{className:"flex shrink-0 items-center gap-0.5",children:[isAttachmentError?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"!size-7 min-w-7 shrink-0 p-0 text-destructive-text hover:text-destructive-text","aria-label":`${messages.composer.retryAttachment}: ${attachment.name}`,onClick:()=>onIntent?.({type:"retry-attachment",attachmentId:attachment.id}),children:jsxRuntime.jsx(lucideReact.RotateCcw,{className:"size-3.5"})}):null,jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"!size-7 min-w-7 shrink-0 p-0 text-muted-foreground hover:text-foreground","aria-label":`${messages.composer.removeAttachment}: ${attachment.name}`,onClick:()=>onIntent?.({type:"remove-attachment",attachmentId:attachment.id}),children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5"})})]})]},attachment.id)})}):null,jsxRuntime.jsx(AutosizeTextarea,{value:viewModel.value,minHeight:compact?44:54,maxHeight:256,"aria-label":messages.composer.message,placeholder:viewModel.placeholder,className:cn2("min-w-0 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent px-0 py-0 text-sm leading-relaxed text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",classNames?.textarea),onChange:event=>onIntent?.({type:"change-value",value:event.target.value}),onKeyDown:event=>{if(event.key==="Enter"&&!event.shiftKey&&!event.nativeEvent.isComposing){event.preventDefault();submit();}}}),jsxRuntime.jsxs("div",{className:cn2("agent-workbench-composer__toolbar mt-2 flex min-w-0 max-w-full items-center",compact?"min-h-7 gap-1.5":"min-h-8 gap-2",isNarrow?"flex-wrap":"flex-nowrap",classNames?.toolbar),children:[jsxRuntime.jsxs("div",{"data-agent-workbench-composer-controls":true,className:cn2("agent-workbench-composer__controls flex min-w-0 max-w-full flex-1 items-center gap-1.5",isNarrow?"w-full flex-wrap":"flex-nowrap overflow-x-auto overscroll-x-contain pb-1"),children:[viewModel.capabilities.attachments?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.attach,onClick:()=>fileInputRef.current?.click(),children:jsxRuntime.jsx(lucideReact.Paperclip,{className:"size-4"})}),jsxRuntime.jsx("input",{ref:fileInputRef,type:"file",className:"hidden",multiple:true,onChange:event=>{const files=Array.from(event.target.files||[]);if(files.length>0)onIntent?.({type:"request-attachments",files});event.target.value="";}})]}):null,inputActions.length>0?jsxRuntime.jsxs(Tabs,{value:selectedInputActionId,onValueChange:actionId=>onIntent?.({type:"select-input-action",actionId}),children:[jsxRuntime.jsx(TabsList,{className:cn2("shrink-0 gap-0.5 rounded-md bg-muted/60 p-0.5",compact?"h-7":"h-8"),children:inputActions.map(action=>{const ActionIcon=action.icon==="image"?lucideReact.Image:lucideReact.FileText;return jsxRuntime.jsxs(TabsTrigger,{value:action.id,className:cn2("min-w-0 gap-1.5 px-2.5 text-xs text-foreground/75 shadow-none hover:text-foreground data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",compact?"h-6":"h-7"),children:[action.icon?jsxRuntime.jsx(ActionIcon,{className:"size-3.5"}):null,jsxRuntime.jsx("span",{className:"max-w-32 truncate",children:action.label})]},action.id)})}),inputActions.map(action=>jsxRuntime.jsx(TabsContent,{value:action.id,className:"hidden"},action.id))]}):null,viewModel.capabilities.voiceInput?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:iconButtonClass,"aria-label":messages.composer.voice,onClick:()=>onIntent?.({type:"request-voice-input"}),children:jsxRuntime.jsx(lucideReact.Mic,{className:"size-4"})}):null,viewModel.capabilities.webSearch?jsxRuntime.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap px-1 text-xs font-medium text-foreground",children:[messages.composer.webSearch,jsxRuntime.jsx(Switch,{checked:viewModel.webSearchEnabled,onCheckedChange:enabled=>onIntent?.({type:"toggle-web-search",enabled})})]}):null,modeSelectionEnabled?jsxRuntime.jsxs(Tabs,{value:viewModel.mode,onValueChange:mode=>onIntent?.({type:"change-mode",mode}),children:[jsxRuntime.jsx(TabsList,{"aria-label":messages.composer.chatMode,className:cn2("shrink-0 gap-0.5 rounded-md bg-muted/60 p-0.5",compact?"h-7":"h-8"),children:["chat","work"].map(mode=>jsxRuntime.jsx(TabsTrigger,{value:mode,className:cn2("min-w-0 px-2.5 text-xs text-foreground/75 shadow-none hover:text-foreground data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",compact?"h-6":"h-7"),children:messages.modes[mode]},mode))}),["chat","work"].map(mode=>jsxRuntime.jsx(TabsContent,{value:mode,className:"hidden"},mode))]}):null,viewModel.capabilities.modelSelection?jsxRuntime.jsx(ComposerSelect,{value:selectedModelValue,label:messages.composer.model,placeholder:messages.composer.noModels,className:"w-48 min-w-36",options:visibleModelOptions.map(option=>({value:modelOptionValue(option),label:`${option.label} \xB7 ${messages.modes[option.mode]}`,disabled:option.disabled})),onValueChange:value=>{const option=visibleModelOptions.find(item=>modelOptionValue(item)===value);if(option)onIntent?.({type:"select-model",modelId:option.id,mode:option.mode});}}):null,viewModel.capabilities.reasoning&&viewModel.reasoning?jsxRuntime.jsx(ComposerSelect,{value:viewModel.reasoning.value,label:messages.composer.reasoning,className:"w-32 min-w-24",options:viewModel.reasoning.options.map(value=>({value,label:messages.composer.reasoningOptions[value]})),onValueChange:value=>onIntent?.({type:"change-reasoning",value})}):null,viewModel.capabilities.permissions&&viewModel.permissionProfile?jsxRuntime.jsx(ComposerSelect,{value:viewModel.permissionProfile,label:messages.composer.permissions,className:"w-40 min-w-32",options:["approval-required","auto-approve","full-access"].map(value=>({value,label:messages.composer.permissionOptions[value]})),onValueChange:value=>onIntent?.({type:"change-permission",value})}):null]}),jsxRuntime.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[showSubmitButton?jsxRuntime.jsx(Button,{type:"submit",size:"icon",className:cn2(iconButtonClass,"bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground disabled:bg-primary/40 disabled:!opacity-100"),"aria-label":isBusy&&viewModel.capabilities.queue?messages.composer.queue:messages.composer.send,disabled:!canSubmit,children:jsxRuntime.jsx(lucideReact.Send,{className:"size-4 !text-white [&_path]:!stroke-white"})}):null,isBusy&&!canSubmit&&viewModel.capabilities.stop?jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"icon",className:iconButtonClass,"aria-label":isStopping?messages.run.stopping:messages.composer.stop,disabled:isStopping,onClick:()=>onIntent?.({type:"stop"}),children:jsxRuntime.jsx(lucideReact.Square,{className:"size-3 fill-current"})}):null]})]})]}),viewModel.status==="error"&&viewModel.error?jsxRuntime.jsx("p",{role:"alert",className:"text-sm text-destructive-text",children:viewModel.error}):null]})})}var ICONS={sparkles:lucideReact.Sparkles,palette:lucideReact.Palette,search:lucideReact.Search,"file-text":lucideReact.FileText,code:lucideReact.Code2,"shopping-bag":lucideReact.ShoppingBag};var QUICK_START_CATEGORY_ID="__quick-start__";function TemplateVisual({template}){const Icon2=ICONS[template.icon||"sparkles"];if(template.coverImageUrl){return jsxRuntime.jsx("img",{src:template.coverImageUrl,alt:"",className:"size-full bg-muted object-contain"})}return jsxRuntime.jsx("span",{className:"flex size-full items-center justify-center bg-gradient-to-br from-primary/5 via-muted/50 to-primary/15",children:jsxRuntime.jsx("span",{className:"flex size-14 items-center justify-center rounded-2xl border border-primary/10 bg-background/85 text-primary shadow-sm",children:jsxRuntime.jsx(Icon2,{className:"size-7","aria-hidden":"true"})})})}function AgentWorkbenchQuickStart({viewModel,className,onIntent}){const messages=useMonkeysLocaleMessages().agentWorkbench.quickStart;const fileInputRef=React5.useRef(null);const[activeCategoryId,setActiveCategoryId]=React5.useState();const[activeSectionId,setActiveSectionId]=React5.useState();const[pendingTemplate,setPendingTemplate]=React5.useState();const categories=React5.useMemo(()=>viewModel.categories.map(category=>({...category,sections:category.sections.map(section=>({...section,templates:section.templates.filter(template=>!template.modes||template.modes.includes(viewModel.mode))})).filter(section=>section.templates.length>0)})).filter(category=>category.sections.length>0),[viewModel.categories,viewModel.mode]);const quickStartCategory=React5.useMemo(()=>{const templates=categories.flatMap(category=>category.sections.filter(section=>section.id==="quick-start")).map(section=>section.templates).flat().filter((template,index,allTemplates)=>allTemplates.findIndex(item=>item.id===template.id)===index);if(templates.length===0)return void 0;return {id:QUICK_START_CATEGORY_ID,label:messages.label,icon:"sparkles",sections:[{id:"quick-start",label:messages.label,templates}]}},[categories,messages.label]);const activeCategory=activeCategoryId===QUICK_START_CATEGORY_ID?quickStartCategory:categories.find(category=>category.id===activeCategoryId);const activeSection=activeCategory?.sections.find(section=>section.id===activeSectionId)||activeCategory?.sections[0];const usesCompactList=activeSection?.templates.length?activeSection.templates.every(template=>!template.coverImageUrl):false;React5.useEffect(()=>{if(activeCategoryId&&activeCategoryId!==QUICK_START_CATEGORY_ID&&!categories.some(category=>category.id===activeCategoryId)){setActiveCategoryId(void 0);setActiveSectionId(void 0);}if(activeCategoryId===QUICK_START_CATEGORY_ID&&!quickStartCategory){setActiveCategoryId(void 0);setActiveSectionId(void 0);}},[activeCategoryId,categories,quickStartCategory]);if(categories.length===0)return null;const selectCategory=category=>{setActiveCategoryId(category.id);setActiveSectionId(category.sections[0]?.id);onIntent?.({type:"change-category",categoryId:category.id});};const selectQuickStart=()=>{if(!quickStartCategory)return;setActiveCategoryId(QUICK_START_CATEGORY_ID);setActiveSectionId(quickStartCategory.sections[0]?.id);onIntent?.({type:"change-category"});};const selectSection=sectionId=>{if(!activeCategory)return;setActiveSectionId(sectionId);onIntent?.({type:"change-section",categoryId:activeCategory.id,sectionId});};const selectTemplate=template=>{if(viewModel.disabled)return;if(template.action!=="upload"){onIntent?.({type:"select-template",templateId:template.id,prompt:template.prompt});return}const input=fileInputRef.current;if(!input)return;input.accept=template.accept||"*/*";input.multiple=template.multiple===true;setPendingTemplate(template);input.click();};return jsxRuntime.jsxs("section",{className:cn2("agent-workbench-quick-start min-w-0 max-w-full",className),"aria-label":messages.label,children:[jsxRuntime.jsx("input",{ref:fileInputRef,type:"file",className:"hidden",onChange:event=>{const files=Array.from(event.target.files||[]);if(pendingTemplate&&files.length>0){onIntent?.({type:"select-template",templateId:pendingTemplate.id,prompt:pendingTemplate.prompt,files:pendingTemplate.multiple?files:files.slice(0,1)});}setPendingTemplate(void 0);event.target.value="";}}),!activeCategory?jsxRuntime.jsxs("div",{className:"flex max-w-full items-center justify-center gap-2 overflow-x-auto px-1 pb-1",children:[quickStartCategory?jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-10 shrink-0 items-center gap-2 rounded-full border border-border bg-background px-4 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring","aria-pressed":activeCategoryId===QUICK_START_CATEGORY_ID,onClick:selectQuickStart,children:[jsxRuntime.jsx(lucideReact.Sparkles,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),messages.label]}):null,categories.map(category=>{const Icon2=ICONS[category.icon||"sparkles"];return jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-10 shrink-0 items-center gap-2 rounded-full border border-border bg-background px-4 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>selectCategory(category),children:[jsxRuntime.jsx(Icon2,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),category.label]},category.id)})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 max-w-full items-center gap-1 overflow-x-auto pb-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{setActiveCategoryId(void 0);setActiveSectionId(void 0);onIntent?.({type:"change-category"});},children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4","aria-hidden":"true"}),messages.back]}),activeCategory.sections.map((section,index)=>jsxRuntime.jsx("button",{type:"button","aria-pressed":activeSection?.id===section.id,className:cn2("h-9 shrink-0 rounded-full px-4 text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",activeSection?.id===section.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>selectSection(section.id),children:activeCategory.id!==QUICK_START_CATEGORY_ID&&index===0?activeCategory.label:section.label},section.id))]}),jsxRuntime.jsx("div",{"data-quick-start-layout":usesCompactList?"list":"cards",className:cn2("grid",usesCompactList?"grid-cols-1 gap-0":"grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3"),children:activeSection?.templates.map(template=>jsxRuntime.jsxs("button",{type:"button",disabled:viewModel.disabled,"data-quick-start-template-id":template.id,className:cn2("group min-w-0 overflow-hidden text-left transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",usesCompactList?"flex min-h-14 items-center rounded-none border-x-0 border-t-0 bg-transparent shadow-none hover:border-border hover:bg-muted/40 last:border-b-0":"rounded-xl border border-border bg-background hover:border-primary/30 hover:bg-muted/20"),onClick:()=>selectTemplate(template),children:[jsxRuntime.jsxs("span",{className:cn2(usesCompactList?"min-w-0 flex-1 px-2 py-2.5":"block px-4 pb-3 pt-4"),children:[jsxRuntime.jsxs("span",{className:cn2("flex items-center gap-2 text-sm text-foreground",usesCompactList?"font-medium":"font-semibold"),children:[template.title,template.action==="upload"?jsxRuntime.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Upload,{className:"size-3","aria-hidden":"true"}),messages.addFile]}):null]}),template.description?jsxRuntime.jsx("span",{className:cn2("line-clamp-2 block text-xs leading-4 text-muted-foreground",usesCompactList?"mt-0.5 min-h-0 text-muted-foreground/75":"mt-1 min-h-8"),children:template.description}):null]}),usesCompactList?jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"mr-2 size-4 shrink-0 text-muted-foreground/45","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:cn2("block overflow-hidden",template.coverImageUrl?"aspect-[5/2]":"h-28"),children:jsxRuntime.jsx(TemplateVisual,{template})})]},template.id))})]})]})}var AgentWorkbenchSidebarContainer=React5.forwardRef(function AgentWorkbenchSidebarContainer2({children,header,search,primaryAction,actions,groups,footer,className,classNames,bodyProps,bodyScrollable=true,status="ready",variant,density,loadingState,emptyState,errorState,...props},ref){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const hasToolbar=search!==void 0||primaryAction!==void 0||actions!==void 0;const statusContent=status==="loading"?loadingState:status==="empty"?emptyState:status==="error"?errorState:children;return jsxRuntime.jsxs("nav",{ref,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":status,className:cn2("flex h-full min-h-0 flex-col bg-card text-card-foreground",classNames?.root,className),...props,children:[header!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.header),children:header}):null,hasToolbar?jsxRuntime.jsxs("div",{className:cn2("shrink-0",compact?"space-y-2 px-3 pb-2 pt-3":"space-y-3 px-4 pb-2 pt-4",classNames?.search),children:[search,primaryAction!==void 0?jsxRuntime.jsx("div",{className:cn2(classNames?.primaryAction),children:primaryAction}):null,actions!==void 0?jsxRuntime.jsx("div",{className:cn2("flex min-w-0 items-center gap-2",classNames?.actions),children:actions}):null]}):null,jsxRuntime.jsx("div",{"data-agent-workbench-scroll-region":bodyScrollable?"":void 0,...bodyProps,tabIndex:bodyProps?.tabIndex??(bodyScrollable?0:void 0),className:cn2("min-h-0 flex-1",compact?"px-3 pb-3":"px-4 pb-4",bodyScrollable&&"overflow-x-hidden overflow-y-auto overscroll-contain",classNames?.body),children:statusContent}),groups!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.groups),children:groups}):null,footer!==void 0?jsxRuntime.jsx("div",{className:cn2("shrink-0",classNames?.footer),children:footer}):null]})});AgentWorkbenchSidebarContainer.displayName="AgentWorkbenchSidebarContainer";function AgentWorkbenchSidebarSearch({value,label,placeholder=label,className,variant="default",onChange}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const searchRef=React5.useRef(null);React5.useEffect(()=>{const handleShortcut=event=>{if(!(event.ctrlKey||event.metaKey)||event.key.toLocaleLowerCase()!=="k")return;event.preventDefault();searchRef.current?.focus();searchRef.current?.select();};window.addEventListener("keydown",handleShortcut);return ()=>window.removeEventListener("keydown",handleShortcut)},[]);return jsxRuntime.jsxs(InputGroup,{className:cn2(variant==="trend"?"h-12 rounded-[var(--radius)] border-border bg-card text-foreground":"h-10 rounded-lg bg-card",className),children:[jsxRuntime.jsx(InputGroupAddon,{children:jsxRuntime.jsx(lucideReact.Search,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx(InputGroupInput,{ref:searchRef,type:"search",value,"aria-label":label,placeholder,className:"min-w-0 [&::-webkit-search-cancel-button]:hidden",onChange:event=>onChange(event.target.value),onKeyDown:event=>{if(event.key!=="Escape")return;onChange("");event.currentTarget.blur();}}),value?jsxRuntime.jsx(InputGroupAddon,{align:"inline-end",children:jsxRuntime.jsx(InputGroupButton,{size:"icon-xs","aria-label":messages.clearSearch,onClick:()=>onChange(""),children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5","aria-hidden":"true"})})}):jsxRuntime.jsx(InputGroupAddon,{align:"inline-end",children:jsxRuntime.jsx("kbd",{className:"border border-border px-1.5 py-0.5 text-[10px]",children:"Ctrl K"})})]})}function AgentWorkbenchSidebarNewSessionButton({label,className,variant="default",onClick}){return jsxRuntime.jsxs(Button,{type:"button",variant:variant==="trend"?"default":"ghost",className:cn2(variant==="trend"?"h-11 w-full justify-center gap-2 rounded-[var(--radius)] border border-primary/60 bg-primary px-3 font-semibold text-primary-foreground hover:bg-primary/90":"h-9 w-full justify-start gap-2 px-3 text-sm",className),onClick,children:[jsxRuntime.jsx(lucideReact.SquarePen,{className:"size-4","aria-hidden":"true"}),label]})}function SessionAvatar({item}){const[failed,setFailed]=React5.useState(false);if(item.thumbnailUrl&&!failed){return jsxRuntime.jsx("img",{src:item.thumbnailUrl,alt:"",className:"size-full object-cover",loading:"lazy",onError:()=>setFailed(true)})}return jsxRuntime.jsx(lucideReact.Image,{className:"size-5","aria-hidden":"true"})}function SessionMeta({item}){const{locale}=useMonkeysLocale();const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;return jsxRuntime.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 truncate text-xs text-foreground/80",children:new Intl.DateTimeFormat(locale,{dateStyle:"medium",timeStyle:"short"}).format(new Date(item.updatedAt))}),item.mode?jsxRuntime.jsx("span",{className:cn2("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",item.mode==="work"?"bg-primary/10 text-primary":"bg-muted text-foreground"),children:item.mode==="work"?messages.work:messages.chat}):null]})}function StatusIndicator({status}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;if(status==="running"){return jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin text-primary","aria-label":messages.running})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-primary","aria-label":messages.completed})}if(status==="error"){return jsxRuntime.jsx(lucideReact.AlertCircle,{className:"size-4 text-destructive-text","aria-label":messages.failed})}return null}function AgentWorkbenchSessionList({sessions,selectedSessionId,status="ready",error,query="",emptyLabel,noResultsLabel,retryLabel,groupByMode=false,showHeading=false,variant="default",className,itemClassName,capabilities,onSelect,onTogglePin,onRename,onDelete,onRetry}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const renameInputRef=React5.useRef(null);const[editingSessionId,setEditingSessionId]=React5.useState();const[editingTitle,setEditingTitle]=React5.useState("");React5.useEffect(()=>{if(!editingSessionId)return;renameInputRef.current?.focus();renameInputRef.current?.select();},[editingSessionId]);const cancelRename=()=>{setEditingSessionId(void 0);setEditingTitle("");};const saveRename=item=>{const title=editingTitle.trim();if(title&&title!==item.title)onRename?.(item.id,title);cancelRename();};if(status==="loading"&&sessions.length===0){return jsxRuntime.jsx("div",{className:"space-y-2 px-1 py-3",role:"status","aria-label":messages.loading,children:Array.from({length:4},(_,index)=>jsxRuntime.jsx("div",{"aria-hidden":"true",className:cn2("animate-pulse rounded-[var(--radius)] bg-muted/70",variant==="trend"?"h-10":"h-14")},index))})}if(status==="error"){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 px-3 py-8 text-center",children:[jsxRuntime.jsx("p",{className:"max-w-full break-words text-sm text-muted-foreground",role:"alert",children:error}),onRetry?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"gap-1.5 px-0 text-sm text-primary hover:text-primary",onClick:onRetry,children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-3.5","aria-hidden":"true"}),retryLabel??messages.retry]}):null]})}if(sessions.length===0){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:query?noResultsLabel:emptyLabel})}const renderTrendItems=items=>jsxRuntime.jsx("div",{className:"space-y-3",children:items.map(item=>jsxRuntime.jsxs("div",{"aria-current":item.id===selectedSessionId?"page":void 0,"data-agent-session-status":item.status??"idle","aria-busy":item.status==="running"?"true":void 0,className:"group flex h-10 w-full min-w-0 items-center rounded-[var(--radius)] border border-transparent bg-muted/60 text-foreground transition hover:bg-muted focus-within:border-ring focus-within:ring-2 focus-within:ring-ring aria-[current=page]:border-primary aria-[current=page]:bg-primary/10",children:[jsxRuntime.jsx("button",{type:"button",title:item.title,className:"h-full min-w-0 flex-1 truncate px-3 text-left text-sm font-semibold",onClick:()=>onSelect(item.id),children:item.title}),capabilities?.delete?jsxRuntime.jsx("span",{"data-agent-workbench-item-actions":true,className:"mr-1 shrink-0 opacity-0 transition-opacity group-aria-[current=page]:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100",onClick:event=>event.stopPropagation(),onKeyDown:event=>event.stopPropagation(),children:jsxRuntime.jsxs(DropdownMenu2,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":messages.actions,className:"size-8 text-muted-foreground",children:jsxRuntime.jsx(lucideReact.Ellipsis,{className:"size-4","aria-hidden":"true"})})}),jsxRuntime.jsx(DropdownMenuContent,{align:"end",children:jsxRuntime.jsxs(DropdownMenuItem,{className:"text-destructive-text",onSelect:()=>onDelete?.(item.id),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"mr-2 size-4","aria-hidden":"true"}),messages.delete]})})]})}):null]},item.id))});const renderItems=items=>jsxRuntime.jsx("div",{className:"space-y-1",children:items.map(item=>{const percent=item.contextUsage&&item.contextUsage.maxTokens>0?Math.min(100,Math.round(item.contextUsage.usedTokens/item.contextUsage.maxTokens*100)):void 0;return jsxRuntime.jsxs("div",{"aria-current":item.id===selectedSessionId?"page":void 0,className:cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",itemClassName),children:[editingSessionId===item.id?jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(SessionAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx(Input,{ref:renameInputRef,value:editingTitle,"aria-label":messages.rename,appearance:"compact",className:"h-6 w-full border-primary px-1.5 text-sm font-medium",onChange:event=>setEditingTitle(event.target.value),onClick:event=>event.stopPropagation(),onBlur:()=>saveRename(item),onKeyDown:event=>{event.stopPropagation();if(event.key==="Enter"){event.preventDefault();saveRename(item);}else if(event.key==="Escape"){event.preventDefault();cancelRename();}}}),jsxRuntime.jsx(SessionMeta,{item})]})]}):jsxRuntime.jsxs("button",{type:"button",title:item.title,className:"flex min-w-0 flex-1 items-center gap-3 text-left",onClick:()=>onSelect(item.id),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(SessionAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-sm font-medium",children:item.title}),jsxRuntime.jsx(SessionMeta,{item})]})]}),jsxRuntime.jsxs("span",{"data-agent-workbench-item-actions":true,className:"flex shrink-0 items-center gap-1",children:[percent!==void 0&&item.status==="idle"?jsxRuntime.jsxs("span",{className:"text-xs text-foreground","aria-label":messages.contextUsage({percent}),children:[percent,"%"]}):jsxRuntime.jsx(StatusIndicator,{status:item.status}),capabilities?.pin?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":item.pinned?messages.unpin:messages.pin,className:cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100",item.pinned&&"text-primary opacity-100"),onClick:event=>{event.stopPropagation();onTogglePin?.(item.id,!item.pinned);},children:jsxRuntime.jsx(lucideReact.Pin,{className:cn2("size-4",item.pinned&&"fill-current")})}):null,capabilities?.rename||capabilities?.delete?jsxRuntime.jsx("span",{onClick:event=>event.stopPropagation(),onKeyDown:event=>event.stopPropagation(),children:jsxRuntime.jsxs(DropdownMenu2,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8","aria-label":messages.actions,children:jsxRuntime.jsx(lucideReact.Ellipsis,{className:"size-4","aria-hidden":"true"})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[capabilities.rename?jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>{setEditingSessionId(item.id);setEditingTitle(item.title);},children:[jsxRuntime.jsx(lucideReact.Pencil,{className:"mr-2 size-4","aria-hidden":"true"}),messages.rename]}):null,capabilities.delete?jsxRuntime.jsxs(DropdownMenuItem,{className:"text-destructive-text",onSelect:()=>onDelete?.(item.id),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"mr-2 size-4","aria-hidden":"true"}),messages.delete]}):null]})]})}):null]})]},item.id)})});return jsxRuntime.jsxs("div",{className:cn2("space-y-2",className),children:[showHeading&&!groupByMode?jsxRuntime.jsx("h3",{className:"mb-2 px-3 text-xs font-medium text-muted-foreground",children:messages.recentSessions}):null,variant==="trend"?renderTrendItems(sessions):groupByMode?[{id:"chatbot",label:messages.chats,icon:lucideReact.MessageSquare,items:sessions.filter(item=>item.mode!=="work")},{id:"agent",label:messages.agents,icon:lucideReact.Bot,items:sessions.filter(item=>item.mode==="work")}].map(({id,label,icon:Icon2,items})=>jsxRuntime.jsxs("details",{open:true,"aria-label":label,children:[jsxRuntime.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 rounded-md px-3 text-sm font-semibold hover:bg-muted",children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 truncate",children:label})]}),renderItems(items)]},id)):renderItems(sessions)]})}var EMPTY_NAVIGATION_VIEW_MODEL={contract:"AgentWorkbenchNavigationViewModel",activeTab:"sessions",searchQuery:"",agents:{status:"loading",items:[]},sessions:{status:"loading",items:[]},capabilities:{createAgent:false,createSession:false,manageCapabilities:false,manageAgentSettings:false,pinAgents:false,pinSessions:false,renameSessions:false,deleteSessions:false}};function ItemAvatar({item}){const[failed,setFailed]=React5.useState(false);if(item.iconUrl&&!failed){return jsxRuntime.jsx("img",{src:item.iconUrl,alt:"",className:"size-full object-cover",onError:()=>setFailed(true)})}const initial=item.name.trim().charAt(0).toLocaleUpperCase();return initial?jsxRuntime.jsx("span",{className:"text-sm font-semibold",children:initial}):jsxRuntime.jsx(lucideReact.Bot,{className:"size-4"})}function CollectionState({status,empty,noResults,hasItems,query,error,onRetry}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;if(status==="loading"&&!hasItems){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:messages.loading})}if(status==="error"){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 px-3 py-8 text-center",children:[jsxRuntime.jsx("p",{className:"max-w-full break-words text-sm text-muted-foreground",role:"alert",children:error}),jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"gap-1.5 px-0 text-sm text-primary hover:text-primary",onClick:onRetry,children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-3.5","aria-hidden":"true"}),messages.retry]})]})}if(!hasItems){return jsxRuntime.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:query?noResults:empty})}return null}function AgentWorkbenchSidebar({viewModel=EMPTY_NAVIGATION_VIEW_MODEL,navigationMode,config,header,headerActions,footer,className,classNames,onIntent}){const messages=useMonkeysLocaleMessages().agentWorkbench.navigation;const resolvedConfig=React5.useMemo(()=>monkeys.resolveAgentWorkbenchSidebarConfig(config),[config]);const visibleSections=React5.useMemo(()=>new Set(resolvedConfig.visibleSections),[resolvedConfig.visibleSections]);const sessionsOnly=navigationMode==="sessions-only"||navigationMode===void 0&&resolvedConfig.navigationMode!=="default";const showAgents=visibleSections.has("agents")&&!sessionsOnly;const showSessions=visibleSections.has("sessions");const query=viewModel.searchQuery.trim().toLocaleLowerCase();const agents=React5.useMemo(()=>viewModel.agents.items.filter(item=>!query||`${item.name} ${item.description??""}`.toLocaleLowerCase().includes(query)),[query,viewModel.agents.items]);const sessions=React5.useMemo(()=>viewModel.sessions.items.filter(item=>!query||item.title.toLocaleLowerCase().includes(query)),[query,viewModel.sessions.items]);return jsxRuntime.jsx(Tabs,{value:sessionsOnly||!showAgents?"sessions":viewModel.activeTab,onValueChange:value=>{if(!sessionsOnly&&(value==="agents"||value==="sessions"))onIntent?.({type:"change-tab",tab:value});},className:"h-full min-h-0",children:jsxRuntime.jsxs(AgentWorkbenchSidebarContainer,{"data-sidebar-width-percent":resolvedConfig.widthPercent,"aria-label":messages.tabsLabel,header:visibleSections.has("header")?header:void 0,search:visibleSections.has("search")?jsxRuntime.jsx(AgentWorkbenchSidebarSearch,{value:viewModel.searchQuery,label:sessionsOnly?messages.searchSessions:messages.search,className:classNames?.search,onChange:query2=>onIntent?.({type:"change-search",query:query2})}):void 0,actions:showAgents&&showSessions||headerActions?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[showAgents&&showSessions?jsxRuntime.jsxs(TabsList,{className:cn2("grid min-w-0 flex-1 grid-cols-2 text-foreground",classNames?.tabs),"aria-label":messages.tabsLabel,children:[jsxRuntime.jsx(TabsTrigger,{value:"agents",children:messages.agents}),jsxRuntime.jsx(TabsTrigger,{value:"sessions",children:messages.sessions})]}):null,headerActions?jsxRuntime.jsx("div",{className:"flex shrink-0 items-center",children:headerActions}):null]}):void 0,footer:visibleSections.has("footer")&&(!sessionsOnly&&viewModel.capabilities.manageAgentSettings||footer)?jsxRuntime.jsxs("div",{className:cn2("border-t border-border p-4",classNames?.footer),children:[!sessionsOnly&&viewModel.capabilities.manageAgentSettings?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"h-10 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"open-agent-settings"}),children:[jsxRuntime.jsx(lucideReact.Settings,{className:"size-4","aria-hidden":"true"}),messages.settings]}):null,footer]}):void 0,bodyScrollable:false,className,classNames:{root:classNames?.root,body:"flex min-h-0 flex-1 flex-col p-0"},children:[showAgents?jsxRuntime.jsxs(TabsContent,{value:"agents","data-agent-workbench-scroll-region":true,className:cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",classNames?.body),children:[viewModel.capabilities.createAgent?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"create-agent"}),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"size-4","aria-hidden":"true"}),messages.newAgent]}):null,jsxRuntime.jsx("h3",{className:"mb-2 px-3 text-xs font-medium text-muted-foreground",children:messages.allAgents}),jsxRuntime.jsx(CollectionState,{status:viewModel.agents.status,empty:messages.emptyAgents,noResults:messages.noResults,hasItems:agents.length>0,query,error:viewModel.agents.error,onRetry:()=>onIntent?.({type:"retry-agents"})}),jsxRuntime.jsx("div",{className:"space-y-1",children:agents.map(item=>jsxRuntime.jsxs("div",{"aria-current":item.id===viewModel.selectedAgentItem?"page":void 0,className:cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",classNames?.item),children:[jsxRuntime.jsxs("button",{type:"button",title:item.name,className:"flex min-w-0 flex-1 items-center gap-3 text-left",onClick:()=>onIntent?.({type:"select-agent",itemId:item.id}),children:[jsxRuntime.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted",children:jsxRuntime.jsx(ItemAvatar,{item})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"block truncate text-sm font-medium",children:item.name}),jsxRuntime.jsx("span",{className:"block truncate text-xs text-foreground/80",children:item.description||messages.noDescription})]})]}),item.builtIn?jsxRuntime.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-1 text-[10px] text-foreground",children:messages.builtIn}):null,viewModel.capabilities.pinAgents?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":item.pinned?messages.unpin:messages.pin,className:cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100",item.pinned&&"text-primary opacity-100"),onClick:event=>{event.stopPropagation();onIntent?.({type:"toggle-agent-pin",itemId:item.id,pinned:!item.pinned});},onKeyDown:event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();event.stopPropagation();onIntent?.({type:"toggle-agent-pin",itemId:item.id,pinned:!item.pinned});}},children:jsxRuntime.jsx(lucideReact.Pin,{className:cn2("size-4",item.pinned&&"fill-current",item.pinPending&&"animate-pulse")})}):null]},item.id))})]}):null,showSessions?jsxRuntime.jsxs(TabsContent,{value:"sessions","data-agent-workbench-scroll-region":true,className:cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",classNames?.body),children:[visibleSections.has("new-session")&&viewModel.capabilities.createSession?jsxRuntime.jsx(AgentWorkbenchSidebarNewSessionButton,{label:messages.newSession,onClick:()=>onIntent?.({type:"create-session"})}):null,!sessionsOnly&&viewModel.capabilities.manageCapabilities?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",onClick:()=>onIntent?.({type:"open-capabilities"}),children:[jsxRuntime.jsx(lucideReact.Blocks,{className:"size-4","aria-hidden":"true"}),messages.capabilities]}):null,jsxRuntime.jsx(AgentWorkbenchSessionList,{sessions,selectedSessionId:viewModel.selectedSessionItem,status:viewModel.sessions.status,error:viewModel.sessions.error,query,emptyLabel:messages.emptySessions,noResultsLabel:messages.noResults,groupByMode:sessionsOnly,showHeading:!sessionsOnly,itemClassName:classNames?.item,capabilities:{pin:viewModel.capabilities.pinSessions,rename:viewModel.capabilities.renameSessions,delete:viewModel.capabilities.deleteSessions},onSelect:sessionId=>onIntent?.({type:"select-session",sessionId}),onTogglePin:(sessionId,pinned)=>onIntent?.({type:"toggle-session-pin",sessionId,pinned}),onRename:(sessionId,title)=>onIntent?.({type:"rename-session",sessionId,title}),onDelete:sessionId=>onIntent?.({type:"delete-session",sessionId}),onRetry:()=>onIntent?.({type:"retry-sessions"})})]}):null]})})}function AgentWorkbenchExploreCardMedia({item,src=item.imageUrl,className,onError}){if(!src)return null;const variant=item.mediaVariant??"cover";const isLogo=variant==="logo";const showLabel=variant==="cover-with-label";const treatmentClass=item.mediaTreatment==="monochrome-light"?"brightness-0 invert":item.mediaTreatment==="invert"?"invert":"";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:cn2(isLogo?"flex size-full items-center justify-center bg-[hsl(var(--monkeys-color-media-surface))] p-token-xl":"block size-full",className),children:jsxRuntime.jsx("img",{src,alt:"",className:cn2("transition-transform duration-300 group-hover:scale-[1.03]",isLogo?"max-h-full max-w-full object-contain":"size-full object-cover",treatmentClass),onError})}),showLabel?jsxRuntime.jsxs("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 text-[hsl(var(--monkeys-color-media-foreground))]",style:{paddingInline:"var(--global-spacing, 0.75rem)",paddingBottom:"var(--global-spacing-sm, 0.5rem)",paddingTop:"var(--global-spacing-2xl, 1.5rem)",backgroundImage:"linear-gradient(to top, hsl(var(--monkeys-color-media-overlay) / 0.8), hsl(var(--monkeys-color-media-overlay) / 0.3), transparent)"},children:[jsxRuntime.jsx("span",{className:"block text-base font-semibold",children:item.title}),item.subtitle?jsxRuntime.jsx("span",{className:"block text-xs opacity-75",style:{marginTop:"calc(var(--global-spacing, 0.75rem) / 6)"},children:item.subtitle}):null]}):null]})}function AgentWorkbenchExploreSidebar({sessions,groups:configuredGroups,config,labels,selectedSessionId,searchQuery="",loading=false,error,showDraftSession=!selectedSessionId,deleteSessions=false,variant="default",defaultGroupId,header,footer,className,renderItemMedia,onIntent}){const resolvedConfig=React5.useMemo(()=>monkeys.resolveAgentWorkbenchSidebarConfig(config),[config]);const visibleSections=React5.useMemo(()=>new Set(resolvedConfig.visibleSections),[resolvedConfig.visibleSections]);const groups=configuredGroups?.length?configuredGroups:resolvedConfig.groups;const resolvedDefaultGroupId=defaultGroupId??resolvedConfig.defaultGroupId;const[activeGroupId,setActiveGroupId]=React5.useState(resolvedDefaultGroupId??groups[0]?.id??"");const activeGroup=groups.find(group=>group.id===activeGroupId)??groups[0];const normalizedQuery=searchQuery.trim().toLocaleLowerCase();const draftVisible=showDraftSession&&(!normalizedQuery||labels.draftSession.toLocaleLowerCase().includes(normalizedQuery));const filteredSessions=React5.useMemo(()=>sessions.filter(session=>!normalizedQuery||session.title.toLocaleLowerCase().includes(normalizedQuery)),[normalizedQuery,sessions]);React5.useEffect(()=>{if(groups.some(group=>group.id===activeGroupId))return;setActiveGroupId(resolvedDefaultGroupId??groups[0]?.id??"");},[activeGroupId,groups,resolvedDefaultGroupId]);const changeGroup=groupId=>{setActiveGroupId(groupId);onIntent?.({type:"change-group",groupId});};const groupNavigation=visibleSections.has("groups")&&activeGroup?jsxRuntime.jsx("div",{className:"border-t border-border px-4 pb-4 pt-3",children:jsxRuntime.jsxs(Tabs,{value:activeGroup.id,onValueChange:changeGroup,children:[jsxRuntime.jsx(TabsList,{className:"grid h-10 w-full rounded-[var(--radius)] bg-muted p-0.5 text-foreground",style:{gridTemplateColumns:`repeat(${groups.length}, minmax(0, 1fr))`},children:groups.map(group=>jsxRuntime.jsx(TabsTrigger,{value:group.id,className:"rounded-md text-sm font-semibold text-foreground data-[state=active]:border data-[state=active]:border-border data-[state=active]:bg-background",children:group.label},group.id))}),groups.map(group=>jsxRuntime.jsx(TabsContent,{value:group.id,className:"mt-3",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:group.items.map(item=>jsxRuntime.jsx("button",{type:"button","aria-label":item.title,className:"group relative aspect-[1.27] overflow-hidden rounded-[var(--radius)] border border-border bg-card text-left transition hover:border-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",style:Number.isFinite(group.itemAspectRatio)&&Number(group.itemAspectRatio)>0?{aspectRatio:group.itemAspectRatio}:void 0,onClick:()=>onIntent?.({type:"select-item",groupId:group.id,item}),children:renderItemMedia?.(item,group)??jsxRuntime.jsx(AgentWorkbenchExploreCardMedia,{item})},item.id))})},group.id))]})}):void 0;return jsxRuntime.jsx(AgentWorkbenchSidebarContainer,{"data-sidebar-style":"explore","data-sidebar-width-percent":resolvedConfig.widthPercent,"aria-label":labels.navigation,variant,density:variant==="trend"?"compact":void 0,header:visibleSections.has("header")?header:void 0,search:visibleSections.has("search")?jsxRuntime.jsx(AgentWorkbenchSidebarSearch,{value:searchQuery,label:labels.search,variant,onChange:query=>onIntent?.({type:"change-search",query})}):void 0,primaryAction:visibleSections.has("new-session")?jsxRuntime.jsx(AgentWorkbenchSidebarNewSessionButton,{label:labels.newSession,variant,onClick:()=>onIntent?.({type:"create-session"})}):void 0,groups:groupNavigation,footer:visibleSections.has("footer")?footer:void 0,bodyProps:{"data-agent-workbench-session-scroll-region":""},className,classNames:{body:"min-h-[160px] flex-[0_1_280px]"},children:visibleSections.has("sessions")?jsxRuntime.jsxs("div",{className:"space-y-2",children:[draftVisible?jsxRuntime.jsx("button",{type:"button","aria-current":"page",className:"block h-10 w-full min-w-0 truncate rounded-[var(--radius)] border border-primary bg-primary/10 px-3 text-left text-sm font-semibold text-foreground",onClick:()=>onIntent?.({type:"create-session"}),children:labels.draftSession}):null,filteredSessions.length>0||!draftVisible||loading||error?jsxRuntime.jsx(AgentWorkbenchSessionList,{sessions:filteredSessions,selectedSessionId,status:error?"error":loading?"loading":"ready",error,query:normalizedQuery,emptyLabel:labels.emptySessions,noResultsLabel:labels.noResults,retryLabel:labels.retry,groupByMode:resolvedConfig.navigationMode!=="default",variant,capabilities:{delete:deleteSessions},onSelect:sessionId=>onIntent?.({type:"select-session",sessionId}),onDelete:sessionId=>onIntent?.({type:"delete-session",sessionId}),onRetry:labels.retry?()=>onIntent?.({type:"retry-sessions"}):void 0}):null]}):null})}var EVENT_CAPABILITIES={reasoning:"reasoning",plan:"plan",task:"tasks",tool:"tools",approval:"approval",artifact:"artifacts",usage:"usage"};function projectRun(events){const statuses=events.filter(event=>event.eventType==="status");const run=statuses.at(-1);if(!run)return void 0;if(run.payload.status!=="stopped"||run.payload.durationMs!==void 0)return run;const runStatuses=run.runId?statuses.filter(event=>event.runId===run.runId&&event.sequence<=run.sequence):statuses.filter(event=>event.sequence<=run.sequence);let previousStoppedIndex=-1;for(let index=runStatuses.length-1;index>=0;index-=1){const event=runStatuses[index];if(event.sequence<run.sequence&&event.payload.status==="stopped"){previousStoppedIndex=index;break}}const started=runStatuses.slice(previousStoppedIndex+1).reverse().find(event=>event.payload.status==="running"||event.payload.status==="queued");const startedAt=started?.payload.startedAt??started?.occurredAt;const stoppedAt=run.payload.stoppedAt??run.occurredAt;if(!startedAt||!stoppedAt)return run;const durationMs=Date.parse(stoppedAt)-Date.parse(startedAt);return Number.isFinite(durationMs)&&durationMs>=0?{...run,resolvedDurationMs:durationMs}:run}function isVisible(event,capabilities){const capability=EVENT_CAPABILITIES[event.eventType];return capability?capabilities[capability]===true:true}function latestBy(events,eventType,key2){const latest=new Map;for(const event of events){if(event.eventType!==eventType)continue;const typedEvent=event;latest.set(key2(typedEvent),typedEvent);}return [...latest.values()].sort((left,right)=>left.sequence-right.sequence)}function createAgentWorkbenchActivityModel(viewModel){const visibleEvents=viewModel.events.filter(event=>isVisible(event,viewModel.snapshot.capabilities));return {mode:viewModel.snapshot.mode,status:viewModel.status,reasoning:latestBy(visibleEvents,"reasoning",event=>event.payload.reasoningId),plans:latestBy(visibleEvents,"plan",event=>event.payload.planId),tasks:latestBy(visibleEvents,"task",event=>event.payload.taskId),tools:latestBy(visibleEvents,"tool",event=>event.payload.toolCallId),approvals:latestBy(visibleEvents,"approval",event=>event.payload.approvalId),artifacts:latestBy(visibleEvents,"artifact",event=>event.payload.artifactId),usage:[...visibleEvents].reverse().find(event=>event.eventType==="usage"),run:projectRun(visibleEvents)}}function JsonValue({value}){if(value===void 0)return null;const content=typeof value==="string"?value:JSON.stringify(value,null,2);return jsxRuntime.jsx("pre",{className:"max-h-48 max-w-full overflow-auto overscroll-contain whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs text-foreground [overflow-wrap:anywhere]",tabIndex:0,children:content})}function AgentWorkbenchApproval({approval,className,onDecision}){const messages=useMonkeysLocaleMessages().agentWorkbench.approval;const requested=approval.status==="requested";const approved=approval.status==="approved";return jsxRuntime.jsx("article",{className:cn2("min-w-0 overflow-hidden rounded-lg border border-border bg-card p-3 text-card-foreground",className),"data-agent-approval-status":approval.status,children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[requested?jsxRuntime.jsx(lucideReact.Clock3,{className:"mt-0.5 size-4 shrink-0 text-warning-foreground","aria-hidden":"true"}):approved?jsxRuntime.jsx(lucideReact.Check,{className:"mt-0.5 size-4 shrink-0 text-success","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.X,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("h3",{className:"break-words text-sm font-medium",children:approval.title}),approval.description?jsxRuntime.jsx("p",{tabIndex:0,className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words text-sm text-muted-foreground [overflow-wrap:anywhere]",children:approval.description}):null,approval.requestedAction!==void 0?jsxRuntime.jsx("div",{className:"mt-3 min-w-0",children:jsxRuntime.jsx(JsonValue,{value:approval.requestedAction})}):null,requested?jsxRuntime.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[jsxRuntime.jsx(Button,{type:"button",size:"sm",className:"h-auto px-3 py-1.5 text-sm",disabled:!onDecision,onClick:()=>onDecision?.({approvalId:approval.approvalId,approved:true}),children:messages.approve}),jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto px-3 py-1.5 text-sm",disabled:!onDecision,onClick:()=>onDecision?.({approvalId:approval.approvalId,approved:false}),children:messages.reject})]}):jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:approved?messages.approved:messages.rejected})]})]})})}function JsonValue2({value,className}){if(value===void 0)return null;const content=typeof value==="string"?value:JSON.stringify(value,null,2);return jsxRuntime.jsx("pre",{tabIndex:0,className:cn2("max-h-64 max-w-full overflow-auto overscroll-contain whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs text-foreground [overflow-wrap:anywhere]",className),children:content})}function ToolStatus({status}){useMonkeysLocaleMessages().agentWorkbench.tool.status;const commonClassName="size-3.5 shrink-0";if(status==="pending"){return jsxRuntime.jsx(lucideReact.Clock3,{className:commonClassName,"aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Loader2,{className:cn2(commonClassName,"animate-spin"),"aria-hidden":"true"})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:cn2(commonClassName,"text-primary"),"aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.XCircle,{className:cn2(commonClassName,"text-destructive-text"),"aria-hidden":"true"})}function AgentWorkbenchTool({event,expanded,defaultExpanded=event.payload.status==="failed",className,classNames,onExpandedChange}){const messages=useMonkeysLocaleMessages().agentWorkbench.tool;const[uncontrolledExpanded,setUncontrolledExpanded]=React5.useState(defaultExpanded);const isControlled=expanded!==void 0;const isExpanded=expanded??uncontrolledExpanded;const status=event.payload.status;const setExpanded=nextExpanded=>{if(!isControlled)setUncontrolledExpanded(nextExpanded);onExpandedChange?.(nextExpanded);};return jsxRuntime.jsxs("details",{open:isExpanded,className:cn2("group min-w-0 overflow-hidden rounded-lg border border-border bg-card text-card-foreground",classNames?.root,className),"data-tool-status":status,children:[jsxRuntime.jsxs("summary",{className:cn2("flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",classNames?.trigger),onClick:event2=>{event2.preventDefault();setExpanded(!isExpanded);},children:[jsxRuntime.jsx(lucideReact.TerminalSquare,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:event.payload.toolName}),jsxRuntime.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground",children:[jsxRuntime.jsx(ToolStatus,{status}),messages.status[status]]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:cn2("min-w-0 space-y-3 border-t border-border px-3 py-3 text-sm",classNames?.content),children:[event.payload.input!==void 0?jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:messages.input}),jsxRuntime.jsx(JsonValue2,{value:event.payload.input,className:classNames?.input})]}):null,event.payload.output!==void 0?jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:messages.output}),jsxRuntime.jsx(JsonValue2,{value:event.payload.output,className:classNames?.output})]}):null,event.payload.error?jsxRuntime.jsx("p",{tabIndex:0,className:"max-h-32 overflow-auto whitespace-pre-wrap break-words text-sm text-destructive-text [overflow-wrap:anywhere]",role:"alert",children:event.payload.error}):null]})]})}function ArtifactDownloadButton({artifact,label,onDownload}){const busy=React5.useRef(false);const[downloading,setDownloading]=React5.useState(false);return jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon","aria-label":label,title:label,disabled:downloading,className:"text-muted-foreground hover:text-foreground",onClick:async event=>{event.preventDefault();event.stopPropagation();if(busy.current)return;busy.current=true;setDownloading(true);try{await onDownload(artifact);}finally{busy.current=false;setDownloading(false);}},children:downloading?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Download,{className:"size-4","aria-hidden":"true"})})}function ActivityDetails({icon:Icon2,title,open,streaming,className,triggerClassName,contentClassName,children}){return jsxRuntime.jsxs("details",{className:cn2("group min-w-0 overflow-hidden rounded-lg border border-border bg-card text-card-foreground",className),open,children:[jsxRuntime.jsxs("summary",{className:cn2("flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",triggerClassName),children:[streaming?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsx("div",{className:cn2("min-w-0 border-t border-border px-3 py-3 text-sm",contentClassName),children})]})}function StatusIcon({status}){if(status==="completed"||status==="passed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-success","aria-hidden":"true"})}if(status==="failed"){return jsxRuntime.jsx(lucideReact.XCircle,{className:"size-4 text-destructive-text","aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 animate-pulse text-warning-foreground","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}function formatDuration(durationMs){if(durationMs<1e3)return "<1s";const totalSeconds=Math.floor(durationMs/1e3);const minutes=Math.floor(totalSeconds/60);const seconds=totalSeconds%60;return minutes>0?`${minutes}m ${seconds}s`:`${seconds}s`}function RunStatus({event}){const messages=useMonkeysLocaleMessages().agentWorkbench;const status=event.payload.status;if(status!=="stopping"&&status!=="stopped")return null;return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status",children:[status==="stopping"?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.CircleStop,{className:"size-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:status==="stopping"?messages.run.stopping:messages.run.stoppedAfter({duration:formatDuration(event.payload.durationMs??event.resolvedDurationMs??0)})})]})}function AgentWorkbenchActivity({viewModel,ariaLabel,hiddenToolCallIds,hideReasoning=false,hideStoppedRun=false,className,classNames,onApprovalDecision,onArtifactOpen,onArtifactDownload}){const messages=useMonkeysLocaleMessages().agentWorkbench;if(!viewModel)return null;const activity=createAgentWorkbenchActivityModel(viewModel);const reasoning=hideReasoning?[]:activity.reasoning;const tools=activity.tools.filter(event=>!hiddenToolCallIds?.has(event.payload.toolCallId));const approvals=activity.approvals.filter(event=>!event.payload.toolCallId||!hiddenToolCallIds?.has(event.payload.toolCallId));const usage=activity.usage?.payload;const contextWindow=typeof usage?.contextWindow==="number"&&usage.contextWindow>0?usage.contextWindow:void 0;const showRun=activity.run?.payload.status==="stopping"||activity.run?.payload.status==="stopped"&&!hideStoppedRun;const hasActivity=reasoning.length>0||activity.plans.length>0||activity.tasks.length>0||tools.length>0||approvals.length>0||activity.artifacts.length>0||showRun||contextWindow!==void 0;if(!hasActivity)return null;return jsxRuntime.jsxs("section",{className:cn2("space-y-3",classNames?.root,className),"aria-label":ariaLabel??messages.label,"data-agent-workbench-mode":activity.mode,"data-agent-workbench-status":activity.status,children:[reasoning.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:messages.reasoning,open:event.payload.status==="streaming",streaming:event.payload.status==="streaming",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsx("div",{tabIndex:0,className:"max-h-64 overflow-auto whitespace-pre-wrap break-words text-muted-foreground [overflow-wrap:anywhere]",children:event.payload.text})},event.payload.reasoningId)),activity.plans.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:event.payload.title||messages.plan,open:event.payload.status==="running",streaming:event.payload.status==="running",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsx("ol",{className:"space-y-2",children:event.payload.steps.map(step=>jsxRuntime.jsxs("li",{className:"flex min-w-0 items-start gap-2",children:[jsxRuntime.jsx(StatusIcon,{status:step.status}),jsxRuntime.jsx("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:step.title})]},step.id))})},event.payload.planId)),activity.tasks.map(event=>jsxRuntime.jsx(ActivityDetails,{icon:lucideReact.Circle,title:event.payload.title,open:event.payload.status==="running",streaming:event.payload.status==="running",className:classNames?.item,triggerClassName:classNames?.trigger,contentClassName:classNames?.content,children:jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(StatusIcon,{status:event.payload.status}),jsxRuntime.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-muted-foreground [overflow-wrap:anywhere]",children:event.payload.detail||messages.taskNoDetail})]})},event.payload.taskId)),tools.map(event=>jsxRuntime.jsx(AgentWorkbenchTool,{event,defaultExpanded:event.payload.status==="failed",classNames:{root:classNames?.item,trigger:classNames?.trigger,content:classNames?.content}},event.payload.toolCallId)),approvals.map(event=>{return jsxRuntime.jsx(AgentWorkbenchApproval,{approval:event.payload,className:classNames?.approval,onDecision:onApprovalDecision},event.payload.approvalId)}),activity.artifacts.map(event=>{const canOpen=Boolean(event.payload.url&&onArtifactOpen);return jsxRuntime.jsxs("article",{className:cn2("flex items-center gap-3 rounded-lg border border-border bg-card p-3 text-card-foreground",classNames?.artifact),children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"truncate text-sm font-medium",children:event.payload.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:messages.artifact[event.payload.status]})]}),event.payload.url?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground","aria-label":messages.artifact.open({name:event.payload.name}),title:messages.artifact.open({name:event.payload.name}),disabled:!canOpen,onClick:click=>{click.preventDefault();click.stopPropagation();if(!event.payload.url)return;onArtifactOpen?.({artifactId:event.payload.artifactId,name:event.payload.name,url:event.payload.url});},children:jsxRuntime.jsx(lucideReact.PanelRightOpen,{className:"size-4","aria-hidden":"true"})}):null,event.payload.url&&event.payload.status==="ready"&&onArtifactDownload?jsxRuntime.jsx(ArtifactDownloadButton,{artifact:{artifactId:event.payload.artifactId,name:event.payload.name,url:event.payload.url},label:messages.artifactWorkspace.download({name:event.payload.name}),onDownload:onArtifactDownload}):null]},event.payload.artifactId)}),showRun&&activity.run?jsxRuntime.jsx(RunStatus,{event:activity.run}):null,usage&&contextWindow!==void 0?jsxRuntime.jsx("div",{className:cn2("flex justify-end",classNames?.usage),"aria-label":messages.usage.label,children:jsxRuntime.jsx("span",{className:"rounded-full border border-border bg-muted px-2.5 py-1 text-xs text-foreground",children:messages.usage.context({used:usage.contextTokens??usage.totalTokens??0,total:contextWindow})})}):null]})}var WORKSPACE_CAPABILITIES={diff:"diff","workspace-file":"workspaceFiles",terminal:"terminal","test-result":"testResults",artifact:"artifacts"};function latestBy2(events,eventType,key2){const latest=new Map;for(const event of events){if(event.eventType!==eventType)continue;const typedEvent=event;latest.set(key2(typedEvent),typedEvent);}return [...latest.values()].sort((left,right)=>left.sequence-right.sequence)}function projectTerminals(events){const terminals=new Map;for(const event of events){const current=terminals.get(event.payload.terminalId)??{terminalId:event.payload.terminalId,stdin:"",stdout:"",stderr:"",status:"",sequence:event.sequence};const stream=event.payload.stream;terminals.set(event.payload.terminalId,{...current,...stream==="status"?{status:event.payload.chunk}:{[stream]:`${current[stream]}${event.payload.chunk}`},...event.payload.exitCode===void 0?{}:{exitCode:event.payload.exitCode},sequence:event.sequence});}return [...terminals.values()].sort((left,right)=>left.sequence-right.sequence)}function createAgentWorkbenchDetailsModel(viewModel){const capabilities=viewModel.snapshot.capabilities;const workspaceEvents=viewModel.events.filter(event=>{const capability=WORKSPACE_CAPABILITIES[event.eventType];return capability?capabilities[capability]===true:false});const run=[...viewModel.events].reverse().find(event=>event.eventType==="status");const currentRunId=run?.runId;const summary=[...viewModel.events].reverse().find(event=>event.eventType==="summary"&&capabilities.summary===true&&(!currentRunId||event.runId===currentRunId));return {mode:viewModel.snapshot.mode,modelId:viewModel.snapshot.modelId,permissionProfile:viewModel.snapshot.permissionProfile,status:viewModel.status,sessionId:viewModel.sessionId,capabilities,resumable:capabilities.resume===true&&viewModel.resumable,summary,error:[...viewModel.events].reverse().find(event=>event.eventType==="error"),run,usage:capabilities.usage?[...viewModel.events].reverse().find(event=>event.eventType==="usage"):void 0,workspace:{diffs:latestBy2(workspaceEvents,"diff",event=>event.payload.path),files:latestBy2(workspaceEvents,"workspace-file",event=>event.payload.path),terminals:projectTerminals(workspaceEvents.filter(event=>event.eventType==="terminal")),tests:latestBy2(workspaceEvents,"test-result",event=>event.payload.testId),artifacts:latestBy2(workspaceEvents,"artifact",event=>event.payload.artifactId)}}}function formatDuration2(durationMs){if(durationMs===void 0)return "-";const seconds=Math.max(0,Math.round(durationMs/1e3));if(seconds<60)return `${seconds}s`;return `${Math.floor(seconds/60)}m ${seconds%60}s`}function formatDate(value,locale){if(!value)return "-";const date=new Date(value);if(Number.isNaN(date.getTime()))return "-";return new Intl.DateTimeFormat(locale,{dateStyle:"medium",timeStyle:"short"}).format(date)}function Count({value}){return jsxRuntime.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-semibold text-foreground",children:value})}function DetailsSection({title,count,icon:Icon2,className,children}){if(count===0)return null;return jsxRuntime.jsxs("details",{className:cn2("group rounded-lg border border-border bg-card text-card-foreground",className),open:true,children:[jsxRuntime.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",children:[jsxRuntime.jsx(Icon2,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:title}),jsxRuntime.jsx(Count,{value:count}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"size-4 text-muted-foreground transition-transform group-open:rotate-180","aria-hidden":"true"})]}),jsxRuntime.jsx("div",{className:"border-t border-border p-3",children})]})}function StatusIcon2({status}){if(status==="completed"||status==="passed"){return jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"size-4 text-primary","aria-hidden":"true"})}if(status==="failed"){return jsxRuntime.jsx(lucideReact.XCircle,{className:"size-4 text-destructive-text","aria-hidden":"true"})}if(status==="running"){return jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 animate-pulse","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}function StateContent({state}){const messages=useMonkeysLocaleMessages().agentWorkbench.details;const error=state==="error";return jsxRuntime.jsxs("div",{className:"flex min-h-48 flex-col items-center justify-center gap-2 px-6 text-center",role:error?"alert":state==="loading"?"status":void 0,"aria-busy":state==="loading"||void 0,children:[state==="loading"?jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-5 animate-spin text-muted-foreground","aria-hidden":"true"}):error?jsxRuntime.jsx(lucideReact.AlertCircle,{className:"size-5 text-destructive-text","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("div",{className:"text-sm font-medium",children:messages.state[state].title}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:messages.state[state].description})]})}function SummaryPanel({model,onIntent}){const workbenchMessages=useMonkeysLocaleMessages().agentWorkbench;const messages=workbenchMessages.details;const locale=useMonkeysLocale().locale;const summary=model.summary;const run=model.run?.payload;const error=model.error;const retryable=model.status==="failed"&&error?.payload.retryable;const canResume=model.resumable&&["stopped","completed","failed"].includes(model.status);const canContinueInNewTask=model.capabilities.threadForking;const canEditAndRerun=model.capabilities.editAndRerun;const tokenUsage=model.usage?.payload.totalTokens??(model.usage?.payload.inputTokens!==void 0||model.usage?.payload.outputTokens!==void 0?(model.usage.payload.inputTokens??0)+(model.usage.payload.outputTokens??0):void 0);return jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("section",{className:"rounded-lg border border-border bg-muted/40 p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(StatusIcon2,{status:model.status}),jsxRuntime.jsx("span",{className:"text-sm font-semibold",children:messages.status[model.status]})]}),jsxRuntime.jsxs("dl",{className:"mt-3 grid grid-cols-2 gap-3 text-xs",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.duration}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:formatDuration2(run?.durationMs)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.updated}),jsxRuntime.jsx("dd",{className:"mt-0.5 truncate font-medium",children:formatDate(run?.stoppedAt??run?.completedAt??run?.failedAt,locale)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.model}),jsxRuntime.jsx("dd",{className:"mt-0.5 truncate font-medium",children:model.modelId})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.mode}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:workbenchMessages.modes[model.mode]})]}),model.permissionProfile?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.permissions}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:workbenchMessages.composer.permissionOptions[model.permissionProfile]})]}):null,tokenUsage!==void 0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("dt",{className:"text-muted-foreground",children:messages.tokenUsage}),jsxRuntime.jsx("dd",{className:"mt-0.5 font-medium",children:new Intl.NumberFormat(locale).format(tokenUsage)})]}):null]}),error?jsxRuntime.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/5 p-2.5 text-sm text-destructive-text",role:"alert",children:error.payload.message}):null,retryable||canResume?jsxRuntime.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[retryable?jsxRuntime.jsx(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"retry",eventId:error.eventId}),children:messages.actions.retry}):null,canResume?jsxRuntime.jsx(Button,{type:"button",size:"sm",className:"h-auto px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"resume",sessionId:model.sessionId}),children:messages.actions.resume}):null]}):null]}),jsxRuntime.jsxs("section",{className:"flex flex-wrap gap-2 rounded-lg border border-border bg-card p-3 text-card-foreground",children:[canContinueInNewTask?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"continue-in-new-task",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.GitFork,{className:"size-3.5","aria-hidden":"true"}),messages.actions.continueInNewTask]}):null,canEditAndRerun?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"edit-and-rerun",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.PencilLine,{className:"size-3.5","aria-hidden":"true"}),messages.actions.editAndRerun]}):null,jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"export",sessionId:model.sessionId}),children:[jsxRuntime.jsx(lucideReact.Download,{className:"size-3.5","aria-hidden":"true"}),messages.actions.export]})]}),jsxRuntime.jsxs("section",{className:"rounded-lg border border-border bg-card p-3 text-card-foreground",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:messages.summary}),summary?.payload.text?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-foreground","aria-label":messages.actions.copySummary,disabled:!onIntent,onClick:()=>onIntent?.({type:"copy-summary",summaryId:summary.payload.summaryId,text:summary.payload.text}),children:jsxRuntime.jsx(lucideReact.Copy,{className:"size-4","aria-hidden":"true"})}):null]}),summary?.payload.status==="failed"?jsxRuntime.jsxs("div",{className:"mt-3 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive-text",role:"alert",children:messages.summaryFailed}),jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"h-auto gap-1.5 px-2.5 py-1.5 text-xs",disabled:!onIntent,onClick:()=>onIntent?.({type:"retry-summary",eventId:summary.eventId}),children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"size-3.5","aria-hidden":"true"}),messages.actions.retrySummary]})]}):summary?.payload.text?jsxRuntime.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[jsxRuntime.jsx("p",{className:"whitespace-pre-wrap text-muted-foreground",children:summary.payload.text}),summary.payload.highlights.length>0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium",children:messages.highlights}),jsxRuntime.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 text-muted-foreground",children:summary.payload.highlights.map(item=>jsxRuntime.jsx("li",{children:item},item))})]}):null,summary.payload.pendingItems.length>0?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium",children:messages.pendingItems}),jsxRuntime.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 text-muted-foreground",children:summary.payload.pendingItems.map(item=>jsxRuntime.jsx("li",{children:item},item))})]}):null]}):jsxRuntime.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:messages.summaryEmpty})]})]})}function WorkspacePanel({model,sectionClassName,codeClassName}){const messages=useMonkeysLocaleMessages().agentWorkbench.details.workspace;const workspace=model.workspace;return jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(DetailsSection,{title:messages.diffs,count:workspace.diffs.length,icon:lucideReact.FileCode2,className:sectionClassName,children:jsxRuntime.jsx("div",{className:"space-y-3",children:workspace.diffs.map(event=>jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[jsxRuntime.jsx("span",{className:"truncate font-medium",children:event.payload.path}),jsxRuntime.jsx("span",{className:"shrink-0 text-muted-foreground",children:messages.diffStatus[event.payload.status]})]}),event.payload.patch?jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:event.payload.patch}):null]},event.payload.path))})}),jsxRuntime.jsx(DetailsSection,{title:messages.files,count:workspace.files.length,icon:lucideReact.Files,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.files.map(event=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.path}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:messages.fileOperation[event.payload.operation]})]},event.payload.path))})}),jsxRuntime.jsx(DetailsSection,{title:messages.terminals,count:workspace.terminals.length,icon:lucideReact.TerminalSquare,className:sectionClassName,children:jsxRuntime.jsx("div",{className:"space-y-3",children:workspace.terminals.map(terminal=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex justify-between gap-2 text-xs font-medium",children:[jsxRuntime.jsx("span",{children:terminal.terminalId}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:terminal.exitCode===void 0?terminal.status:messages.exitCode({code:terminal.exitCode})})]}),jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:[terminal.stdin,terminal.stdout,terminal.stderr].filter(Boolean).join("\n")})]},terminal.terminalId))})}),jsxRuntime.jsx(DetailsSection,{title:messages.tests,count:workspace.tests.length,icon:lucideReact.TestTube2,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.tests.map(event=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(StatusIcon2,{status:event.payload.status}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.name}),event.payload.durationMs===void 0?null:jsxRuntime.jsx("span",{className:"text-muted-foreground",children:formatDuration2(event.payload.durationMs)})]}),event.payload.output?jsxRuntime.jsx("pre",{className:cn2("mt-2 max-h-48 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",codeClassName),children:event.payload.output}):null]},event.payload.testId))})}),jsxRuntime.jsx(DetailsSection,{title:messages.artifacts,count:workspace.artifacts.length,icon:lucideReact.FileOutput,className:sectionClassName,children:jsxRuntime.jsx("ul",{className:"space-y-2 text-xs",children:workspace.artifacts.map(event=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.FileOutput,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:event.payload.name}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:event.payload.kind})]},event.payload.artifactId))})})]})}function AgentWorkbenchTaskDetails({viewModel,state="ready",activeTab="summary",className,classNames,onActiveTabChange,onIntent,onExport,onCopySummary,onRetry,onRetrySummary}){const dispatch=onIntent||onExport||onCopySummary||onRetry||onRetrySummary?intent=>{if(intent.type==="export"&&onExport)return onExport(intent);if(intent.type==="copy-summary"&&onCopySummary)return onCopySummary(intent);if(intent.type==="retry"&&onRetry)return onRetry(intent);if(intent.type==="retry-summary"&&onRetrySummary)return onRetrySummary(intent);onIntent?.(intent);}:void 0;const messages=useMonkeysLocaleMessages().agentWorkbench.details;if(state!=="ready"){return jsxRuntime.jsx("aside",{className:cn2("flex h-full min-h-0 flex-col border-l border-border bg-background",classNames?.root,className),children:jsxRuntime.jsx(StateContent,{state})})}if(!viewModel){return jsxRuntime.jsx("aside",{className:cn2("flex h-full min-h-0 flex-col border-l border-border bg-background",classNames?.root,className),children:jsxRuntime.jsx(StateContent,{state:"empty"})})}const model=createAgentWorkbenchDetailsModel(viewModel);const workspaceCount=Object.values(model.workspace).reduce((total,items)=>total+items.length,0);const workspaceAvailable=workspaceCount>0;const resolvedTab=activeTab==="workspace"&&!workspaceAvailable?"summary":activeTab;const tabs=[{id:"summary",label:messages.tabs.summary,count:model.summary?1:0},...workspaceAvailable?[{id:"workspace",label:messages.tabs.workspace,count:workspaceCount}]:[]];return jsxRuntime.jsxs("aside",{className:cn2("flex h-full min-h-0 min-w-0 flex-col border-l border-border bg-background text-foreground",classNames?.root,className),"data-agent-workbench-mode":model.mode,children:[jsxRuntime.jsxs("header",{className:cn2("flex shrink-0 items-center gap-2 border-b border-border px-4 py-3",classNames?.header),children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("h2",{className:"truncate text-sm font-semibold",children:messages.title}),jsxRuntime.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:messages.description})]}),onIntent?jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground","aria-label":messages.actions.close,onClick:()=>onIntent({type:"close"}),children:jsxRuntime.jsx(lucideReact.X,{className:"size-4","aria-hidden":"true"})}):null]}),jsxRuntime.jsxs(Tabs,{value:resolvedTab,className:"flex min-h-0 flex-1 flex-col",onValueChange:tab=>onActiveTabChange?.(tab),children:[jsxRuntime.jsx(TabsList,{"aria-label":messages.tabs.label,className:cn2("flex h-auto shrink-0 gap-1 rounded-none border-b border-border bg-transparent px-3 py-2",classNames?.tabs),children:tabs.map(tab=>jsxRuntime.jsxs(TabsTrigger,{value:tab.id,className:"min-w-0 flex-1 gap-1 px-2 py-1.5 text-xs shadow-none data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",children:[jsxRuntime.jsx("span",{className:"truncate",children:tab.label}),jsxRuntime.jsx(Count,{value:tab.count})]},tab.id))}),jsxRuntime.jsx(TabsContent,{value:"summary",className:cn2("mt-0 min-h-0 flex-1 overflow-y-auto p-3",classNames?.body),children:jsxRuntime.jsx(SummaryPanel,{model,onIntent:dispatch})}),workspaceAvailable?jsxRuntime.jsx(TabsContent,{value:"workspace",className:cn2("mt-0 min-h-0 flex-1 overflow-y-auto p-3",classNames?.body),children:jsxRuntime.jsx(WorkspacePanel,{model,sectionClassName:classNames?.section,codeClassName:classNames?.code})}):null]})]})}var AgentWorkbenchMessage=React5.forwardRef(function AgentWorkbenchMessage2({role,className,...messageProps},ref){return jsxRuntime.jsx("div",{...messageProps,ref,"data-agent-message-role":role,className:cn2("group flex w-full max-w-[95%] min-w-0 flex-col gap-2",role==="user"?"is-user ml-auto justify-end":"is-assistant",role==="system"&&"mx-auto items-center text-center",className)})});var AgentWorkbenchMessageContent=React5.forwardRef(function AgentWorkbenchMessageContent2({children,className,tabIndex=0,...contentProps},ref){return jsxRuntime.jsx("div",{...contentProps,ref,tabIndex,className:cn2("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-x-auto overflow-y-hidden break-words text-sm [overflow-wrap:anywhere]","[&_a]:max-w-full [&_a]:break-all [&_code]:max-w-full [&_code]:break-words","[&_pre]:w-max [&_pre]:min-w-full [&_pre]:whitespace-pre [&_pre_code]:break-normal","[&_table]:w-max [&_table]:min-w-full [&_table]:whitespace-nowrap","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",className),children})});var AgentWorkbenchMessageActions=React5.forwardRef(function AgentWorkbenchMessageActions2({children,className,...actionsProps},ref){return jsxRuntime.jsx("div",{...actionsProps,ref,className:cn2("flex min-w-0 items-center gap-1",className),children})});var AgentWorkbenchMessageAction=React5.forwardRef(function AgentWorkbenchMessageAction2({children,label,tooltip,className,disabled=false,type="button",...buttonProps},ref){return jsxRuntime.jsx("button",{...buttonProps,ref,type,"aria-label":label,title:tooltip,disabled,className:cn2("inline-flex size-8 shrink-0 items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground shadow-none transition-colors","hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",className),children})});function materializeMessages(events){const messages=new Map;for(const event of events){if(event.eventType!=="message")continue;const current=messages.get(event.payload.messageId);const parts=event.payload.operation==="replace"?event.payload.parts:[...current?.parts??[],...event.payload.parts];messages.set(event.payload.messageId,{id:event.payload.messageId,role:event.payload.role,parts,sequence:event.sequence});}return [...messages.values()]}function logicalActivityKey(event){switch(event.eventType){case "reasoning":return `reasoning:${event.payload.reasoningId}`;case "plan":return `plan:${event.payload.planId}`;case "task":return `task:${event.payload.taskId}`;case "tool":return `tool:${event.payload.toolCallId}`;case "approval":return `approval:${event.payload.approvalId}`;case "artifact":return `artifact:${event.payload.artifactId}`;case "usage":return "usage";case "status":return "status";default:return void 0}}function createThreadEntries(viewModel){const messages=materializeMessages(viewModel.events).map(message=>({type:"message",sequence:message.sequence,message}));const activity=new Map;for(const event of viewModel.events){const key2=logicalActivityKey(event);if(key2)activity.set(key2,event);}return [...messages,...viewModel.events.filter(event=>event.eventType==="error").map(event=>({type:"error",sequence:event.sequence,event})),...[...activity.values()].map(event=>({type:"activity",sequence:event.sequence,event}))].sort((left,right)=>left.sequence-right.sequence)}function partText(part){if(typeof part==="string")return part;if(!part||typeof part!=="object"||Array.isArray(part))return String(part??"");const record=part;if(typeof record.text==="string")return record.text;if(typeof record.name==="string")return record.name;return JSON.stringify(record,null,2)}function DefaultMessageContent({message}){const content=message.parts.map(partText).filter(Boolean).join("");return jsxRuntime.jsx("div",{className:"whitespace-pre-wrap break-words",children:content})}function singleEventViewModel(viewModel,event){return {...viewModel,events:[event],lastSequence:event.sequence}}function AgentWorkbenchThread({viewModel,loading=false,emptyTitle,emptyDescription,autoScroll=true,className,classNames,renderMessageContent,onApprovalDecision,onArtifactOpen}){const messages=useMonkeysLocaleMessages().agentWorkbench;const resolvedEmptyTitle=emptyTitle??messages.navigation.emptySessions;const scrollRef=React5.useRef(null);const entries=React5.useMemo(()=>viewModel?createThreadEntries(viewModel):[],[viewModel]);React5.useEffect(()=>{if(!autoScroll||!viewModel)return;const element=scrollRef.current;if(element)element.scrollTop=element.scrollHeight;},[autoScroll,viewModel?.lastSequence,viewModel?.sessionId]);return jsxRuntime.jsx("div",{ref:scrollRef,role:"log","aria-label":messages.label,className:cn2("min-h-0 flex-1 overflow-y-auto bg-background",classNames?.root,className),children:loading&&entries.length===0?jsxRuntime.jsxs("div",{className:cn2("flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground",classNames?.loading),role:"status",children:[jsxRuntime.jsx("span",{className:"size-4 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-muted-foreground","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.navigation.loading})]}):entries.length===0?jsxRuntime.jsxs("div",{className:cn2("flex min-h-48 flex-col items-center justify-center px-6 text-center",classNames?.empty),children:[jsxRuntime.jsx("h2",{className:"text-base font-semibold text-foreground",children:resolvedEmptyTitle}),emptyDescription?jsxRuntime.jsx("p",{className:"mt-1 max-w-lg text-sm text-muted-foreground",children:emptyDescription}):null]}):jsxRuntime.jsx("div",{className:cn2("mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 sm:px-6",classNames?.list),children:entries.map(entry=>{if(entry.type==="error"){return jsxRuntime.jsx("div",{role:"alert",className:cn2("rounded-lg border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive-text",classNames?.activity),children:entry.event.payload.message},`error:${entry.event.eventId}`)}if(entry.type==="activity"){return jsxRuntime.jsx(AgentWorkbenchActivity,{viewModel:singleEventViewModel(viewModel,entry.event),ariaLabel:`${messages.label} ${entry.sequence+1}`,className:classNames?.activity,onApprovalDecision,onArtifactOpen},`activity:${entry.event.eventId}`)}const{message}=entry;const isUser=message.role==="user";const isSystem=message.role==="system";if(isSystem){return jsxRuntime.jsx("div",{className:cn2("text-center text-xs text-muted-foreground",classNames?.message),children:renderMessageContent?.(message)??jsxRuntime.jsx(DefaultMessageContent,{message})},message.id)}return jsxRuntime.jsxs(AgentWorkbenchMessage,{role:message.role,className:cn2("flex-row items-start gap-3",isUser&&"flex-row-reverse",classNames?.message),"data-message-role":message.role,children:[jsxRuntime.jsx("span",{className:cn2("flex size-8 shrink-0 items-center justify-center rounded-full",isUser?"bg-primary text-primary-foreground":"bg-muted text-foreground"),"aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-current"})}),jsxRuntime.jsx(AgentWorkbenchMessageContent,{className:cn2("max-w-[85%] rounded-2xl px-4 py-2.5 text-sm leading-6",!isUser&&"bg-card text-card-foreground",classNames?.messageContent),children:renderMessageContent?.(message)??jsxRuntime.jsx(DefaultMessageContent,{message})})]},message.id)})})})}var AgentWorkbenchThreadShell=React5.forwardRef(function AgentWorkbenchThreadShell2({children,title,headerActions,showHeader=Boolean(title||headerActions),variant,density,className,classNames,...shellProps},ref){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";return jsxRuntime.jsxs("section",{...shellProps,ref,"data-agent-thread-shell":"true","data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,className:cn2("flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground",classNames?.root,className),children:[showHeader?jsxRuntime.jsxs("div",{className:cn2("flex min-w-0 items-center justify-between border-b border-border",compact?"min-h-10 gap-2 px-3 py-1.5":"min-h-11 gap-3 px-4 py-2",classNames?.header),children:[jsxRuntime.jsx("h1",{className:cn2("min-w-0 flex-1 truncate font-normal text-foreground",compact?"text-base leading-5":"text-lg leading-6",classNames?.title),children:title}),headerActions?jsxRuntime.jsx("div",{className:cn2("flex min-w-0 shrink-0 items-center gap-0.5",classNames?.headerActions),children:headerActions}):null]}):null,jsxRuntime.jsx("div",{className:cn2("flex min-h-0 min-w-0 flex-1 flex-col",classNames?.body),children})]})});var AGENT_WORKBENCH_SHELL_BREAKPOINTS=Object.freeze({mobile:768,drawer:1200,compact:1440,lowHeight:768});function resolveAgentWorkbenchShellLayout(width,breakpoints=AGENT_WORKBENCH_SHELL_BREAKPOINTS){if(width<breakpoints.mobile)return "mobile";if(width<breakpoints.drawer)return "drawer";if(width<breakpoints.compact)return "compact";return "wide"}var OVERLAY_EVENT="monkeys-agent-workbench-overlay-open";function cssSize(value){return typeof value==="number"?`${value}px`:value}function clamp(value,min,max){return Math.min(Math.max(value,min),Math.max(min,max))}function initialMeasuredSize(){if(typeof window==="undefined")return {width:1440,height:900};return {width:window.visualViewport?.width??window.innerWidth,height:window.visualViewport?.height??window.innerHeight}}function readStoredWidths(storageKey){if(!storageKey||typeof window==="undefined")return {};try{const value=JSON.parse(window.localStorage.getItem(storageKey)??"{}");return typeof value==="object"&&value!==null?value:{}}catch{return {}}}function writeStoredWidths(storageKey,widths){if(!storageKey||typeof window==="undefined")return;window.localStorage.setItem(storageKey,JSON.stringify(widths));}function AgentWorkbenchShell({sidebar,children,details,sidebarOpen=true,sidebarDefaultOpen=true,detailsOpen=true,onDetailsOpenChange,sidebarWidth=280,detailsWidth=360,sidebarMinWidth=240,sidebarMaxWidth=400,detailsMinWidth=320,detailsMaxWidth=720,mainMinWidth=600,responsive=false,responsiveMeasurement="container",responsiveWidth,responsiveHeight,breakpoints=AGENT_WORKBENCH_SHELL_BREAKPOINTS,onLayoutChange,showResponsiveControls=true,overlayGroupId,resizable=false,widthStorageKey,onSidebarWidthChange,onDetailsWidthChange,labels,variant,density,className,classNames,style,...rootProps}){const appearance=useAgentWorkbenchAppearance({variant,density});const rootRef=React5.useRef(null);const sidebarReturnFocusRef=React5.useRef(null);const detailsReturnFocusRef=React5.useRef(null);const shellId=React5.useId();const[measuredSize,setMeasuredSize]=React5.useState(initialMeasuredSize);const storedWidths=React5.useMemo(()=>readStoredWidths(widthStorageKey),[widthStorageKey]);const[sidebarPixelWidth,setSidebarPixelWidth]=React5.useState(()=>typeof sidebarWidth==="number"?storedWidths.sidebar??sidebarWidth:280);const[detailsPixelWidth,setDetailsPixelWidth]=React5.useState(()=>typeof detailsWidth==="number"?storedWidths.details??detailsWidth:360);const[sidebarOverlayOpen,setSidebarOverlayOpen]=React5.useState(false);const[detailsOverlayOpen,setDetailsOverlayOpen]=React5.useState(false);const[sidebarExpanded,setSidebarExpanded]=React5.useState(sidebarDefaultOpen);const rememberReturnFocus=React5.useCallback((region,candidate=document.activeElement)=>{if(!(candidate instanceof HTMLElement)||candidate===document.body||candidate===document.documentElement){return}const targetRef=region==="sidebar"?sidebarReturnFocusRef:detailsReturnFocusRef;targetRef.current=candidate;},[]);const restoreReturnFocus=React5.useCallback(region=>{const targetRef=region==="sidebar"?sidebarReturnFocusRef:detailsReturnFocusRef;const target=targetRef.current;targetRef.current=null;if(!target?.isConnected)return;window.requestAnimationFrame(()=>{if(target.isConnected)target.focus();});},[]);React5.useEffect(()=>{if(typeof sidebarWidth==="number"){setSidebarPixelWidth(storedWidths.sidebar??sidebarWidth);}},[sidebarWidth,storedWidths.sidebar]);React5.useEffect(()=>setSidebarExpanded(sidebarDefaultOpen),[sidebarDefaultOpen]);React5.useEffect(()=>{if(typeof detailsWidth==="number"){setDetailsPixelWidth(storedWidths.details??detailsWidth);}},[detailsWidth,storedWidths.details]);React5.useEffect(()=>{if(!responsive)return void 0;const updateViewport=()=>{const viewport=initialMeasuredSize();setMeasuredSize({width:responsiveWidth??viewport.width,height:responsiveHeight??viewport.height});};if(responsiveMeasurement==="viewport"||responsiveWidth!==void 0||responsiveHeight!==void 0){updateViewport();if(responsiveWidth!==void 0&&responsiveHeight!==void 0){return void 0}window.addEventListener("resize",updateViewport);window.visualViewport?.addEventListener("resize",updateViewport);return ()=>{window.removeEventListener("resize",updateViewport);window.visualViewport?.removeEventListener("resize",updateViewport);}}const root=rootRef.current;if(!root)return void 0;const updateContainer=()=>{const rect=root.getBoundingClientRect();setMeasuredSize({width:rect.width,height:rect.height});};updateContainer();if(typeof ResizeObserver==="undefined"){window.addEventListener("resize",updateContainer);return ()=>window.removeEventListener("resize",updateContainer)}const observer=new ResizeObserver(updateContainer);observer.observe(root);return ()=>observer.disconnect()},[responsive,responsiveHeight,responsiveMeasurement,responsiveWidth]);const layout=responsive?resolveAgentWorkbenchShellLayout(responsiveWidth??measuredSize.width,breakpoints):"wide";const lowHeight=responsive&&(responsiveHeight??measuredSize.height)<=breakpoints.lowHeight;React5.useEffect(()=>onLayoutChange?.(layout),[layout,onLayoutChange]);const hasSidebar=sidebar!==void 0&&sidebarOpen;const hasDetails=details!==void 0&&detailsOpen;const sidebarUsesOverlay=layout==="drawer"||layout==="mobile";const inlineSidebar=hasSidebar&&sidebarExpanded&&!sidebarUsesOverlay;const inlineDetails=hasDetails&&layout==="wide";const resolvedSidebarMax=Math.max(sidebarMinWidth,Math.min(sidebarMaxWidth,layout==="compact"?320:sidebarMaxWidth,measuredSize.width-(inlineDetails?detailsPixelWidth:0)-mainMinWidth));const resolvedDetailsMax=Math.max(detailsMinWidth,Math.min(detailsMaxWidth,measuredSize.width-(inlineSidebar?sidebarPixelWidth:0)-mainMinWidth));const resolvedSidebarWidth=typeof sidebarWidth==="number"?clamp(sidebarPixelWidth,sidebarMinWidth,resolvedSidebarMax):sidebarWidth;const resolvedDetailsWidth=typeof detailsWidth==="number"?clamp(detailsPixelWidth,detailsMinWidth,resolvedDetailsMax):detailsWidth;const requestOverlay=React5.useCallback(region=>{if(!overlayGroupId||typeof window==="undefined")return;window.dispatchEvent(new CustomEvent(OVERLAY_EVENT,{detail:{groupId:overlayGroupId,ownerId:shellId,region}}));},[overlayGroupId,shellId]);React5.useEffect(()=>{if(!overlayGroupId||typeof window==="undefined")return void 0;const handleOverlayOpen=event=>{const detail=event.detail;if(detail?.groupId!==overlayGroupId||detail?.ownerId===shellId)return;setSidebarOverlayOpen(false);setDetailsOverlayOpen(open=>{if(open)onDetailsOpenChange?.(false);return false});};window.addEventListener(OVERLAY_EVENT,handleOverlayOpen);return ()=>window.removeEventListener(OVERLAY_EVENT,handleOverlayOpen)},[onDetailsOpenChange,overlayGroupId,shellId]);React5.useEffect(()=>{if(inlineSidebar||!hasSidebar)setSidebarOverlayOpen(false);},[hasSidebar,inlineSidebar]);React5.useEffect(()=>{if(inlineDetails||!hasDetails){setDetailsOverlayOpen(false);return}rememberReturnFocus("details");requestOverlay("details");setDetailsOverlayOpen(true);},[hasDetails,inlineDetails,rememberReturnFocus,requestOverlay]);const persistWidths=React5.useCallback((sidebarValue,detailsValue)=>{writeStoredWidths(widthStorageKey,{sidebar:sidebarValue,details:detailsValue});},[widthStorageKey]);const updateRegionWidth=React5.useCallback((region,value)=>{if(region==="sidebar"){const next2=clamp(value,sidebarMinWidth,resolvedSidebarMax);setSidebarPixelWidth(next2);onSidebarWidthChange?.(next2);return next2}const next=clamp(value,detailsMinWidth,resolvedDetailsMax);setDetailsPixelWidth(next);onDetailsWidthChange?.(next);return next},[detailsMinWidth,onDetailsWidthChange,onSidebarWidthChange,resolvedDetailsMax,resolvedSidebarMax,sidebarMinWidth]);const beginResize=React5.useCallback((region,event)=>{if(!resizable||event.button!==0)return;event.preventDefault();const startX=event.clientX;const startWidth=region==="sidebar"?sidebarPixelWidth:detailsPixelWidth;let latestWidth=startWidth;const previousCursor=document.body.style.cursor;const previousUserSelect=document.body.style.userSelect;document.body.style.cursor="col-resize";document.body.style.userSelect="none";const handleMove=pointerEvent=>{const delta=pointerEvent.clientX-startX;latestWidth=updateRegionWidth(region,startWidth+(region==="sidebar"?delta:-delta));};const handleUp=()=>{document.body.style.cursor=previousCursor;document.body.style.userSelect=previousUserSelect;window.removeEventListener("pointermove",handleMove);window.removeEventListener("pointerup",handleUp);persistWidths(region==="sidebar"?latestWidth:sidebarPixelWidth,region==="details"?latestWidth:detailsPixelWidth);};window.addEventListener("pointermove",handleMove);window.addEventListener("pointerup",handleUp,{once:true});},[detailsPixelWidth,persistWidths,resizable,sidebarPixelWidth,updateRegionWidth]);const resizeWithKeyboard=React5.useCallback((region,direction)=>{const current=region==="sidebar"?sidebarPixelWidth:detailsPixelWidth;const next=updateRegionWidth(region,current+direction*16);persistWidths(region==="sidebar"?next:sidebarPixelWidth,region==="details"?next:detailsPixelWidth);},[detailsPixelWidth,persistWidths,sidebarPixelWidth,updateRegionWidth]);const shellStyle={"--agent-workbench-sidebar-width":inlineSidebar?cssSize(resolvedSidebarWidth):"0px","--agent-workbench-details-width":inlineDetails?cssSize(resolvedDetailsWidth):"0px",gridTemplateColumns:inlineSidebar&&inlineDetails?"var(--agent-workbench-sidebar-width) minmax(0, 1fr) var(--agent-workbench-details-width)":inlineSidebar?"var(--agent-workbench-sidebar-width) minmax(0, 1fr)":inlineDetails?"minmax(0, 1fr) var(--agent-workbench-details-width)":"minmax(0, 1fr)",...style};const sidebarOverlay=hasSidebar&&sidebarUsesOverlay;const sidebarRestoreControl=hasSidebar&&!sidebarExpanded&&!sidebarUsesOverlay;const detailsOverlay=hasDetails&&!inlineDetails;const showControls=responsive&&showResponsiveControls&&(sidebarOverlay||sidebarRestoreControl||detailsOverlay);const mobilePanel=layout==="mobile";const controlSize=mobilePanel?"size-11":"size-9";const panelCloseClass=mobilePanel?"[&>button]:flex [&>button]:size-11 [&>button]:items-center [&>button]:justify-center":"";return jsxRuntime.jsxs("div",{...rootProps,ref:rootRef,role:rootProps.role??"region","aria-label":rootProps["aria-label"]??"Agent workbench","data-agent-workbench-shell":"true","data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-layout":layout,"data-agent-workbench-low-height":lowHeight?"true":"false","data-sidebar-open":hasSidebar?"true":"false","data-sidebar-expanded":sidebarExpanded?"true":"false","data-sidebar-presentation":inlineSidebar?"inline":sidebarOverlay?"overlay":"hidden","data-details-open":hasDetails?"true":"false","data-details-presentation":inlineDetails?"inline":detailsOverlay?"overlay":"hidden",className:cn2("relative grid size-full min-h-0 min-w-0 overflow-hidden bg-background text-foreground",classNames?.root,className),style:shellStyle,children:[inlineSidebar?jsxRuntime.jsx("div",{"data-agent-workbench-region":"sidebar",className:cn2("min-h-0 min-w-0 overflow-hidden border-r border-border bg-card text-card-foreground",classNames?.sidebar),children:sidebar}):null,jsxRuntime.jsxs("div",{"data-agent-workbench-region":"main",className:cn2("flex min-h-0 min-w-0 flex-col overflow-hidden bg-background",classNames?.main),children:[showControls?jsxRuntime.jsxs("div",{"data-agent-workbench-responsive-controls":"true",className:cn2("flex min-h-11 shrink-0 items-center gap-1 border-b border-border bg-background px-2",lowHeight&&"min-h-10",classNames?.controls),children:[sidebarOverlay||sidebarRestoreControl?jsxRuntime.jsx("button",{type:"button",className:cn2("inline-flex items-center justify-center rounded-[var(--radius)] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",controlSize),"aria-label":labels?.openSidebar??"Open navigation","aria-expanded":sidebarRestoreControl?sidebarExpanded:sidebarOverlayOpen,onClick:event=>{if(sidebarRestoreControl){setSidebarExpanded(true);return}rememberReturnFocus("sidebar",event.currentTarget);requestOverlay("sidebar");setSidebarOverlayOpen(true);},children:jsxRuntime.jsx(lucideReact.PanelLeft,{className:"size-5","aria-hidden":"true"})}):null,detailsOverlay&&details?jsxRuntime.jsx("button",{type:"button",className:cn2("ml-auto inline-flex items-center justify-center rounded-[var(--radius)] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",controlSize),"aria-label":labels?.openDetails??"Open details","aria-expanded":detailsOverlayOpen,onClick:event=>{rememberReturnFocus("details",event.currentTarget);requestOverlay("details");setDetailsOverlayOpen(true);},children:jsxRuntime.jsx(lucideReact.PanelRight,{className:"size-5","aria-hidden":"true"})}):null]}):null,jsxRuntime.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children})]}),inlineDetails?jsxRuntime.jsx("div",{"data-agent-workbench-region":"details",className:cn2("min-h-0 min-w-0 overflow-hidden border-l border-border bg-card text-card-foreground",classNames?.details),children:details}):null,resizable&&inlineSidebar&&typeof sidebarWidth==="number"?jsxRuntime.jsx("button",{type:"button",role:"separator","aria-orientation":"vertical","aria-label":labels?.resizeSidebar??"Resize navigation","aria-valuemin":sidebarMinWidth,"aria-valuemax":resolvedSidebarMax,"aria-valuenow":Number(resolvedSidebarWidth),className:cn2("absolute inset-y-0 z-20 w-2 -translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-border after:transition-colors hover:after:bg-primary focus-visible:after:w-0.5 focus-visible:after:bg-ring",classNames?.resizeHandle),style:{left:"var(--agent-workbench-sidebar-width)"},onPointerDown:event=>beginResize("sidebar",event),onKeyDown:event=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault();resizeWithKeyboard("sidebar",event.key==="ArrowRight"?1:-1);}}):null,resizable&&inlineDetails&&typeof detailsWidth==="number"?jsxRuntime.jsx("button",{type:"button",role:"separator","aria-orientation":"vertical","aria-label":labels?.resizeDetails??"Resize details","aria-valuemin":detailsMinWidth,"aria-valuemax":resolvedDetailsMax,"aria-valuenow":Number(resolvedDetailsWidth),className:cn2("absolute inset-y-0 right-[var(--agent-workbench-details-width)] z-20 w-2 translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-border after:transition-colors hover:after:bg-primary focus-visible:after:w-0.5 focus-visible:after:bg-ring",classNames?.resizeHandle),onPointerDown:event=>beginResize("details",event),onKeyDown:event=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault();resizeWithKeyboard("details",event.key==="ArrowLeft"?1:-1);}}):null,sidebarOverlay?jsxRuntime.jsx(Sheet,{open:sidebarOverlayOpen,onOpenChange:open=>{setSidebarOverlayOpen(open);if(!open)restoreReturnFocus("sidebar");},children:jsxRuntime.jsxs(SheetContent,{side:"left","aria-describedby":void 0,className:cn2("flex h-dvh flex-col gap-0 overflow-hidden bg-card p-0 text-card-foreground",mobilePanel?"inset-0 size-dvw !max-w-none border-0":"w-[min(360px,90vw)] !max-w-none",panelCloseClass,classNames?.sidebarOverlay),children:[jsxRuntime.jsx(SheetTitle,{className:"sr-only",children:labels?.sidebar??"Navigation"}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:sidebar})]})}):null,detailsOverlay?jsxRuntime.jsx(Sheet,{open:detailsOverlayOpen,onOpenChange:open=>{setDetailsOverlayOpen(open);if(!open){restoreReturnFocus("details");onDetailsOpenChange?.(false);}},children:jsxRuntime.jsxs(SheetContent,{side:"right","aria-describedby":void 0,className:cn2("flex h-dvh flex-col gap-0 overflow-hidden bg-card p-0 text-card-foreground",mobilePanel?"inset-0 size-dvw !max-w-none border-0":"w-[min(520px,92vw)] !max-w-none",panelCloseClass,classNames?.detailsOverlay),children:[jsxRuntime.jsx(SheetTitle,{className:"sr-only",children:labels?.details??"Details"}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:details})]})}):null]})}function formatDuration3(durationMs){const totalSeconds=Math.max(0,Math.floor(durationMs/1e3));const hours=Math.floor(totalSeconds/3600);const minutes=Math.floor(totalSeconds%3600/60);const seconds=totalSeconds%60;if(hours>0)return minutes>0?`${hours}h ${minutes}m`:`${hours}h`;if(minutes===0)return `${seconds}s`;return `${minutes}m ${seconds}s`}function isActive(status){return status==="queued"||status==="running"||status==="waiting_approval"}function AgentWorkbenchProcess({status,children,durationMs,completedCount,totalCount,open,defaultOpen,onOpenChange,className,contentClassName,label,title:processTitle,createdAt,showStatusIcon=true,variant,density}){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const messages=useMonkeysLocaleMessages().agentWorkbench;const controlled=open!==void 0;const[internalOpen,setInternalOpen]=React5.useState(defaultOpen??isActive(status));const userChangedOpen=React5.useRef(false);const previousStatus=React5.useRef(status);const resolvedOpen=controlled?open:internalOpen;React5.useEffect(()=>{if(controlled||userChangedOpen.current||previousStatus.current===status)return;previousStatus.current=status;setInternalOpen(isActive(status));},[controlled,status]);const handleOpenChange=nextOpen=>{userChangedOpen.current=true;if(!controlled)setInternalOpen(nextOpen);onOpenChange?.(nextOpen);};const duration=durationMs===void 0?void 0:formatDuration3(durationMs);const title=label??(status==="queued"?messages.process.queued:status==="waiting_approval"?messages.process.waitingApproval:status==="running"?messages.process.running:status==="failed"?messages.process.failed:status==="stopped"?messages.process.stopped:duration?messages.process.processedFor({duration}):messages.process.processed);const showCount=totalCount!==void 0&&totalCount>0;const displayTitle=processTitle??title;const parsedCreatedAt=createdAt?new Date(createdAt):void 0;const createdTime=parsedCreatedAt&&Number.isFinite(parsedCreatedAt.getTime())?parsedCreatedAt.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false}):void 0;const hasProcessDetails=processTitle!==void 0&&(createdTime!==void 0||label!==void 0);return jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Root,{open:resolvedOpen,onOpenChange:handleOpenChange,className:cn2("group/process w-full min-w-0",className),"data-agent-process-status":status,"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"aria-busy":isActive(status)?"true":void 0,children:[jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Trigger,{className:cn2("flex w-full min-w-0 items-center gap-2 border-b border-border/70 text-left text-sm text-muted-foreground outline-hidden transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",compact?"min-h-8 py-1.5":"min-h-9 py-2"),children:[showStatusIcon?status==="running"||status==="queued"?jsxRuntime.jsx(lucideReact.Loader2,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}):status==="waiting_approval"?jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 shrink-0 text-warning-foreground","aria-hidden":"true"}):status==="failed"?jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-4 shrink-0 text-destructive-text","aria-hidden":"true"}):status==="completed"?jsxRuntime.jsx(lucideReact.Check,{className:"size-4 shrink-0 text-success","aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Clock3,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:hasProcessDetails?jsxRuntime.jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxRuntime.jsxs("span",{className:"flex min-w-0 items-center gap-2 truncate",children:[jsxRuntime.jsx("span",{className:"truncate",children:displayTitle}),createdTime?jsxRuntime.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/70",children:createdTime}):null]}),label?jsxRuntime.jsx("span",{className:"truncate text-xs text-muted-foreground/70",children:label}):null]}):title}),showCount?jsxRuntime.jsx("span",{className:"shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground",children:messages.process.completedCount({completed:completedCount??0,total:totalCount})}):null,jsxRuntime.jsx(lucideReact.ChevronRight,{className:"size-4 shrink-0 transition-transform group-data-[state=open]/process:rotate-90","aria-hidden":"true"})]}),jsxRuntime.jsx(CollapsiblePrimitive__namespace.Content,{className:cn2("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",contentClassName),children:jsxRuntime.jsx("div",{className:cn2("flex min-w-0 flex-col",compact?"gap-2 py-3":"gap-3 py-4"),children})})]})}var ACTION_ICONS={read:lucideReact.BookOpen,search:lucideReact.Search,tool:lucideReact.Wrench,command:lucideReact.TerminalSquare,file:lucideReact.FileText};function ActionStatusIcon({status}){if(status==="running"||status==="pending"){return jsxRuntime.jsx(lucideReact.Loader2,{className:"size-3.5 shrink-0 animate-spin","aria-hidden":"true"})}if(status==="failed"||status==="denied"){return jsxRuntime.jsx(lucideReact.CircleAlert,{className:"size-3.5 shrink-0 text-destructive-text","aria-hidden":"true"})}if(status==="completed"){return jsxRuntime.jsx(lucideReact.Check,{className:"size-3.5 shrink-0","aria-hidden":"true"})}return jsxRuntime.jsx(lucideReact.Circle,{className:"size-3.5 shrink-0","aria-hidden":"true"})}function AgentWorkbenchAction({summary,kind="tool",status="completed",children,open,defaultOpen=false,onOpenChange,icon,className,contentClassName}){const Icon2=icon??ACTION_ICONS[kind];const row=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate",children:summary}),jsxRuntime.jsx(ActionStatusIcon,{status}),children?jsxRuntime.jsx(lucideReact.ChevronRight,{className:"size-3.5 shrink-0 transition-transform group-data-[state=open]/action:rotate-90","aria-hidden":"true"}):null]});if(!children){return jsxRuntime.jsx("div",{className:cn2("flex min-h-7 min-w-0 items-center gap-2 text-[13px] text-muted-foreground",className),"data-agent-action-status":status,children:row})}return jsxRuntime.jsxs(CollapsiblePrimitive__namespace.Root,{open,defaultOpen,onOpenChange,className:cn2("group/action min-w-0",className),"data-agent-action-status":status,children:[jsxRuntime.jsx(CollapsiblePrimitive__namespace.Trigger,{className:"flex min-h-7 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground outline-hidden hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:row}),jsxRuntime.jsx(CollapsiblePrimitive__namespace.Content,{className:"overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",children:jsxRuntime.jsx("div",{className:cn2("ml-6 mt-2 min-w-0 border-l border-border pl-3",contentClassName),children})})]})}var ARTIFACT_ICONS={audio:lucideReact.Music2,file:lucideReact.File,html:lucideReact.FileCode2,image:lucideReact.FileImage,markdown:lucideReact.FileText,pdf:lucideReact.FileText,presentation:lucideReact.Presentation,video:lucideReact.Film,web:lucideReact.Globe2};function ArtifactThumbnail({artifact}){const[thumbnailFailed,setThumbnailFailed]=React5.useState(false);if(artifact.status==="loading"){return jsxRuntime.jsx("span",{className:"size-7 shrink-0 animate-pulse rounded bg-muted","aria-hidden":"true"})}if(artifact.status==="error"){return jsxRuntime.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded bg-destructive/10 text-destructive-text",children:jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"size-4","aria-hidden":"true"})})}if(artifact.thumbnailUrl&&!thumbnailFailed){return jsxRuntime.jsx("img",{src:artifact.thumbnailUrl,alt:"",loading:"lazy",className:"size-7 shrink-0 rounded object-cover",onError:()=>setThumbnailFailed(true)})}const Icon2=ARTIFACT_ICONS[artifact.kind];return jsxRuntime.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded bg-muted text-muted-foreground",children:jsxRuntime.jsx(Icon2,{className:"size-4","aria-hidden":"true"})})}function ArtifactGroup({title,artifacts,maxItems,onArtifactOpen}){return jsxRuntime.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[jsxRuntime.jsx("div",{role:"heading","aria-level":2,className:"text-sm font-medium text-muted-foreground",children:title}),artifacts.slice(0,maxItems).map(artifact=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",className:"h-auto min-w-0 justify-start gap-2 px-0.5 py-0.5 text-left text-sm font-normal disabled:cursor-default",disabled:!onArtifactOpen||artifact.status==="loading",onClick:()=>onArtifactOpen?.(artifact),children:[jsxRuntime.jsx(ArtifactThumbnail,{artifact}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:artifact.name})]},artifact.id))]})}function AgentWorkbenchArtifactSummary({artifacts,open,defaultOpen=false,maxItemsPerGroup=3,showAll=false,className,contentClassName,onOpenChange,onArtifactOpen,onViewAll}){const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const outputs=artifacts.filter(artifact=>artifact.origin==="output");const sources=artifacts.filter(artifact=>artifact.origin==="source");if(artifacts.length===0)return null;return jsxRuntime.jsxs(PopoverPrimitive__namespace.Root,{open,defaultOpen,onOpenChange,children:[jsxRuntime.jsx(PopoverPrimitive__namespace.Trigger,{type:"button",className:cn2("flex size-9 items-center justify-center rounded-xl bg-muted text-muted-foreground outline-hidden transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:text-foreground",className),"aria-label":messages.toggleSummary,children:jsxRuntime.jsx(lucideReact.ListFilter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsxs(PopoverPrimitive__namespace.Content,{"aria-label":messages.toggleSummary,side:"bottom",align:"end",sideOffset:8,collisionPadding:12,className:cn2("z-50 w-[min(22rem,calc(100vw-1.5rem))] rounded-3xl border border-border bg-popover p-4 text-popover-foreground shadow-xl outline-hidden",contentClassName),children:[jsxRuntime.jsxs("div",{className:"flex max-h-[min(34rem,calc(100vh-5rem))] min-w-0 flex-col gap-4 overflow-y-auto",children:[outputs.length>0?jsxRuntime.jsx(ArtifactGroup,{title:messages.outputs,artifacts:outputs,maxItems:showAll?outputs.length:maxItemsPerGroup,onArtifactOpen}):null,outputs.length>0&&sources.length>0?jsxRuntime.jsx("div",{className:"h-px bg-border"}):null,sources.length>0?jsxRuntime.jsx(ArtifactGroup,{title:messages.sources,artifacts:sources,maxItems:showAll?sources.length:maxItemsPerGroup,onArtifactOpen}):null,onViewAll&&!showAll&&(outputs.length>maxItemsPerGroup||sources.length>maxItemsPerGroup)?jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",className:"min-h-8 gap-2 px-0 text-sm text-muted-foreground hover:text-foreground",onClick:onViewAll,children:[jsxRuntime.jsx(lucideReact.Link2,{className:"size-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.viewAll})]}):null]}),jsxRuntime.jsx(PopoverPrimitive__namespace.Arrow,{className:"fill-popover"})]})]})}var ARTIFACT_ICONS2={audio:lucideReact.Music2,file:lucideReact.File,html:lucideReact.FileCode2,image:lucideReact.FileImage,markdown:lucideReact.FileText,pdf:lucideReact.FileText,presentation:lucideReact.Presentation,video:lucideReact.Film,web:lucideReact.Globe2};function SortableArtifactTab({artifact,selected,onClose}){const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const Icon2=ARTIFACT_ICONS2[artifact.kind];const{attributes,listeners,setNodeRef,setActivatorNodeRef,transform,transition,isDragging}=sortable.useSortable({id:artifact.id});const{role:_sortableRole,tabIndex:_sortableTabIndex,...sortableA11y}=attributes;const setTabRef=node=>{setNodeRef(node);setActivatorNodeRef(node);};const handleMouseDown=event=>{if(event.button!==1)return;event.preventDefault();onClose();};const handleClick=event=>{if(!(event.target instanceof Element)||!event.target.closest("[data-close-artifact-tab]"))return;event.preventDefault();onClose();};const handleKeyDown=event=>{listeners?.onKeyDown?.(event);if(event.key!=="Delete"&&event.key!=="Backspace")return;event.preventDefault();onClose();};return jsxRuntime.jsxs(TabsPrimitive__namespace.Trigger,{ref:setTabRef,value:artifact.id,style:{transform:utilities.CSS.Transform.toString(transform),transition},className:cn2("group/tab relative flex h-9 max-w-56 shrink-0 items-center gap-2 rounded-lg pl-3 pr-8 text-sm outline-hidden focus-visible:ring-2 focus-visible:ring-ring",selected?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60",isDragging&&"opacity-60"),onMouseDown:handleMouseDown,onClick:handleClick,...sortableA11y,...listeners,onKeyDown:handleKeyDown,children:[jsxRuntime.jsx(Icon2,{className:"size-4 shrink-0","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"truncate",children:artifact.name}),jsxRuntime.jsx("span",{className:"absolute right-1.5 flex size-6 items-center justify-center rounded-md opacity-0 hover:bg-muted group-focus/tab:opacity-100 group-hover/tab:opacity-100 data-[selected=true]:opacity-100","data-selected":selected,"data-close-artifact-tab":"",title:messages.closeTab({name:artifact.name}),"aria-hidden":"true",children:jsxRuntime.jsx(lucideReact.X,{className:"size-3.5","aria-hidden":"true"})})]})}function AgentWorkbenchArtifactWorkspace({artifacts,activeArtifactId,className,variant,density,renderArtifact,onIntent}){const appearance=useAgentWorkbenchAppearance({variant,density});const compact=appearance.density==="compact";const messages=useMonkeysLocaleMessages().agentWorkbench.artifactWorkspace;const activeArtifact=artifacts.find(artifact=>artifact.id===activeArtifactId)??artifacts[0];const sensors=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:5}}),core.useSensor(core.KeyboardSensor,{coordinateGetter:sortable.sortableKeyboardCoordinates}));if(!activeArtifact)return null;const handleDragEnd=({active,over})=>{if(!over||active.id===over.id)return;onIntent?.({type:"reorder",artifactId:String(active.id),overArtifactId:String(over.id)});};const artifactContent=activeArtifact.status==="loading"?jsxRuntime.jsx("div",{className:"flex size-full min-h-48 items-center justify-center p-6 text-center",role:"status",children:jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col items-center gap-3 text-sm text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"size-5 animate-spin","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:messages.loading})]})}):activeArtifact.status==="error"?jsxRuntime.jsx("div",{className:"flex size-full min-h-48 items-center justify-center p-6 text-center",role:"alert",children:jsxRuntime.jsxs("div",{className:"flex min-w-0 max-w-sm flex-col items-center gap-3",children:[jsxRuntime.jsx("span",{className:"flex size-10 items-center justify-center rounded-full bg-destructive/10 text-destructive-text",children:jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"size-5","aria-hidden":"true"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"break-words text-sm font-medium text-foreground [overflow-wrap:anywhere]",children:messages.failed}),activeArtifact.description?jsxRuntime.jsx("p",{className:"mt-1 max-h-24 overflow-auto whitespace-pre-wrap break-words text-sm text-muted-foreground [overflow-wrap:anywhere]",children:activeArtifact.description}):null]}),onIntent?jsxRuntime.jsxs(Button,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>onIntent({type:"retry",artifactId:activeArtifact.id}),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"size-4","aria-hidden":"true"}),messages.retry]}):null]})}):renderArtifact(activeArtifact);return jsxRuntime.jsxs(TabsPrimitive__namespace.Root,{value:activeArtifact.id,onValueChange:artifactId=>onIntent?.({type:"select",artifactId}),"data-agent-workbench-variant":appearance.variant,"data-agent-workbench-density":appearance.density,"data-agent-workbench-status":activeArtifact.status,"data-agent-workbench-surface":"panel",className:cn2("flex size-full min-h-0 min-w-0 flex-col bg-card text-card-foreground",className),orientation:"horizontal",children:[jsxRuntime.jsxs("div",{className:cn2("relative z-10 flex shrink-0 items-center gap-2 border-b border-border bg-muted/40 px-2",compact?"h-10":"h-12"),children:[jsxRuntime.jsx(core.DndContext,{sensors,collisionDetection:core.closestCenter,onDragEnd:handleDragEnd,children:jsxRuntime.jsx(sortable.SortableContext,{items:artifacts.map(artifact=>artifact.id),strategy:sortable.horizontalListSortingStrategy,children:jsxRuntime.jsx(TabsPrimitive__namespace.List,{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","aria-label":messages.tabs,children:artifacts.map(artifact=>jsxRuntime.jsx(SortableArtifactTab,{artifact,selected:artifact.id===activeArtifact.id,onClose:()=>onIntent?.({type:"close",artifactId:artifact.id})},artifact.id))})})}),jsxRuntime.jsxs("div",{className:"relative z-20 flex shrink-0 items-center gap-2",children:[activeArtifact.url?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.download({name:activeArtifact.name}),onClick:()=>onIntent?.({type:"download",artifactId:activeArtifact.id}),children:jsxRuntime.jsx(lucideReact.Download,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.openExternal({name:activeArtifact.name}),onClick:()=>onIntent?.({type:"open-external",artifactId:activeArtifact.id}),children:jsxRuntime.jsx(lucideReact.ExternalLink,{className:"size-4","aria-hidden":"true"})})]}):null,jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":messages.closeWorkspace,onClick:()=>onIntent?.({type:"close-workspace"}),children:jsxRuntime.jsx(lucideReact.PanelRightClose,{className:"size-4","aria-hidden":"true"})})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:artifacts.map(artifact=>jsxRuntime.jsx(TabsPrimitive__namespace.Content,{value:artifact.id,className:"size-full min-h-0 min-w-0 outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:artifact.id===activeArtifact.id?artifactContent:null},artifact.id))})]})}
|
|
57
57
|
|
|
58
58
|
exports.AGENT_WORKBENCH_SHELL_BREAKPOINTS = AGENT_WORKBENCH_SHELL_BREAKPOINTS;
|
|
59
59
|
exports.AgentWorkbenchAction = AgentWorkbenchAction;
|