super-agent-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1124 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),he=require("react-dom"),e=require("react/jsx-runtime");var _,A=he;if(process.env.NODE_ENV==="production")_=A.createRoot,A.hydrateRoot;else{var U=A.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;_=function(a,s){U.usingClientEntryPoint=!0;try{return A.createRoot(a,s)}finally{U.usingClientEntryPoint=!1}}}function Y(a){const{sdk:s,sessionId:l,onSessionCreated:r,onStreamStart:t,onStreamEnd:i,onError:d,onMessageSend:n}=a,[o,x]=c.useState([]),[f,m]=c.useState("ready"),[v,g]=c.useState(null),p=c.useRef(null),h=c.useRef(!1),b=c.useRef(l);b.current=l;const u=c.useCallback(j=>{if(h.current)return;h.current=!0,n==null||n(j);const L={id:`user_${Date.now()}`,role:"user",parts:[{type:"text",content:j}],timestamp:Date.now()},z=`assistant_${Date.now()}`,xe={id:z,role:"assistant",parts:[],timestamp:Date.now()};x(N=>[...N,L,xe]),m("submitted"),g(null);const F=N=>{let $="",I="",M=[],q=!1;const O=()=>{const w=[...M];if($){const E=w.findIndex(R=>R.type==="thinking");E>=0?w[E]={type:"thinking",content:$}:w.unshift({type:"thinking",content:$})}if(I){const E=w.findLastIndex(R=>R.type==="text");E>=0?w[E]={type:"text",content:I}:w.push({type:"text",content:I})}x(E=>E.map(R=>R.id===z?{...R,parts:w}:R))};p.current=s.chat({sessionId:N,message:j,stream:!0,onMessage:w=>{switch(q||(q=!0,m("streaming")),w.type){case"thinking":$+=w.content;break;case"ai":I+=w.content;break;case"tool_call":M.push({type:"tool_call",toolName:w.toolName,toolCallId:w.toolCallId,args:w.args??"{}"});break;case"tool_result":M.push({type:"tool_result",toolName:w.toolName??"",toolCallId:w.toolCallId,content:w.content}),I&&(M.push({type:"text",content:I}),I="");break}O()},onDone:w=>{(I||M.length>0||$)&&O(),w.sessionId&&w.sessionId!==b.current&&(r==null||r(w.sessionId)),i==null||i(w.sessionId||N),m("ready"),h.current=!1,p.current=null},onError:w=>{M.push({type:"error",content:w.message}),O(),g(w),m("error"),d==null||d(w),h.current=!1,p.current=null}}),t==null||t(N)};b.current?F(b.current):s.createSession().then(N=>{b.current=N,r==null||r(N),F(N)}).catch(N=>{g(N instanceof Error?N:new Error(String(N))),m("error"),d==null||d(N instanceof Error?N:new Error(String(N))),h.current=!1})},[s,r,t,i,d,n]),y=c.useCallback(()=>{var j;(j=p.current)==null||j.abort(),p.current=null,m("ready"),h.current=!1},[]),C=c.useCallback(()=>{if(h.current)return;const j=o.findLastIndex(z=>z.role==="user");if(j<0)return;const L=o[j].parts.filter(z=>z.type==="text").map(z=>z.content).join("");x(z=>z.slice(0,j)),u(L)},[o,u]);return{messages:o,status:f,error:v,sendMessage:u,stop:y,regenerate:C,setMessages:x}}const D="sa_active_conversation";function K(){try{return localStorage.getItem(D)}catch{return null}}function me(a){try{a?localStorage.setItem(D,a):localStorage.removeItem(D)}catch{}}function J(a){const{sdk:s,onConversationChange:l}=a,[r,t]=c.useState([]),[i,d]=c.useState(()=>K()),[n,o]=c.useState(!1),x=c.useRef(!0);c.useEffect(()=>()=>{x.current=!1},[]);const f=c.useCallback(u=>{d(u),me(u),u&&(l==null||l(u))},[l]),m=c.useCallback(async()=>{o(!0);try{const u=await s.listConversations({page:1,size:100});if(!x.current)return;t(u.items);const y=K();y&&!u.items.find(C=>C.sessionId===y)&&f(null)}catch{}finally{x.current&&o(!1)}},[s,f]),v=c.useCallback(async u=>(f(u),await s.getMessages(u)),[s,f]),g=c.useCallback(()=>{f(null)},[f]),p=c.useCallback(async u=>{await s.deleteConversation(u),t(y=>y.filter(C=>C.sessionId!==u)),i===u&&f(null)},[s,i,f]),h=c.useCallback(async(u,y)=>{await s.renameConversation(u,y),t(C=>C.map(j=>j.sessionId===u?{...j,title:y}:j))},[s]),{enabled:b=!0}=a;return c.useEffect(()=>{b&&m()},[b,m]),{conversations:r,activeConversationId:i,loading:n,loadConversations:m,switchConversation:v,newConversation:g,deleteConversation:p,renameConversation:h,setActiveConversationId:f}}const X=c.createContext(null);function T(){const a=c.useContext(X);if(!a)throw new Error("useChatContext must be used within ChatProvider");return a}function H({sdk:a,hooks:s,children:l}){const[r,t]=c.useState(!1),[i,d]=c.useState(!1);c.useEffect(()=>{a.getToken().then(()=>{d(!0)}).catch(()=>{d(!0)})},[a]);const n=J({sdk:a,onConversationChange:s==null?void 0:s.onConversationChange,enabled:i}),o=Y({sdk:a,sessionId:n.activeConversationId,onSessionCreated:p=>{n.setActiveConversationId(p),n.loadConversations()},onStreamStart:s==null?void 0:s.onStreamStart,onStreamEnd:p=>{var h;(h=s==null?void 0:s.onStreamEnd)==null||h.call(s,p),n.loadConversations()},onError:s==null?void 0:s.onError,onMessageSend:s==null?void 0:s.onMessageSend}),x=c.useCallback(async p=>{const h=await n.switchConversation(p);o.setMessages(h),t(!1)},[n,o]),f=c.useCallback(()=>{n.newConversation(),o.setMessages([]),t(!1)},[n,o]),m=c.useCallback(async p=>{await n.deleteConversation(p),n.activeConversationId===p&&o.setMessages([])},[n,o]);c.useEffect(()=>{n.activeConversationId&&o.messages.length===0&&a.getMessages(n.activeConversationId).then(p=>{o.setMessages(p)}).catch(()=>{})},[]);const v=c.useCallback(()=>{t(p=>!p)},[]),g={status:o.status,error:o.error,messages:o.messages,conversations:n.conversations,activeConversationId:n.activeConversationId,isThreadListOpen:r,sendMessage:o.sendMessage,stop:o.stop,regenerate:o.regenerate,switchConversation:x,newConversation:f,deleteConversation:m,renameConversation:n.renameConversation,toggleThreadList:v,feedback:(p,h)=>{a.feedback(p,h)}};return e.jsx(X.Provider,{value:g,children:l})}function k({name:a,size:s=16,color:l="currentColor",className:r,style:t}){return e.jsx("svg",{className:r,style:{width:s,height:s,fill:l,verticalAlign:"middle",...t},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${a}`})})}function G({isOpen:a,onClick:s}){return e.jsx("button",{className:`sa-trigger ${a?"sa-trigger-open":""}`,onClick:s,children:a?e.jsx(k,{name:"x",size:24,color:"#fff"}):e.jsx(k,{name:"message-square",size:24,color:"#fff"})})}function Z({title:a,onClose:s,onToggleThreadList:l,showClose:r=!0}){return e.jsxs("div",{className:"sa-header",children:[e.jsxs("div",{className:"sa-header-left",children:[e.jsx("div",{className:"sa-header-avatar",children:"A"}),e.jsxs("div",{className:"sa-header-info",children:[e.jsx("div",{className:"sa-header-title",children:a}),e.jsx("div",{className:"sa-header-status",children:"● Online"})]})]}),e.jsxs("div",{className:"sa-header-actions",children:[e.jsx("button",{className:"sa-header-btn",onClick:l,title:"会话列表",children:e.jsx(k,{name:"menu",size:16})}),r&&e.jsx("button",{className:"sa-header-btn",onClick:s,title:"关闭",children:e.jsx(k,{name:"x",size:16})})]})]})}function Q(){const{conversations:a,activeConversationId:s,switchConversation:l,newConversation:r,deleteConversation:t,renameConversation:i,isThreadListOpen:d,toggleThreadList:n}=T(),[o,x]=c.useState(null),[f,m]=c.useState(""),v=c.useCallback((p,h)=>{x(p),m(h??"")},[]),g=c.useCallback(p=>{f.trim()&&i(p,f.trim()),x(null)},[f,i]);return d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-thread-list-overlay",onClick:n}),e.jsxs("div",{className:"sa-thread-list",children:[e.jsxs("div",{className:"sa-thread-list-header",children:[e.jsx("span",{children:"会话列表"}),e.jsxs("button",{className:"sa-thread-list-new",onClick:r,children:[e.jsx(k,{name:"plus",size:14})," 新会话"]})]}),e.jsxs("div",{className:"sa-thread-list-items",children:[a.length===0&&e.jsx("div",{className:"sa-thread-list-empty",children:"暂无会话"}),a.map(p=>e.jsxs("div",{className:`sa-thread-item ${p.sessionId===s?"active":""}`,onClick:()=>l(p.sessionId),children:[o===p.sessionId?e.jsx("input",{className:"sa-thread-item-edit",value:f,onChange:h=>m(h.target.value),onBlur:()=>g(p.sessionId),onKeyDown:h=>{h.key==="Enter"&&g(p.sessionId),h.key==="Escape"&&x(null)},onClick:h=>h.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"sa-thread-item-title",onDoubleClick:h=>{h.stopPropagation(),v(p.sessionId,p.title)},children:p.title||"新会话"}),e.jsx("button",{className:"sa-thread-item-delete",onClick:h=>{h.stopPropagation(),t(p.sessionId)},title:"删除",children:e.jsx(k,{name:"trash2",size:14})})]},p.sessionId))]})]})]}):null}function ee(a){const s=c.useRef(null),l=c.useRef(!1),r=c.useRef(0),t=c.useCallback(()=>{const d=s.current;if(!d)return;const{scrollTop:n,scrollHeight:o,clientHeight:x}=d,f=o-n-x<40;n<r.current&&!f&&(l.current=!0),f&&(l.current=!1),r.current=n},[]);c.useEffect(()=>{const d=s.current;if(d)return d.addEventListener("scroll",t,{passive:!0}),()=>d.removeEventListener("scroll",t)},[t]),c.useEffect(()=>{if(l.current)return;const d=s.current;d&&requestAnimationFrame(()=>{d.scrollTop=d.scrollHeight})},a);const i=c.useCallback(()=>{l.current=!1;const d=s.current;d&&(d.scrollTop=d.scrollHeight)},[]);return{containerRef:s,scrollToBottom:i}}function S(a){return a.value++}function P(a,s){const l=[],r=[],t=()=>{r.length>0&&(l.push(r.join("")),r.length=0)};let i=0;for(;i<a.length;){const d=a[i];if(d==="`"){const n=a.indexOf("`",i+1);if(n!==-1){t(),l.push(e.jsx("code",{className:"sa-inline-code",children:a.slice(i+1,n)},S(s))),i=n+1;continue}}else if(d==="*"&&a[i+1]==="*"){const n=a.indexOf("**",i+2);if(n!==-1){t(),l.push(e.jsx("strong",{children:P(a.slice(i+2,n),s)},S(s))),i=n+2;continue}}else if(d==="*"){const n=a.indexOf("*",i+1);if(n!==-1){t(),l.push(e.jsx("em",{children:P(a.slice(i+1,n),s)},S(s))),i=n+1;continue}}else if(d==="["){const n=a.indexOf("]",i+1);if(n!==-1&&a[n+1]==="("){const o=a.indexOf(")",n+2);if(o!==-1){const x=a.slice(i+1,n),f=a.slice(n+2,o);t(),l.push(e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",children:P(x,s)},S(s))),i=o+1;continue}}}r.push(d),i++}return t(),l}function ge(a,s){const l=[],r=a.split(`
2
+ `);let t=0;const i=o=>o.trim()==="",d=o=>/^#{1,6}\s+\S/.test(o.trim()),n=o=>/^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());for(;t<r.length;){const o=r[t],x=o.trim();if(i(o)){t++;continue}if(d(o)){const m=x.match(/^(#{1,6})\s+(.*)$/);if(m){const g=`h${Math.min(m[1].length,6)}`;l.push(c.createElement(g,{key:S(s)},P(m[2],s)))}t++;continue}if(n(o)){const m=/^\d+[.)]/.test(x),v=[];for(;t<r.length&&n(r[t]);){const g=r[t].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);g&&v.push(e.jsx("li",{children:P(g[1],s)},S(s))),t++}l.push(m?e.jsx("ol",{className:"sa-list",children:v},S(s)):e.jsx("ul",{className:"sa-list",children:v},S(s)));continue}const f=[];for(;t<r.length&&!i(r[t])&&!d(r[t])&&!n(r[t]);)f.push(r[t]),t++;l.push(e.jsx("p",{className:"sa-text-paragraph",children:P(f.join(" "),s)},S(s)))}return l}function be(a){const s={value:0},l=[],r=a.split("```");for(let t=0;t<r.length;t++)if(t%2===0)l.push(...ge(r[t],s));else if(r[t].trim()!==""){let i=r[t].replace(/^\r?\n/,"");i=i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/,""),i=i.replace(/\r?\n$/,""),l.push(e.jsx("pre",{className:"sa-code-block",children:e.jsx("code",{children:i})},S(s)))}return l}function se({content:a}){return e.jsx("div",{className:"sa-text-part",children:be(a)})}function ae({content:a}){const[s,l]=c.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>l(!s),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(k,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${s?"expanded":""}`,children:e.jsx(k,{name:"chevron-right",size:12})})]}),s&&e.jsx("div",{className:"sa-thinking-content",children:a})]})}function te({toolName:a,toolCallId:s,args:l}){const[r,t]=c.useState(!1);let i=l;try{i=JSON.stringify(JSON.parse(l),null,2)}catch{}return e.jsxs("div",{className:"sa-tool-call-part",children:[e.jsxs("div",{className:"sa-tool-call-header",onClick:()=>t(!r),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(k,{name:"zap",size:14})}),e.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",a]}),e.jsx("span",{className:`sa-thinking-arrow ${r?"expanded":""}`,children:e.jsx(k,{name:"chevron-right",size:12})})]}),r&&e.jsx("pre",{className:"sa-tool-args",children:i})]})}function re({toolName:a,toolCallId:s,content:l}){return e.jsxs("div",{className:"sa-tool-result-part",children:[e.jsxs("div",{className:"sa-tool-result-header",children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(k,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:a||"工具返回"})]}),e.jsx("div",{className:"sa-tool-result-content",children:l})]})}function ne({content:a,onRetry:s}){return e.jsxs("div",{className:"sa-error-part",children:[e.jsxs("div",{className:"sa-error-content",children:[e.jsx("span",{className:"sa-error-icon",children:e.jsx(k,{name:"triangle-alert",size:14})}),e.jsx("span",{children:a})]}),s&&e.jsx("button",{className:"sa-error-retry",onClick:s,children:"重试"})]})}function ie({message:a,onCopy:s,onRegenerate:l,onFeedback:r}){const{status:t}=T(),[i,d]=c.useState(null),[n,o]=c.useState(!1);if(t!=="ready"&&t!=="error")return null;const x=c.useCallback(()=>{s(),o(!0),setTimeout(()=>o(!1),2e3)},[s]),f=c.useCallback(m=>{const v=i===m?null:m;d(v),v&&(r==null||r(a.id,v))},[i,a.id,r]);return e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:x,title:"复制",children:[e.jsx(k,{name:n?"circle-check":"copy",size:14})," ",n?"已复制":"复制"]}),e.jsxs("button",{className:"sa-action-btn",onClick:l,title:"重新生成",children:[e.jsx(k,{name:"refresh-cw",size:14})," 重新生成"]}),e.jsx("span",{className:"sa-action-divider"}),e.jsx("button",{className:`sa-action-btn ${i==="like"?"sa-action-btn-active":""}`,onClick:()=>f("like"),title:"有用",children:e.jsx(k,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${i==="dislike"?"sa-action-btn-active":""}`,onClick:()=>f("dislike"),title:"无用",children:e.jsx(k,{name:"thumbs-down",size:14})})]})}function V({src:a,role:s}){const l=s==="assistant"?"A":"U";return a?a.startsWith("http")||a.startsWith("/")||a.startsWith("data:")?e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:e.jsx("img",{src:a,alt:s,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}})}):e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:a}):e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:l})}function oe({message:a,isStreaming:s,isLast:l,slots:r,avatar:t}){const{regenerate:i,feedback:d}=T(),n=c.useCallback(()=>{var u;const b=a.parts.filter(y=>y.type==="text").map(y=>y.content).join(`
3
+ `);(u=navigator.clipboard)==null||u.writeText(b).catch(()=>{})},[a]),o=a.role==="user",x=r.Message;if(x)return e.jsx(x,{message:a,isStreaming:s,isLast:l,avatar:t,slots:r,onCopy:n,onRegenerate:i,onFeedback:d});const f=r.TextPart??se,m=r.ThinkingPart??ae,v=r.ToolCallPart??te,g=r.ToolResultPart??re,p=r.ErrorPart??ne,h=r.ActionBar??ie;return e.jsxs("div",{className:`sa-message ${o?"sa-message-user":"sa-message-assistant"}`,children:[!o&&e.jsx(V,{src:t==null?void 0:t.assistant,role:"assistant"}),e.jsxs("div",{className:"sa-message-body",children:[a.parts.map((b,u)=>{switch(b.type){case"text":return e.jsx(f,{content:b.content},u);case"thinking":return e.jsx(m,{content:b.content},u);case"tool_call":return e.jsx(v,{toolName:b.toolName,toolCallId:b.toolCallId,args:b.args},u);case"tool_result":return e.jsx(g,{toolName:b.toolName,toolCallId:b.toolCallId,content:b.content},u);case"error":return e.jsx(p,{content:b.content,onRetry:i},u);default:return null}}),s&&l&&!o&&e.jsx("span",{className:"sa-streaming-cursor",children:"|"}),!o&&!s&&a.parts.length>0&&e.jsx(h,{message:a,onCopy:n,onRegenerate:i,onFeedback:d})]}),o&&e.jsx(V,{src:t==null?void 0:t.user,role:"user"})]})}function le({message:a,suggestedPrompts:s,onPromptClick:l}){return e.jsxs("div",{className:"sa-welcome",children:[e.jsx("div",{className:"sa-welcome-icon",children:e.jsx(k,{name:"sparkles",size:40})}),e.jsx("p",{className:"sa-welcome-message",children:a||"你好!有什么可以帮你的?"}),s&&s.length>0&&e.jsx("div",{className:"sa-welcome-prompts",children:s.map((r,t)=>e.jsx("button",{className:"sa-welcome-prompt",onClick:()=>l(r),children:r},t))})]})}function B({slots:a,welcomeMessage:s,suggestedPrompts:l,avatar:r}){const{messages:t,status:i,sendMessage:d}=T(),{containerRef:n}=ee([t]),o=i==="streaming",x=a.WelcomeScreen??le;return t.length===0?e.jsx("div",{className:"sa-thread",ref:n,children:e.jsx(x,{message:s,suggestedPrompts:l,onPromptClick:d})}):e.jsx("div",{className:"sa-thread",ref:n,children:t.map((f,m)=>e.jsx(oe,{message:f,isStreaming:o,isLast:m===t.length-1,slots:a,avatar:r},f.id))})}function W(){const{status:a,sendMessage:s,stop:l}=T(),[r,t]=c.useState(""),i=c.useRef(null),d=a==="streaming"||a==="submitted",n=c.useCallback(()=>{const f=r.trim();!f||d||(s(f),t(""),i.current&&(i.current.style.height="auto"))},[r,d,s]),o=c.useCallback(f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),n())},[n]),x=c.useCallback(f=>{t(f.target.value);const m=f.target;m.style.height="auto",m.style.height=Math.min(m.scrollHeight,120)+"px"},[]);return e.jsxs("div",{className:"sa-composer",children:[e.jsx("textarea",{ref:i,className:"sa-composer-input",value:r,onChange:x,onKeyDown:o,placeholder:"输入消息...",rows:1,disabled:a==="submitted"}),d?e.jsx("button",{className:"sa-composer-stop",onClick:l,title:"停止",children:e.jsx(k,{name:"circle-stop",size:16,color:"#fff"})}):e.jsx("button",{className:"sa-composer-send",onClick:n,disabled:!r.trim(),title:"发送",children:e.jsx(k,{name:"arrow-up",size:16,color:"#fff"})})]})}function ve({isOpen:a,onClose:s,title:l,slots:r,welcomeMessage:t,suggestedPrompts:i,avatar:d}){const{status:n,sendMessage:o,stop:x,toggleThreadList:f,conversations:m,activeConversationId:v,switchConversation:g,newConversation:p,deleteConversation:h,renameConversation:b,isThreadListOpen:u}=T();if(!a)return null;const y=r.Header,C=r.Composer,j=r.ThreadList;return e.jsxs("div",{className:"sa-panel",children:[y?e.jsx(y,{title:l,onClose:s,onToggleThreadList:f}):e.jsx(Z,{title:l,onClose:s,onToggleThreadList:f}),j&&u?e.jsx(j,{conversations:m,activeSessionId:v,onSwitch:g,onNew:p,onDelete:h,onRename:b}):e.jsx(Q,{}),e.jsx(B,{slots:r,welcomeMessage:t,suggestedPrompts:i,avatar:d}),C?e.jsx(C,{status:n,onSend:o,onStop:x}):e.jsx(W,{})]})}function ye({conversations:a,activeSessionId:s,onSwitch:l,onNew:r,onDelete:t,isCollapsed:i,onToggleCollapse:d}){const[n,o]=c.useState(null),[x,f]=c.useState(null),m=c.useCallback((g,p)=>{p.stopPropagation(),x===g?(t(g),f(null)):(f(g),setTimeout(()=>f(null),3e3))},[x,t]),v=(()=>{const g=Date.now(),p=[],h=[],b=[];for(const y of a){const C=g-new Date(y.updateTime).getTime();C<864e5?p.push(y):C<6048e5?h.push(y):b.push(y)}const u=[];return p.length&&u.push({label:"今天",items:p}),h.length&&u.push({label:"最近 7 天",items:h}),b.length&&u.push({label:"更早",items:b}),u})();return i?e.jsxs("div",{className:"sa-fp-sidebar sa-fp-sidebar-collapsed",children:[e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:d,title:"展开",children:e.jsx(k,{name:"panel-left",size:18})}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:r,title:"新会话",style:{marginTop:4},children:e.jsx(k,{name:"plus",size:18})})]}):e.jsxs("div",{className:"sa-fp-sidebar",children:[e.jsxs("div",{className:"sa-fp-sidebar-header",children:[e.jsxs("button",{className:"sa-fp-sidebar-new",onClick:r,children:[e.jsx(k,{name:"plus",size:15})," ",e.jsx("span",{children:"新会话"})]}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:d,title:"收起侧边栏",children:e.jsx(k,{name:"panel-left-close",size:18})})]}),e.jsxs("div",{className:"sa-fp-sidebar-list",children:[a.length===0&&e.jsx("div",{className:"sa-fp-sidebar-empty",children:"开始你的第一个对话"}),v.map(g=>e.jsxs("div",{children:[e.jsx("div",{className:"sa-fp-sidebar-group",children:g.label}),g.items.map(p=>{const h=p.sessionId===s,b=n===p.sessionId,u=x===p.sessionId;return e.jsxs("div",{className:`sa-fp-sidebar-item ${h?"active":""}`,onClick:()=>l(p.sessionId),onMouseEnter:()=>o(p.sessionId),onMouseLeave:()=>o(null),children:[e.jsx("span",{className:"sa-fp-sidebar-item-title",children:p.title||"新会话"}),b&&e.jsx("button",{className:`sa-fp-sidebar-item-action ${u?"danger":""}`,onClick:y=>m(p.sessionId,y),title:u?"确认删除":"删除",children:e.jsx(k,{name:u?"x":"trash2",size:14})})]},p.sessionId)})]},g.label))]})]})}function ce({title:a,slots:s,welcomeMessage:l,suggestedPrompts:r,sidebarDefaultOpen:t=!0,onClose:i,avatar:d}){const{status:n,sendMessage:o,stop:x,conversations:f,activeConversationId:m,switchConversation:v,newConversation:g,deleteConversation:p,renameConversation:h}=T(),[b,u]=c.useState(t),y=c.useCallback(()=>u(L=>!L),[]),C=s.ThreadList,j=s.Composer;return e.jsxs("div",{className:"sa-fullpage",children:[C?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${b?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(C,{conversations:f,activeSessionId:m,onSwitch:v,onNew:g,onDelete:p,onRename:h})}):e.jsx(ye,{conversations:f,activeSessionId:m,onSwitch:v,onNew:g,onDelete:p,onRename:h,isCollapsed:!b,onToggleCollapse:y}),e.jsxs("div",{className:"sa-fp-main",children:[e.jsxs("div",{className:"sa-fp-header",children:[!b&&!C&&e.jsx("button",{className:"sa-fp-header-btn",onClick:y,title:"展开侧边栏",children:e.jsx(k,{name:"panel-left",size:18})}),e.jsx("div",{className:"sa-fp-header-title",children:a}),e.jsx("div",{className:"sa-fp-header-actions",children:i&&e.jsx("button",{className:"sa-fp-header-btn",onClick:i,title:"关闭",children:e.jsx(k,{name:"x",size:18})})})]}),e.jsx(B,{slots:s,welcomeMessage:l,suggestedPrompts:r,avatar:d}),j?e.jsx(j,{status:n,onSend:o,onStop:x}):e.jsx(W,{})]})]})}function de(a){const{sdk:s,mode:l="floating",slots:r={},hooks:t={},welcomeMessage:i,suggestedPrompts:d,title:n="AI Assistant",initialOpen:o=!1,onOpenChange:x,sidebarDefaultOpen:f,avatar:m}=a,[v,g]=c.useState(o);c.useEffect(()=>{g(o)},[o]);const p=c.useCallback(()=>{var y,C;const u=!v;g(u),x==null||x(u),u?(y=t.onOpen)==null||y.call(t):(C=t.onClose)==null||C.call(t)},[v,t,x]),h=c.useCallback(()=>{var u;g(!1),x==null||x(!1),(u=t.onClose)==null||u.call(t)},[t,x]),b=r.Trigger??G;return l==="fullpage"?v?e.jsx(H,{sdk:s,hooks:t,children:e.jsx(ce,{title:n,slots:r,welcomeMessage:i,suggestedPrompts:d,sidebarDefaultOpen:f,onClose:h,avatar:m})}):null:e.jsxs(H,{sdk:s,hooks:t,children:[e.jsx(b,{isOpen:v,onClick:p}),e.jsx(ve,{isOpen:v,onClose:h,title:n,slots:r,welcomeMessage:i,suggestedPrompts:d,avatar:m})]})}const pe=`
4
+ [data-super-agent-widget] {
5
+ --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
6
+ --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
7
+ --sa-text: #1f2937;
8
+ --sa-text-muted: #6b7280;
9
+ --sa-border: #e5e7eb;
10
+ --sa-surface: #f9fafb;
11
+
12
+ font-family: var(--sa-font);
13
+ color: var(--sa-text);
14
+ line-height: 1.5;
15
+ -webkit-font-smoothing: antialiased;
16
+ text-rendering: optimizeLegibility;
17
+ }
18
+
19
+ [data-super-agent-widget] *,
20
+ [data-super-agent-widget] *::before,
21
+ [data-super-agent-widget] *::after {
22
+ box-sizing: border-box;
23
+ margin: 0;
24
+ padding: 0;
25
+ }
26
+
27
+ [data-super-agent-widget] button {
28
+ font-family: inherit;
29
+ }
30
+
31
+ /* ── Trigger ─────────────────────────────────────────────── */
32
+
33
+ .sa-trigger {
34
+ position: fixed;
35
+ bottom: 24px;
36
+ right: 24px;
37
+ width: 56px;
38
+ height: 56px;
39
+ border: none;
40
+ border-radius: 50%;
41
+ cursor: pointer;
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
46
+ color: #ffffff;
47
+ font-size: 24px;
48
+ box-shadow: 0 8px 24px color-mix(in srgb, var(--sa-primary) 35%, transparent);
49
+ z-index: var(--sa-z-index, 9999);
50
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
51
+ }
52
+
53
+ .sa-trigger:hover {
54
+ transform: scale(1.08);
55
+ box-shadow: 0 12px 32px color-mix(in srgb, var(--sa-primary) 45%, transparent);
56
+ }
57
+
58
+ .sa-trigger:active {
59
+ transform: scale(0.94);
60
+ }
61
+
62
+ .sa-trigger-open {
63
+ transform: rotate(90deg);
64
+ }
65
+
66
+ /* ── Panel ───────────────────────────────────────────────── */
67
+
68
+ .sa-panel {
69
+ position: fixed;
70
+ bottom: 96px;
71
+ right: 24px;
72
+ width: var(--sa-panel-width, 380px);
73
+ height: var(--sa-panel-height, 520px);
74
+ max-height: calc(100vh - 120px);
75
+ display: flex;
76
+ flex-direction: column;
77
+ overflow: hidden;
78
+ background: var(--sa-bg);
79
+ border: 1px solid var(--sa-border);
80
+ border-radius: var(--sa-radius, 16px);
81
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
82
+ z-index: var(--sa-z-index, 9999);
83
+ animation: sa-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
84
+ }
85
+
86
+ /* ── Header ──────────────────────────────────────────────── */
87
+
88
+ .sa-header {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 10px;
92
+ padding: 14px 16px;
93
+ color: #ffffff;
94
+ background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
95
+ flex-shrink: 0;
96
+ }
97
+
98
+ .sa-header-left {
99
+ display: flex;
100
+ align-items: center;
101
+ gap: 10px;
102
+ flex: 1;
103
+ }
104
+
105
+ .sa-header-avatar {
106
+ width: 28px;
107
+ height: 28px;
108
+ border-radius: 50%;
109
+ background: rgba(255,255,255,0.2);
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: center;
113
+ font-size: 12px;
114
+ font-weight: 600;
115
+ }
116
+
117
+ .sa-header-info {
118
+ display: flex;
119
+ flex-direction: column;
120
+ }
121
+
122
+ .sa-header-status {
123
+ font-size: 11px;
124
+ opacity: 0.8;
125
+ color: #a5f3a6;
126
+ }
127
+
128
+ .sa-header-actions {
129
+ display: flex;
130
+ gap: 4px;
131
+ }
132
+
133
+ .sa-header-title {
134
+ flex: 1;
135
+ font-size: 16px;
136
+ font-weight: 600;
137
+ white-space: nowrap;
138
+ overflow: hidden;
139
+ text-overflow: ellipsis;
140
+ }
141
+
142
+ .sa-header-btn {
143
+ width: 30px;
144
+ height: 30px;
145
+ border: none;
146
+ border-radius: 8px;
147
+ background: transparent;
148
+ color: #ffffff;
149
+ font-size: 16px;
150
+ cursor: pointer;
151
+ display: flex;
152
+ align-items: center;
153
+ justify-content: center;
154
+ transition: background 0.15s ease;
155
+ }
156
+
157
+ .sa-header-btn:hover {
158
+ background: rgba(255, 255, 255, 0.18);
159
+ }
160
+
161
+ /* ── Thread / messages ───────────────────────────────────── */
162
+
163
+ .sa-thread {
164
+ flex: 1;
165
+ display: flex;
166
+ flex-direction: column;
167
+ gap: 14px;
168
+ overflow-y: auto;
169
+ padding: 16px;
170
+ background: var(--sa-surface);
171
+ scroll-behavior: smooth;
172
+ }
173
+
174
+ .sa-thread::-webkit-scrollbar {
175
+ width: 6px;
176
+ }
177
+
178
+ .sa-thread::-webkit-scrollbar-thumb {
179
+ background: rgba(0, 0, 0, 0.14);
180
+ border-radius: 3px;
181
+ }
182
+
183
+ .sa-thread::-webkit-scrollbar-thumb:hover {
184
+ background: rgba(0, 0, 0, 0.24);
185
+ }
186
+
187
+ .sa-message {
188
+ display: flex;
189
+ align-items: flex-start;
190
+ gap: 10px;
191
+ width: 100%;
192
+ }
193
+
194
+ .sa-message-user {
195
+ justify-content: flex-end;
196
+ }
197
+
198
+ .sa-message-body {
199
+ max-width: 78%;
200
+ display: flex;
201
+ flex-direction: column;
202
+ gap: 4px;
203
+ }
204
+
205
+ .sa-message-user .sa-message-body {
206
+ padding: 10px 14px;
207
+ border-radius: 16px;
208
+ border-bottom-right-radius: 4px;
209
+ background: var(--sa-primary);
210
+ color: #ffffff;
211
+ font-size: 14px;
212
+ line-height: 1.55;
213
+ word-break: break-word;
214
+ }
215
+
216
+ .sa-message-assistant .sa-message-body {
217
+ padding: 10px 14px;
218
+ border-radius: 16px;
219
+ border-bottom-left-radius: 4px;
220
+ background: #ffffff;
221
+ color: var(--sa-text);
222
+ font-size: 14px;
223
+ line-height: 1.55;
224
+ word-break: break-word;
225
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
226
+ }
227
+
228
+ .sa-avatar {
229
+ width: 28px;
230
+ height: 28px;
231
+ flex-shrink: 0;
232
+ border-radius: 50%;
233
+ display: flex;
234
+ align-items: center;
235
+ justify-content: center;
236
+ color: #ffffff;
237
+ font-size: 12px;
238
+ font-weight: 600;
239
+ overflow: hidden;
240
+ }
241
+
242
+ .sa-avatar-assistant {
243
+ background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
244
+ }
245
+
246
+ .sa-avatar-user {
247
+ background: linear-gradient(135deg, #64748b, #475569);
248
+ }
249
+
250
+ /* ── Text part (markdown) ────────────────────────────────── */
251
+
252
+ .sa-text-part {
253
+ font-size: 14px;
254
+ line-height: 1.6;
255
+ word-break: break-word;
256
+ }
257
+
258
+ .sa-text-part p {
259
+ margin: 0 0 8px;
260
+ }
261
+
262
+ .sa-text-part p:last-child {
263
+ margin-bottom: 0;
264
+ }
265
+
266
+ .sa-text-part strong {
267
+ font-weight: 600;
268
+ }
269
+
270
+ .sa-text-part em {
271
+ font-style: italic;
272
+ }
273
+
274
+ .sa-text-part h1,
275
+ .sa-text-part h2,
276
+ .sa-text-part h3,
277
+ .sa-text-part h4,
278
+ .sa-text-part h5,
279
+ .sa-text-part h6 {
280
+ margin: 12px 0 6px;
281
+ font-weight: 600;
282
+ line-height: 1.3;
283
+ }
284
+
285
+ .sa-text-part h1 {
286
+ font-size: 1.4em;
287
+ }
288
+
289
+ .sa-text-part h2 {
290
+ font-size: 1.25em;
291
+ }
292
+
293
+ .sa-text-part h3 {
294
+ font-size: 1.1em;
295
+ }
296
+
297
+ .sa-text-part h4,
298
+ .sa-text-part h5,
299
+ .sa-text-part h6 {
300
+ font-size: 1em;
301
+ }
302
+
303
+ .sa-text-part a {
304
+ color: var(--sa-primary);
305
+ text-decoration: underline;
306
+ text-underline-offset: 2px;
307
+ }
308
+
309
+ .sa-text-part a:hover {
310
+ color: var(--sa-primary-dark);
311
+ }
312
+
313
+ .sa-inline-code {
314
+ padding: 2px 5px;
315
+ border-radius: 4px;
316
+ background: rgba(0, 0, 0, 0.06);
317
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
318
+ font-size: 0.9em;
319
+ }
320
+
321
+ .sa-code-block {
322
+ margin: 8px 0;
323
+ padding: 12px 14px;
324
+ border-radius: 10px;
325
+ background: #1e293b;
326
+ color: #e2e8f0;
327
+ overflow-x: auto;
328
+ font-size: 13px;
329
+ line-height: 1.55;
330
+ }
331
+
332
+ .sa-code-block code {
333
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
334
+ white-space: pre;
335
+ }
336
+
337
+ .sa-list {
338
+ margin: 6px 0;
339
+ padding-left: 22px;
340
+ }
341
+
342
+ .sa-list li {
343
+ margin: 3px 0;
344
+ line-height: 1.5;
345
+ }
346
+
347
+ ul.sa-list {
348
+ list-style: disc;
349
+ }
350
+
351
+ ol.sa-list {
352
+ list-style: decimal;
353
+ }
354
+
355
+ /* ── Thinking part ───────────────────────────────────────── */
356
+
357
+ .sa-thinking-part {
358
+ margin: 6px 0;
359
+ padding: 8px 12px;
360
+ border-left: 3px solid var(--sa-primary);
361
+ border-radius: 8px;
362
+ background: var(--sa-primary-light);
363
+ cursor: pointer;
364
+ font-size: 13px;
365
+ }
366
+
367
+ .sa-thinking-header {
368
+ display: flex;
369
+ align-items: center;
370
+ gap: 6px;
371
+ color: var(--sa-primary-dark);
372
+ font-weight: 500;
373
+ user-select: none;
374
+ }
375
+
376
+ .sa-thinking-icon {
377
+ font-size: 14px;
378
+ line-height: 1;
379
+ }
380
+
381
+ .sa-thinking-label {
382
+ flex: 1;
383
+ }
384
+
385
+ .sa-thinking-arrow {
386
+ font-size: 12px;
387
+ transition: transform 0.2s ease;
388
+ }
389
+
390
+ .sa-thinking-arrow.expanded {
391
+ transform: rotate(90deg);
392
+ }
393
+
394
+ .sa-thinking-content {
395
+ margin-top: 8px;
396
+ color: #4b5563;
397
+ white-space: pre-wrap;
398
+ line-height: 1.55;
399
+ }
400
+
401
+ /* ── Tool call / result ──────────────────────────────────── */
402
+
403
+ .sa-tool-call-part {
404
+ margin: 6px 0;
405
+ border: 1px solid var(--sa-border);
406
+ border-radius: 10px;
407
+ overflow: hidden;
408
+ background: #ffffff;
409
+ }
410
+
411
+ .sa-tool-call-header {
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 8px;
415
+ padding: 8px 12px;
416
+ cursor: pointer;
417
+ font-size: 13px;
418
+ user-select: none;
419
+ }
420
+
421
+ .sa-tool-call-header:hover {
422
+ background: var(--sa-surface);
423
+ }
424
+
425
+ .sa-tool-icon {
426
+ font-size: 14px;
427
+ line-height: 1;
428
+ }
429
+
430
+ .sa-tool-name {
431
+ flex: 1;
432
+ color: #374151;
433
+ font-weight: 500;
434
+ overflow: hidden;
435
+ white-space: nowrap;
436
+ text-overflow: ellipsis;
437
+ }
438
+
439
+ .sa-tool-args {
440
+ margin: 0;
441
+ padding: 10px 12px;
442
+ border-top: 1px solid var(--sa-border);
443
+ background: var(--sa-surface);
444
+ color: #374151;
445
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
446
+ font-size: 12px;
447
+ line-height: 1.5;
448
+ white-space: pre;
449
+ overflow-x: auto;
450
+ }
451
+
452
+ .sa-tool-result-part {
453
+ margin: 6px 0;
454
+ border: 1px solid var(--sa-border);
455
+ border-radius: 10px;
456
+ overflow: hidden;
457
+ background: #ffffff;
458
+ }
459
+
460
+ .sa-tool-result-header {
461
+ display: flex;
462
+ align-items: center;
463
+ gap: 8px;
464
+ padding: 8px 12px;
465
+ border-bottom: 1px solid var(--sa-border);
466
+ background: var(--sa-surface);
467
+ color: #374151;
468
+ font-size: 13px;
469
+ font-weight: 500;
470
+ }
471
+
472
+ .sa-tool-result-content {
473
+ padding: 10px 12px;
474
+ color: #4b5563;
475
+ font-size: 13px;
476
+ line-height: 1.55;
477
+ white-space: pre-wrap;
478
+ word-break: break-word;
479
+ }
480
+
481
+ /* ── Error part ──────────────────────────────────────────── */
482
+
483
+ .sa-error-part {
484
+ margin: 6px 0;
485
+ padding: 10px 12px;
486
+ border: 1px solid #fecaca;
487
+ border-radius: 10px;
488
+ background: #fef2f2;
489
+ color: #b91c1c;
490
+ }
491
+
492
+ .sa-error-content {
493
+ display: flex;
494
+ align-items: flex-start;
495
+ gap: 8px;
496
+ font-size: 13px;
497
+ line-height: 1.5;
498
+ }
499
+
500
+ .sa-error-icon {
501
+ font-size: 14px;
502
+ line-height: 1.4;
503
+ }
504
+
505
+ .sa-error-retry {
506
+ margin-top: 8px;
507
+ padding: 6px 14px;
508
+ border: none;
509
+ border-radius: 8px;
510
+ background: #ef4444;
511
+ color: #ffffff;
512
+ font-size: 13px;
513
+ cursor: pointer;
514
+ transition: background 0.2s ease;
515
+ }
516
+
517
+ .sa-error-retry:hover {
518
+ background: #dc2626;
519
+ }
520
+
521
+ /* ── Action bar ──────────────────────────────────────────── */
522
+
523
+ .sa-action-bar {
524
+ display: flex;
525
+ gap: 6px;
526
+ margin-top: 6px;
527
+ }
528
+
529
+ .sa-action-btn {
530
+ padding: 4px 10px;
531
+ border: none;
532
+ border-radius: 6px;
533
+ background: transparent;
534
+ color: var(--sa-text-muted);
535
+ font-size: 12px;
536
+ cursor: pointer;
537
+ transition: color 0.15s ease, background 0.15s ease;
538
+ }
539
+
540
+ .sa-action-btn:hover {
541
+ color: var(--sa-text);
542
+ background: rgba(0, 0, 0, 0.05);
543
+ }
544
+
545
+ .sa-action-btn-active {
546
+ color: var(--sa-primary) !important;
547
+ background: var(--sa-primary-light) !important;
548
+ }
549
+
550
+ .sa-action-divider {
551
+ width: 1px;
552
+ height: 16px;
553
+ background: var(--sa-border);
554
+ margin: 0 2px;
555
+ align-self: center;
556
+ }
557
+
558
+ /* ── Composer ────────────────────────────────────────────── */
559
+
560
+ .sa-composer {
561
+ display: flex;
562
+ align-items: flex-end;
563
+ gap: 10px;
564
+ padding: 12px 14px;
565
+ border-top: 1px solid var(--sa-border);
566
+ background: var(--sa-bg);
567
+ flex-shrink: 0;
568
+ }
569
+
570
+ .sa-composer-input {
571
+ flex: 1;
572
+ min-height: 38px;
573
+ max-height: 120px;
574
+ padding: 9px 14px;
575
+ border: 1px solid var(--sa-border);
576
+ border-radius: 19px;
577
+ background: var(--sa-surface);
578
+ color: var(--sa-text);
579
+ font-family: var(--sa-font);
580
+ font-size: 14px;
581
+ line-height: 1.5;
582
+ resize: none;
583
+ outline: none;
584
+ transition: border-color 0.2s ease, background 0.2s ease;
585
+ }
586
+
587
+ .sa-composer-input::placeholder {
588
+ color: #9ca3af;
589
+ }
590
+
591
+ .sa-composer-input:focus {
592
+ border-color: var(--sa-primary);
593
+ background: #ffffff;
594
+ }
595
+
596
+ .sa-composer-send,
597
+ .sa-composer-stop {
598
+ width: 38px;
599
+ height: 38px;
600
+ flex-shrink: 0;
601
+ border: none;
602
+ border-radius: 50%;
603
+ cursor: pointer;
604
+ display: flex;
605
+ align-items: center;
606
+ justify-content: center;
607
+ color: #ffffff;
608
+ font-size: 16px;
609
+ transition: transform 0.15s ease, background 0.2s ease;
610
+ }
611
+
612
+ .sa-composer-send {
613
+ background: var(--sa-primary);
614
+ }
615
+
616
+ .sa-composer-send:hover {
617
+ background: var(--sa-primary-dark);
618
+ transform: scale(1.05);
619
+ }
620
+
621
+ .sa-composer-send:disabled {
622
+ opacity: 0.5;
623
+ cursor: not-allowed;
624
+ transform: none;
625
+ }
626
+
627
+ .sa-composer-stop {
628
+ background: #ef4444;
629
+ }
630
+
631
+ .sa-composer-stop:hover {
632
+ background: #dc2626;
633
+ transform: scale(1.05);
634
+ }
635
+
636
+ /* ── Thread list ─────────────────────────────────────────── */
637
+
638
+ .sa-thread-list-overlay {
639
+ position: absolute;
640
+ inset: 0;
641
+ background: rgba(0,0,0,0.3);
642
+ z-index: 19;
643
+ }
644
+
645
+ .sa-thread-list {
646
+ position: absolute;
647
+ top: 0;
648
+ left: 0;
649
+ bottom: 0;
650
+ width: 100%;
651
+ display: flex;
652
+ flex-direction: column;
653
+ background: #ffffff;
654
+ z-index: 20;
655
+ box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
656
+ animation: sa-slide-in-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
657
+ }
658
+
659
+ .sa-thread-list-header {
660
+ display: flex;
661
+ align-items: center;
662
+ gap: 10px;
663
+ padding: 14px 16px;
664
+ border-bottom: 1px solid var(--sa-border);
665
+ flex-shrink: 0;
666
+ }
667
+
668
+ .sa-thread-list-items {
669
+ flex: 1;
670
+ overflow-y: auto;
671
+ }
672
+
673
+ .sa-thread-list-empty {
674
+ padding: 24px 16px;
675
+ text-align: center;
676
+ color: var(--sa-text-muted);
677
+ font-size: 13px;
678
+ }
679
+
680
+ .sa-thread-list-new {
681
+ display: block;
682
+ width: calc(100% - 24px);
683
+ margin: 12px;
684
+ padding: 10px;
685
+ border: 1px dashed var(--sa-border);
686
+ border-radius: 10px;
687
+ background: transparent;
688
+ color: var(--sa-primary);
689
+ font-size: 14px;
690
+ cursor: pointer;
691
+ text-align: center;
692
+ transition: background 0.15s, border-color 0.15s;
693
+ }
694
+
695
+ .sa-thread-list-new:hover {
696
+ background: var(--sa-primary-light);
697
+ border-color: var(--sa-primary);
698
+ }
699
+
700
+ .sa-thread-item {
701
+ display: flex;
702
+ align-items: center;
703
+ justify-content: space-between;
704
+ gap: 8px;
705
+ padding: 12px 16px;
706
+ border-bottom: 1px solid #f3f4f6;
707
+ color: #374151;
708
+ font-size: 14px;
709
+ cursor: pointer;
710
+ transition: background 0.15s ease;
711
+ }
712
+
713
+ .sa-thread-item:hover {
714
+ background: var(--sa-surface);
715
+ }
716
+
717
+ .sa-thread-item.active {
718
+ background: var(--sa-primary-light);
719
+ color: var(--sa-primary-dark);
720
+ font-weight: 500;
721
+ }
722
+
723
+ .sa-thread-item-title {
724
+ flex: 1;
725
+ overflow: hidden;
726
+ white-space: nowrap;
727
+ text-overflow: ellipsis;
728
+ }
729
+
730
+ .sa-thread-item-edit {
731
+ width: 100%;
732
+ padding: 4px 8px;
733
+ border: 1px solid var(--sa-primary);
734
+ border-radius: 6px;
735
+ font-size: 13px;
736
+ outline: none;
737
+ background: var(--sa-bg);
738
+ color: var(--sa-text);
739
+ }
740
+
741
+ .sa-thread-item-delete {
742
+ border: none;
743
+ background: transparent;
744
+ color: var(--sa-text-muted);
745
+ font-size: 14px;
746
+ cursor: pointer;
747
+ opacity: 0;
748
+ transition: opacity 0.15s ease, color 0.15s ease;
749
+ }
750
+
751
+ .sa-thread-item:hover .sa-thread-item-delete {
752
+ opacity: 1;
753
+ }
754
+
755
+ .sa-thread-item-delete:hover {
756
+ color: #ef4444;
757
+ }
758
+
759
+ /* ── Welcome ─────────────────────────────────────────────── */
760
+
761
+ .sa-welcome {
762
+ flex: 1;
763
+ display: flex;
764
+ flex-direction: column;
765
+ align-items: center;
766
+ justify-content: center;
767
+ padding: 24px;
768
+ text-align: center;
769
+ }
770
+
771
+ .sa-welcome-icon {
772
+ font-size: 40px;
773
+ margin-bottom: 12px;
774
+ }
775
+
776
+ .sa-welcome-message {
777
+ margin-bottom: 20px;
778
+ font-size: 14px;
779
+ color: var(--sa-text-muted);
780
+ line-height: 1.6;
781
+ }
782
+
783
+ .sa-welcome-prompts {
784
+ display: flex;
785
+ flex-direction: column;
786
+ gap: 8px;
787
+ width: 100%;
788
+ }
789
+
790
+ .sa-welcome-prompt {
791
+ padding: 10px 16px;
792
+ border: 1px solid var(--sa-border);
793
+ border-radius: 999px;
794
+ background: #ffffff;
795
+ color: #374151;
796
+ font-size: 13px;
797
+ cursor: pointer;
798
+ transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
799
+ }
800
+
801
+ .sa-welcome-prompt:hover {
802
+ border-color: var(--sa-primary);
803
+ background: var(--sa-primary-light);
804
+ color: var(--sa-primary-dark);
805
+ }
806
+
807
+ /* ── Streaming cursor ────────────────────────────────────── */
808
+
809
+ .sa-streaming-cursor {
810
+ display: inline-block;
811
+ width: 2px;
812
+ height: 1em;
813
+ margin-left: 2px;
814
+ background: var(--sa-primary);
815
+ vertical-align: text-bottom;
816
+ animation: sa-blink 1s steps(2, start) infinite;
817
+ }
818
+
819
+ /* ── Animations ──────────────────────────────────────────── */
820
+
821
+ @keyframes sa-slide-up {
822
+ from {
823
+ opacity: 0;
824
+ transform: translateY(16px) scale(0.98);
825
+ }
826
+ to {
827
+ opacity: 1;
828
+ transform: translateY(0) scale(1);
829
+ }
830
+ }
831
+
832
+ @keyframes sa-blink {
833
+ 0%,
834
+ 100% {
835
+ opacity: 1;
836
+ }
837
+ 50% {
838
+ opacity: 0;
839
+ }
840
+ }
841
+
842
+ @keyframes sa-slide-in-left {
843
+ from {
844
+ opacity: 0;
845
+ transform: translateX(-100%);
846
+ }
847
+ to {
848
+ opacity: 1;
849
+ transform: translateX(0);
850
+ }
851
+ }
852
+
853
+ /* ── Fullpage Layout (DeepSeek-style) ────────────────────────── */
854
+
855
+ .sa-fullpage {
856
+ position: fixed;
857
+ inset: 0;
858
+ width: 100vw;
859
+ height: 100vh;
860
+ display: flex;
861
+ background: #f7f7f8;
862
+ z-index: var(--sa-z-index, 9999);
863
+ }
864
+
865
+ /* Sidebar */
866
+ .sa-fp-sidebar {
867
+ width: 260px;
868
+ display: flex;
869
+ flex-direction: column;
870
+ background: #f2f2f3;
871
+ flex-shrink: 0;
872
+ transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
873
+ overflow: hidden;
874
+ border-right: 1px solid #e8e8ea;
875
+ }
876
+
877
+ .sa-fp-sidebar-collapsed {
878
+ width: 52px;
879
+ align-items: center;
880
+ padding-top: 12px;
881
+ gap: 4px;
882
+ border-right: 1px solid #e8e8ea;
883
+ }
884
+
885
+ .sa-fp-sidebar-header {
886
+ display: flex;
887
+ align-items: center;
888
+ gap: 8px;
889
+ padding: 12px 12px 8px;
890
+ flex-shrink: 0;
891
+ }
892
+
893
+ .sa-fp-sidebar-toggle {
894
+ width: 32px;
895
+ height: 32px;
896
+ border: none;
897
+ border-radius: 8px;
898
+ background: transparent;
899
+ color: #71717a;
900
+ cursor: pointer;
901
+ display: flex;
902
+ align-items: center;
903
+ justify-content: center;
904
+ transition: background 0.12s, color 0.12s;
905
+ flex-shrink: 0;
906
+ }
907
+
908
+ .sa-fp-sidebar-toggle:hover {
909
+ background: #e4e4e7;
910
+ color: #18181b;
911
+ }
912
+
913
+ .sa-fp-sidebar-new {
914
+ flex: 1;
915
+ padding: 7px 12px;
916
+ border: 1px solid #d4d4d8;
917
+ border-radius: 8px;
918
+ background: #fff;
919
+ color: #3f3f46;
920
+ font-size: 13px;
921
+ font-weight: 500;
922
+ cursor: pointer;
923
+ display: flex;
924
+ align-items: center;
925
+ gap: 6px;
926
+ transition: border-color 0.12s, box-shadow 0.12s;
927
+ }
928
+
929
+ .sa-fp-sidebar-new:hover {
930
+ border-color: #a1a1aa;
931
+ box-shadow: 0 1px 3px rgba(0,0,0,0.06);
932
+ }
933
+
934
+ .sa-fp-sidebar-new span {
935
+ font-size: 13px;
936
+ }
937
+
938
+ .sa-fp-sidebar-list {
939
+ flex: 1;
940
+ overflow-y: auto;
941
+ padding: 4px 8px 12px;
942
+ }
943
+
944
+ .sa-fp-sidebar-list::-webkit-scrollbar {
945
+ width: 4px;
946
+ }
947
+
948
+ .sa-fp-sidebar-list::-webkit-scrollbar-thumb {
949
+ background: rgba(0,0,0,0.08);
950
+ border-radius: 2px;
951
+ }
952
+
953
+ .sa-fp-sidebar-list::-webkit-scrollbar-thumb:hover {
954
+ background: rgba(0,0,0,0.15);
955
+ }
956
+
957
+ .sa-fp-sidebar-group {
958
+ padding: 12px 8px 4px;
959
+ font-size: 11px;
960
+ font-weight: 500;
961
+ color: #a1a1aa;
962
+ letter-spacing: 0.3px;
963
+ }
964
+
965
+ .sa-fp-sidebar-item {
966
+ display: flex;
967
+ align-items: center;
968
+ gap: 8px;
969
+ padding: 8px 10px;
970
+ margin: 1px 0;
971
+ border-radius: 8px;
972
+ cursor: pointer;
973
+ color: #3f3f46;
974
+ font-size: 13px;
975
+ line-height: 1.4;
976
+ transition: background 0.1s;
977
+ }
978
+
979
+ .sa-fp-sidebar-item:hover {
980
+ background: #e8e8ea;
981
+ }
982
+
983
+ .sa-fp-sidebar-item.active {
984
+ background: #e4e4e7;
985
+ color: #18181b;
986
+ font-weight: 500;
987
+ }
988
+
989
+ .sa-fp-sidebar-item-title {
990
+ flex: 1;
991
+ overflow: hidden;
992
+ white-space: nowrap;
993
+ text-overflow: ellipsis;
994
+ }
995
+
996
+ .sa-fp-sidebar-item-action {
997
+ width: 24px;
998
+ height: 24px;
999
+ border: none;
1000
+ border-radius: 6px;
1001
+ background: transparent;
1002
+ color: #a1a1aa;
1003
+ cursor: pointer;
1004
+ display: flex;
1005
+ align-items: center;
1006
+ justify-content: center;
1007
+ flex-shrink: 0;
1008
+ transition: color 0.1s, background 0.1s;
1009
+ }
1010
+
1011
+ .sa-fp-sidebar-item-action:hover {
1012
+ color: #71717a;
1013
+ background: rgba(0,0,0,0.05);
1014
+ }
1015
+
1016
+ .sa-fp-sidebar-item-action.danger {
1017
+ color: #ef4444;
1018
+ }
1019
+
1020
+ .sa-fp-sidebar-item-action.danger:hover {
1021
+ color: #dc2626;
1022
+ background: rgba(239,68,68,0.08);
1023
+ }
1024
+
1025
+ .sa-fp-sidebar-empty {
1026
+ padding: 32px 12px;
1027
+ text-align: center;
1028
+ color: #a1a1aa;
1029
+ font-size: 13px;
1030
+ }
1031
+
1032
+ /* Sidebar wrapper (for custom ThreadList slot) */
1033
+ .sa-fp-sidebar-wrapper {
1034
+ width: 260px;
1035
+ flex-shrink: 0;
1036
+ overflow: hidden;
1037
+ border-right: 1px solid #e8e8ea;
1038
+ background: #f2f2f3;
1039
+ transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
1040
+ }
1041
+
1042
+ .sa-fp-sidebar-wrapper-collapsed {
1043
+ width: 0;
1044
+ }
1045
+
1046
+ /* Main area */
1047
+ .sa-fp-main {
1048
+ flex: 1;
1049
+ display: flex;
1050
+ flex-direction: column;
1051
+ min-width: 0;
1052
+ background: #fff;
1053
+ }
1054
+
1055
+ .sa-fp-header {
1056
+ display: flex;
1057
+ align-items: center;
1058
+ gap: 12px;
1059
+ padding: 10px 16px;
1060
+ border-bottom: 1px solid #f0f0f0;
1061
+ background: #fff;
1062
+ flex-shrink: 0;
1063
+ min-height: 52px;
1064
+ }
1065
+
1066
+ .sa-fp-header-title {
1067
+ flex: 1;
1068
+ font-size: 15px;
1069
+ font-weight: 500;
1070
+ color: #18181b;
1071
+ letter-spacing: -0.2px;
1072
+ }
1073
+
1074
+ .sa-fp-header-actions {
1075
+ display: flex;
1076
+ gap: 4px;
1077
+ }
1078
+
1079
+ .sa-fp-header-btn {
1080
+ width: 34px;
1081
+ height: 34px;
1082
+ border: none;
1083
+ border-radius: 8px;
1084
+ background: transparent;
1085
+ color: #71717a;
1086
+ cursor: pointer;
1087
+ display: flex;
1088
+ align-items: center;
1089
+ justify-content: center;
1090
+ transition: background 0.12s, color 0.12s;
1091
+ }
1092
+
1093
+ .sa-fp-header-btn:hover {
1094
+ background: #f4f4f5;
1095
+ color: #18181b;
1096
+ }
1097
+
1098
+ /* Fullpage thread/composer override */
1099
+ .sa-fp-main .sa-thread {
1100
+ margin: 0 auto;
1101
+ width: 100%;
1102
+ padding: 24px 24px;
1103
+ }
1104
+
1105
+ .sa-fp-main .sa-composer {
1106
+ margin: 0 auto;
1107
+ width: 100%;
1108
+ padding: 12px 24px 20px;
1109
+ border-top: none;
1110
+ background: transparent;
1111
+ }
1112
+
1113
+ .sa-fp-main .sa-composer-input {
1114
+ background: #f7f7f8;
1115
+ border: 1px solid #e4e4e7;
1116
+ box-shadow: none;
1117
+ }
1118
+
1119
+ .sa-fp-main .sa-composer-input:focus {
1120
+ background: #fff;
1121
+ border-color: #d4d4d8;
1122
+ box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
1123
+ }
1124
+ `,fe={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:380,panelHeight:520,zIndex:9999};function ue(a){const s={...fe,...a};return[`--sa-primary: ${s.primaryColor}`,`--sa-bg: ${s.backgroundColor}`,`--sa-font: ${s.fontFamily}`,`--sa-radius: ${s.borderRadius}px`,`--sa-panel-width: ${s.panelWidth}px`,`--sa-panel-height: ${s.panelHeight}px`,`--sa-z-index: ${s.zIndex}`].join("; ")}function ke(a,s){const l=typeof a=="string"?document.querySelector(a):a;if(!l)throw new Error(`Target element not found: ${a}`);const r=document.createElement("div");r.setAttribute("data-super-agent-widget","");const t=ue(s.theme??{});if(r.setAttribute("style",t),l.appendChild(r),!document.getElementById("sa-widget-styles")){const o=document.createElement("style");o.id="sa-widget-styles",o.textContent=pe,document.head.appendChild(o)}let i=_(r),d=!1;const n=o=>{i&&i.render(c.createElement(de,{...s,initialOpen:o??d,onOpenChange:x=>{d=x}}))};return n(!1),{open(){d=!0,n(!0)},close(){d=!1,n(!1)},destroy(){i&&(i.unmount(),i=null),r.remove()}}}exports.ActionBar=ie;exports.ChatProvider=H;exports.ChatWidget=de;exports.Composer=W;exports.ErrorPart=ne;exports.FullpageLayout=ce;exports.Header=Z;exports.Icon=k;exports.Message=oe;exports.TextPart=se;exports.ThinkingPart=ae;exports.Thread=B;exports.ThreadList=Q;exports.ToolCallPart=te;exports.ToolResultPart=re;exports.Trigger=G;exports.WelcomeScreen=le;exports.defaultTheme=fe;exports.mount=ke;exports.themeToCSSVars=ue;exports.useAutoScroll=ee;exports.useChat=Y;exports.useChatContext=T;exports.useConversations=J;exports.widgetStyles=pe;