PageSourceSearch

https://www.sketricgen.ai/_next/static/chunks/66184-57f3b21060e92492.js

js sketricgen.ai collected 2026-09-25 20:07:53 UTC 104,950 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66184],{8906:(e,t,n)=>{n.d(t,{Xs:()=>d,cw:()=>u,zC:()=>p});var r=n(22342),a=n(47931),l=n(33670),s=n(25016);function i(e){let t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return -1===n?t:t.slice(n+1)||t}function o(e){return e.startsWith("/project/")?"project":e.startsWith("/agent/")?"agent":e.startsWith("/conversation/")?"conversation":""}function d(e){let t,n=[],r=/@\[([^\]]+)\]/g,a=0;for(;null!==(t=r.exec(e));){var l;t.index>a&&n.push({type:"text",value:e.slice(a,t.index)}),n.push({type:"mention",value:null!=(l=t[1])?l:""}),a=t.index+t[0].length}return a<e.length&&n.push({type:"text",value:e.slice(a)}),n}function u(e){let{path:t}=e,n=i(t),l=o(t);return(0,r.jsxs)("span",{title:t,className:"inline-flex items-center gap-1 rounded bg-muted text-muted-foreground px-1.5 py-0.5 text-xs font-medium font-mono align-middle mx-0.5 leading-tight",children:[(0,r.jsx)(a.A,{className:"size-3 shrink-0"}),n,l?(0,r.jsx)("span",{className:"opacity-55 text-[10px] font-sans font-normal",children:l}):null]})}function c(e){let t="";return e.childNodes.forEach(e=>{var n,r;e.nodeType===Node.TEXT_NODE?t+=null!=(n=e.textContent)?n:"":e instanceof HTMLElement&&(e.dataset.mention?t+="@[".concat(e.dataset.mention,"]"):"BR"===e.tagName?t+="\n":t+=null!=(r=e.textContent)?r:"")}),t}function m(e){var t,n,r,a;let l=window.getSelection();if(!l||0===l.rangeCount||!l.getRangeAt(0).collapsed)return null;let{startContainer:s,startOffset:i}=l.getRangeAt(0);if(s.nodeType!==Node.TEXT_NODE||!e.contains(s))return null;let o=(null!=(t=s.textContent)?t:"").slice(0,i),d=/(^|[\s])@([^\s@]*)$/.exec(o);if(!d)return null;let u=null!=(n=d[0])?n:"",c=null!=(r=d[1])?r:"",m=o.length-u.length+c.length,p=null!=(a=d[2])?a:"",f=document.createRange();return f.setStart(s,m),f.setEnd(s,i),{query:p,range:f}}let p=(0,l.forwardRef)(function(e,t){let{mentionablePaths:n,placeholder:d="Message…",disabled:u=!1,onValueChange:p,onUserEdit:f,onEnter:g,className:x}=e,h=(0,l.useRef)(null),[v,b]=(0,l.useState)(!1),[y,j]=(0,l.useState)(""),[N,w]=(0,l.useState)(0),k=(0,l.useRef)(null),_=(0,l.useCallback)(()=>{let e=h.current;if(!e)return;let t=c(e).trim().length>0;null==p||p(t)},[p]);(0,l.useImperativeHandle)(t,()=>({getValue:()=>c(h.current),clear:()=>{h.current&&(h.current.innerHTML=""),null==p||p(!1)},focus:()=>{var e;return null==(e=h.current)?void 0:e.focus()},isEmpty:()=>""===c(h.current).trim(),insertTextAtCursor:e=>{let t=h.current;if(!t||!e)return;t.focus();let n=window.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0):null;r&&t.contains(r.commonAncestorContainer)||((r=document.createRange()).selectNodeContents(t),r.collapse(!1)),r.deleteContents();let a=document.createTextNode(e);r.insertNode(a),r.setStartAfter(a),r.collapse(!0),null==n||n.removeAllRanges(),null==n||n.addRange(r),_()}}),[p,_]);let C=n.filter(e=>{if(!y)return!0;let t=y.toLowerCase();return e.toLowerCase().includes(t)||i(e).toLowerCase().includes(t)}).slice(0,12),A=(0,l.useRef)(C);A.current=C,(0,l.useEffect)(()=>{w(0)},[v,y]),(0,l.useEffect)(()=>{if(!v)return;let e=e=>{var t;null!=(t=h.current)&&t.contains(e.target)||b(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[v]);let I=(0,l.useCallback)(()=>{null==f||f(),_();let e=h.current;if(!e)return;let t=m(e);t?(j(t.query),k.current=t.range,b(!0)):(b(!1),k.current=null)},[f,_]),z=(0,l.useCallback)(e=>{var t,n,r;let a=h.current;if(!a)return;let l=m(a),s=null!=(r=null==l?void 0:l.range)?r:k.current;if(!s)return;s.deleteContents();let o=function(e){let t=i(e),n=document.createElement("span");return n.contentEditable="false",n.dataset.mention=e,n.className="mention-pill inline-flex items-center gap-0.5 rounded bg-muted text-muted-foreground px-1 py-0.5 text-xs font-medium font-mono select-none mx-0.5 align-middle leading-none",n.textContent="@".concat(t),n}(e);s.insertNode(o);let d=document.createTextNode("\xa0");o.after(d);let u=document.createRange();u.setStartAfter(d),u.collapse(!0),null==(t=window.getSelection())||t.removeAllRanges(),null==(n=window.getSelection())||n.addRange(u),b(!1),j(""),k.current=null,_
1(),a.focus()},[_]),S=(0,l.useCallback)(e=>{if(v){if("ArrowDown"===e.key){e.preventDefault(),w(e=>Math.min(e+1,A.current.length-1));return}if("ArrowUp"===e.key){e.preventDefault(),w(e=>Math.max(e-1,0));return}if("Enter"===e.key){e.preventDefault();let t=A.current[N];t&&z(t);return}"Escape"===e.key&&(e.preventDefault(),b(!1));return}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),null==g||g())},[v,N,z,g]);return(0,r.jsxs)("div",{className:(0,s.cn)("relative w-full min-w-0",x),children:[v&&C.length>0&&(0,r.jsx)("div",{className:"absolute bottom-full mb-1 left-0 z-50 w-72 rounded-lg border border-border bg-popover shadow-md overflow-hidden",children:(0,r.jsxs)("div",{className:"p-1",children:[(0,r.jsx)("p",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Workspace files"}),C.map((e,t)=>{let n=i(e),l=o(e);return(0,r.jsxs)("div",{onPointerDown:e=>e.preventDefault(),onClick:()=>z(e),className:(0,s.cn)("flex items-center gap-2 px-2 py-1.5 rounded-sm cursor-pointer select-none",t===N?"bg-accent text-accent-foreground":"hover:bg-accent hover:text-accent-foreground"),children:[(0,r.jsx)(a.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"font-mono text-xs truncate flex-1",children:n}),l?(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground shrink-0",children:l}):null]},e)})]})}),(0,r.jsx)("div",{ref:h,contentEditable:!u,suppressContentEditableWarning:!0,"data-placeholder":d,onInput:I,onKeyDown:S,role:"textbox","aria-label":"Write your prompt here","aria-multiline":"true",className:(0,s.cn)("min-h-[3.5rem] max-h-[10rem] w-full overflow-y-auto","p-3 text-sm leading-relaxed outline-none","empty:before:content-[attr(data-placeholder)] empty:before:text-muted-foreground empty:before:pointer-events-none","[&_.mention-pill]:cursor-default",u&&"cursor-not-allowed opacity-50")})]})})},25941:(e,t,n)=>{n.d(t,{m:()=>r});function r(e){let t=function(e){let t=e.trim();if(!t||/\s/.test(t))return null;let n=/^https?:\/\//i.test(t)?t:"https://".concat(t);try{let e=new URL(n);if("http:"!==e.protocol&&"https:"!==e.protocol||e.username||e.password||!e.hostname.includes("."))return null;return e.toString()}catch(e){return null}}(e);if(!t)return null;try{let e=new URL(t),n=new URL("https://www.google.com/s2/favicons");return n.searchParams.set("domain_url",e.origin),n.searchParams.set("sz","64"),{directUrl:"https://".concat(e.host,"/favicon.ico"),googleUrl:n.toString(),hostname:e.hostname,origin:e.origin}}catch(e){return null}}},38565:(e,t,n)=>{n.d(t,{_m:()=>r,kC:()=>l,sw:()=>a});let r={hideAgentNames:!1,hideHandoffToolCalls:!1,handoffToolNamePrefix:"transfer_to_",hideBranding:!1},a={primaryColor:"#7C3AED",theme:"light",widgetButtonPosition:"right",agentDisplayName:"SketricGen Agent",initialMessages:["Hello! How can I help you today?"],showCallouts:!0,suggestedMessages:["What are your services?","Contact support"],messagePlaceholder:"Type your message...",agentIcon:"",enableFullscreen:!1,ctaTitle:"",ctaLink:"",chatDisplay:{...r}},l={...a,suggestedMessages:["What can you do for me?","What should we work on first?"]}},45990:(e,t,n)=>{n.d(t,{f:()=>i,t:()=>s});var r=n(22342),a=n(33670),l=n(25016);function s(e){let{children:t}=e;return 0===a.Children.toArray(t).length?null:(0,r.jsx)("div",{className:"relative z-20 mx-auto w-full max-w-[800px] shrink-0 space-y-2 px-4 pb-2 sm:px-3","data-testid":"hitl-composer-dock",children:t})}function i(e){let{children:t,className:n,...a}=e;return(0,r.jsx)("div",{className:(0,l.cn)("overflow-hidden rounded-2xl border border-border/70 bg-card shadow-sm",n),...a,children:t})}},68381:(e,t,n)=>{n.d(t,{i:()=>u});var r=n(22342),a=n(72251),l=n(81288),s=n(15279),i=n(18720),o=n(25016),d=n(97003);
1function u(e){let{content:t,copyMessage:n,className:u}=e,[c,m]=(0,s.Cj)();return(0,r.jsxs)(d.$,{variant:"ghost",size:"icon",className:(0,o.cn)("relative h-6 w-6 group bg-transparent",u),"aria-label":"Copy to clipboard",onClick:()=>{m(t).then(()=>{i.toast.success(n)}).catch(()=>{i.toast.error("Failed to copy to clipboard.")})},children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)(a.A,{className:(0,o.cn)("transition-transform ease-in-out text-inherit group-hover:text-gray-700 dark:group-hover:text-white",c?"scale-100":"scale-0"),strokeWidth:2.5})}),(0,r.jsx)(l.A,{className:(0,o.cn)("transition-transform ease-in-out text-inherit group-hover:text-gray-700 dark:group-hover:text-gray-100",c?"scale-0":"scale-100"),strokeWidth:2.5})]})}},73439:(e,t,n)=>{n.d(t,{DT:()=>o,MH:()=>a,_P:()=>d,as:()=>i,pI:()=>l});var r=n(38565);function a(e){return e.replace(/[_-]+/g," ").trim().split(/\s+/).map(e=>/\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function l(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let a={...r._m};for(let e of t)e&&(void 0!==e.hideAgentNames&&(a.hideAgentNames=e.hideAgentNames),void 0!==e.hideHandoffToolCalls&&(a.hideHandoffToolCalls=e.hideHandoffToolCalls),void 0!==e.handoffToolNamePrefix&&(a.handoffToolNamePrefix=e.handoffToolNamePrefix),void 0!==e.hideBranding&&(a.hideBranding=e.hideBranding));return a}let s=["transfer_to_"];function i(e,t){if(s.some(t=>e.startsWith(t)))return!0;let n=t.trim();return!!n&&e.startsWith(n)}function o(e,t){return(null==e?void 0:e.length)?t.hideHandoffToolCalls?e.filter(e=>!i(e.toolName,t.handoffToolNamePrefix)):e:[]}function d(e,t){var n,r,a,l;if("assistant"!==e.role)return!0;let s=o(e.toolInvocations,t),i=!1;if(null==(n=e.parts)?void 0:n.length){for(let n of e.parts)if("text"===n.type&&(null==(a=n.text)?void 0:a.trim())||"tool-invocation"===n.type&&n.toolInvocation&&o([n.toolInvocation],t).length>0||"reasoning"===n.type){i=!0;break}}let d=(null!=(l=e.content)?l:"").trim().length>0,u=s.length>0;return(null==(r=e.parts)?void 0:r.length)?i||d||u:d||u}},74507:(e,t,n)=>{n.d(t,{A:()=>t_});var r=n(22342),a=n(60406),l=n(66065),s=n(76140),i=n(92378),o=n(92033),d=n(20233),u=n(33670),c=n(41165),m=n(50129),p=n(25016),f=n(97003);let g=e=>{let{className:t,...n}=e;return(0,r.jsx)(m.z,{className:(0,p.cn)("relative flex-1 overflow-y-hidden",t),initial:"smooth",resize:"smooth",role:"log",...n})},x=e=>{let{className:t,...n}=e;return!function(){let{scrollRef:e,contentRef:t}=(0,m.B)();(0,u.useEffect)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let a=()=>{let e=getComputedStyle(r),t=(Number.parseFloat(e.marginTop)||0)+(Number.parseFloat(e.paddingTop)||0)+(Number.parseFloat(e.paddingBottom)||0);n.style.setProperty("--conversation-anchor-height","".concat(Math.max(0,n.clientHeight-t),"px"))};a();let l=new ResizeObserver(a);return l.observe(n),l.observe(r),()=>l.disconnect()},[t,e])}(),(0,r.jsx)(m.z.Content,{className:(0,p.cn)("flex flex-col p-4",t),...n})},h=e=>{let{className:t,...n}=e,{isAtBottom:a,scrollToBottom:l}=(0,m.B)(),s=(0,u.useCallback)(()=>{l()},[l]);return!a&&(0,r.jsx)(f.$,{className:(0,p.cn)("absolute bottom-[2%] left-[50%] translate-x-[-50%] rounded-full bg-muted hover:brightness-90",t),onClick:s,size:"icon",type:"button",variant:"outline",...n,children:(0,r.jsx)(c.A,{className:"size-4"})})};var v=n(36460),b=n(68381),y=n(62399),j=n(33884),N=n(93133),w=n(98731),k=n(48941),_=n(26615),C=n(72251),A=n(59007),I=n(92925),z=n(74115),S=n(82274),T=n(85524),M=n(66156),R=n(23558),W=n(16359),L=n(35561);let O=(0,u.createContext)(null);function D(){let e=(0,u.useContext)(O);if(!e)throw Error("Reasoning components must be used within <Reasoning>");return e}let E=(0,u.memo)(function(e){let{className:t,children:n,isStreaming:a=!1,duration:l,open:s,defaultOpen:i=!1,onOpenChange:o,...d}=e,[c,m]=(0,R.i)({defaultProp:i,onChange:o,prop:s}),f=(0,u.useRef)(null),[g,x]=(0,u.useState)(),h=void 0!==s;(0,u.useEffect)(()=>{a?(f.current=Date.now(),x(void 0),h||m(!0)):(null!=f.current&&(x(Math.round((Date.now()-f.current)/1e3*10)/10),f.current=null),h||m(!1))},[a,h,m]);let v=void 0!==l?l:g,b=(0,u.useMemo)(()=>({isStreaming:a,isOpen:!!c,setIsOpen:m,duration:v}),[a,c,m,v]);return(0,r.jsx)(O.Provider,{value:b,children:(0,r.jsx)(L.Nt,{open:!!c,onOpenChange:m,className:(0,p.cn)("group not-prose w-full overflow-hidden rounded-md pb-1",t),...d,children:n})})}),F=(0,u.memo)(function(e){let t,{className:n,children:a,getThinkingMessage:l,...s}=e,{isStreaming:i,duration:o}=D();return t=null!=a?a:l?l(i,o):i?"Thinking…":null!=o&&o>0?"Thought for ".concat(o,"s"):"Reasoning",(0,r.jsx)("div",{className:"flex items-center py-1",children:(0,r.jsx)(L.R6,{asChild:!0,...s,children:(0,r.jsxs)("button",{type:"button",className:(0,p.cn)("flex min-h-8 w-full items-center gap-2 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",n),children:[(0,r.jsx)(W.A,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,r.jsx)("span",{className:"min-w-0 flex-1 font-medium",children:t}),(0,r.jsx)(A.A,{className:"size-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180 motion-reduce:transition-none","aria-hidden":!0})]})})})}),B=(0,u.memo)(function(e){let{className:t,children:n,animated:a=!1,...l}=e,{isStreaming:s,isOpen:i}=D(),o=(0,v.jJ)(n,a),d=(0,u.useRef)(null),c=(0,u.useRef)(null),m=(0,u.useCallback)(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,u.useLayoutEffect)(()=>{i&&s&&m()},[n,i,s,m]),(0,u.useEffect)(()=>
1{if(!i||!s)return;let e=d.current,t=c.current;if(!e||!t)return;let n=new ResizeObserver(()=>{e.scrollTop=e.scrollHeight});return n.observe(t),()=>n.disconnect()},[i,s]),(0,r.jsx)(L.Ke,{className:(0,p.cn)("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down motion-reduce:animate-none",t),...l,children:(0,r.jsx)("div",{ref:d,className:(0,p.cn)("mx-[7px] border-l border-border/60 pb-2.5 pl-4 pr-1 pt-1","max-h-[min(220px,28vh)] overflow-y-auto overscroll-contain"),children:(0,r.jsx)("div",{ref:c,className:"min-h-0",children:(0,r.jsx)(v.YK,{className:"text-xs leading-5 text-muted-foreground/80",animated:a,isAnimating:s||o.length<n.length,children:o})})})})}),U=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("div",{className:(0,p.cn)("not-prose overflow-hidden rounded-xl border border-border/70 bg-background/50 shadow-none",t),...n})});U.displayName="Queue";let q=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)(L.Nt,{className:(0,p.cn)("group w-full",t),...n})});q.displayName="QueueSection";let $=(0,u.memo)(e=>{let{className:t,children:n,...a}=e;return(0,r.jsxs)(L.R6,{className:(0,p.cn)("flex min-h-9 w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground",t),...a,children:[(0,r.jsx)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:n}),(0,r.jsx)(A.A,{className:"size-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180 motion-reduce:transition-none"})]})});$.displayName="QueueSectionTrigger",(0,u.memo)(e=>{let{label:t,count:n,icon:a,className:l,...s}=e;return(0,r.jsxs)("span",{className:(0,p.cn)("flex min-w-0 items-center gap-2 text-sm font-medium text-foreground",l),...s,children:[a?(0,r.jsx)("span",{className:"inline-flex size-4 shrink-0 text-muted-foreground",children:a}):null,(0,r.jsx)("span",{className:"truncate",children:t}),void 0!==n?(0,r.jsx)("span",{className:"shrink-0 rounded-full border border-primary/55 bg-muted/65 px-1.5 py-0.5 text-[10px] font-semibold text-foreground tabular-nums",children:n}):null]})}).displayName="QueueSectionLabel";let H=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)(L.Ke,{className:(0,p.cn)("border-border/50 border-t px-2 pb-1.5 pt-1 data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down motion-reduce:animate-none",t),...n})});H.displayName="QueueSectionContent";let P=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("ul",{className:(0,p.cn)("space-y-0.5",t),...n})});P.displayName="QueueList";let J=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("li",{className:(0,p.cn)("flex items-start gap-2 rounded-md px-1 py-1 text-sm",t),...n})});J.displayName="QueueItem";let V=(0,u.memo)(e=>{let{completed:t=!1,status:n,className:a,...l}=e,s=null!=n?n:t?"completed":"pending";return(0,r.jsxs)("span",{className:(0,p.cn)("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border ring-1","completed"===s&&"border-emerald-500/35 bg-emerald-500/5 text-emerald-600 ring-emerald-500/15","in_progress"===s&&"border-primary/30 bg-primary/5 text-primary ring-primary/15","pending"===s&&"border-border/70 bg-muted/40 text-muted-foreground ring-transparent",a),...l,children:["completed"===s?(0,r.jsx)(C.A,{className:"size-3",strokeWidth:2.5,"aria-hidden":!0}):null,"in_progress"===s?(0,r.jsx)(o.A,{className:"size-3 animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"pending"===s?(0,r.jsx)("span",{className:"size-1.5 rounded-full bg-current opacity-50","aria-hidden":!0}):null]})});V.displayName="QueueItemIndicator";let K=(0,u.memo)(e=>{let{completed:t=!1,className:n,...a}=e;return(0,r.jsx)("span",{className:(0,p.cn)("min-w-0 flex-1 text-sm leading-5",t?"text-muted-foreground line-through":"text-foreground",n),...a})});K.displayName="QueueItemContent";let Q=(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("div",{className:(0,p.cn)("text-[11px] text-muted-foreground",t),...n})});Q.displayName="QueueItemDescription",(0,u.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("div",{className:(0,p.cn)(t),...n})}).displayName="QueueScrollArea";var X=n(14888),Y=n(72883),G=n(33357),Z=n(83101),ee=n(5379),et=n(79572),en=n(62787),er=n(17682),ea=n(84916),el=n(33789),es=n(90235),ei=n(47507),eo=n(67001),ed=n(94163);function eu(e){try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(e){return null}}function ec(e){let{invocation:t,accumulatedArgsJson:n,context:a,isIframeFullscreen:l=!1,isCanvasWidget:s=!1,layout:i="default",hasSideAvatar:d=!1}=e,[c,m]=(0,u.useState)(""),[g,x]=(0,u.useState)(""),[h,v]=(0,u.useState)({}),[b,y]=(0,u.useState)(!1),[j,N]=(0,u.useState)(!1),[k,_]=(0,u.useState)(null),[C,A]=(0,u.useState)(null),{resolvedTheme:I}=(0,ee.D)(),z=(0,u.useMemo)(()=>
1{if(l)return{};if(s){let e="floating"===i;return"dark"===I?{backgroundColor:e?"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 30%, hsl(var(--muted)))":"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 25%, hsl(var(--card)))",color:"hsl(var(--foreground))"}:{backgroundColor:e?"color-mix(in srgb,var(--sketric-widget-primary-color, hsl(var(--primary))) 22%, white)":"color-mix(in srgb,var(--sketric-widget-primary-color, hsl(var(--primary))) 15%, white)",color:"hsl(var(--foreground))"}}return{backgroundColor:"var(--_sketric-agent-bubble-bg)",color:"var(--_sketric-agent-bubble-fg)"}},[l,s,i,I]),S=(0,u.useMemo)(()=>(function(e,t){let n=(null==e?void 0:e.trim())?eu(e):null;if((!n||!Array.isArray(n.extra_fields))&&"result"===t.state&&t.result&&"object"==typeof t.result){let e=t.result;n||"string"!=typeof e.raw||(n=eu(e.raw)),n&&Array.isArray(n.extra_fields)||(n=e)}let r=null==n?void 0:n.extra_fields;return{extra_fields:Array.isArray(r)?r:[],form_schema_version:"number"==typeof(null==n?void 0:n.form_schema_version)?n.form_schema_version:1}})(n,t),[n,t]),T=(0,u.useMemo)(()=>{if(null!=a.persistedLeadCaptureForm){let e=(0,ed.JE)(a.persistedLeadCaptureForm);return{extra_fields:e.extra_fields,form_schema_version:e.form_schema_version}}return S},[a.persistedLeadCaptureForm,S]),M=j||null!==C,R="function"==typeof a.resumeHitl,W=!!a.hitlSubmitEnabled,L="call"===t.state||"result"===t.state||"partial-call"===t.state&&!!(null==n?void 0:n.trim()),O=R&&W||!R&&L||R&&!W&&L,D="call"===t.state||"result"===t.state||"partial-call"===t.state&&(null==n?void 0:n.trim())||R&&W||R&&"partial-call"===t.state,E=a.onLeadFormActiveChange;(0,u.useEffect)(()=>{if(D&&!C)return null==E||E(!0),()=>null==E?void 0:E(!1)},[D,C,E]);let F=a.leadSubmitBaseUrl.replace(/\/+$/,""),B=!!F,U=(0,u.useCallback)(async e=>{e.preventDefault(),_(null);let t=c.trim(),n=g.trim();if(!t||!n)return void _("Please enter your full name and email.");if(T.extra_fields.filter(e=>{var t;return!!e.required&&!(null!=(t=h[e.id])?t:"").trim()}).length>0)return void _("Please fill all required fields.");if((!R||!W&&L)&&!B)return void _("Lead submission is not configured.");let r={...h},l={form_schema_version:T.form_schema_version,extra_fields_snapshot:T.extra_fields},s=JSON.stringify({full_name:t,email:n,form_payload:r,consent_given:!!b||void 0,consent_text_version:b?"brand_agent_widget_v1":void 0,metadata:l});N(!0);try{let e=!1;if(B){let e=a.getAuthToken?await a.getAuthToken():null,s=await fetch("".concat(F,"/api/submit-brand-agent-lead/authorize"),{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:"Bearer ".concat(e)}:a.apiKey?{"API-KEY":a.apiKey}:{}},body:JSON.stringify({agent_id:a.agentId})}),i=await s.json();if(!s.ok||!i.token)throw Error(i.error||"Could not authorize lead submission");let o=await fetch("".concat(F,"/api/submit-brand-agent-lead"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:a.agentId,auth_token:i.token,full_name:t,email:n,conversation_id:a.conversationId||void 0,contact_id:a.contactId||void 0,session_id:a.contactId||void 0,page_url:window.location.href,form_payload:r,consent_given:!!b||void 0,consent_text_version:b?"brand_agent_widget_v1":void 0,metadata:l})}),d=await o.json();if(!o.ok||!1===d.success)throw Error(d.error||"Could not submit")}R&&W&&a.resumeHitl&&(await a.resumeHitl(s),e=!0),A("submitted"),e||a.onLeadSubmitted()}catch(e){_(e instanceof Error?e.message:"Submission failed. Try again.")}finally{N(!1)}},[c,g,h,b,T,a,R,W,L,B]),q=(0,u.useCallback)(async()=>{if(_(null),R&&W&&a.resumeHitl){let e=JSON.stringify({skipped:!0,full_name:null,email:null,form_payload:{},consent_given:!1,metadata:{form_schema_version:T.form_schema_version,extra_fields_snapshot:T.extra_fields,skip_reason:"user_dismissed"}});try{await a.resumeHitl(e)}catch(e){_(e instanceof Error?e.message:"Could not skip. Try again.");return}}A("skipped")},[a,R,W,T]),$=(e,t)=>{v(n=>({...n,[e]:t}))};return(0,w.Uy)(t.toolName)?C?(0,r.jsx)("p",{className:(0,p.cn)("text-xs text-muted-foreground",l?"px-2":d?"mb-1":"ml-8"),children:"submitted"===C?"Thanks — your details were sent.":"No problem — feel free to continue chatting."}):D?(0,r.jsxs)("form",{onSubmit:U,className:(0,p.cn)("mt-2 space-y-2 relative wrap-break-word text-sm",l?"mx-2 w-full max-w-[min(100%,500px)] px-2 py-2":d?"mr-2 max-w-[min(100%,400px)] rounded-2xl rounded-bl-none p-3":"ml-8 mr-2 max-w-[min(100%,400px)] rounded-2xl rounded-bl-none p-3"),style:l?void 0:z,children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Share your details"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(es.J,{htmlFor:"lc-fn-".concat(t.toolName),className:"text-xs",children:["Full name ",(0,r.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,r.jsx)(el.p,{id:"lc-fn-".concat(t.toolName),value:c,onChange:e=>
1m(e.target.value),disabled:M,className:"h-9 text-sm bg-input/70 border-(--sketric-widget-primary-color)/30",autoComplete:"name"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(es.J,{htmlFor:"lc-em-".concat(t.toolName),className:"text-xs",children:["Email ",(0,r.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,r.jsx)(el.p,{id:"lc-em-".concat(t.toolName),type:"email",value:g,onChange:e=>x(e.target.value),disabled:M,className:"h-9 text-sm bg-input/70 border-(--sketric-widget-primary-color)/30",autoComplete:"email"})]}),T.extra_fields.map(e=>{var t,n,a,l;return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(es.J,{className:"text-xs",children:[e.label||e.id,e.required?(0,r.jsx)("span",{className:"text-destructive",children:" *"}):null]}),"textarea"===e.type?(0,r.jsx)(eo.T,{value:null!=(t=h[e.id])?t:"",onChange:t=>$(e.id,t.target.value),disabled:M,className:"min-h-[72px] text-sm"}):"select"===e.type?(0,r.jsxs)(ei.l6,{value:null!=(n=h[e.id])?n:"",onValueChange:t=>$(e.id,t),disabled:M,children:[(0,r.jsx)(ei.bq,{className:"h-9 text-sm bg-input/70 border-(--sketric-widget-primary-color)/30",children:(0,r.jsx)(ei.yv,{placeholder:"Choose…"})}),(0,r.jsx)(ei.gC,{children:(null!=(a=e.options)?a:[]).map(e=>(0,r.jsx)(ei.eb,{value:e,children:e},e))})]}):(0,r.jsx)(el.p,{type:"number"===e.type?"number":"email"===e.type?"email":"phone"===e.type?"tel":"text",value:null!=(l=h[e.id])?l:"",onChange:t=>$(e.id,t.target.value),disabled:M,className:"h-9 text-sm bg-input/70 border-(--sketric-widget-primary-color)/30"})]},e.id)}),(0,r.jsxs)("div",{className:"flex items-start gap-2 pt-1",children:[(0,r.jsx)(ea.S,{id:"lc-consent-".concat(t.toolName),checked:b,onCheckedChange:e=>y(!0===e),disabled:M,className:"data-[state=checked]:bg-(--sketric-widget-primary-color) border-(--sketric-widget-primary-color)"}),(0,r.jsx)(es.J,{htmlFor:"lc-consent-".concat(t.toolName),className:"text-[11px] leading-snug font-normal text-muted-foreground cursor-pointer",children:"I agree you may contact me about my request."})]}),k?(0,r.jsx)("p",{className:"text-xs text-destructive",children:k}):null,(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(f.$,{type:"button",size:"sm",variant:"outline",className:"flex-1 border-border/60 text-muted-foreground hover:text-foreground",onClick:q,disabled:M,children:"Skip"}),(0,r.jsx)(f.$,{type:"submit",size:"sm",className:"flex-1 border-transparent text-primary-foreground hover:brightness-90",style:{backgroundColor:"var(--sketric-widget-primary-color, hsl(var(--primary)))"},disabled:M||!O,children:j?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"mr-2 size-4 animate-spin",strokeWidth:3}),"Sending…"]}):"Submit"})]})]}):null:null}var em=n(74955),ep=n(94915);function ef(e){let{invocation:t,accumulatedArgsJson:n,context:a,isIframeFullscreen:l=!1}=e,[s,i]=(0,u.useState)(!1),[d,c]=(0,u.useState)(!1),[m,f]=(0,u.useState)(null),g=(0,u.useMemo)(()=>(function(e){if(!(null==e?void 0:e.trim()))return null;try{let t=JSON.parse(e);return"string"==typeof t.url&&t.url.trim()?t.url.trim():null}catch(e){return null}})(n),[n]),x="function"==typeof(null==a?void 0:a.resumeHitl),h=!!(null==a?void 0:a.hitlSubmitEnabled),v="call"===t.state||"result"===t.state||"partial-call"===t.state&&!!(null==n?void 0:n.trim()),b=x&&h||!x&&v||x&&!h&&v,y=(0,u.useCallback)(async()=>{if(g){f(null),i(!0);try{x&&(null==a?void 0:a.resumeHitl)&&await a.resumeHitl("Navigation succeeded: ".concat(g),"","client_navigation")}catch(e){}window.parent!==window?window.parent.postMessage({type:"client_navigate",url:g},"*"):window.open(g,"_blank","noopener,noreferrer"),c(!0),i(!1)}},[g,x,a]);if(!(0,N.lc)(t.toolName)||d||!("call"===t.state||"result"===t.state||"partial-call"===t.state&&(null==n?void 0:n.trim())||x&&h||x&&"partial-call"===t.state))return null;let j=g?function(e){try{let t=new URL(e);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash||e;return e}catch(t){return e}}(g):null;return(0,r.jsxs)("div",{className:(0,p.cn)("mt-2 flex flex-wrap items-center gap-2 relative pb-2 hover:brightness-95 active:scale-[0.98] hover:scale-98 transition-all duration-200",l?"px-2":"ml-9"),children:[(0,r.jsxs)("button",{type:"button",disabled:s||!g||!b,onClick:()=>void y(),className:(0,p.cn)("inline-flex min-h-8 max-w-full cursor-pointer items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium shadow-sm","transition-[filter,opacity,transform] duration-200","","disabled:cursor-not-allowed disabled:opacity-60 disabled:active:scale-100","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--sketric-widget-primary-color)/35 focus-visible:ring-offset-2"),style:{backgroundColor:"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 10%, transparent)",borderColor:"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 32%, transparent)",color:"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 80%, white 20%)"},"aria-label":j?"Navigate to ".concat(j):"Navigate to page",children:[s?(0,r.jsx)(o.A,{className:"size-3 shrink-0 animate-spin",strokeWidth:2.25}):(0,r.jsx)(em.A,{className:"size-3 shrink-0",strokeWidth:2.25}),(0,r.jsx)("span",{className:"truncate leading-snug",children:s?"Taking you there...":j||"Preparing link…"}),!s&&j?(0,r.jsx)(ep.A,{className:"size-4 shrink-0 opacity-75 ",strokeWidth:2.5}):null,!s&&j&&(0,r.jsx)("span",{style:{backgroundColor:"color-mix(in srgb, var(--sketric-widget-primary-color, hsl(var(--primary))) 75%, transparent)"},className:"text-[8px] text-primary-foreground block absolute bottom-0 left-3 px-1.5 py-px rounded-sm",children:"Click to open"})]}),m?(0,r.jsx)("span",{className:"text-sm text-destructive",children:m}):null]})}var eg=n(8906),ex=n(17482);let eh=new Set(["search_catalog","count_catalog","get_product"]);function ev(e){return null===e||"object"!=typeof e||Array.isArray(e)?null:e}function eb(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(e){return null}}function ey(e){if("string"==typeof e)try{let t=new URL(e);return"https:"===t.protocol?t.href:void 0}catch(e){return}}function ej(e,t){var n,r,a,l;let s=ev(e),i=null!=(n=null==s?void 0:s.amount)?n:"object"!=typeof e?e:null,o=String(null!=(l=null!=(a=null!=(r=null==s?void 0:s.currency)?r:null==s?void 0:s.currency_code)?a:t)?l:"").toUpperCase();if(!o||"number"!=typeof i&&"string"!=typeof i)return;let d=Number(i);if(Number.isFinite(d))try{return new Intl.NumberFormat(void 0,{style:"currency",currency:o}).format(d)}catch(e){return"".concat(d.toFixed(2)," ").concat(o)}}function eN(e){let{invocations:t}=e,n=(0,u.useMemo)(()=>(function(e){let t=new Set,n=[];for(let s of e)if("result"===s.state&&eh.has(s.toolName))for(let e of function e(t){var n,r,a;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(l>6)return[];if(Array.isArray(t))return t.flatMap(t=>e(t,l+1));let s=ev(t);if(!s)return[];let i=null!=(n=s.title)?n:s.name,o=null!=(a=null!=(r=s.url)?r:s.product_url)?a:s.online_store_url;return"string"==typeof i&&"string"==typeof o?[s]:[s.products,s.product,s.items,s.results,s.catalog].flatMap(t=>e(t,l+1))}(function(e){var t,n,r,a;let l=eb(e);if(Array.isArray(l))for(let e of l){let t=ev(e);
1if((null==t?void 0:t.type)==="text"){let e=eb(t.text);e&&(l=e)}}let s=ev(l);return s&&null!=(a=null!=(r=null!=(n=s.structuredContent)?n:s.structured_content)?r:null==(t=ev(s.result))?void 0:t.structuredContent)?a:null}(s.result))){var r,a,l;let s=ey(null!=(a=null!=(r=e.url)?r:e.product_url)?a:e.online_store_url),i=null!=(l=e.title)?l:e.name;if(!s||"string"!=typeof i||!i.trim()||t.has(s))continue;let o=function(e){var t,n,r,a,l,s,i,o,d,u;let c=(Array.isArray(e.media)?e.media:[]).map(ev).find(Boolean),m=ev(e.featured_image),p=ev(e.image);return{url:ey(null!=(s=null!=(l=null!=(a=null!=(r=null!=(n=null!=(t=null==c?void 0:c.url)?t:null==c?void 0:c.src)?n:null==m?void 0:m.url)?r:null==m?void 0:m.src)?a:null==p?void 0:p.url)?l:null==p?void 0:p.src)?s:e.image_url),alt:"string"==typeof(null!=(o=null!=(i=null==c?void 0:c.alt_text)?i:null==m?void 0:m.alt)?o:null==p?void 0:p.alt)?String(null!=(u=null!=(d=null==c?void 0:c.alt_text)?d:null==m?void 0:m.alt)?u:null==p?void 0:p.alt):void 0}}(e);if(t.add(s),n.push({title:i.trim(),url:s,imageUrl:o.url,imageAlt:o.alt,price:function(e){var t,n,r,a,l,s,i;let o=ev(null!=(n=e.price_range)?n:e.priceRange),d="string"==typeof e.currency?e.currency:void 0;if(o){let e=ej(null!=(a=null!=(r=o.min)?r:o.minimum)?a:o.from,d),t=ej(null!=(s=null!=(l=o.max)?l:o.maximum)?s:o.to,d);return e&&t&&e!==t?"".concat(e," – ").concat(t):null!=e?e:t}return ej(null!=(i=e.price)?i:null==(t=ev(e.offer))?void 0:t.price,d)}(e),availability:function(e){var t,n,r;let a=null!=(r=null!=(n=null==(t=ev(e.availability))?void 0:t.available)?n:e.availability)?r:e.available;if("string"==typeof a)return a;if("boolean"==typeof a)return a?"Available":"Unavailable";let l=(Array.isArray(e.variants)?e.variants.map(ev):[]).filter(Boolean).map(e=>{var t,n;return null!=(n=null==e?void 0:e.available)?n:null==(t=ev(null==e?void 0:e.availability))?void 0:t.available}).filter(e=>void 0!==e);return l.some(e=>!0===e||"available"===e||"in_stock"===e)?"Available":l.length?"Unavailable":void 0}(e)}),4===n.length)return n}return n})(t),[t]);return t.some(e=>"result"!==e.state)&&0===n.length?(0,r.jsx)("div",{className:"grid w-full grid-cols-2 gap-2","aria-label":"Searching products",children:[0,1].map(e=>(0,r.jsxs)("div",{className:"animate-pulse overflow-hidden rounded-xl border bg-background",children:[(0,r.jsx)("div",{className:"aspect-square bg-muted"}),(0,r.jsxs)("div",{className:"space-y-2 p-2.5",children:[(0,r.jsx)("div",{className:"h-3 w-4/5 rounded bg-muted"}),(0,r.jsx)("div",{className:"h-3 w-2/5 rounded bg-muted"})]})]},e))}):0===n.length?null:(0,r.jsx)("div",{className:"grid w-full grid-cols-2 gap-2","aria-label":"Recommended products",children:n.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{window.parent.postMessage({type:"client_navigate",url:e.url},"*")},className:"group overflow-hidden rounded-xl border bg-background text-left shadow-sm transition hover:border-primary/50 hover:shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"View ".concat(e.title),children:[(0,r.jsx)("div",{className:"flex aspect-square items-center justify-center overflow-hidden bg-muted/60",children:e.imageUrl?(0,r.jsx)("img",{src:e.imageUrl,alt:e.imageAlt||e.title,className:"h-full w-full object-cover transition-transform group-hover:scale-[1.02]",loading:"lazy"}):(0,r.jsx)(ex.A,{className:"h-8 w-8 text-muted-foreground/60","aria-hidden":"true"})}),(0,r.jsxs)("div",{className:"min-w-0 space-y-1 p-2.5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[(0,r.jsx)("span",{className:"line-clamp-2 min-w-0 flex-1 text-xs font-medium leading-4",children:e.title}),(0,r.jsx)(ep.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"})]}),e.price?(0,r.jsx)("p",{className:"text-xs font-semibold",children:e.price}):null,e.availability?(0,r.jsx)("p",{className:"truncate text-[11px] text-muted-foreground",children:e.availability}):null]})]},e.url))})}var ew=n(73439),ek=n(80239),e_=n(83862);let eC=/```[\s\S]*?```|`[^`\n]*`|\/(?:project|agent|conversation)\/[^\s`"'()[\]{}<>]+/g,eA=/[.,;:!?)\]}'"]+$/,eI=/^\/(?:project|agent|conversation)\/[^\s`"'()[\]{}<>]+$/,ez="sketric-workspace-file",eS="".concat(ez,":"),eT=(()=>{var e,t;let[n,r]=et.XX.sanitize;return[et.XX.raw,[n,{...r,protocols:{...r.protocols,href:[...null!=(t=null==(e=r.protocols)?void 0:e.href)?t:[],ez]}}],et.XX.harden]})(),eM={...v.$j,a:e=>{let t="string"==typeof e.href?e.href:"";if(t.startsWith(eS))return(0,r.jsx)("a",{title:e.title,target:e.target,rel:e.rel,href:t,className:"no-underline transition-opacity hover:opacity-80",children:(0,r.jsx)(eg.cw,{path:t.slice(eS.length)})});let n=null===v.$j||void 0===v.$j?void 0:v.$j.a;return n?(0,r.jsx)(n,{...e}):(0,r.jsx)("a",{...e})}};function eR(e){let{text:t,animate:n,isStreaming:a,className:l,onOpenWorkspaceFile:s}=e,i=(0,v.jJ)(t,n),o=(0,en.g_)(i),d=(0,r.jsx)(v.YK,{className:l,animated:n,isAnimating:a||i.length<t.length,rehypePlugins:s?eT:void 0,components:s?eM:void 0,children:s?o.replace(eC,e=>{if(e.startsWith("```"))return e;if(e.startsWith("`")){let t=e.slice(1,-1);return eI.test(t)?"[".concat(t,"](").concat(eS).concat(t,' "Open in workspace")'):e}let t=e.match(eA),n=t?t[0]:"",r=n?e.slice(0,-n.length):e;return r.length<=1?e:"[".concat(r,"](").concat(eS).concat(r,' "Open in workspace")').concat(n)}):o});return s?(0,r.jsx)("div",{className:"contents",onClick:e=>{var t,n;let r=null==(t=(n=e.target).closest)?void 0:t.call(n,"a"),a=null==r?void 0:r.getAttribute("href");(null==a?void 0:a.startsWith(eS))&&(e.preventDefault(),s(a.slice(eS.length)))},children:d}):d}
1function eW(e){let{content:t}=e;if(!t.includes("@["))return(0,r.jsx)(v.YK,{children:(0,en.g_)(t)});let n=(0,eg.Xs)(t);return(0,r.jsx)("p",{className:"whitespace-pre-wrap",children:n.map((e,t)=>"mention"===e.type?(0,r.jsx)(eg.cw,{path:e.value},t):(0,r.jsx)(u.Fragment,{children:e.value},t))})}let eL=(0,Z.F)("group/message relative wrap-break-word rounded-2xl p-3 text-sm sm:max-w-none",{variants:{isUser:{true:"rounded-br-none bg-accent text-foreground ml-20 mb-0.5",false:"rounded-bl-none bg-accent text-accent-foreground"},animation:{none:"",slide:"duration-300 animate-in fade-in-0",scale:"duration-300 animate-in fade-in-0 zoom-in-75",fade:"duration-500 animate-in fade-in-0"}},compoundVariants:[{isUser:!0,animation:"slide",class:"slide-in-from-right"},{isUser:!1,animation:"slide",class:"slide-in-from-left"},{isUser:!0,animation:"scale",class:"origin-bottom-right"},{isUser:!1,animation:"scale",class:"origin-bottom-left"}]});function eO(e){let{toolInvocations:t,toolCallAccumulatedArgs:n,leadCapture:a,isIframeFullscreen:l,isCanvasWidget:s,layout:i="default",agentIcon:o,agentDisplayName:d,theme:u}=e,c=(0,ek._)(),m=(0,ew.DT)(t,c);if(!m.length)return null;let p=m.filter(e=>eh.has(e.toolName));if(p.length)return(0,r.jsx)("div",{className:"w-full max-w-full",children:(0,r.jsx)(eN,{invocations:p})});let f=m[0],g=!!a&&f&&(0,w.Uy)(f.toolName),x=!!a&&f&&(0,N.lc)(f.toolName),h=!!(("default"===i||"floating"===i)&&!l);return(0,r.jsx)("div",{className:"w-full max-w-full",children:g?h?(0,r.jsxs)("div",{className:"flex w-full max-w-full items-end justify-start gap-2",children:[(0,r.jsx)(er.T,{agentIcon:o||"",isUser:!1,isAssistant:!0,agentDisplayName:d||"",isCanvasWidget:s,layout:i,theme:u}),(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsx)(ec,{invocation:f,accumulatedArgsJson:n,context:a,isIframeFullscreen:l,isCanvasWidget:s,layout:i,hasSideAvatar:!0})})]}):(0,r.jsx)(ec,{invocation:f,accumulatedArgsJson:n,context:a,isIframeFullscreen:l,isCanvasWidget:s,layout:i}):x?(0,r.jsx)(ef,{invocation:f,accumulatedArgsJson:n,context:a,isIframeFullscreen:l,isCanvasWidget:s,layout:i}):null})}let eD=e=>{let{role:t,content:n,createdAt:a,timestamp:l,showTimeStamp:s=!1,animation:i="scale",actions:o,toolInvocations:d,parts:c,agentIcon:m,agentDisplayName:f,isCanvasWidget:g=!1,agentName:x,layout:h="default",toolCallAccumulatedArgs:v,leadCapture:b,isStreaming:y=!1,appearance:k="legacy",messageTextClassName:_,sender:A,onOpenWorkspaceFile:I,...z}=e,[S]=(0,u.useState)(y),T="user"===t,M="assistant"===t,R="iframe-fullscreen"===h,W="default"===h||"floating"===h,{resolvedTheme:L}=(0,ee.D)(),O=z.assets,D=(0,ek._)(),U={};M&&!R&&"legacy"===k&&(U={backgroundColor:"var(--_sketric-agent-bubble-bg)",color:"var(--_sketric-agent-bubble-fg)"});let q=a||(l?new Date(l):void 0),$=q?(0,p.r6)(q.toISOString()):"";if(M&&!(0,ew._P)({role:"assistant",content:n,toolInvocations:d,parts:c},D))return null;if(!M){let e="string"==typeof n?n.trim().length>0:!!n,t=Array.isArray(O)&&O.length>0;if(!e&&!t)return null}if(T){var H,P,J,V,K;let e=(0,e_.CQ)("string"==typeof n?n:String(n||"")),t=g&&!!A,a=(null==A||null==(H=A.first_name)?void 0:H.trim())||(null==A||null==(P=A.name)?void 0:P.trim().split(/\s+/)[0])||(null==A||null==(J=A.email)?void 0:J.split("@")[0])||"Team member",l=((null==A||null==(V=A.name)?void 0:V.trim())||(null==A||null==(K=A.email)?void 0:K.split("@")[0])||a).split(/\s+/).filter(Boolean).slice(0,2).map(e=>{var t;return null==(t=e[0])?void 0:t.toUpperCase()}).join("");if(e){let n=t?"Answers from ".concat(a):"Your answers";return(0,r.jsxs)("div",{className:"group/message-container ml-auto flex w-full flex-col items-end",children:[s&&q?(0,r.jsx)("span",{className:"mb-0.5 mr-2 px-1 text-[10px] font-medium text-muted-foreground opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100",children:$}):null,(0,r.jsxs)("div",{className:"flex w-full items-end justify-end gap-2",children:[(0,r.jsx)("section",{"aria-label":n,"data-testid":"human-input-response",className:"ml-6 w-full sm:ml-12",style:{maxWidth:"iframe-fullscreen"===h?"720px":"var(--_sketric-message-max-width, 330px)"},children:(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-background/50",children:[(0,r.jsxs)("header",{className:"flex items-center gap-2 px-2.5 py-2",children:[(0,r.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full border border-primary/40 bg-primary/10 text-primary ring-1 ring-primary/15",children:(0,r.jsx)(C.A,{className:"size-3",strokeWidth:2.5,"aria-hidden":!0})}),(0,r.jsxs)("span",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium leading-4 text-foreground",children:n}),(0,r.jsxs)("span",{className:"block text-[10px] leading-3 text-muted-foreground",children:[e.length," ",1===e.length?"answer":"answers"," ","submitted"]})]})]}),(0,r.jsx)("dl",{className:"border-t border-border/50",children:e.map((e,t)=>{let{question:n,answer:a}=e;return(0,r.jsxs)("div",{className:"border-b border-border/50 px-2.5 py-2 last:border-b-0",children:[(0,r.jsx)("dt",{className:"text-[11px] leading-4 text-muted-foreground",children:n}),(0,r.jsx)("dd",{className:"mt-0.5 text-xs font-medium leading-5 whitespace-pre-wrap text-foreground",children:a})]},"".concat(n,"-").concat(t))})})]})}),t?(0,r.jsxs)("div",{className:"flex w-10 shrink-0 flex-col items-center gap-1 text-center text-[10px] font-medium leading-none text-muted-foreground",title:a,children:[(0,r.jsx)(j.eu,{className:"h-7 w-7",children:(0,r.jsx)(j.q5,{className:"bg-primary/10 text-[10px] font-semibold text-primary",children:l||"TM"})}),(0,r.jsx)("span",{className:"max-w-16 truncate",children:a})]}):null]}),o?(0,r.jsx)("div",{className:(0,p.cn)("mt-1 z-10 font-medium text-muted-foreground opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100",t&&"mr-12"),children:o}):null]})}return(0,r.jsxs)("div",{className:(0,p.cn)("flex flex-col group/message-container","iframe-fullscreen"===h?"items-end ml-auto":"items-end"),children:[s&&q?(0,r.jsx)("span",{className:(0,p.cn)("mb-0.5 px-1 text-[10px] text-muted-foreground font-medium opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100 z-10",T?"mr-2":"iframe-fullscreen"===h?"ml-1":"ml-12"),children:$}):null,(0,r.jsxs)("div",{className:"flex items-end justify-end gap-2",children:[W&&!t?(0,r.jsx)(er.T,{agentIcon:m||"",isUser:T,isAssistant:M,agentDisplayName:f||"",isCanvasWidget:g,layout:h,theme:L}):null,(0,r.jsx)("div",{className:"flex flex-col items-end",children:(0,r.jsxs)("div",{className:(0,p.cn)(eL({isUser:T,animation:i}),"iframe-fullscreen"===h&&"ml-0","modern"===k&&"mb-0 ml-6 rounded-[18px] rounded-br-md bg-muted/70 px-3.5 py-2 text-sm leading-6 shadow-none sm:ml-12",_),style:{maxWidth:"iframe-fullscreen"===h?"640px":"var(--_sketric-message-max-width, 330px)"},children:[null,O&&O.length>0?(0,r.jsx)(G.R,{assets:O}):null,(0,r.jsx)(eW,{content:"string"==typeof n?n:String(n||"")}),o&&!R&&"legacy"===k?(0,r.jsx)("div",{className:"absolute top-2 right-2 flex space-x-1 rounded-lg text-foreground opacity-0 transition-opacity duration-200 group-hover/message:opacity-100",children:o}):null]})}),t?(0,r.jsxs)("div",{className:"flex w-10 shrink-0 flex-col items-center gap-1 text-center text-[10px] font-medium leading-none text-muted-foreground",title:a,children:[(0,r.jsx)(j.eu,{className:"h-7 w-7",children:(0,r.jsx)(j.q5,{className:"bg-primary/10 text-[10px] font-semibold text-primary",children:l||"TM"})}),(0,r.jsx)("span",{className:"max-w-16 truncate",children:a})]}):null]}),o&&(R||"modern"===k)?(0,r.jsx)("div",{className:(0,p.cn)("mt-1 text-muted-foreground font-medium z-10 opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100",t&&"mr-12"),children:o}):null]})}if(c&&c.length>0){let e=c.findIndex(e=>"text"===e.type),t=c.map((t,n)=>{if("text"===t.type){let a=n===e;return(0,r.jsxs)("div",{className:(0,p.cn)("flex min-w-0 flex-col group/message-container",T?"items-end":"items-start"),children:[s&&q?(0,r.jsx)("span",{className:(0,p.cn)("mb-0.5 px-1 text-[10px] text-muted-foreground font-medium opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100 z-10",T?"mr-2":"iframe-fullscreen"===h?"ml-1":"ml-12"),children:$}):null,(0,r.jsxs)("div",{className:"flex min-w-0 items-end justify-start gap-2",children:[W&&(0,r.jsx)(er.T,{agentIcon:m||"",agentDisplayName:f||"",isUser:T,isAssistant:M,isCanvasWidget:g,layout:h,theme:L}),(0,r.jsxs)("div",{className:(0,p.cn)("min-w-0",R&&M?"relative w-full overflow-x-auto px-1 py-1.5":eL({isUser:T,animation:i}),"iframe-fullscreen"===h&&T&&"ml-4 sm:ml-20","modern"===k&&M&&"rounded-none bg-transparent p-0.5 text-sm leading-6 text-foreground shadow-none","modern"===k&&!M&&!T&&"rounded-xl bg-muted/45 p-3 text-sm text-muted-foreground",_),style:{...U,maxWidth:R&&M?"800px":"var(--_sketric-message-max-width, 330px)"},children:[null,a&&O&&O.length>0?(0,r.jsx)(G.R,{assets:O}):null,(0,r.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto",children:(0,r.jsx)(eR,{text:"string"==typeof t.text?t.text:String(t.text||""),animate:S,isStreaming:y,onOpenWorkspaceFile:R?I:void 0},n)}),o&&!R&&"legacy"===k?(0,r.jsx)("div",{className:"absolute top-2 right-2 flex space-x-1 rounded-lg text-foreground opacity-0 transition-opacity duration-200 group-hover/message:opacity-100",children:o}):null]})]}),o&&(R||"modern"===k)&&(0,r.jsx)("div",{className:(0,p.cn)("text-muted-foreground font-medium z-10 opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100"),children:o})]},"text-".concat(n))}if("reasoning"===t.type)return(0,r.jsx)("div",{className:(0,p.cn)("flex flex-col items-start","iframe-fullscreen"===h?"mb-1 ml-0":"ml-8"),style:{maxWidth:"iframe-fullscreen"===h?"800px":"var(--_sketric-message-max-width, 330px)"},children:(0,r.jsxs)(E,{className:"w-full",isStreaming:!!t.isStreaming,defaultOpen:!!t.isStreaming,children:[(0,r.jsx)(F,{}),(0,r.jsx)(B,{className:"text-muted-foreground",animated:S&&!!t.isStreaming,children:t.reasoning})]})},"reasoning-".concat(n));if("tool-invocation"===t.type){let e=(0,ew.DT)([t.toolInvocation],D);if(!e.length)return null;let a=e[0];return a&&((0,w.Uy)(a.toolName)||(0,N.lc)(a.toolName)||eh.has(a.toolName))?(0,r.jsx)(eO,{toolInvocations:e,toolCallAccumulatedArgs:v,leadCapture:b,isIframeFullscreen:R,isCanvasWidget:g,layout:h,agentIcon:m,agentDisplayName:f,theme:L},"tool-".concat(n)):null}return null}),n=M&&d&&d.length>0?(0,r.jsx)(eO,{toolInvocations:d,toolCallAccumulatedArgs:v,leadCapture:b,isIframeFullscreen:R,isCanvasWidget:g,layout:h,agentIcon:m,agentDisplayName:f,theme:L}):null;return(0,r.jsxs)(r.Fragment,{children:[t,n]})}return d&&d.length>0?(0,r.jsx)(eO,{toolInvocations:d,toolCallAccumulatedArgs:v,leadCapture:b,isIframeFullscreen:R,isCanvasWidget:g,layout:h,agentIcon:m,agentDisplayName:f,theme:L}):(0,r.jsxs)("div",{className:(0,p.cn)("flex min-w-0 flex-col group/message-container",T?"items-end":"items-start"),children:[s&&q?(0,r.jsx)("span",{className:(0,p.cn)("mb-0.5 px-1 text-[10px] text-muted-foreground font-medium opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100 z-10",T?"mr-2":"iframe-fullscreen"===h?"ml-1":"ml-12"),children:$}):null,(0,r.jsxs)("div",{className:"flex min-w-0 items-end justify-start gap-2",children:[W&&(0,r.jsx)(er.T,{agentIcon:m||"",agentDisplayName:f||"",isUser:T,isAssistant:M,isCanvasWidget:g,layout:h,theme:L}),(0,r.jsxs)("div",{className:(0,p.cn)("min-w-0",R&&M?"relative w-full overflow-x-auto px-1 py-1.5":eL({isUser:T,animation:i}),"iframe-fullscreen"===h&&T&&"ml-4 sm:ml-20","modern"===k&&M&&"rounded-none bg-transparent p-0.5 text-sm leading-6 text-foreground shadow-none","modern"===k&&!M&&!T&&"rounded-xl bg-muted/45 p-3 text-sm text-muted-foreground",_),style:{...U,maxWidth:R&&M?"800px":"var(--_sketric-message-max-width, 330px)"},children:[null,O&&O.length>0?(0,r.jsx)(G.R,{assets:O}):null,(0,r.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto",children:(0,r.jsx)(eR,{text:"string"==typeof n?n:String(n||""),animate:S,isStreaming:y,onOpenWorkspaceFile:R?I:void 0})}),o&&!R&&"legacy"===k?(0,r.jsx)("div",{className:"absolute top-2 right-2 flex space-x-1 rounded-lg text-foreground opacity-0 transition-opacity duration-200 group-hover/message:opacity-100",children:o}):o?(0,r.jsx)("div",{className:(0,p.cn)("mt-2 text-muted-foreground font-medium z-10 opacity-0 transition-opacity duration-200 group-hover/message-container:opacity-100"),children:o}):null]})]})]})};var eE=n(15239),eF=n(90109),eB=n(5225),eU=n(18844),eq=n(94979),e$=n(63830),eH=n(47922),eP=n(36304),eJ=n(60272),eV=n(25941),eK=n(19213);let eQ=[/(^|[^a-z0-9])glob([^a-z0-9]|$)/,/(^|[^a-z0-9])grep([^a-z0-9]|$)/,/(^|[^a-z0-9])ls([^a-z0-9]|$)/,/(^|[^a-z0-9])list[_\s-]?(dir|directory)([^a-z0-9]|$)/,/(^|[^a-z0-9])read[_\
1s-]?(file|text[_\s-]?file)([^a-z0-9]|$)/,/(^|[^a-z0-9])(find|search)[_\s-]?files?([^a-z0-9]|$)/,/(^|[^a-z0-9])file[_\s-]?search([^a-z0-9]|$)/,/(^|[^a-z0-9])file[_\s-]?exists([^a-z0-9]|$)/,/(^|[^a-z0-9])get[_\s-]?file[_\s-]?(metadata|link)([^a-z0-9]|$)/],eX=[/(^|[^a-z0-9])(edit|write|create|append|update|delete|remove)[_\s-]?file([^a-z0-9]|$)/,/(^|[^a-z0-9])(copy|move|rename)[_\s-]?file([^a-z0-9]|$)/];function eY(e){return eX.some(t=>t.test(e.toLowerCase()))}function eG(e){return/(^|[^a-z0-9])(web[_\s-]?search|search[_\s-]?web)([^a-z0-9]|$)/.test(e.toLowerCase())}function eZ(e){let t=e.toLowerCase();return!(eG(t)||eY(t))&&(/^search_[a-z0-9]/.test(t)||eQ.some(e=>e.test(t)))}function e0(e){return/(^|[^a-z0-9])(task|delegate|delegation|subagent|spawn[_\s-]?agent)([^a-z0-9]|$)/.test(e.toLowerCase())}let e1=[{terms:["airtable"],label:"Airtable",src:"/brand-icons/airtable.avif"},{terms:["facebook"],label:"Facebook",src:"/brand-icons/facebook.avif"},{terms:["gmail","google"],label:"Google",src:"/brand-icons/google.avif"},{terms:["notion"],label:"Notion",src:"/brand-icons/notion.avif"},{terms:["shopify"],label:"Shopify",src:"/brand-icons/shopify.avif"},{terms:["slack"],label:"Slack",src:"/brand-icons/slack.avif"},{terms:["stripe"],label:"Stripe",src:"/brand-icons/stripe.avif"},{terms:["trello"],label:"Trello",src:"/brand-icons/trello.avif"},{terms:["whatsapp"],label:"WhatsApp",src:"/brand-icons/whatsapp.avif"},{terms:["wix"],label:"Wix",src:"/brand-icons/wix.avif"}];function e2(e){let t=e.toLowerCase(),n=e1.find(e=>e.terms.some(e=>t.includes(e)));return n?{appLabel:n.label,brandSrc:n.src,kind:"generic"}:eZ(t)?{kind:"file"}:eG(t)?{kind:"search"}:/schedule|cron/.test(t)?{kind:"schedule"}:/file|document|pdf|read|write/.test(t)?{kind:"file"}:t.includes("search")?{kind:"search"}:/browse|fetch|http|url|web/.test(t)?{kind:"web"}:/github|gitlab/.test(t)?{appLabel:"GitHub",kind:"github"}:/sql|database|query/.test(t)?{kind:"data"}:/message|email|send/.test(t)?{kind:"message"}:/product|catalog|order|cart/.test(t)?{kind:"commerce"}:/code|terminal|shell|execute|python/.test(t)?{kind:"code"}:{kind:"generic"}}let e5={search:eF.A,web:z.A,code:T.A,file:eB.A,data:eU.A,message:eq.A,commerce:e$.A,github:eH.A,schedule:eP.A,generic:eJ.A};function e3(e){let{toolName:t,configuredVisual:n,url:a,className:l}=e,[s,i]=(0,u.useState)(null),[o,d]=(0,u.useState)("google");if((null==n?void 0:n.appIcon)&&n.appIcon!==s)return(0,r.jsx)(eE.default,{src:n.appIcon,alt:"".concat(n.appLabel," icon"),width:28,height:28,unoptimized:!0,onError:()=>i(n.appIcon),className:(0,p.cn)("rounded-[5px] object-cover",null!=l?l:"size-4")});let c=e2(t);if(c.brandSrc)return(0,r.jsx)(eE.default,{src:c.brandSrc,alt:c.appLabel?"".concat(c.appLabel," icon"):"App icon",width:28,height:28,className:(0,p.cn)("rounded-[5px] object-cover",null!=l?l:"size-4")});if("web"===c.kind&&a&&"failed"!==o){let e=(0,eV.m)(a),t="google"===o?null==e?void 0:e.googleUrl:null==e?void 0:e.directUrl;if(t)return(0,r.jsx)(eE.default,{src:t,alt:"",width:28,height:28,unoptimized:!0,referrerPolicy:"no-referrer",onError:()=>d(e=>"google"===e?"direct":"failed"),className:(0,p.cn)("rounded-[3px] object-contain",null!=l?l:"size-4")},t)}let m=eG(t)?z.A:e5[c.kind];return(0,r.jsx)(m,{"aria-hidden":"true",className:(0,p.cn)("size-4",l)})}function e6(e){let{sources:t,className:n}=e;return 0===t.length?null:(0,r.jsxs)("div",{className:(0,p.cn)("mt-2 flex max-w-full flex-wrap items-center gap-1.5",n),"aria-label":"Web search sources",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[(0,r.jsx)(eF.A,{className:"size-3","aria-hidden":"true"}),"Sources"]}),t.map((e,t)=>(0,r.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",title:e.title?"".concat(e.title," — ").concat(e.url):e.url,className:"inline-flex max-w-[13rem] items-center gap-1 rounded-full border border-border bg-muted/50 px-2 py-1 text-xs text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:t+1}),(0,r.jsx)("span",{className:"truncate",children:e.hostname}),(0,r.jsx)(I.A,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"})]},e.url))]})}
1let e9=new Set(["write_todos","write todos","writetodos","todo_write","todos_write"]);var e4=n(96442);function e8(e,t){if(!e||!t||t<e)return null;let n=Math.max(1,Math.round((t-e)/1e3));return n<60?"".concat(n,"s"):"".concat(Math.floor(n/60),"m ").concat(n%60,"s")}function e7(e){if(e&&"object"==typeof e&&!Array.isArray(e))return e;if("string"!=typeof e)return null;try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(e){return null}}function te(e,t){if(!e)return null;for(let n of t){let t=e[n];if("string"==typeof t&&t.trim())return t.trim()}return null}function tt(e){if(!e)return null;try{return new URL(e).hostname.replace(/^www\./,"")}catch(t){return e.length>72?"".concat(e.slice(0,69),"…"):e}}let tn=new Set(["get","list","create","update","delete","search","fetch","find","add","remove","check","read","write","send","post","put","patch","run","execute","upload","download","sync","generate","analyze","query"]);function tr(e){var t,n;let r=e.split(/[_-]+/);return r.length>2&&!tn.has((null!=(t=r[0])?t:"").toLowerCase())&&tn.has((null!=(n=r[1])?n:"").toLowerCase())?r.slice(1).join("_"):e}function ta(e,t){var n,r,a,l,s,i;let o=e7(null!=(n=e.arguments)?n:e.argumentBuffer),d=te(o,["query","q","search_query","search"]),u=te(o,["url","href","link"]),c=te(o,["path","file_path","filepath","directory","dir_path","pattern"]),m=e2(e.name),p="search"===m.kind,f="running"!==e.status;if(t)return{title:"".concat(f?"Used":"Using"," ").concat(t.appLabel),detail:function(e,t){let n=e.replaceAll("_"," ").replaceAll("-"," "),r=(n.toLowerCase().startsWith(t.appLabel.toLowerCase())?n.slice(t.appLabel.length):n).trim();return r?"".concat(r.charAt(0).toUpperCase()).concat(r.slice(1)):void 0}(e.name,t)};if(eY(e.name)){let t=e.name.toLowerCase(),n=/(^|[^a-z0-9])edit[_\s-]?file/.test(t)?[f?"Edited":"Editing","file"]:/(^|[^a-z0-9])(copy)[_\s-]?file/.test(t)?[f?"Copied":"Copying","file"]:/(^|[^a-z0-9])(move|rename)[_\s-]?file/.test(t)?[f?"Moved":"Moving","file"]:/(^|[^a-z0-9])(delete|remove)[_\s-]?file/.test(t)?[f?"Deleted":"Deleting","file"]:[f?"Wrote":"Writing","file"];return{title:"".concat(n[0]," ").concat(n[1]),detail:null!=c?c:void 0}}if(eZ(e.name)){let t=e.name.toLowerCase();return/(^|[^a-z0-9])file[_\s-]?exists/.test(t)?{title:f?"Checked file":"Checking file",detail:null!=c?c:void 0}:/(^|[^a-z0-9])get[_\s-]?file[_\s-]?(metadata|link)/.test(t)?{title:f?"Read file details":"Reading file details",detail:null!=c?c:void 0}
1:/(^|[^a-z0-9])read[_\s-]?(file|text[_\s-]?file)/.test(t)?{title:f?"Read file":"Reading file",detail:null!=c?c:void 0}:/(^|[^a-z0-9])(glob|grep|find|search)/.test(t)?{title:f?"Searched files":"Searching files",detail:null!=(r=null!=c?c:d)?r:void 0}:{title:f?"Listed files":"Listing files",detail:null!=c?c:void 0}}if(p){let t=null!=(s=null!=(l=tt(u))?l:null==(a=e.sources[0])?void 0:a.hostname)?s:null;return{title:t?"".concat(f?"Searched":"Searching"," ").concat(t):f?"Searched the web":"Searching the web",detail:null!=d?d:void 0}}if("web"===m.kind)return{title:f?"Opened a webpage":"Opening a webpage",detail:null!=(i=tt(u))?i:void 0};if(m.appLabel){let t=tr(e.name).replaceAll("_"," ").replaceAll("-"," ").replace(RegExp("^".concat(m.appLabel,"\\s*"),"i"),"").trim();return{title:"".concat(f?"Used":"Using"," ").concat(m.appLabel),detail:t?"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1)):void 0}}return{title:tr(e.name).replaceAll("_"," ").replaceAll("-"," ")}}function tl(e){let{status:t,compact:n=!1}=e,a=n?"size-3":"size-3.5";return"running"===t?(0,r.jsx)(o.A,{"aria-label":"Running",className:(0,p.cn)(a,"animate-spin text-primary motion-reduce:animate-none")}):"paused"===t||"interrupted"===t?(0,r.jsx)(k.A,{"aria-label":"paused"===t?"Waiting for input":"Interrupted",className:(0,p.cn)(a,"text-muted-foreground")}):"error"===t?(0,r.jsx)(_.A,{"aria-label":"Failed",className:(0,p.cn)(a,"text-destructive")}
1):(0,r.jsx)(C.A,{"aria-label":"Completed",className:(0,p.cn)(a,"text-emerald-600")})}let ts=(0,u.memo)(function(e){var t,n;let{tool:a,toolVisuals:l,compact:s=!1}=e,[i,o]=(0,u.useState)(!1),d=(0,e4.nf)(a.name,l),c=ta(a,d),m="web"===e2(a.name).kind&&null!=(n=te(e7(null!=(t=a.arguments)?t:a.argumentBuffer),["url","href","link"]))?n:void 0,f=[...new Map(a.sources.map(e=>[e.url,e])).values()];return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:(0,p.cn)("group flex animate-in items-start duration-200 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",s?"min-h-7 gap-1.5 py-0.5":"min-h-9 gap-2 py-1.5"),children:[(0,r.jsx)(e3,{toolName:a.name,configuredVisual:d,url:m,className:(0,p.cn)("mt-0.5 shrink-0 opacity-70",s?"size-3":"size-3.5")}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:(0,p.cn)("truncate font-medium capitalize",s?"text-[10px] leading-4":"text-xs leading-4"),children:"running"===a.status?(0,r.jsx)(X.F,{text:c.title,startOnView:!1,duration:1.8,repeatDelay:.25}):(0,r.jsx)("span",{className:"text-muted-foreground",children:c.title})}),c.detail?(0,r.jsx)("div",{className:(0,p.cn)("truncate text-muted-foreground/80",s?"text-[10px] leading-3":"text-[11px] leading-4"),children:c.detail}):null]}),f.length>0?(0,r.jsxs)("button",{type:"button","aria-expanded":i,onClick:()=>o(e=>!e),className:(0,p.cn)("inline-flex shrink-0 items-center gap-1 rounded-full bg-muted font-medium tabular-nums text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",s?"min-h-6 px-1.5 text-[10px]":"min-h-7 px-2 text-[11px]"),children:[f.length," ",1===f.length?"source":"sources",(0,r.jsx)(A.A,{className:(0,p.cn)("size-3 transition-transform motion-reduce:transition-none",i&&"rotate-180"),"aria-hidden":"true"})]}):null]}),i?(0,r.jsx)("div",{className:(0,p.cn)("grid gap-1 border-l border-border/60 sm:grid-cols-2",s?"ml-7 py-0.5 pl-2":"ml-9 py-1 pl-3"),children:f.map(e=>(0,r.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:(0,p.cn)("group/source flex min-w-0 items-center gap-2 rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted/40 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",s?"min-h-7 px-1.5 text-[11px]":"min-h-8 px-2 text-xs"),children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title||e.hostname}),(0,r.jsx)(I.A,{className:"size-3 shrink-0 opacity-60 transition-opacity group-hover/source:opacity-100","aria-hidden":"true"})]},e.url))}):null]})});function ti(e){let{group:t,tools:n,toolVisuals:a,compact:l=!1}=e,[s,i]=(0,u.useState)(!1),o=n.some(e=>"running"===e.status)?"running":n.some(e=>"error"===e.status)?"error":n.some(e=>"paused"===e.status)?"paused":n.some(e=>"interrupted"===e.status)?"interrupted":"success",d=n.reduce((e,t)=>(e[function(e){let t=e.toLowerCase();
1return/(^|[^a-z0-9])read[_\s-]?(file|text[_\s-]?file)/.test(t)?"read":/(^|[^a-z0-9])(glob|grep|find|search)/.test(t)?"search":/(^|[^a-z0-9])(file[_\s-]?exists|get[_\s-]?file)/.test(t)?"check":"list"}(t.name)]+=1,e),{read:0,search:0,check:0,list:0}),c=[d.read>0?"".concat(d.read," ").concat(1===d.read?"read":"reads"):null,d.search>0?"".concat(d.search," ").concat(1===d.search?"search":"searches"):null,d.check>0?"".concat(d.check," ").concat(1===d.check?"check":"checks"):null,d.list>0?"".concat(d.list," ").concat(1===d.list?"listing":"listings"):null].filter(Boolean).join(" \xb7 "),m=new Set(n.flatMap(e=>e.sources.map(e=>e.url))).size,f="web-search"===t?{title:"running"===o?"Searching the web":"error"===o?"Some web searches failed":"Searched the web",countLabel:"".concat(n.length," ").concat(1===n.length?"search":"searches"),detail:m?"".concat(m," ").concat(1===m?"source":"sources"):"View queries and results",icon:(0,r.jsx)(z.A,{className:(0,p.cn)("mt-0.5 shrink-0 opacity-70 text-muted-foreground",l?"size-3":"size-3.5"),"aria-hidden":!0})}:"file-edit"===t?{title:"running"===o?"Editing files":"error"===o?"Some file edits failed":"Edited files",countLabel:"".concat(n.length," ").concat(1===n.length?"change":"changes"),detail:[...new Set(n.map(e=>ta(e).detail).filter(e=>!!e))].join(" \xb7 ").slice(0,120),icon:(0,r.jsx)(S.A,{className:(0,p.cn)("mt-0.5 shrink-0 opacity-70 text-muted-foreground",l?"size-3":"size-3.5"),"aria-hidden":!0})}:"code"===t?{title:"running"===o?"Using code interpreter":"error"===o?"Code interpreter failed":"Used code interpreter",countLabel:"".concat(n.length," ").concat(1===n.length?"action":"actions"),detail:"View code interpreter details",icon:(0,r.jsx)(T.A,{className:(0,p.cn)("mt-0.5 shrink-0 opacity-70 text-muted-foreground",l?"size-3":"size-3.5"),"aria-hidden":!0})}:{title:"running"===o?"Exploring files":"error"===o?"Some file actions failed":"Explored files",countLabel:"".concat(n.length," ").concat(1===n.length?"action":"actions"),detail:c,icon:(0,r.jsx)(M.A,{className:(0,p.cn)("mt-0.5 shrink-0 opacity-70 text-muted-foreground",l?"size-3":"size-3.5"),"aria-hidden":!0})};return(0,r.jsxs)(L.Nt,{open:s,onOpenChange:i,className:(0,p.cn)("animate-in rounded-lg fade-in slide-in-from-bottom-1 transition-colors duration-200 motion-reduce:animate-none",s&&"bg-muted/20"),children:[(0,r.jsx)(L.R6,{asChild:!0,children:(0,r.jsxs)("button",{type:"button",className:(0,p.cn)("flex w-full items-start rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",l?"min-h-8 gap-1.5 py-1":"min-h-10 gap-2 py-1.5"),children:[f.icon,(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:(0,p.cn)("truncate font-medium",l?"text-[10px] leading-4":"text-xs leading-4"),children:["running"===o?(0,r.jsx)(X.F,{text:f.title,startOnView:!1,duration:1.8,repeatDelay:.25}):(0,r.jsx)("span",{className:"text-muted-foreground",children:f.title}),(0,r.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground/80",children:["\xb7 ",f.countLabel]})]}),(0,r.jsx)("div",{className:(0,p.cn)("truncate text-muted-foreground/80",l?"text-[10px] leading-3":"text-[11px] leading-4"),children:f.detail})]}),(0,r.jsx)(A.A,{className:(0,p.cn)("mt-0.5 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",l?"size-3":"size-3.5",s&&"rotate-180"),"aria-hidden":"true"})]})}),(0,r.jsx)(L.Ke,{className:"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-1 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-top-1 motion-reduce:animate-none",children:(0,r.jsx)("div",{className:(0,p.cn)("border-l border-border/60 pr-1",l?"ml-4 pb-0.5 pl-3":"ml-[19px] pb-1 pl-4"),children:n.map(e=>{let t=ta(e,(0,e4.nf)(e.name,a));return(0,r.jsxs)("div",{className:(0,p.cn)("flex min-w-0 items-center",l?"min-h-6 gap-1.5 text-[11px]":"min-h-7 gap-2 text-xs"),children:[(0,r.jsx)(tl,{status:e.status,compact:l}),(0,r.jsx)("span",{className:"shrink-0 font-medium capitalize text-foreground/80",children:t.title}),t.detail?(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:t.detail}):null]},e.id)})})})]})}function to(e){let{segments:t,compact:n=!1,animate:a=!0}
1=e,l=t.some(e=>e.streaming),s=t.map(e=>e.text.trim()).filter(Boolean).join("\n\n");return s?(0,r.jsxs)(E,{className:(0,p.cn)("animate-in duration-200 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",n?"text-[10px]":"text-xs"),isStreaming:l,defaultOpen:l,children:[(0,r.jsxs)(F,{className:(0,p.cn)("px-0 hover:text-muted-foreground",n?"gap-1.5":"gap-2"),children:["Thinking",t.length>1?(0,r.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground/70",children:["\xb7 ",t.length," updates"]}):null]}),(0,r.jsx)(B,{animated:a&&l,children:s})]}):null}function td(e){let{segment:t,className:n,forceAnimate:a=!1,allowAnimate:l=!0,onOpenWorkspaceFile:s}=e,[i]=(0,u.useState)(a||l&&t.streaming);return(0,r.jsx)(eR,{text:t.text,animate:i,isStreaming:t.streaming,className:n,onOpenWorkspaceFile:s})}function tu(e){let{name:t,iconSrc:n,compact:a=!1}=e;return(0,r.jsxs)("div",{className:(0,p.cn)("mb-1.5 flex min-w-0 items-center",a?"gap-1.5":"gap-2"),children:[(0,r.jsxs)("span",{className:(0,p.cn)("inline-flex min-w-0 max-w-full items-center rounded-full border border-border/60 bg-muted/40 font-mono font-medium text-foreground/90",a?"gap-1 px-1.5 py-0.5 text-[9px] leading-3.5":"gap-1 px-1.5 py-0.5 text-[10px] leading-4"),children:[n?(0,r.jsx)(tf,{src:n,name:t,className:(0,p.cn)("shrink-0 rounded-full",a?"size-2.5":"size-3")}):null,(0,r.jsx)("span",{className:"truncate",children:(0,ew.MH)(t)})]}),(0,r.jsx)("span",{className:(0,p.cn)("shrink-0 font-normal text-muted-foreground/70",a?"text-[10px]":"text-xs"),children:"(Sub-Agent)"})]})}function tc(e){let{segment:t,showAgentName:n,iconSrc:a,compact:l=!1,onOpenWorkspaceFile:s}=e;return"reasoning"===t.kind?(0,r.jsxs)(E,{className:"animate-in text-xs duration-200 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",isStreaming:t.streaming,defaultOpen:t.streaming,children:[(0,r.jsx)(F,{className:(0,p.cn)("px-0 hover:text-muted-foreground",l?"gap-1.5":"gap-2"),children:"Thinking"}),(0,r.jsx)(B,{animated:!1,children:t.text})]}):(0,r.jsxs)("div",{className:(0,p.cn)("animate-in duration-200 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",l?"py-0.5":"py-1.5"),children:[n&&t.agentName&&t.subagentCallId?(0,r.jsx)(tu,{name:t.agentName,iconSrc:a,compact:l}):null,(0,r.jsx)(td,{segment:t,allowAnimate:!1,className:(0,p.cn)("text-foreground",l?"text-xs leading-5":"text-[15px] leading-7"),onOpenWorkspaceFile:s})]})}function tm(e){let{tasks:t,compact:n}=e,a=t.findIndex(e=>"completed"!==e.status),l=t.filter(e=>"completed"===e.status).length;return(0,r.jsx)("span",{className:"flex shrink-0 items-center gap-0.5",role:"progressbar","aria-label":"Task progress: ".concat(l," of ").concat(t.length," complete"),"aria-valuemin":0,"aria-valuemax":t.length,"aria-valuenow":l,children:t.map((e,t)=>{let l="completed"===e.status,s=t===a;return(0,r.jsx)("span",{"data-task-status":l?"completed":s?"active":"pending",className:(0,p.cn)("h-1 shrink-0 rounded-full transition-colors duration-300 motion-reduce:transition-none",n?"w-2":"w-2.5",(l||s)&&"bg-primary",!l&&!s&&"bg-muted-foreground/30"),"aria-hidden":"true"},e.id)})})}function tp(e){var t,n;let{tasks:a,compact:l=!1}=e,[s,i]=(0,u.useState)(!1),o=a.filter(e=>"completed"===e.status).length,d=null!=(t=a.find(e=>"in_progress"===e.status))?t:a.find(e=>"pending"===e.status);return 0===a.length?null:(0,r.jsx)(U,{className:(0,p.cn)("animate-in duration-200 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",l?"mt-0.5":"mt-1"),children:(0,r.jsxs)(q,{open:s,onOpenChange:i,children:[(0,r.jsxs)($,{className:(0,p.cn)(l?"min-h-7 px-1.5 text-[11px]":"px-2","hover:bg-transparent"),children:[(0,r.jsx)(tm,{tasks:a,compact:l}),s?null:(0,r.jsx)("span",{className:(0,p.cn)("min-w-0 flex-1 truncate text-xs text-muted-foreground",d&&"hidden sm:block"),children:null!=(n=null==d?void 0:d.title)?n:"All tasks completed!"}),(0,r.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[o,"/",a.length]})]}),(0,r.jsx)(H,{children:(0,r.jsx)(P,{children:a.map(e=>{let t="completed"===e.status;return(0,r.jsxs)(J,{className:(0,p.cn)("in_progress"===e.status&&"bg-primary/5",t&&"opacity-80"),children:[(0,r.jsx)(V,{status:e.status}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)(K,{completed:t,children:e.title}),e.description?(0,r.jsx)(Q,{children:e.description}):null]})]},e.id)})})})]})})}function tf(e){let{src:t,name:n,className:a}=e;return(0,r.jsx)("img",{src:t,alt:n?"".concat(n," icon"):"Sub agent icon",loading:"lazy",className:(0,p.cn)("size-full rounded-[7px] object-cover",a)})}function tg(e){let{tool:t,summary:n,iconSrc:a,compact:l=!1,showSources:s=!0,children:i}=e,[o,d]=(0,u.useState)(!1),c=function(e){var t;let n=te(e7(null!=(t=e.arguments)?t:e.argumentBuffer),["subagent_type","agent_name","agent","name"]);return n?(0,ew.MH)(n):null}(t),m="running"===t.status,f=[...new Map(t.sources.map(e=>[e.url,e])).values()];return(0,r.jsxs)(L.Nt,{open:o,onOpenChange:d,className:(0,p.cn)("animate-in rounded-lg fade-in slide-in-from-bottom-1 transition-colors duration-200 motion-reduce:animate-none",o&&"bg-muted/20"),children:[(0,r.jsx)(L.R6,{asChild:!0,children:(0,r.jsxs)("button",{type:"button",className:(0,p.cn)("flex w-full items-start rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",l?"min-h-8 gap-1.5 py-1":"min-h-10 gap-2 py-1.5"),children:[(0,r.jsx)(tf,{src:a,name:null!=c?c:void 0,className:(0,p.cn)("mt-0.5 shrink-0 rounded-[5px]",l?"size-3":"size-3.5")}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:(0,p.cn)("truncate font-medium",l?"text-[10px] leading-4":"text-xs leading-4"),children:[m?(0,r.jsx)(X.F,{text:n.title,startOnView:!1,duration:1.8,repeatDelay:.25}):(0,r.jsx)("span",{className:"text-muted-foreground",children:n.title}),c?(0,r.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground
1/80",children:["\xb7 ",c]}):null]}),n.detail?(0,r.jsx)("div",{className:(0,p.cn)("truncate text-muted-foreground/80",l?"text-[10px] leading-3":"text-[11px] leading-4"),children:n.detail}):null]}),(0,r.jsx)(A.A,{className:(0,p.cn)("mt-0.5 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",l?"size-3":"size-3.5",o&&"rotate-180"),"aria-hidden":"true"})]})}),i||f.length>0?(0,r.jsx)(L.Ke,{className:"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-1 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-top-1 motion-reduce:animate-none",children:(0,r.jsxs)("div",{className:(0,p.cn)("border-l border-border/60",l?"ml-[30px] space-y-0 pl-3":"ml-9 space-y-0.5 pl-4"),children:[i,s?(0,r.jsx)(e6,{sources:f}):null]})}):null]})}let tx=(0,u.memo)(function(e){var t,n;let l,s,{turn:o,agentIcon:d,agentDisplayName:c,primaryAgentIcon:m,isCanvasWidget:g,isBrandAgent:x,layout:h,toolVisuals:v,onOpenTrace:y,assets:j,hideMessageActions:N,onOpenWorkspaceFile:w}=e,I=(0,ek._)(),z="running"===o.status||"paused"===o.status,S=x&&"iframe-fullscreen"!==h,[T,M]=(0,u.useState)(()=>!x),[R]=(0,u.useState)(z),W=e8(o.startedAt,o.finishedAt),O=(0,u.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.finalMessageId?e.segmentsById[e.finalMessageId]:void 0,r=(null==n?void 0:n.kind)==="text"?n:void 0,a=null!=r?r:e.timeline.toReversed().filter(e=>"text"===e.kind).map(t=>e.segmentsById[t.refId]).find(n=>(null==n?void 0:n.kind)==="text"&&("partial"===n.presentation||!t.deferProvisionalResponse&&"running"===e.status&&"provisional"===n.presentation&&0===n.namespace.length&&null===n.subagentCallId));return{primaryResponse:a,activityEntries:a?e.timeline.filter(e=>e.refId!==a.id):e.timeline}})(o),[o]),D=O.primaryResponse,E=x?T:z||T,F="iframe-fullscreen"!==h,[B,U]=(0,u.useState)(!1),q=(0,u.useMemo)(()=>O.activityEntries.filter(e=>{if("tasks"===e.kind||"hitl"===e.kind)return!1;if("text"===e.kind||"reasoning"===e.kind){let t=o.segmentsById[e.refId];return!!(null==t?void 0:t.text.trim())&&(null==t?void 0:t.id)!==o.finalMessageId}let t=o.toolsById[e.refId];return!!(t&&!function(e){let t=e.trim().toLowerCase().replace(/\s+/g,"_");return!!(e9.has(t)||t.includes("write_todo"))}(t.name)&&(!I.hideHandoffToolCalls||!(0,ew.as)(t.name,I.handoffToolNamePrefix)))}),[I.handoffToolNamePrefix,I.hideHandoffToolCalls,o,O]),$=z?0:new Set([...o.sources.map(e=>e.url),...Object.values(o.toolsById).flatMap(e=>e.sources.map(e=>e.url))]).size,H=q.filter(e=>"tool"===e.kind).length;for(let e=q.length-1;e>=0;e-=1){let t=q[e];if((null==t?void 0:t.kind)!=="tool")continue;let n=o.toolsById[t.refId];if(n&&(null!=l||(l=n),"running"===n.status)){s=n;break}}let P=null!=s?s:l,J=x&&z&&P?ta(P,(0,e4.nf)(P.name,v)).title:null,V=(0,u.useMemo)(()=>(function e(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=new Set(t.filter(e=>{var t,r;return"tool"===e.kind&&e0(null!=(r=null==(t=n[e.refId])?void 0:t.name)?r:"")}).map(e=>e.refId)),l=e=>{var t,l,s,i;if("text"===e.kind)return null;let o="tool"===e.kind?null!=(s=null==(t=n[e.refId])?void 0:t.subagentCallId)?s:null:null!=(i=null==(l=r[e.refId])?void 0:l.subagentCallId)?i:null;return o&&o!==e.refId&&a.has(o)?o:null},s=new Map,i=[];for(let e of t){let t=l(e);if(!t){i.push(e);continue}let n=s.get(t);n?n.push(e):s.set(t,[e])}let o=[],d=e=>{if("reasoning"===e.kind)return"reasoning";if("tool"!==e.kind||a.has(e.refId))return null;let t=n[e.refId];return t?function(e){if(eY(e))return"file-edit";if(eZ(e))return"file-exploration";if(eG(e))return"web-search";let t=e.toLowerCase();return/(^|[^a-z0-9])(code|terminal|shell|execute|python|sandbox)([^a-z0-9]|$)/.test(t)?"code":null}(t.name):null},u=new Map;for(let e of i){let t=d(e);if(!t)continue;let n=u.get(t);n?n.push(e):u.set(t,[e])}let c=new Set;for(let t of i){if("tool"===t.kind&&a.has(t.refId)){var m;o.push({kind:"subagent",key:"subagent:".concat(t.key),entry:t,children:e(null!=(m=s.get(t.refId))?m:[],n,r)});continue}let l=d(t),i=l?u.get(l):void 0;if(!l||!i){o.push({kind:"entry",key:t.key,entry:t});continue}c.has(l)||(c.add(l),"reasoning"===l?o.push({kind:"reasoning-group",key:"reasoning-group:".concat(t.key),entries:i}):o.push({kind:"tool-group",key:"".concat(l,":").concat(t.key),group:l,entries:i}))}return o}
1)(q,o.toolsById,o.segmentsById),[q,o.segmentsById,o.toolsById]),K=(0,u.useMemo)(()=>(function(e,t){let n=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=(31*t+e.charCodeAt(n))%1000003;return t}(e);return new Map(t.map((e,t)=>[e,(0,Y.Ie)((0,Y.Hj)(n+7*t))]))})(o.runId,o.timeline.filter(e=>{var t,n;return"tool"===e.kind&&e0(null!=(n=null==(t=o.toolsById[e.refId])?void 0:t.name)?n:"")}).map(e=>e.refId)),[o.runId,o.timeline,o.toolsById]),Q=e=>{var t;return e.subagentCallId?null!=(t=K.get(e.subagentCallId))?t:(0,Y.Ie)((0,Y.ge)(e.subagentCallId)):m},Z=D?Q(D):void 0,ee=function(e){let{turn:t,compact:n=!1}=e,l=n?"size-3":"size-3.5";return"running"===t.status?null:"paused"===t.status?(0,r.jsx)(k.A,{className:(0,p.cn)(l,"text-amber-600")}):"error"===t.status||"halted"===t.status?(0,r.jsx)(a.A,{className:(0,p.cn)(l,"text-destructive")}):"cancelled"===t.status?(0,r.jsx)(_.A,{className:(0,p.cn)(l,"text-muted-foreground")}):(0,r.jsx)(C.A,{className:(0,p.cn)(l,"text-emerald-600")})}({turn:o,compact:S}),et=z?"paused"===o.status?"Waiting for your input":"Working":"finished"===o.status?"Completed":"halted"===o.status||"cancelled"===o.status?"Stopped":"Couldn’t complete",en=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("subagent"===e.kind){var n;let t=o.toolsById[e.entry.refId];return t?(0,r.jsx)(tg,{tool:t,summary:(e=>{var t;let n=Object.values(o.toolsById).filter(t=>t.subagentCallId===e.id);if("running"!==e.status){let t=e8(e.startedAt,e.endedAt),r=new Set(e.sources.map(e=>e.url)).size,a=[n.length>0?"".concat(n.length," ").concat(1===n.length?"tool":"tools"):null,r>0?"".concat(r," ").concat(1===r?"source":"sources"):null,t].filter(Boolean).join(" \xb7 ");return{title:"error"===e.status?"Sub agent failed":"Sub agent finished",detail:a||void 0}}let r=null!=(t=n.find(e=>"running"===e.status))?t:n.at(-1);return r?{title:"Sub agent running",detail:ta(r,(0,e4.nf)(r.name,v)).title}:{title:"Starting sub agent"}})(t),iconSrc:null!=(n=K.get(t.id))?n:(0,Y.Ie)((0,Y.ge)(t.id)),compact:S,showSources:!z,children:e.children.length>0?e.children.map(e=>en(e,!0)):null},e.key):null}if("tool-group"===e.kind){let t=e.entries.map(e=>o.toolsById[e.refId]).filter(e=>!!e);return t.length>0?(0,r.jsx)(ti,{group:e.group,tools:t,toolVisuals:v,compact:S},e.key):null}if("reasoning-group"===e.kind){let n=e.entries.map(e=>o.segmentsById[e.refId]).filter(e=>!!e);return n.length>0?(0,r.jsx)(to,{segments:n,compact:S,animate:!t},e.key):null}var a=e.entry;if("tool"===a.kind){let e=o.toolsById[a.refId];return e?(0,r.jsx)(ts,{tool:e,toolVisuals:v,compact:S},a.key):null}let l=o.segmentsById[a.refId];return l?(0,r.jsx)(tc,{segment:l,showAgentName:!I.hideAgentNames,iconSrc:Q(l),compact:S,onOpenWorkspaceFile:"iframe-fullscreen"===h?w:void 0},a.key):null};return(0,r.jsxs)("article",{className:(0,p.cn)("group/turn w-full gap-2",S?"py-0":"py-1","iframe-fullscreen"===h?"mx-auto flex w-full min-w-0 max-w-[800px]":"grid max-w-full grid-cols-[1.75rem_minmax(0,1fr)]"),"aria-label":"".concat(c," activity"),children:["iframe-fullscreen"!==h?(0,r.jsx)(er.T,{agentIcon:d,agentDisplayName:c,isUser:!1,isAssistant:!0,isCanvasWidget:g,layout:h,className:(null==D?void 0:D.text)?S?"mb-5 self-end":"mb-7 self-end":"self-end"}):null,(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)(L.Nt,{open:E,onOpenChange:e=>{(x||!z)&&M(e)},children:[(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(L.R6,{asChild:!0,children:(0,r.jsxs)("button",{type:"button",className:(0,p.cn)("flex min-w-0 flex-1 items-center rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",S?"min-h-7 gap-1.5 text-xs":"min-h-9 gap-2 text-sm"),children:[ee?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:ee}):null,"running"===o.status?(0,r.jsx)(X.F,{text:"Working",startOnView:!1,duration:1.8,repeatDelay:.25,className:"font-medium"}):(0,r.jsx)("span",{className:(0,p.cn)("font-medium text-foreground/90","error"===o.status&&"text-destructive"),children:et}),(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:J?(0,r.jsxs)(r.Fragment,{children:["\xb7 ",J]}
1):(0,r.jsxs)(r.Fragment,{children:[H>0?"\xb7 ".concat(H," ").concat(1===H?"tool":"tools"):"",$>0?" \xb7 ".concat($," ").concat(1===$?"source":"sources"):"",o.tasks.length>0?" \xb7 ".concat(o.tasks.length," tasks"):"",W?" \xb7 ".concat(W):""]})}),(0,r.jsx)(A.A,{className:(0,p.cn)("ml-auto shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",S?"size-3":"size-3.5",E&&"rotate-180")})]})})}),(0,r.jsx)(L.Ke,{className:"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-1 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-top-1 motion-reduce:animate-none",children:(0,r.jsxs)("div",{className:S?"space-y-0":"space-y-0.5",children:[(0,r.jsx)(tp,{tasks:o.tasks,compact:S}),V.map(e=>en(e))]})})]}),j&&j.length>0?(0,r.jsx)("div",{className:S?"mt-1":"mt-2",children:(0,r.jsx)(G.R,{assets:j})}):null,(null==D?void 0:D.text)?(0,r.jsxs)("div",{className:(0,p.cn)("min-w-0",S?"mt-1":"mt-2"),children:[(0,r.jsxs)("div",{className:(0,p.cn)("min-w-0 max-w-full",S?"text-sm leading-6":"text-[15px] leading-7",F?"rounded-2xl rounded-bl-none px-3 py-2":"px-0"),style:F?{backgroundColor:"var(--_sketric-agent-bubble-bg)",color:"var(--_sketric-agent-bubble-fg)",maxWidth:"var(--_sketric-message-max-width, 330px)"}:void 0,onClick:()=>U(e=>!e),children:[!I.hideAgentNames&&D.agentName&&D.subagentCallId?(0,r.jsx)(tu,{name:D.agentName,iconSrc:Z,compact:S}):null,(0,r.jsx)(td,{segment:D,forceAnimate:x&&R,className:(0,p.cn)(S?"text-sm leading-6":"text-[15px] leading-7",!F&&"text-foreground"),onOpenWorkspaceFile:"iframe-fullscreen"===h?w:void 0})]}),z?null:(0,r.jsx)(e6,{sources:o.sources,className:F?"px-1":void 0}),(0,r.jsxs)("div",{className:(0,p.cn)("flex items-center gap-0.5 text-muted-foreground opacity-0 transition-opacity [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/turn:opacity-100 [@media(hover:hover)]:group-focus-within/turn:opacity-100 [@media(hover:none)]:data-[message-actions-visible=true]:opacity-60",S?"mt-1 h-4 items-start":"mt-1 min-h-6",N&&"invisible"),"data-message-actions-visible":B?"true":"false",children:[(0,r.jsx)(b.i,{content:D.text,copyMessage:"Response copied",className:(0,p.cn)("rounded-md",S?"size-4 [&_svg]:size-3":"size-6 [&_svg]:size-3.5")}),y&&!z?(0,r.jsx)(f.$,{type:"button",variant:"ghost",size:"icon",className:"size-6 rounded-md text-muted-foreground","aria-label":"View detailed trace",title:"View detailed trace",onClick:()=>y(o.runId),children:(0,r.jsx)(i.A,{className:"size-3.5","aria-hidden":"true"})}):null,D.endedAt||o.finishedAt?(0,r.jsx)("time",{dateTime:new Date(null!=(t=D.endedAt)?t:o.finishedAt).toISOString(),className:(0,p.cn)("ml-0.5 px-1 font-medium tabular-nums",S?"text-[10px] leading-4":"text-[11px]"),children:(0,p.r6)(new Date(null!=(n=D.endedAt)?n:o.finishedAt).toISOString())}):null]})]}):null]})]})});var th=n(5558),tv=n(27346);let tb=e=>{let{suggestedMessages:t,onReplyClick:n,isLoading:a}=e,l=!a;return 0===t.length?null:(0,r.jsx)("div",{className:"shrink-0 p-3",children:(0,r.jsxs)(tv.F,{className:"w-full whitespace-nowrap [scrollbar-width:none]",children:[(0,r.jsx)("p",{className:"text-sm text-secondary-foreground font-normal mb-2",children:"Here are some suggestions, or ask me anything!"}),(0,r.jsx)("div",{className:"flex flex-col items-end gap-3",children:t.map((e,t)=>(0,r.jsx)(th.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:.15+.2*t},children:(0,r.jsx)(f.$,{variant:"outline",size:"lg",onClick:()=>n(e),disabled:!l,className:" px-4 py-2 w-fit text-sm bg-accent/20 p-3 text-secondary-foreground rounded-2xl rounded-br-none hover:bg-secondary/80 ",children:e},t)},t))}),(0,r.jsx)(tv.$,{orientation:"horizontal"})]})})},ty=e=>{let{primaryColor:t}=e;return(0,r.jsxs)("div",{className:"typing-indicator-content",children:[(0,r.jsx)("span",{style:{backgroundColor:t}}),(0,r.jsx)("span",{style:{backgroundColor:t}}),(0,r.jsx)("span",{style:{backgroundColor:t}})]})};var tj=n(76666);let tN=[],tw=(0,u.memo)(function(e){let{message:t,agentIcon:n,agentDisplayName:o,isCanvasWidget:d,isBrandAgent:c,layout:m,leadCapture:g,isStreaming:x,isRunActive:h,onOpenTrace:y,onRetry:j,hideMessageActions:N,onOpenWorkspaceFile:w}=e,[k,_]=(0,u.useState)(!1);if("system"===t.role){let e=void 0!==t.errorCode;return(0,r.jsxs)("div",{role:e?"alert":"status",className:(0,p.cn)("my-0.5 rounded-lg border px-2.5 py-2 text-sm leading-6",e?"border-destructive/30 bg-destructive/5 text-foreground
1/75":"border-border/65 bg-muted/35 text-muted-foreground"),children:[(0,r.jsxs)("div",{className:"flex min-h-9 items-start gap-2",children:[e?(0,r.jsx)(a.A,{className:"mt-1 size-3.5 shrink-0 text-destructive","aria-hidden":"true"}):(0,r.jsx)(l.A,{className:"mt-1 size-3.5 shrink-0 text-primary","aria-hidden":"true"}),(0,r.jsx)(v.YK,{className:"min-w-0 text-sm leading-6",children:t.content})]}),e&&j?(0,r.jsx)("div",{className:"mt-1.5 flex w-full justify-end",children:(0,r.jsxs)(f.$,{type:"button",variant:"ghost",size:"sm",onClick:j,"aria-label":"Retry",title:"Retry",className:"h-7 gap-1.5 rounded-md px-2 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[(0,r.jsx)(s.A,{className:"size-3.5","aria-hidden":"true"}),"Retry"]})}):null]})}let C="assistant"===t.role&&t.reasoning?[{type:"reasoning",reasoning:t.reasoning,isStreaming:!!t.isReasoningStreaming},...t.content?[{type:"text",text:t.content}]:[]]:t.parts,A=function(e){if(!e)return null;let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=t.toISOString();return{dateTime:n,label:(0,p.r6)(n)}}(t.timestamp),I=c&&"iframe-fullscreen"!==m,z=!N&&(t.content.trim()||y||A)?(0,r.jsxs)("div",{className:(0,p.cn)("flex gap-0.5","user"===t.role&&"flex-row-reverse",I?"h-4 items-start":"min-h-6 items-center"),children:[t.content.trim()?(0,r.jsx)(b.i,{content:t.content,copyMessage:"Message copied",className:(0,p.cn)("rounded-md",I?"size-4 [&_svg]:size-3":"size-6 [&_svg]:size-3.5")}):null,y?(0,r.jsx)(f.$,{type:"button",variant:"ghost",size:"icon",className:(0,p.cn)("rounded-md text-muted-foreground",I?"size-3":"size-6"),"aria-label":"View detailed trace",title:"View detailed trace",onClick:y,children:(0,r.jsx)(i.A,{className:I?"size-2":"size-3.5","aria-hidden":"true"})}):null,A?(0,r.jsx)("time",{dateTime:A.dateTime,className:(0,p.cn)("mx-0.5 px-1 font-medium tabular-nums text-muted-foreground",I?"text-[10px] leading-4":"text-[11px]"),children:A.label}):null]}):void 0;return(0,r.jsxs)("div",{className:(0,p.cn)("w-full max-w-full overflow-hidden",I&&"group/brand-message"),onClick:I?()=>_(e=>!e):void 0,children:[(0,r.jsx)(eD,{id:t.id,role:t.role,content:t.content,parts:C,timestamp:t.timestamp,showTimeStamp:!1,toolInvocations:t.toolInvocations,toolCallAccumulatedArgs:t.toolCallAccumulatedArgs,leadCapture:g,agentIcon:n,agentDisplayName:o,animation:"none",isCanvasWidget:d,agentName:t.agentName,layout:m,assets:t.assets,sender:t.sender,isStreaming:x,onOpenWorkspaceFile:w,actions:I?void 0:z,messageTextClassName:I?void 0:(t.role,"text-[15px] leading-7")}),x||h?null:(0,r.jsx)(e6,{sources:"assistant"===t.role?(0,eK.sF)(t.web_search_citations):tN,className:d?void 0:"pl-9"}),I&&z?(0,r.jsx)("div",{"data-brand-message-actions":!0,className:(0,p.cn)("mt-1 flex h-4 items-start text-muted-foreground opacity-0 transition-opacity [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/brand-message:opacity-100 [@media(hover:hover)]:group-focus-within/brand-message:opacity-100 [@media(hover:none)]:data-[message-actions-visible=true]:opacity-60","user"===t.role?"justify-end":"pl-9"),"data-message-actions-visible":k?"true":"false",onClick:e=>e.stopPropagation(),children:z}):null]})},(e,t)=>e.message===t.message&&e.agentIcon===t.agentIcon&&e.agentDisplayName===t.agentDisplayName&&e.isCanvasWidget===t.isCanvasWidget&&e.isBrandAgent===t.isBrandAgent&&e.layout===t.layout&&e.leadCapture===t.leadCapture&&e.isStreaming===t.isStreaming&&e.isRunActive===t.isRunActive&&e.hideMessageActions===t.hideMessageActions&&!!e.onOpenTrace==!!t.onOpenTrace&&!!e.onRetry==!!t.onRetry&&!!e.onOpenWorkspaceFile==!!t.onOpenWorkspaceFile);function tk(e){var t,n;let{messages:a,activityTurns:l=[],isLoading:s,agentIcon:i,agentDisplayName:c,hasMoreHistory:m=!1,isLoadingMoreHistory:v=!1,onLoadMoreHistory:b,isCanvasWidget:k=!1,isBrandAgent:_=!1,layout:C="default",showSuggestedReplies:A=!1,suggestedMessages:I=[],onSendUserMessage:z=()=>{},isStreaming:S=!1,isRunActive:T=!1,leadCapture:M=null,typingParticipants:R=[],toolVisuals:W,primaryAgentIcon:L,contentAfterMessages:O,inlineContent:D,hideMessageActions:E=!1,onOpenWorkspaceFile:F}=e,[B,U]=(0,u.useState)(null),[q,$]=(0,u.useState)(()=>new Set),H=_&&"iframe-fullscreen"!==C,P=(0,u.useMemo)(()=>(function(e){var t,n,r,a,l,s;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=new Set(i.map(e=>e.runId)),u=new Map,c=null!=(t=o.shouldProjectTool)?t:()=>!0;for(let t of e){if("assistant"!==t.role)continue;let e=null==(n=t.run_id)?void 0:n.trim();!e||d.has(e)||(u.has(e)||u.set(e,[]),null==(r=u.get(e))||r.push(t))}let m=[];for(let[t,n]of u){let r,i;if(0===n.flatMap(e=>{var t;return(null!=(t=e.toolInvocations)?t:[]).filter(e=>c(e.toolName)).map(t=>({message:e,invocation:t}))}).length)continue;let o=[],d={},u={},p=0,f=e=>{void 0===e||Number.isNaN(e)||(r=void 0===r?e:Math.min(r,e),i=void 0===i?e:Math.max(i,e))};for(let e of n){f(e.timestamp);let t=(null!=(a=e.toolInvocations)?a:[]).filter(e=>c(e.toolName));for(let n=0;n<t.length;n+=1){let r=t[n];if(!r)continue;let a=1===t.length?e.id:"".concat(e.id,":").concat(n),l=function(e,t,n){var r,a,l;let s="result"===t.state,i=s?t.result:void 0;return{id:n,name:t.toolName,status:s&&(null==i?void 0:i.__cancelled)?"error":s?"success":"running",arguments:function(e){if(e)try{return JSON.parse(e)}catch(t){return e}}(e.toolCallAccumulatedArgs),argumentBuffer:null!=(r=e.toolCallAccumulatedArgs)?r:"",result:i,parentCallId:null,subagentCallId:null!=(a=e.subagent_call_id)?a:null,agentName:e.agentName,namespace:null!=(l=e.namespace)?l:[],startedAt:e.timestamp,endedAt:s?e.timestamp:void 0,sources:[]}}(e,r,a);u[a]=l,o.push({key:"tool:".concat(a),kind:"tool",refId:a,ordinal:p}),p+=1}let n=e.content.trim();if(!n||e.id.startsWith("tool_")&&/^(?:🔧|✅)\s/.test(e.content.trim())||e.hitlRequest&&n===e_.Em)continue;let r={id:e.id,kind:"text",text:e.content,streaming:!1,presentation:"progress",agentName:e.agentName,namespace:null!=(l=e.namespace)?l:[],subagentCallId:null!=(s=e.subagent_call_id)?s:null,
1startedAt:e.timestamp,endedAt:e.timestamp};d[r.id]=r,o.push({key:"text:".concat(r.id),kind:"text",refId:r.id,ordinal:p}),p+=1}let g=o.filter(e=>"text"===e.kind).at(-1);if(g){let e=d[g.refId];e&&(e.presentation="final")}let x=(0,e_.yt)(e),h=(0,e_.Ir)(x)?x:null,v=!!(h&&n.some(e=>{var t;return(null==(t=e.hitlRequest)?void 0:t.request_id)===h.request_id}));for(let e of Object.values(u))"running"===e.status&&(e.status=v?"paused":(0,e_._2)(e.name)&&n.some(e=>{var t;return(null==(t=e.hitlRequest)?void 0:t.status)==="resolved"})?"success":"interrupted");m.push({id:"turn_".concat(t),runId:t,status:v?"paused":"finished",timeline:o,segmentsById:d,toolsById:u,sources:n.reduce((e,t)=>(0,eK.Tk)(e,(0,eK.sF)(t.web_search_citations)),[]),tasks:[],hitlById:{},finalMessageId:null==g?void 0:g.refId,startedAt:r,finishedAt:i})}return m})(a,l,{shouldProjectTool:e=>!(0,N.lc)(e)&&!(0,w.Uy)(e)&&!eh.has(e)&&!/^aws[_-]?dynamodb[_-]?scan/i.test(e)}),[l,a]),J=(0,u.useMemo)(()=>[...l,...P],[l,P]),V=(0,u.useMemo)(()=>new Map(J.map(e=>[e.runId,e])),[J]),K=(0,u.useMemo)(()=>{let e=new Map;for(let r of a){var t,n;
1"assistant"===r.role&&r.run_id&&(null==(t=r.assets)?void 0:t.length)&&V.has(r.run_id)&&e.set(r.run_id,[...null!=(n=e.get(r.run_id))?n:[],...r.assets])}return e},[a,V]),Q=(0,u.useMemo)(()=>{if(!D)return null;let e=a.find(e=>e.id===D.messageId);if(!e)return null;let t=e.run_id?V.get(e.run_id):void 0;return t&&"assistant"===e.role?"turn:".concat(t.id):"message:".concat(e.id)},[D,a,V]),X=(e,t)=>{if(!D||Q!==e)return t;let n=e.startsWith("message:")&&"before"===D.position;return(0,r.jsxs)(u.Fragment,{children:[n?D.content:null,t,n?null:D.content]},e)},Y=(0,u.useMemo)(()=>(function(e,t){let n=new Map(t.map(e=>[e.runId,e])),r=new Set,a=[];for(let t of e){let e=t.afterTurnRunId?n.get(t.afterTurnRunId):void 0;e&&!r.has(e.runId)&&(r.add(e.runId),a.push({kind:"turn",key:"turn:".concat(e.id),turn:e}));let l=t.run_id?n.get(t.run_id):void 0;if(!l){a.push({kind:"message",key:"message:".concat(t.id),message:t});continue}"assistant"!==t.role||r.has(l.runId)||(r.add(l.runId),a.push({kind:"turn",key:"turn:".concat(l.id),turn:l})),("assistant"!==t.role||t.keepWithTurn)&&a.push({kind:"message",key:"message:".concat(t.id),message:t}),"user"!==t.role||r.has(l.runId)||(r.add(l.runId),a.push({kind:"turn",key:"turn:".concat(l.id),turn:l}))}for(let e of t)r.has(e.runId)||a.push({kind:"turn",key:"turn:".concat(e.id),turn:e});return a})(a.filter(e=>{var t;return!(e.id.startsWith("tool_")&&!(null==(t=e.toolInvocations)?void 0:t.length))}).map(e=>{var t;return(null==(t=e.toolInvocations)?void 0:t.some(e=>(0,N.lc)(e.toolName)||(0,w.Uy)(e.toolName)||eh.has(e.toolName)))?{...e,keepWithTurn:!0}:e}),J),[J,a]),G=J.some(e=>"running"===e.status||"paused"===e.status),Z=s&&!G,ee=(0,u.useMemo)(()=>(function(e){let t=[];for(let n of e){let e="message"===n.kind&&"user"===n.message.role&&!n.message.afterTurnRunId,r=t.at(-1);if(e||!r){t.push({key:n.key,items:[n]});continue}r.items.push(n)}return t})(Y),[Y]),et=(0,u.useMemo)(()=>{for(let e=a.length-1;e>=0;e-=1){let t=a[e];if((null==t?void 0:t.role)==="user"&&!t.afterTurnRunId)return t.id}return null},[a]),en="working:".concat(null!=et?et:"pending"),er=(0,u.useMemo)(()=>({id:"turn_".concat(en),runId:en,status:"running",timeline:[],segmentsById:{},toolsById:{},sources:[],tasks:[],hitlById:{}}),[en]),ea=null!=(n=null==(t=J.findLast(e=>"running"===e.status))?void 0:t.runId)?n:null,[el,es]=(0,u.useState)(!1),ei=(0,u.useRef)(void 0);(0,u.useLayoutEffect)(()=>{let e=void 0===ei.current;if(ei.current===et||(ei.current=et,e||!et))return;es(!0);let t=setTimeout(()=>es(!1),700);return()=>clearTimeout(t)},[et]);let eo=el&&!G,ed="iframe-fullscreen"===C?"gap-1":H?"gap-0.5":"gap-1",eu=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return X(t,(0,r.jsx)(tx,{turn:e,agentIcon:i,agentDisplayName:c,isCanvasWidget:k,isBrandAgent:_,layout:C,toolVisuals:W,primaryAgentIcon:L,assets:K.get(e.runId),hideMessageActions:E,onOpenTrace:k&&"iframe-fullscreen"===C?U:void 0,onOpenWorkspaceFile:"iframe-fullscreen"===C?F:void 0},n))},ec=e=>{var t;if("turn"===e.kind)return eu(e.turn,e.key);let n=e.message;if(q.has(n.id))return null;let a="assistant"===n.role&&void 0!==n.run_id&&n.run_id===ea,l="system"===n.role&&void 0!==n.errorCode,s=!!(!(n.run_id&&V.has(n.run_id))&&k&&"iframe-fullscreen"===C&&"assistant"===n.role&&n.run_id&&!n.isIntermediate&&!(null==(t=n.toolInvocations)?void 0:t.length));return X(e.key,(0,r.jsx)(tw,{message:n,agentIcon:i,agentDisplayName:c,isCanvasWidget:k,isBrandAgent:_,layout:C,leadCapture:M,isStreaming:S&&a,isRunActive:T&&a,hideMessageActions:E,onOpenTrace:s&&n.run_id?()=>U(n.run_id):void 0,onRetry:l?()=>{$(e=>new Set(e).add(n.id)),z("Continue")}:void 0,onOpenWorkspaceFile:"iframe-fullscreen"===C?F:void 0},e.key))},em=Z?(0,r.jsx)("div",{"data-stream-handoff-slot":!0,className:H?"min-h-7":"min-h-9",children:eu(er,en)},en):null,ep=(0,r.jsxs)(r.Fragment,{children:[O,em,R.map(e=>(0,r.jsxs)("div",{className:"my-1 ml-auto flex max-w-[85%] items-end justify-end gap-2","data-testid":"collaborator-typing","aria-label":"".concat((0,tj.yg)(e)," is typing"),children:[(0,r.jsx)("div",{className:"flex h-8 items-center px-1 text-muted-foreground",children:(0,r.jsx)(ty,{primaryColor:"currentColor"})}),(0,r.jsxs)("div",{className:"flex w-12 shrink-0 flex-col items-center gap-1 text-center text-[10px] font-medium leading-none text-muted-foreground",children:[(0,r.jsx)(j.eu,{className:"size-7",children:(0,r.jsx)(j.q5,{className:"bg-primary/10 text-[10px] font-semibold text-primary",children:(0,tj.zC)(e)})}),(0,r.jsx)("span",{className:"max-w-12 truncate",children:(0,tj.yg)(e)})]})]},e.user_id)),A?(0,r.jsx)("div",{"data-brand-suggested-replies":H?"true":void 0,className:(0,p.cn)(H&&"-mt-[18px] ml-auto flex flex-col space-y-2"),children:(0,r.jsx)(tb,{suggestedMessages:I,onReplyClick:z,isLoading:s||S})}):null]});return(0,r.jsxs)(g,{className:"grow",initial:eo?"smooth":"instant",resize:eo?"smooth":"instant","aria-label":"Chat messages","aria-busy":S||s,style:{scrollbarWidth:"thin"},children:[(0,r.jsxs)(x,{className:(0,p.cn)("mx-auto flex w-full flex-col overflow-hidden","iframe-fullscreen"===C?"mt-6 max-w-[800px] gap-1 px-4 pb-4 pt-10 sm:px-3 sm:pb-3":H?"max-w-full gap-0.5 px-2 py-4":"max-w-full gap-1 px-3 py-3"),children:[m?(0,r.jsx)("div",{className:"mb-3 flex justify-center",children:(0,r.jsxs)(f.$,{variant:"ghost",size:"sm",onClick:b,disabled:v||!b,className:"min-h-9 gap-2 rounded-full px-3 text-xs text-muted-foreground",children:[v?(0,r.jsx)(o.A,{className:"size-3.5 animate-spin motion-reduce:animate-none"}):(0,r.jsx)(d.A,{className:"size-3.5"}),v?"Loading messages":"Earlier messages"]})}):null,ee.map((e,t)=>{let n=t===ee.length-1;return(0,r.jsxs)("div",{className:(0,p.cn)("flex min-w-0 flex-col",ed,n&&eo&&1===ee.length&&"animate-in fade-in slide-in-from-bottom-4 duration-500 motion-reduce:animate-none"),style:n?{minHeight:"var(--conversation-anchor-height, 0px)"}:void 0,children:[e.items.map(ec),n?ep:null]},e.key)}),0===ee.length?ep:null]}),(0,r.jsx)(h,{className:"bottom-4 size-8 shadow-sm"}),(0,r.jsx)(y.y,{isOpen:!!B,onClose:()=>U(null),runId:null!=B?B:"",traces:[],onNavigateToTrace:()=>{}})]})}let t_=e=>(0,r.jsx)(tk,{...e})},76666:(e,t,n)=>{n.d(t,{X$:()=>i,yg:()=>l,zC:()=>s});var r=n(22342),a=n(33884);function l(e){var t,n,r;return(null==(t=e.first_name)?void 0:t.trim())||(null==(n=e.name)?void 0:n.trim().split(/\s+/)[0])||(null==(r=e.email)?void 0:r.split("@")[0])||"Teammate"}function s(e){var t,n;return((null==(t=e.name)?void 0:t.trim())||(null==(n=e.email)?void 0:n.split("@")[0])||l(e)).split(/\s+/).filter(
1Boolean).slice(0,2).map(e=>{var t;return null==(t=e[0])?void 0:t.toUpperCase()}).join("")||"TM"}function i(e){let{participants:t}=e;if(0===t.length)return null;let n=1===t.length?"".concat(l(t[0])," is viewing this agent"):"".concat(t.length," teammates are viewing this agent");return(0,r.jsxs)("div",{className:"flex max-w-56 items-center gap-2 rounded-full border border-border/70 bg-background/90 py-1 pl-1 pr-3 text-[11px] font-medium text-muted-foreground shadow-sm backdrop-blur","data-testid":"collaboration-presence","aria-label":n,title:t.map(l).join(", "),children:[(0,r.jsx)("div",{className:"flex -space-x-1.5",children:t.slice(0,3).map(e=>(0,r.jsx)(a.eu,{className:"h-6 w-6 border border-background",children:(0,r.jsx)(a.q5,{className:"bg-primary/10 text-[8px] font-semibold text-primary",children:s(e)})},e.user_id))}),(0,r.jsx)("span",{className:"truncate",children:n})]})}},80239:(e,t,n)=>{n.d(t,{_:()=>d,m:()=>o});var r=n(22342),a=n(33670),l=n(73439),s=n(38565);let i=(0,a.createContext)((0,l.pI)(s.sw.chatDisplay));function o(e){let{chatDisplay:t,children:n}=e,o=(0,a.useMemo)(()=>(0,l.pI)(s.sw.chatDisplay,t),[t]);return(0,r.jsx)(i.Provider,{value:o,children:n})}function d(){return(0,a.useContext)(i)}},83862:(e,t,n)=>{n.d(t,{CQ:()=>x,CY:()=>w,D4:()=>c,Dr:()=>v,Em:()=>o,GM:()=>C,Ir:()=>h,Kq:()=>k,LD:()=>A,Sk:()=>_,_2:()=>d,cM:()=>f,eK:()=>N,g8:()=>g,jR:()=>p,k1:()=>m,ky:()=>s,rV:()=>l,yt:()=>b});var r=n(98731),a=n(93133);let l="deep_agents_hitl",s="request_human_input",i="sketric_other",o="Agent needs your input.";function d(e){return e===s||(0,r.Uy)(e)||(0,a.lc)(e)}let u="schedule_recurring_job";function c(){return JSON.stringify({status:"skipped",answers:[]})}function m(e,t,n){let r=!0===e.multiSelect?t.includes(n)?t.filter(e=>e!==n):[...t,n]:[n];return e.options.filter(e=>r.includes(e.id)).map(e=>e.id)}function p(e){var t,n;let r=null!=(n=null==e?void 0:e.optionIds)?n:[];return 0!==r.length&&(!r.includes(i)||!!(null==e||null==(t=e.text)?void 0:t.trim()))}function f(e,t){var n,r,a,l;let s=null!=(a=null==t?void 0:t.optionIds)?a:[],o=e.options.filter(e=>s.includes(e.id)),d=o.some(e=>e.id===i)?null==t||null==(n=t.text)?void 0:n.trim():"",u={question_id:e.id,question:e.prompt};return!0===e.multiSelect?{...u,option_ids:o.map(e=>e.id),option_labels:o.map(e=>e.label),...d?{text:d}:{}}:{...u,option_id:null!=(l=null==(r=o[0])?void 0:r.id)?l:"",...o[0]?{option_label:o[0].label}:{},...d?{text:d}:{}}}function g(e,t){let n=new Map(t.map(e=>[e.question_id,e])),r=e.questions.flatMap(e=>{let t=n.get(e.id);if(!t)return[];let r=function(e,t){var n,r;let a=(null!=(r=t.option_ids)?r:t.option_id?[t.option_id]:[]).filter(e=>e!==i).map(t=>{var n,r;return(null==(r=e.options.find(e=>e.id===t))||null==(n=r.label)?void 0:n.trim())||t}),l=null==(n=t.text)?void 0:n.trim();return l&&a.push(l),a.filter(Boolean).join(", ")}(e,t),a=e.prompt.replace(/[?:]\s*$/,"");return r?["".concat(a,": ").concat(r)]:[]});return r.length>0?"Human input provided\n\n".concat(r.join("\n")):"Human input provided"}function x(e){let[t,n,...r]=e.replace(/\r\n/g,"\n").split("\n");if("Human input provided"!==t||""!==n)return null;let a=[];for(let e of r){let t=e.trim();if(!t)continue;let n=t.indexOf(": ");if(n>0)a.push({question:t.slice(0,n).trim(),answer:t.slice(n+2).trim()});else if(a.length>0){let e=a.at(-1);e.answer="".concat(e.answer,"\n").concat(t)}}return a.length>0&&a.every(e=>e.question&&e.answer)?a:null}function h(e){return(null==e?void 0:e.status)==="pending"}function v(e){return!!(null==e?void 0:e.request_id)&&((null==e?void 0:e.status)===void 0||"pending"===e.status)}function b(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=null==n?void 0:n.hitlRequest;if(null==r?void 0:r.request_id)return r;if((null==n?void 0:n.role)==="assistant")break}return null}function y(e){var t,n,r;let a=null!=(r=null!=(n=null!=(t=e.tool_name)?t:e.toolName)?n:e.name)?r:"";return"string"==typeof a?a:""}function j(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function N(e){var t;let n=null==e||null==(t=e.action_requests)?void 0:t.find(e=>y(e)===s);return function(e){if(!j(e)||!Array.isArray(e.questions)||e.questions.length<1||e.questions.length>10)return null;let t=[],n=new Set;for(let r of e.questions){if(!j(r)||!Array.isArray(r.options))return null;
1let e="string"==typeof r.id?r.id.trim():"",a="string"==typeof r.prompt?r.prompt.trim():"";if(!e||!a||n.has(e)||r.options.length<2||r.options.length>5)return null;n.add(e);let l=[],s=new Set;for(let e of r.options){if(!j(e))return null;let t="string"==typeof e.id?e.id.trim():"",n="string"==typeof e.label?e.label.trim():"",r=e.kind;if(!t||!n||s.has(t)||"choice"!==r&&"free_text"!==r||"boolean"!=typeof e.recommended)return null;s.add(t),l.push({id:t,label:n,..."string"==typeof e.description&&e.description.trim()?{description:e.description.trim()}:{},recommended:!0===e.recommended,kind:r})}let o=l.filter(e=>"free_text"===e.kind),d=l.at(-1);if(1!==o.length||d!==o[0]||(null==d?void 0:d.id)!==i||"Something else"!==d.label||d.recommended||l.filter(e=>e.recommended).length>1)return null;t.push({id:e,prompt:a,options:l,...!0===r.multi_select?{multiSelect:!0}:{}})}return{questions:t}}(null==n?void 0:n.args)}function w(e,t,n){if(!(null==e?void 0:e.length))return[{type:"respond",message:t}];let a=n?e.findIndex(e=>y(e)===n):-1,l=e.findIndex(e=>(0,r.Uy)(y(e))),s=a>=0?a:l>=0?l:0;return e.map((e,n)=>({type:"respond",message:n===s?t:""}))}function k(e){let t=null==e?void 0:e.action_requests;if(!(null==t?void 0:t.length))return;let n=t.find(e=>(0,r.Uy)(y(e))),a=null==n?void 0:n.description;return"string"==typeof a&&a.trim()?a.trim():void 0}function _(e){var t,n;let r=null==e||null==(t=e.action_requests)?void 0:t.find(e=>y(e)===u);if(!r)return null;let a=null!=(n=r.args)?n:{},l=e=>"string"==typeof e?e.trim():"",s=Number(a.duration_minutes);return{cron:l(a.cron),timezone:l(a.timezone)||"UTC",note:l(a.note),durationMinutes:Number.isFinite(s)&&s>0?s:null,until:l(a.until)}}function C(e,t){let n={type:t?"approve":"reject"};if(!(null==e?void 0:e.length))return[n];let r=e.findIndex(e=>y(e)===u),a=r>=0?r:0;return e.map((e,t)=>t===a?n:{type:"reject"})}function A(e){var t;return!!(null==e||null==(t=e.action_requests)?void 0:t.some(e=>(0,a.lc)(y(e))))}},84916:(e,t,n)=>{n.d(t,{S:()=>o});var r=n(22342),a=n(33670),l=n(38162),s=n(72251),i=n(25016);let o=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(l.bL,{ref:t,className:(0,i.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background 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",n),...a,children:(0,r.jsx)(l.C1,{className:(0,i.cn)("flex items-center justify-center text-current"),children:(0,r.jsx)(s.A,{className:"h-4 w-4"})})})});o.displayName=l.bL.displayName},96442:(e,t,n)=>{function r(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function a(e){let t={};for(let a of e){var n;if("toolNode"!==a.type||!a.data)continue;let e=a.data,l=(n=e.config)&&"object"==typeof n&&!Array.isArray(n)?n:{},s=String(e.app_icon||l.app_icon||"").trim();if(!s)continue;let i=function(e){let t="string"==typeof e?e.trim():"";return t?t.replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()):"App"}(e.app_name||l.app_name||e.app_slug||l.app_slug);for(let n of[e.name,e.title,e.app_name,l.app_name,e.app_slug,l.app_slug,e.mcpAppSlug,...Array.isArray(e.allowed_tools)?e.allowed_tools:[],...Array.isArray(l.allowed_tools)?l.allowed_tools:[]]){if("string"!=typeof n)continue;let e=r(n);e&&(t[e]={appIcon:s,appLabel:i})}}return t}function l(e,t){if(!t)return;let n=r(e);if(!n)return;if(t[n])return t[n];let a=n.split("_");for(let e=a.length-1;e>0;e-=1){let n=t[a.slice(0,e).join("_")];if(n)return n}for(let e=1;e<a.length;e+=1){let n=t[a.slice(e).join("_")];if(n)return n}}n.d(t,{do:()=>a,nf:()=>l,x6:()=>r})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.