1import{j as l,a as r,f,u as g,b as p,c as b,i as y,F as x,d as v,e as w,B as d,g as N,h as C,k}from"./index-BFa3nKuT.js";import{a as c}from"./datepicker-CN3oO0F6.js";import"./visx-o561FtCw.js";import"./framerMotion-KnKeNhwd.js";import"./charts-BEfaN6Tb.js";import"./apollo-B9xYJgZj.js";import"./shiki-DSW_v8w1.js";import"./betterAuth-wecmey9t.js";import"./tanstack-82Oensom.js";import"./virtuoso-_8EeKo1c.js";import"./sentry-BM1d0HPc.js";import"./forms-BE_8TKCw.js";import"./amplitude-rTYtQKJT.js";import"./amplify-FijOe782.js";import"./qrcode-CMNUHY9J.js";import"./dnd-BjCurfON.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"01e610d75577dcaf5e5c9af84e79c9458f58a767"},e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=(function(t){for(var a=1;a<arguments.length;a++){var n=arguments[a];if(n!=null)for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])}return t})({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:currents-dashboard":!0});var s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="3620ea74-0681-4878-9cc3-324ebda11b7b",e._sentryDebugIdIdentifier="sentry-dbid-3620ea74-0681-4878-9cc3-324ebda11b7b")}catch{}})();function S({onSend:e,disabled:s}){const[t,a]=c.useState(""),n=c.useRef(null),i=c.useCallback(()=>{const o=t.trim();!o||s||(e(o),a(""),n.current&&(n.current.style.height="auto"))},[t,s,e]),h=c.useCallback(o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),i())},[i]);return l("div",{className:"flex shrink-0 items-end gap-2 border-t border-theme-border bg-theme-background p-ui-v2-3",children:[r("textarea",{ref:n,value:t,onChange:o=>{a(o.target.value),o.target.style.height="auto",o.target.style.height=`${Math.min(o.target.scrollHeight,120)}px`},onKeyDown:h,placeholder:"Type a message...",disabled:s,rows:1,className:"flex-1 resize-none rounded-md border border-theme-border bg-theme-accent-1 px-ui-v2-3 py-2 text-sm text-theme-foreground outline-none placeholder:text-theme-placeholder focus-visible:ring-2 focus-visible:ring-theme-outline/50 disabled:opacity-50"}),r("button",{onClick:i,disabled:s||!t.trim(),className:"rounded-md bg-theme-success px-ui-v2-3 py-2 text-sm font-medium text-white hover:opacity-90 disabled:opacity-50",children:"Send"})]})}function A(e){return"text"in e&&typeof e.text=="string"}function T(e){if(A(e))return e.text;try{return JSON.stringify(e)}catch{return"[structured content]"}}function u(e){return(e.parts??[]).map(T).join("")}const _=/\{"type":"step-(?:start|finish|end)"\}\s*/g;function $(e){return e.replace(_,"")}function I(e){return e.replace(/^\[User context:[^\]]*\]\s*/i,"")}function R(){const e="size-1.5 rounded-full bg-theme-secondary";return l("span",{className:"relative grid min-h-5 min-w-[3.25rem] place-items-center",role:"status","aria-live":"polite","aria-label":"Assistant is responding",children:[r("span",{className:"pointer-events-none absolute top-1/2 left-1/2 h-2 w-14 -translate-x-1/2 -translate-y-1/2 rounded-full bg-theme-secondary/25 motion-safe:animate-pulse motion-reduce:animate-none"}),l("span",{className:"relative z-10 grid grid-flow-col gap-1 auto-cols-max items-center",children:[r("span",{className:`${e} animate-assistant-typing-dot`}),r("span",{className:`${e} animate-assistant-typing-dot-delay-1`}),r("span",{className:`${e} animate-assistant-typing-dot-delay-2`})]})]})}function E({messages:e}){const s=c.useRef(null);return c.useEffect(()=>{var t;(t=s.current)==null||t.scrollIntoView({behavior:"smooth"})},[e]),e.length===0?r("div",{className:"flex flex-1 items-center justify-center bg-theme-background p-ui-v2-4 text-sm text-theme-secondary",children:"Start a conversation"}):l("div",{className:"flex flex-1 flex-col gap-ui-v2-3 overflow-y-auto bg-theme-background p-ui-v2-3",children:[e.map(t=>{const a=t.role==="user",n=a?I(u(t)):$(u(t)),i=!a&&n.trim()==="";return r("div",{className:`flex ${a?"justify-end":"justify-start"}`,children:r("div",{className:`max-w-[85%] rounded-lg px-ui-v2-3 py-2 text-sm whitespace-pre-wrap ${a?"bg-theme-success text-white":"bg-theme-accent-2 text-theme-foreground"}`,children:i?r(R,{}):n})},t.id)}),r("div",{ref:s})]})}
1function M({threads:e,activeThreadId:s,onSelect:t}){return e.length===0?r("div",{className:"flex flex-1 items-center justify-center bg-theme-background p-ui-v2-4 text-sm text-theme-secondary",children:"No conversations yet"}):r("div",{className:"flex flex-1 flex-col overflow-y-auto bg-theme-background",children:e.map(a=>l("button",{onClick:()=>t(a.id),className:`flex flex-col gap-1 border-b border-theme-border px-ui-v2-4 py-ui-v2-3 text-left text-sm text-theme-foreground transition-colors hover:bg-theme-hover ${a.id===s?"bg-theme-accent-1":""}`,children:[r("span",{className:"truncate font-medium",children:a.title||"Untitled"}),r("span",{className:"text-xs text-theme-secondary",children:f(a.updatedAt)})]},a.id))})}const m="fixed bottom-24 right-6 z-[2147483002]",O="border-2 border-theme-border bg-theme-foreground text-theme-background shadow-lg hover:opacity-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-theme-success focus-visible:ring-offset-2 focus-visible:ring-offset-theme-background";function Q(){const e=g(),s=p(),t=b(),{widgetView:a,setWidgetView:n}=t;return!(e!=null&&e.isAssistantEnabled())||!y(s,k.failureAnalysis)?null:t.isOpen?l("div",{className:`${m} grid h-[520px] w-[380px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-xl border border-theme-border bg-theme-background text-theme-foreground shadow-2xl`,children:[l("div",{className:"grid grid-cols-[1fr_auto] border-b border-theme-border bg-theme-accent-1 px-ui-v2-4 py-ui-v2-3",children:[r("span",{className:"self-center text-sm font-semibold text-theme-foreground",children:"Currents Assistant"}),l("div",{className:"grid auto-cols-max grid-flow-col gap-2 self-center",children:[r(d,{type:"secondary",onClick:()=>{a==="chat"?(t.refreshThreads(),n("history")):n("chat")},title:a==="chat"?"History":"Chat","aria-label":a==="chat"?"History":"Chat",icon:a==="chat"?r(v,{"aria-hidden":!0}):r(w,{"aria-hidden":!0})}),r(d,{type:"secondary",onClick:()=>t.startNewConversation(),title:"New conversation","aria-label":"New conversation",icon:r(N,{"aria-hidden":!0})}),r(d,{type:"secondary",onClick:()=>t.setIsOpen(!1),title:"Close","aria-label":"Close",icon:r(C,{"aria-hidden":!0})})]})]}),a==="chat"?l("div",{className:"grid min-h-0 grid-rows-[minmax(0,1fr)_auto] bg-theme-background",children:[r("div",{className:"min-h-0 h-full [&>*]:min-h-0 [&>*]:h-full",children:r(E,{messages:t.messages})}
1),r(S,{onSend:t.sendMessage,disabled:!t.canSend})]}):r("div",{className:"grid min-h-0 grid-rows-[minmax(0,1fr)] bg-theme-background",children:r("div",{className:"min-h-0 h-full [&>*]:min-h-0 [&>*]:h-full",children:r(M,{threads:t.threads,activeThreadId:t.activeThreadId,onSelect:i=>{t.switchThread(i),n("chat")}})})})]}):r("button",{onClick:()=>t.setIsOpen(!0),className:`${m} ${O} grid h-12 w-12 place-items-center rounded-full transition-transform hover:scale-105`,"aria-label":"Open assistant",children:r(x,{className:"h-5 w-5","aria-hidden":!0})})}export{Q as AiChatWidget}; 2//# sourceMappingURL=aiChatWidget-DodPVYcN.js.map
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.