super-agent-sdk 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),Me=require("react-dom/client"),e=require("react/jsx-runtime");function te(t){const{sdk:a,sessionId:r,onSessionCreated:n,onStreamStart:s,onStreamEnd:i,onError:l,onMessageSend:c}=t,[d,p]=o.useState([]),[u,m]=o.useState("ready"),[w,f]=o.useState(null),x=o.useRef(null),v=o.useRef(!1),z=o.useRef(null),S=o.useRef(r),E=o.useRef(!0);S.current=r,E.current=d.length===0;const g=o.useCallback(j=>{if(v.current)return;v.current=!0,c==null||c(j);const D={id:`user_${Date.now()}`,role:"user",parts:[{type:"text",content:j}],timestamp:Date.now()},y=`assistant_${Date.now()}`,h={id:y,role:"assistant",parts:[],timestamp:Date.now()},$=E.current;p(k=>[...k,D,h]),m("submitted"),f(null);const M=k=>{let R="",b="",A=[],P=!1;const H=()=>{const T=[...A];if(R){const O=T.findIndex(B=>B.type==="thinking");O>=0?T[O]={type:"thinking",content:R}:T.unshift({type:"thinking",content:R})}if(b){const O=T[T.length-1];(O==null?void 0:O.type)==="text"?T[T.length-1]={type:"text",content:b}:T.push({type:"text",content:b})}p(O=>O.map(B=>B.id===y?{...B,parts:T}:B))};x.current=a.chat({sessionId:k,message:j,stream:!0,onMessage:T=>{switch(P||(P=!0,m("streaming")),T.type){case"thinking":R+=T.content;break;case"ai":b+=T.content;break;case"tool_call":b&&(A.push({type:"text",content:b}),b=""),A.push({type:"tool_call",toolName:T.toolName,toolCallId:T.toolCallId,args:T.args??"{}"});break;case"tool_result":b&&(A.push({type:"text",content:b}),b=""),A.push({type:"tool_result",toolName:T.toolName??"",toolCallId:T.toolCallId,content:T.content,artifacts:T.artifacts,renderMode:T.renderMode,html:T.html});break;case"interrupt":b&&(A.push({type:"text",content:b}),b=""),T.interrupt&&A.push({type:"interrupt",interrupt:T.interrupt,resolved:!1});break;case"stop":T.content&&(b=T.content),H();return}H()},onDone:T=>{(b||A.length>0||R)&&H(),T.sessionId&&T.sessionId!==S.current&&(n==null||n(T.sessionId));const O=()=>{z.current&&(clearTimeout(z.current),z.current=null),i==null||i(T.sessionId||k),m("ready"),v.current=!1,x.current=null};if($){const B=j.slice(0,30),Te=T.sessionId||k;a.renameConversation(Te,B).catch(()=>{}).finally(O)}else O()},onError:T=>{A.push({type:"error",content:T.message}),H(),z.current&&(clearTimeout(z.current),z.current=null),f(T),m("error"),l==null||l(T),v.current=!1,x.current=null}}),s==null||s(k)};S.current?M(S.current):a.createSession().then(k=>{S.current=k,n==null||n(k),M(k)}).catch(k=>{f(k instanceof Error?k:new Error(String(k))),m("error"),l==null||l(k instanceof Error?k:new Error(String(k))),v.current=!1})},[a,n,s,i,l,c]),C=o.useCallback(()=>{const j=S.current;j&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{var D;z.current=null,(D=x.current)==null||D.abort(),x.current=null,v.current=!1,m("ready")},8e3),a.stopGeneration(j).catch(()=>{}))},[a]),I=o.useCallback(()=>{if(v.current)return;const j=d.findLastIndex(y=>y.role==="user");if(j<0)return;const D=d[j].parts.filter(y=>y.type==="text").map(y=>y.content).join("");p(y=>y.slice(0,j)),g(D)},[d,g]),L=o.useCallback((j,D)=>{p(b=>b.map(A=>({...A,parts:A.parts.map(P=>P.type==="interrupt"&&P.interrupt.interruptId===j?{...P,resolved:!0,response:D}:P)})));const y=S.current;if(!y)return;let h=0;p(b=>b.length>0&&b[b.length-1].role==="assistant"?(h=b[b.length-1].parts.length,b):(h=0,[...b,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),m("streaming");let $="",M="",k=[];const R=()=>{const b=[...k];if($){const A=b.findIndex(P=>P.type==="thinking");A>=0?b[A]={type:"thinking",content:$}:b.unshift({type:"thinking",content:$})}if(M){const A=b[b.length-1];(A==null?void 0:A.type)==="text"?b[b.length-1]={type:"text",content:M}:b.push({type:"text",content:M})}p(A=>{const P=A.findLastIndex(H=>H.role==="assistant");return P<0?A:A.map((H,T)=>T===P?{...H,parts:[...H.parts.slice(0,h),...b]}:H)})};a.respondInterrupt(j,y,D,b=>{switch(b.type){case"thinking":$+=b.content;break;case"ai":M+=b.content;break;case"tool_call":M&&(k.push({type:"text",content:M}),M=""),k.push({type:"tool_call",toolName:b.toolName,toolCallId:b.toolCallId,args:b.args??"{}"});break;case"tool_result":M&&(k.push({type:"text",content:M}),M=""),k.push({type:"tool_result",toolName:b.toolName??"",toolCallId:b.toolCallId,content:b.content,artifacts:b.artifacts,renderMode:b.renderMode,html:b.html});break;case"interrupt":M&&(k.push({type:"text",content:M}),M=""),b.interrupt&&k.push({type:"interrupt",interrupt:b.interrupt,resolved:!1});break;case"done":i==null||i(y),m("ready");break}R()},b=>{k.push({type:"error",content:b.message}),R(),f(b),m("error"),l==null||l(b)}).catch(b=>{l==null||l(b instanceof Error?b:new Error(String(b))),m("error")})},[a,l,i]);return{messages:d,status:u,error:w,sendMessage:g,stop:C,regenerate:I,setMessages:p,respondToInterrupt:L}}const ae="sa_active_conversation",Y=20;function G(t){try{return localStorage.getItem(`${ae}_${t}`)}catch{return null}}function $e(t,a){try{const r=`${ae}_${t}`;a?localStorage.setItem(r,a):localStorage.removeItem(r)}catch{}}function se(t){const{sdk:a,onConversationChange:r}=t,n=a.botId,[s,i]=o.useState([]),[l,c]=o.useState(()=>G(n)),[d,p]=o.useState(!1),[u,m]=o.useState(!0),w=o.useRef(!0),f=o.useRef(1),x=o.useRef(!1);o.useEffect(()=>()=>{w.current=!1},[]);const v=o.useCallback(j=>{c(j),$e(n,j),j&&(r==null||r(j))},[n,r]),z=o.useCallback(async()=>{if(!x.current){x.current=!0,p(!0);try{f.current=1;const j=await a.listConversations({page:1,size:Y});if(!w.current)return;i(j.items),m(j.items.length<j.total);const D=G(n);D&&!j.items.find(y=>y.sessionId===D)&&v(null)}catch{}finally{x.current=!1,w.current&&p(!1)}}},[a,v]),S=o.useCallback(async()=>{if(!(x.current||!u)){x.current=!0,p(!0);try{const j=f.current+1,D=await a.listConversations({page:j,size:Y});if(!w.current)return;f.current=j,i(h=>{const $=new Set(h.map(k=>k.sessionId)),M=D.items.filter(k=>!$.has(k.sessionId));return[...h,...M]});const y=f.current*Y;m(y<D.total)}catch{}finally{x.current=!1,w.current&&p(!1)}}},[a,u]),E=o.useCallback(async j=>(v(j),await a.getMessages(j)),[a,v]),g=o.useCallback(async()=>{try{const j=await a.createSession(),D=new Date().toISOString();i(y=>[{sessionId:j,botId:0,title:"新对话",createTime:D,updateTime:D},...y]),v(j)}catch{v(null)}},[a,v]),C=o.useCallback(async j=>{i(D=>D.filter(y=>y.sessionId!==j)),l===j&&v(null);try{await a.deleteConversation(j)}catch{}},[a,l,v]),I=o.useCallback(async(j,D)=>{await a.renameConversation(j,D),i(y=>y.map(h=>h.sessionId===j?{...h,title:D}:h))},[a]),{enabled:L=!0}=t;return o.useEffect(()=>{L&&z()},[L,z]),{conversations:s,activeConversationId:l,loading:d,hasMore:u,loadConversations:z,loadMore:S,switchConversation:E,newConversation:g,deleteConversation:C,renameConversation:I,setActiveConversationId:v}}function re(t){return!t&&t!==0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function ne(t){return t==="pdf"?"PDF":t==="docx"?"DOC":t==="html"?"HTM":t.slice(0,3).toUpperCase()||"FILE"}function ie(t){if(!t)return[];const a=[];for(const r of t)r.type==="file"&&r.data&&a.push({id:r.data.id??"",type:r.data.fileType??r.data.type??"",filename:r.data.name??r.data.filename??"",url:r.data.url??"",mime:r.data.mime,size:r.data.size,summary:r.data.summary});return a}async function K(t){try{const a=await fetch(t.url);if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),n=URL.createObjectURL(r),s=document.createElement("a");s.href=n,s.download=t.filename,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(n),4e3)}catch{const a=document.createElement("a");a.href=t.url,a.download=t.filename,a.target="_blank",document.body.appendChild(a),a.click(),a.remove()}}const oe=o.createContext(null);function _(){const t=o.useContext(oe);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}function U({sdk:t,hooks:a,children:r}){const[n,s]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(!1),[m,w]=o.useState(!1);o.useEffect(()=>{t.getToken().then(()=>{u(!0)}).catch(()=>{u(!0)})},[t]);const f=se({sdk:t,onConversationChange:a==null?void 0:a.onConversationChange,enabled:p}),x=te({sdk:t,sessionId:f.activeConversationId,onSessionCreated:h=>{f.setActiveConversationId(h)},onStreamStart:a==null?void 0:a.onStreamStart,onStreamEnd:h=>{var $;($=a==null?void 0:a.onStreamEnd)==null||$.call(a,h),f.loadConversations()},onError:a==null?void 0:a.onError,onMessageSend:a==null?void 0:a.onMessageSend}),v=o.useCallback(async h=>{w(!0);try{const $=await f.switchConversation(h);x.setMessages($),s(!1)}finally{w(!1)}},[f,x]),z=o.useCallback(async()=>{x.setMessages([]),s(!1),await f.newConversation()},[f,x]),S=o.useCallback(async h=>{f.activeConversationId===h&&x.setMessages([]),await f.deleteConversation(h)},[f,x]);o.useEffect(()=>{f.activeConversationId&&x.messages.length===0&&(w(!0),t.getMessages(f.activeConversationId).then(h=>{x.setMessages(h)}).catch(()=>{}).finally(()=>w(!1)))},[]);const E=o.useCallback(()=>{s(h=>!h)},[]),g=o.useCallback(()=>{l(h=>!h),d(h=>null)},[]),C=o.useCallback(h=>{d(h),l(!0)},[]),I=o.useMemo(()=>{const h=new Set,$=[];for(const M of x.messages)for(const k of M.parts)if(k.type==="tool_result"&&k.artifacts)for(const R of ie(k.artifacts)){const b=R.id||`${R.url}:${R.filename}`;h.has(b)||(h.add(b),$.push(R))}return $},[x.messages]),L=o.useCallback(async()=>{const h=f.activeConversationId;if(!h)return null;try{const $=await t.getMessages(h);x.setMessages($);const M=$.findLast(k=>k.role==="assistant");return(M==null?void 0:M.id)??null}catch{return null}},[t,f.activeConversationId,x]),j=o.useCallback((h,$,M)=>{if(/^\d+$/.test(h)){t.feedback(h,$,M).catch(()=>{});return}L().then(k=>{k&&t.feedback(k,$,M).catch(()=>{})})},[t,L]),D=o.useCallback(h=>{if(/^\d+$/.test(h)){t.cancelFeedback(h).catch(()=>{});return}L().then($=>{$&&t.cancelFeedback($).catch(()=>{})})},[t,L]),y=o.useMemo(()=>({sdk:t,status:x.status,error:x.error,messages:x.messages,conversations:f.conversations,activeConversationId:f.activeConversationId,isThreadListOpen:n,isArtifactDrawerOpen:i,allArtifacts:I,activePreviewArtifact:c,hasMore:f.hasMore,conversationsLoading:f.loading,messagesLoading:m,sendMessage:x.sendMessage,stop:x.stop,regenerate:x.regenerate,switchConversation:v,newConversation:z,deleteConversation:S,renameConversation:f.renameConversation,loadMoreConversations:f.loadMore,toggleThreadList:E,toggleArtifactDrawer:g,openArtifactPreview:C,feedback:j,cancelFeedback:D,respondToInterrupt:x.respondToInterrupt}),[t,x.status,x.error,x.messages,x.sendMessage,x.stop,x.regenerate,x.respondToInterrupt,f.conversations,f.activeConversationId,f.renameConversation,f.hasMore,f.loadMore,f.loading,n,i,I,c,m,v,z,S,E,g,C,j,D]);return e.jsx(oe.Provider,{value:y,children:r})}const Ee="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let J=!1;function le(t=Ee){if(J||typeof document>"u")return;J=!0;const a=t.split("?")[0].split("/").pop();if(a&&document.querySelector(`script[src*="${a}"]`))return;const r=document.createElement("script");r.src=t,document.head.appendChild(r)}le();function N({name:t,size:a=16,color:r="currentColor",className:n,style:s}){return e.jsx("svg",{className:n,style:{width:a,height:a,fill:r,verticalAlign:"middle",...s},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${t}`})})}function ce({isOpen:t,onClick:a}){return e.jsx("button",{className:`sa-trigger ${t?"sa-trigger-open":""}`,onClick:a,children:t?e.jsx(N,{name:"x",size:24,color:"#fff"}):e.jsx(N,{name:"message-square",size:24,color:"#fff"})})}function de({title:t,onClose:a,onToggleThreadList:r,showClose:n=!0,artifactCount:s=0,onToggleArtifactDrawer:i}){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:t}),e.jsx("div",{className:"sa-header-status",children:"● Online"})]})]}),e.jsxs("div",{className:"sa-header-actions",children:[s>0&&i&&e.jsxs("button",{className:"sa-header-btn sa-header-btn-artifact",onClick:i,title:"会话产物",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{children:"产物"})]}),e.jsx("button",{className:"sa-header-btn",onClick:r,title:"会话列表",children:e.jsx(N,{name:"menu",size:16})}),n&&e.jsx("button",{className:"sa-header-btn",onClick:a,title:"关闭",children:e.jsx(N,{name:"x",size:16})})]})]})}const q=t=>String(t).padStart(2,"0");function pe(t){if(!t)return"";const a=new Date(t);return isNaN(a.getTime())?"":`${a.getFullYear()}-${q(a.getMonth()+1)}-${q(a.getDate())} ${q(a.getHours())}:${q(a.getMinutes())}:${q(a.getSeconds())}`}function De(t){const a=new Date,r=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),n=r-6*864e5,s=[],i=[],l=[];for(const d of t){const p=new Date(d.updateTime).getTime();p>=r?s.push(d):p>=n?i.push(d):l.push(d)}const c=[];return s.length&&c.push({label:"今天",items:s}),i.length&&c.push({label:"最近 7 天",items:i}),l.length&&c.push({label:"更早",items:l}),c}function ue(){const{conversations:t,activeConversationId:a,switchConversation:r,newConversation:n,deleteConversation:s,renameConversation:i,isThreadListOpen:l,toggleThreadList:c,hasMore:d,loadMoreConversations:p,conversationsLoading:u}=_(),[m,w]=o.useState(null),[f,x]=o.useState(""),v=o.useRef(null),z=o.useCallback((C,I)=>{w(C),x(I??"")},[]),S=o.useCallback(C=>{f.trim()&&i(C,f.trim()),w(null)},[f,i]),E=o.useCallback(()=>{const C=v.current;!C||!d||C.scrollHeight-C.scrollTop-C.clientHeight<50&&p()},[d,p]),g=o.useMemo(()=>De(t),[t]);return l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-thread-list-overlay",onClick:c}),e.jsxs("div",{className:"sa-thread-list",children:[e.jsxs("div",{className:"sa-thread-list-header",children:[e.jsx("span",{className:"sa-thread-list-title",children:"会话记录"}),e.jsxs("button",{className:"sa-thread-list-new",onClick:n,children:[e.jsx(N,{name:"plus",size:14})," 新会话"]})]}),e.jsxs("div",{className:"sa-thread-list-items",ref:v,onScroll:E,children:[u&&t.length===0&&e.jsx("div",{className:"sa-thread-list-loading",children:"加载中..."}),!u&&t.length===0&&e.jsx("div",{className:"sa-thread-list-empty",children:"暂无会话"}),g.map(C=>e.jsxs("div",{className:"sa-thread-group",children:[e.jsx("div",{className:"sa-thread-group-label",children:C.label}),C.items.map(I=>e.jsxs("div",{className:`sa-thread-item ${I.sessionId===a?"active":""}`,onClick:()=>{m!==I.sessionId&&r(I.sessionId)},children:[m===I.sessionId?e.jsx("input",{className:"sa-thread-item-edit",value:f,onChange:L=>x(L.target.value),onBlur:()=>S(I.sessionId),onKeyDown:L=>{L.key==="Enter"&&S(I.sessionId),L.key==="Escape"&&w(null)},onClick:L=>L.stopPropagation(),autoFocus:!0}):e.jsxs("div",{className:"sa-thread-item-info",children:[e.jsx("span",{className:"sa-thread-item-title",children:I.title||"新会话"}),e.jsx("span",{className:"sa-thread-item-time",children:pe(I.updateTime)})]}),e.jsxs("div",{className:"sa-thread-item-actions",children:[e.jsx("button",{className:"sa-thread-item-action-btn",onClick:L=>{L.stopPropagation(),z(I.sessionId,I.title)},title:"重命名",children:e.jsx(N,{name:"pen",size:13})}),e.jsx("button",{className:"sa-thread-item-action-btn",onClick:L=>{L.stopPropagation(),s(I.sessionId)},title:"删除",children:e.jsx(N,{name:"trash2",size:13})})]})]},I.sessionId))]},C.label)),u&&t.length>0&&e.jsx("div",{className:"sa-thread-list-loading",children:d?"加载更多...":"加载中..."}),!u&&d&&e.jsx("div",{className:"sa-thread-list-hint",children:"向下滚动加载更多"})]})]})]}):null}function fe(t){const a=o.useRef(null),r=o.useRef(!1),n=o.useRef(0),s=o.useCallback(()=>{const l=a.current;if(!l)return;const{scrollTop:c,scrollHeight:d,clientHeight:p}=l,u=d-c-p<40;c<n.current&&!u&&(r.current=!0),u&&(r.current=!1),n.current=c},[]);o.useEffect(()=>{const l=a.current;if(l)return l.addEventListener("scroll",s,{passive:!0}),()=>l.removeEventListener("scroll",s)},[s]),o.useEffect(()=>{if(r.current)return;const l=a.current;l&&requestAnimationFrame(()=>{l.scrollTop=l.scrollHeight})},t);const i=o.useCallback(()=>{r.current=!1;const l=a.current;l&&(l.scrollTop=l.scrollHeight)},[]);return{containerRef:a,scrollToBottom:i}}function F(t){return t.value++}function W(t,a){const r=[],n=[],s=()=>{n.length>0&&(r.push(n.join("")),n.length=0)};let i=0;for(;i<t.length;){const l=t[i];if(l==="`"){const c=t.indexOf("`",i+1);if(c!==-1){s(),r.push(e.jsx("code",{className:"sa-inline-code",children:t.slice(i+1,c)},F(a))),i=c+1;continue}}else if(l==="*"&&t[i+1]==="*"){const c=t.indexOf("**",i+2);if(c!==-1){s(),r.push(e.jsx("strong",{children:W(t.slice(i+2,c),a)},F(a))),i=c+2;continue}}else if(l==="*"){const c=t.indexOf("*",i+1);if(c!==-1){s(),r.push(e.jsx("em",{children:W(t.slice(i+1,c),a)},F(a))),i=c+1;continue}}else if(l==="["){const c=t.indexOf("]",i+1);if(c!==-1&&t[c+1]==="("){const d=t.indexOf(")",c+2);if(d!==-1){const p=t.slice(i+1,c),u=t.slice(c+2,d);s(),r.push(e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:W(p,a)},F(a))),i=d+1;continue}}}n.push(l),i++}return s(),r}function Re(t,a){const r=[],n=t.split(`
2
- `);let s=0;const i=d=>d.trim()==="",l=d=>/^#{1,6}\s+\S/.test(d.trim()),c=d=>/^(?:[-*+]|\d+[.)])\s+\S/.test(d.trim());for(;s<n.length;){const d=n[s],p=d.trim();if(i(d)){s++;continue}if(l(d)){const m=p.match(/^(#{1,6})\s+(.*)$/);if(m){const f=`h${Math.min(m[1].length,6)}`;r.push(o.createElement(f,{key:F(a)},W(m[2],a)))}s++;continue}if(c(d)){const m=/^\d+[.)]/.test(p),w=[];for(;s<n.length&&c(n[s]);){const f=n[s].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);f&&w.push(e.jsx("li",{children:W(f[1],a)},F(a))),s++}r.push(m?e.jsx("ol",{className:"sa-list",children:w},F(a)):e.jsx("ul",{className:"sa-list",children:w},F(a)));continue}const u=[];for(;s<n.length&&!i(n[s])&&!l(n[s])&&!c(n[s]);)u.push(n[s]),s++;r.push(e.jsx("p",{className:"sa-text-paragraph",children:W(u.join(" "),a)},F(a)))}return r}function Le(t){const a={value:0},r=[],n=t.split("```");for(let s=0;s<n.length;s++)if(s%2===0)r.push(...Re(n[s],a));else if(n[s].trim()!==""){let i=n[s].replace(/^\r?\n/,"");i=i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/,""),i=i.replace(/\r?\n$/,""),r.push(e.jsx("pre",{className:"sa-code-block",children:e.jsx("code",{children:i})},F(a)))}return r}function xe({content:t}){return e.jsx("div",{className:"sa-text-part",children:Le(t)})}function me({content:t}){const[a,r]=o.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>r(!a),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(N,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${a?"expanded":""}`,children:e.jsx(N,{name:"chevron-right",size:12})})]}),a&&e.jsx("div",{className:"sa-thinking-content",children:t})]})}function he({toolName:t,toolCallId:a,args:r}){const[n,s]=o.useState(!1),[i,l]=o.useState(!1);let c=r;try{c=JSON.stringify(JSON.parse(r),null,2)}catch{}const d=o.useCallback(()=>{var p;(p=navigator.clipboard)==null||p.writeText(c).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>{})},[c]);return e.jsxs("div",{className:"sa-tool-call-part",children:[e.jsxs("div",{className:"sa-tool-call-header",onClick:()=>s(!n),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(N,{name:"zap",size:14})}),e.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",t]}),e.jsx("span",{className:`sa-thinking-arrow ${n?"expanded":""}`,children:e.jsx(N,{name:"chevron-right",size:12})})]}),n&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-args",children:c}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsxs("button",{className:"sa-action-btn",onClick:d,title:"复制",children:[e.jsx(N,{name:i?"circle-check":"copy",size:14})," ",i?"已复制":"复制"]})})]})]})}function Z({text:t}){const[a,r]=o.useState(!1),n=()=>{var s;(s=navigator.clipboard)==null||s.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)}).catch(()=>{})};return e.jsxs("button",{className:"sa-action-btn",onClick:n,title:"复制",children:[e.jsx(N,{name:a?"circle-check":"copy",size:14})," ",a?"已复制":"复制"]})}function Ae({html:t}){const[a,r]=o.useState(null);return o.useEffect(()=>{let n=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(s=>{n||r(s.default.sanitize(t,{FORCE_BODY:!0,ADD_ATTR:["target"]}))}),()=>{n=!0}},[t]),a===null?null:e.jsx("div",{className:"sa-tool-result-html-scroll",children:e.jsx("div",{className:"sa-tool-result-html sa-text-part",dangerouslySetInnerHTML:{__html:a}})})}function ge({toolName:t,content:a,artifacts:r,renderMode:n,html:s,artifactPreview:i}){const{openArtifactPreview:l}=_(),c=ie(r);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(N,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:t||"工具返回"})]}),n==="html"&&s?e.jsxs(e.Fragment,{children:[e.jsx(Ae,{html:s}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Z,{text:s})})]}):a?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-result-content",children:a}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Z,{text:a})})]}):e.jsx("pre",{className:"sa-tool-result-content",children:"—"}),c.length>0&&e.jsx("ul",{className:"sa-artifact-file-list",role:"list",children:c.map((d,p)=>e.jsxs("li",{className:"sa-artifact-file-card",onClick:i?()=>l(d):void 0,onKeyDown:i?u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l(d))}:void 0,tabIndex:i?0:void 0,role:i?"button":void 0,"aria-label":i?`预览 ${d.filename}`:void 0,style:i?{cursor:"pointer"}:void 0,children:[e.jsx("div",{className:"sa-artifact-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:ne(d.type)})}),e.jsxs("div",{className:"sa-artifact-file-info",children:[e.jsx("span",{className:"sa-artifact-file-name",children:d.filename}),d.size!=null&&e.jsx("span",{className:"sa-artifact-file-size",children:re(d.size)})]}),i&&e.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${d.filename}`,onClick:u=>{u.stopPropagation(),K(d)},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},d.id||`art-${p}`))})]})}function be({content:t,onRetry:a}){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(N,{name:"triangle-alert",size:14})}),e.jsx("span",{children:t})]}),a&&e.jsx("button",{className:"sa-error-retry",onClick:a,children:"重试"})]})}function Pe({interrupt:t,onRespond:a,disabled:r,answeredAction:n}){var c,d;const s=t.options,i=(typeof(s==null?void 0:s[0])=="string"?s[0]:(c=s==null?void 0:s[0])==null?void 0:c.label)||"确认",l=(typeof(s==null?void 0:s[1])=="string"?s[1]:(d=s==null?void 0:s[1])==null?void 0:d.label)||"取消";return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${n==="confirm"?"sa-interrupt-btn-answered":""}`,disabled:r,onClick:()=>a({action:"confirm"}),children:[e.jsx(N,{name:"check",size:14})," ",i]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${n==="cancel"?"sa-interrupt-btn-answered":""}`,disabled:r,onClick:()=>a({action:"cancel"}),children:[e.jsx(N,{name:"x",size:14})," ",l]})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Oe({interrupt:t,onRespond:a,disabled:r,answeredAction:n}){var p,u,m,w;const s=t.options,i=(typeof(s==null?void 0:s[0])=="string"?s[0]:(p=s==null?void 0:s[0])==null?void 0:p.label)||"批准",l=(typeof(s==null?void 0:s[1])=="string"?s[1]:(u=s==null?void 0:s[1])==null?void 0:u.label)||"拒绝",c=(typeof(s==null?void 0:s[2])=="string"?s[2]:(m=s==null?void 0:s[2])==null?void 0:m.label)||"跳过",d=((w=t.metadata)==null?void 0:w.showSkip)!==!1;return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${n==="approve"?"sa-interrupt-btn-answered":""}`,disabled:r,onClick:()=>a({action:"approve"}),children:[e.jsx(N,{name:"check",size:14})," ",i]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-danger ${n==="reject"?"sa-interrupt-btn-answered":""}`,disabled:r,onClick:()=>a({action:"reject"}),children:[e.jsx(N,{name:"x",size:14})," ",l]}),d&&e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${n==="skip"?"sa-interrupt-btn-answered":""}`,disabled:r,onClick:()=>a({action:"skip"}),children:[e.jsx(N,{name:"chevron-right",size:14})," ",c]})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function He(t){return typeof t=="string"?{value:t,label:t}:t}function Fe({interrupt:t,onRespond:a,disabled:r,initialValue:n}){const s=(t.options??[]).map(He);return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"list",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:s.map(i=>{const l=n===i.value;return e.jsxs("button",{className:`sa-interrupt-option ${i.danger?"sa-interrupt-option-danger":""} ${l?"sa-interrupt-option-selected":""}`,disabled:r,onClick:()=>a({action:"select",value:i.value}),children:[e.jsx(N,{name:l?"circle-check":"circle",size:14}),i.icon&&e.jsx(N,{name:i.icon,size:14}),e.jsx("span",{children:i.label}),i.description&&e.jsx("span",{className:"sa-interrupt-option-desc",children:i.description})]},i.value)})}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function _e(t){return typeof t=="string"?{value:t,label:t}:t}function Be({interrupt:t,onRespond:a,disabled:r,initialValue:n}){const s=(t.options??[]).map(_e),[i,l]=o.useState(()=>new Set(Array.isArray(n)?n:[])),c=d=>{r||l(p=>{const u=new Set(p);return u.has(d)?u.delete(d):u.add(d),u})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"list-checks",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:s.map(d=>e.jsxs("button",{className:`sa-interrupt-option ${i.has(d.value)?"sa-interrupt-option-selected":""}`,disabled:r,onClick:()=>c(d.value),children:[e.jsx(N,{name:i.has(d.value)?"square-check":"square",size:14}),e.jsx("span",{children:d.label})]},d.value))}),!r&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:i.size===0,onClick:()=>a({action:"submit",value:Array.from(i)}),children:[e.jsx(N,{name:"check",size:14})," 确认 (",i.size,")"]})}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function We({interrupt:t,onRespond:a,disabled:r,initialValue:n}){const[s,i]=o.useState(n??""),l=t.inputType??"text",c=l==="textarea",d=()=>{r||t.required&&!s.trim()||a({action:"submit",value:s.trim()})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"text-cursor-input",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-input-area",children:c?e.jsx("textarea",{className:"sa-interrupt-textarea",value:s,onChange:p=>i(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,rows:3,disabled:r}):e.jsx("input",{className:"sa-interrupt-input",type:l,value:s,onChange:p=>i(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,onKeyDown:p=>p.key==="Enter"&&d(),disabled:r})}),!r&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:t.required?!s.trim():!1,onClick:d,children:[e.jsx(N,{name:"check",size:14})," 提交"]})}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function qe({interrupt:t,onRespond:a,disabled:r,initialValue:n}){const s=t.fields??[],[i,l]=o.useState(()=>{const u={};for(const m of s)u[m.name]=(n==null?void 0:n[m.name])??m.defaultValue??"";return u}),c=(u,m)=>{r||l(w=>({...w,[u]:m}))},d=!r&&s.every(u=>!u.required||i[u.name]),p=()=>{d&&a({action:"submit",value:i})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(N,{name:"file-text",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-form",children:s.map(u=>e.jsxs("div",{className:"sa-interrupt-form-field",children:[e.jsxs("label",{className:"sa-interrupt-form-label",children:[u.label,u.required&&e.jsx("span",{className:"sa-interrupt-form-required",children:"*"})]}),Ke(u,i[u.name],m=>c(u.name,m),r)]},u.name))}),!r&&e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:!d,onClick:p,children:[e.jsx(N,{name:"check",size:14})," 提交"]}),e.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>a({action:"cancel"}),children:"取消"})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Q(t){return typeof t=="string"?{value:t,label:t}:t}function Ke(t,a,r,n){switch(t.type){case"textarea":return e.jsx("textarea",{className:"sa-interrupt-textarea",value:a,onChange:s=>r(s.target.value),placeholder:t.placeholder,rows:3,disabled:n});case"select":{const s=(t.options??[]).map(Q);return e.jsxs("select",{className:"sa-interrupt-select",value:a,onChange:i=>r(i.target.value),disabled:n,children:[e.jsx("option",{value:"",children:"请选择"}),s.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})}case"multiSelect":{const s=(t.options??[]).map(Q),i=Array.isArray(a)?a:[],l=c=>{n||r(i.includes(c)?i.filter(d=>d!==c):[...i,c])};return e.jsx("div",{className:"sa-interrupt-options",children:s.map(c=>e.jsx("button",{type:"button",className:`sa-interrupt-option ${i.includes(c.value)?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>l(c.value),children:c.label},c.value))})}case"password":return e.jsx("input",{className:"sa-interrupt-input",type:"password",value:a,onChange:s=>r(s.target.value),placeholder:t.placeholder,disabled:n});default:return e.jsx("input",{className:"sa-interrupt-input",type:t.type==="number"?"number":t.type==="date"?"date":"text",value:a,onChange:s=>r(s.target.value),placeholder:t.placeholder,disabled:n})}}function ve({interrupt:t,resolved:a,response:r,onRespond:n}){const s=a,i=r==null?void 0:r.value;switch(t.interruptType){case"confirm":return e.jsx(Pe,{interrupt:t,onRespond:n,disabled:s,answeredAction:r==null?void 0:r.action});case"approve":return e.jsx(Oe,{interrupt:t,onRespond:n,disabled:s,answeredAction:r==null?void 0:r.action});case"select":return e.jsx(Fe,{interrupt:t,onRespond:n,disabled:s,initialValue:i});case"multiSelect":return e.jsx(Be,{interrupt:t,onRespond:n,disabled:s,initialValue:i});case"input":return e.jsx(We,{interrupt:t,onRespond:n,disabled:s,initialValue:i});case"form":return e.jsx(qe,{interrupt:t,onRespond:n,disabled:s,initialValue:i});default:return e.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",t.interruptType]})}}const Ye=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function we({message:t,onCopy:a,onRegenerate:r,onFeedback:n}){const{status:s,cancelFeedback:i}=_(),[l,c]=o.useState(null),[d,p]=o.useState(!1),[u,m]=o.useState(!1),w=o.useRef(null),f=o.useCallback(()=>{a(),p(!0),setTimeout(()=>p(!1),2e3)},[a]),x=o.useCallback(()=>{l==="like"?(c(null),i(t.id)):(c("like"),m(!1),n==null||n(t.id,"like"))},[l,t.id,n,i]),v=o.useCallback(()=>{l==="dislike"?(c(null),m(!1),i(t.id)):m(!0)},[l,t.id,i]),z=o.useCallback((E,g)=>{c("dislike"),m(!1),n==null||n(t.id,"dislike",{reason:E,remark:(g==null?void 0:g.trim())||void 0})},[t.id,n]),S=o.useCallback(()=>{m(!1)},[]);return o.useEffect(()=>{if(!u)return;const E=C=>{w.current&&!w.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",g)}},[u]),s!=="ready"&&s!=="error"?null:e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:f,title:"复制",children:[e.jsx(N,{name:d?"circle-check":"copy",size:14})," ",d?"已复制":"复制"]}),r&&e.jsxs("button",{className:"sa-action-btn",onClick:r,title:"重新生成",children:[e.jsx(N,{name:"refresh-cw",size:14})," 重新生成"]}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sa-action-divider"}),e.jsx("button",{className:`sa-action-btn ${l==="like"?"sa-action-btn-active":""}`,onClick:x,title:"有用","aria-label":"点赞",children:e.jsx(N,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${l==="dislike"?"sa-action-btn-active":""}`,onClick:v,title:"无用","aria-label":"踩","aria-expanded":u,"aria-haspopup":"dialog",children:e.jsx(N,{name:"thumbs-down",size:14})})]}),u&&e.jsx("div",{ref:w,children:e.jsx(Ue,{onSubmit:z,onCancel:S})})]})}function Ue({onSubmit:t,onCancel:a}){const[r,n]=o.useState(void 0),[s,i]=o.useState("");return e.jsxs("div",{className:"sa-dislike-panel",children:[e.jsx("div",{className:"sa-dislike-panel-title",children:"请选择不满意的原因(可选)"}),e.jsx("div",{className:"sa-dislike-reasons",children:Ye.map(l=>e.jsx("button",{className:`sa-dislike-reason-btn ${r===l.value?"active":""}`,onClick:()=>n(r===l.value?void 0:l.value),children:l.label},l.value))}),e.jsx("textarea",{className:"sa-dislike-remark",placeholder:"补充描述(选填,≤500 字)",maxLength:500,value:s,onChange:l=>i(l.target.value),rows:2}),e.jsxs("div",{className:"sa-dislike-actions",children:[e.jsx("button",{className:"sa-dislike-submit",onClick:()=>t(r,s||void 0),children:"提交"}),e.jsx("button",{className:"sa-dislike-cancel",onClick:a,children:"取消"})]})]})}function ee({src:t,role:a}){const r=a==="assistant"?"A":"U";return t?t.startsWith("http")||t.startsWith("/")||t.startsWith("data:")?e.jsx("div",{className:`sa-avatar sa-avatar-${a}`,children:e.jsx("img",{src:t,alt:a,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}})}):e.jsx("div",{className:`sa-avatar sa-avatar-${a}`,children:t}):e.jsx("div",{className:`sa-avatar sa-avatar-${a}`,children:r})}function ye({message:t,isStreaming:a,isLast:r,slots:n,avatar:s,artifactPreview:i}){const{regenerate:l,feedback:c,respondToInterrupt:d}=_(),p=o.useCallback(()=>{var C;const g=t.parts.filter(I=>I.type==="text").map(I=>I.content).join(`
3
- `);(C=navigator.clipboard)==null||C.writeText(g).catch(()=>{})},[t]),u=t.role==="user",m=n.Message;if(m)return e.jsx(m,{message:t,isStreaming:a,isLast:r,avatar:s,slots:n,onCopy:p,onRegenerate:l,onFeedback:c});const w=n.TextPart??xe,f=n.ThinkingPart??me,x=n.ToolCallPart??he,v=n.ToolResultPart??ge,z=n.ErrorPart??be,S=n.ActionBar??we,E=!u&&t.parts.some(g=>g.type==="text"&&g.content);return e.jsxs("div",{className:`sa-message ${u?"sa-message-user":"sa-message-assistant"}`,children:[!u&&e.jsx(ee,{src:s==null?void 0:s.assistant,role:"assistant"}),e.jsxs("div",{className:"sa-message-content",children:[e.jsx("span",{className:`sa-message-time ${u?"sa-message-time-right":""}`,children:pe(t.timestamp)}),e.jsxs("div",{className:"sa-message-body",children:[t.parts.map((g,C)=>{switch(g.type){case"text":return e.jsx(w,{content:g.content},C);case"thinking":return e.jsx(f,{content:g.content},C);case"tool_call":return e.jsx(x,{toolName:g.toolName,toolCallId:g.toolCallId,args:g.args},C);case"tool_result":return e.jsx(v,{toolName:g.toolName,toolCallId:g.toolCallId,content:g.content,artifacts:g.artifacts,renderMode:g.renderMode,html:g.html,artifactPreview:i},C);case"error":return e.jsx(z,{content:g.content,onRetry:l},C);case"interrupt":return e.jsx(ve,{interrupt:g.interrupt,resolved:g.resolved??!1,response:g.response,onRespond:I=>d(g.interrupt.interruptId,I)},C);default:return null}}),a&&r&&!u&&e.jsx("span",{className:"sa-streaming-cursor",children:"|"}),!u&&!a&&E&&e.jsx(S,{message:t,onCopy:p,onRegenerate:r?l:void 0,onFeedback:c})]})]}),u&&e.jsx(ee,{src:s==null?void 0:s.user,role:"user"})]})}function ke({message:t,suggestedPrompts:a,onPromptClick:r}){return e.jsxs("div",{className:"sa-welcome",children:[e.jsx("div",{className:"sa-welcome-icon",children:e.jsx(N,{name:"sparkles",size:40})}),e.jsx("p",{className:"sa-welcome-message",children:t||"你好!有什么可以帮你的?"}),a&&a.length>0&&e.jsx("div",{className:"sa-welcome-prompts",children:a.map((n,s)=>e.jsx("button",{className:"sa-welcome-prompt",onClick:()=>r(n),children:n},s))})]})}function V({slots:t,welcomeMessage:a,suggestedPrompts:r,avatar:n,artifactPreview:s}){const{messages:i,status:l,sendMessage:c}=_(),{containerRef:d}=fe([i]),p=l==="streaming",u=t.WelcomeScreen??ke;return i.length===0?e.jsx("div",{className:"sa-thread",ref:d,children:e.jsx(u,{message:a,suggestedPrompts:r,onPromptClick:c})}):e.jsx("div",{className:"sa-thread",ref:d,children:i.map((m,w)=>e.jsx(ye,{message:m,isStreaming:p,isLast:w===i.length-1,slots:t,avatar:n,artifactPreview:s},m.id))})}function Ve({items:t,activeIndex:a,onSelect:r}){const n=o.useRef(null);return o.useEffect(()=>{var i;const s=(i=n.current)==null?void 0:i.children[a];s==null||s.scrollIntoView({block:"nearest"})},[a]),t.length===0?e.jsx("div",{className:"sa-slash-menu",children:e.jsx("div",{className:"sa-slash-menu-empty",children:"没有匹配的技能"})}):e.jsx("div",{className:"sa-slash-menu",ref:n,children:t.map((s,i)=>e.jsxs("div",{className:`sa-slash-menu-item${i===a?" sa-slash-menu-item--active":""}`,onMouseDown:l=>{l.preventDefault(),r(s)},children:[e.jsxs("span",{className:"sa-slash-menu-item-name",children:["/",s.name]}),(s.displayName||s.description)&&e.jsx("span",{className:"sa-slash-menu-item-desc",children:s.displayName||s.description})]},s.code))})}function Xe({sdk:t,input:a,onSelect:r}){const[n,s]=o.useState([]),[i,l]=o.useState(!1),[c,d]=o.useState(0),p=o.useRef(!1);o.useEffect(()=>{p.current||(p.current=!0,t.listSkills().then(s).catch(()=>s([])))},[t]);const u=/^\/\S*$/.test(a);o.useEffect(()=>{l(u)},[u]),o.useEffect(()=>{u&&d(0)},[a,u]);const m=a.startsWith("/")?a.slice(1).toLowerCase():"",w=o.useMemo(()=>n.filter(g=>!m||g.code.toLowerCase().includes(m)||g.name.toLowerCase().includes(m)||g.displayName&&g.displayName.toLowerCase().includes(m)),[n,m]),f=o.useRef(i),x=o.useRef(w),v=o.useRef(c),z=o.useRef(r);f.current=i,x.current=w,v.current=c,z.current=r;const S=o.useCallback(g=>{if(!f.current||x.current.length===0)return!1;switch(g.key){case"ArrowDown":return g.preventDefault(),d(C=>(C+1)%x.current.length),!0;case"ArrowUp":return g.preventDefault(),d(C=>(C-1+x.current.length)%x.current.length),!0;case"Enter":case"Tab":return g.preventDefault(),z.current(x.current[v.current]),l(!1),!0;case"Escape":return g.preventDefault(),l(!1),!0;default:return!1}},[]),E=o.useCallback(()=>l(!1),[]);return{isOpen:i,items:w,activeIndex:c,handleKeyDown:S,close:E}}function X(){const{status:t,sendMessage:a,stop:r,sdk:n}=_(),[s,i]=o.useState(""),l=o.useRef(null),c=t==="streaming"||t==="submitted",d=o.useCallback(f=>{i(`/${f.name} `),setTimeout(()=>{const x=l.current;x&&(x.focus(),x.selectionStart=x.selectionEnd=x.value.length)},0)},[]),p=Xe({sdk:n,input:s,onSelect:d}),u=o.useCallback(()=>{const f=s.trim();!f||c||(a(f),i(""),l.current&&(l.current.style.height="auto"))},[s,c,a]),m=o.useCallback(f=>{p.handleKeyDown(f)||f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),u())},[u,p.handleKeyDown]),w=o.useCallback(f=>{i(f.target.value);const x=f.target;x.style.height="auto",x.style.height=Math.min(x.scrollHeight,120)+"px"},[]);return e.jsxs("div",{className:"sa-composer",children:[p.isOpen&&e.jsx(Ve,{items:p.items,activeIndex:p.activeIndex,onSelect:d}),e.jsx("textarea",{ref:l,className:"sa-composer-input",value:s,onChange:w,onKeyDown:m,placeholder:c?"回答生成中...":"输入消息,按 / 选择技能...",rows:1,disabled:c}),c?e.jsx("button",{className:"sa-composer-stop",onClick:r,title:"停止",children:e.jsx(N,{name:"circle-stop",size:16,color:"#fff"})}):e.jsx("button",{className:"sa-composer-send",onClick:u,disabled:!s.trim(),title:"发送",children:e.jsx(N,{name:"arrow-up",size:16,color:"#fff"})})]})}function Ge({artifact:t}){const[a,r]=o.useState(null),[n,s]=o.useState(!0),[i,l]=o.useState(null);return o.useEffect(()=>{let c=!1;s(!0),l(null),r(null);async function d(){try{if(t.type==="pdf"){c||s(!1);return}if(t.type==="html"){const p=await fetch(t.url);if(!p.ok)throw new Error(`HTTP ${p.status}`);const u=await p.text(),m=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(r(m.sanitize(u,{FORCE_BODY:!0,ADD_ATTR:["target"]})),s(!1));return}if(t.type==="docx"){const p=await fetch(t.url);if(!p.ok)throw new Error(`HTTP ${p.status}`);const u=await p.arrayBuffer(),w=await(await Promise.resolve().then(()=>require("./mammoth.browser-DiAPPO3x.cjs")).then(x=>x.mammoth_browser)).convertToHtml({arrayBuffer:u}),f=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(r(f.sanitize(w.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),s(!1));return}c||(s(!1),l(`不支持预览「${t.type}」类型`))}catch(p){c||(s(!1),l(p instanceof Error?p.message:"加载失败"))}}return d(),()=>{c=!0}},[t]),n?e.jsx("div",{className:"sa-drawer-preview-loading",children:"加载中"}):i?e.jsxs("div",{className:"sa-drawer-preview-error",children:[i,e.jsx("button",{className:"sa-drawer-btn-sm",onClick:()=>void K(t),children:"下载查看"})]}):t.type==="pdf"?e.jsx("iframe",{src:t.url,title:t.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):a!==null?e.jsx("iframe",{srcDoc:a,title:t.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-same-origin"}):null}function je({artifacts:t,initialArtifact:a,onClose:r}){const[n,s]=o.useState(a?{mode:"preview",artifact:a}:{mode:"list"}),[i,l]=o.useState(!1),c=o.useRef(null),[d,p]=o.useState(340),u=o.useRef(null);o.useEffect(()=>{a&&(c.current&&(clearTimeout(c.current),c.current=null,l(!1)),s({mode:"preview",artifact:a}))},[a]);const m=o.useCallback(()=>{l(!0),c.current=setTimeout(()=>{c.current=null,r()},240)},[r]);o.useEffect(()=>()=>{var v;c.current&&clearTimeout(c.current),(v=u.current)==null||v.call(u)},[]);const w=o.useCallback(v=>{s({mode:"preview",artifact:v})},[]),f=o.useCallback(()=>{s({mode:"list"})},[]);o.useEffect(()=>{const v=z=>{z.key==="Escape"&&m()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[m]);const x=o.useCallback(v=>{v.preventDefault();const z=v.clientX,S=d,E=C=>{const I=z-C.clientX;p(Math.max(240,Math.min(window.innerWidth*.7,S+I)))},g=()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",g),document.body.style.cursor="",document.body.style.userSelect="",u.current=null};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",E),document.addEventListener("mouseup",g),u.current=g},[d]);return e.jsxs("div",{className:`sa-artifact-drawer ${i?"sa-drawer-closing":""}`,style:{width:d},children:[e.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:x}),e.jsxs("div",{className:"sa-artifact-drawer-header",children:[n.mode==="preview"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"sa-drawer-btn",onClick:f,title:"返回列表","aria-label":"返回列表",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsx("span",{className:"sa-artifact-drawer-title",children:n.artifact.filename})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"sa-artifact-drawer-title",children:"会话产物"})]}),e.jsx("div",{style:{flex:1}}),n.mode==="preview"&&e.jsx("button",{className:"sa-drawer-btn",onClick:()=>void K(n.artifact),title:"下载","aria-label":"下载",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),e.jsx("button",{className:"sa-drawer-btn",onClick:m,title:"关闭","aria-label":"关闭",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"sa-artifact-drawer-body",children:n.mode==="list"?t.length===0?e.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):e.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:t.map((v,z)=>e.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>w(v),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w(v))},tabIndex:0,role:"button","aria-label":`预览 ${v.filename}`,children:[e.jsx("div",{className:"sa-drawer-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:ne(v.type)})}),e.jsxs("div",{className:"sa-drawer-file-info",children:[e.jsx("span",{className:"sa-drawer-file-name",children:v.filename}),e.jsx("span",{className:"sa-drawer-file-size",children:re(v.size)})]}),e.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${v.filename}`,onClick:S=>{S.stopPropagation(),K(v)},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},v.id||`artifact-${z}`))}):e.jsx("div",{className:"sa-drawer-view-enter",children:e.jsx(Ge,{artifact:n.artifact})})})]})}function Je({isOpen:t,onClose:a,title:r,slots:n,welcomeMessage:s,suggestedPrompts:i,avatar:l,artifactPreview:c}){const{status:d,sendMessage:p,stop:u,toggleThreadList:m,toggleArtifactDrawer:w,conversations:f,activeConversationId:x,switchConversation:v,newConversation:z,deleteConversation:S,renameConversation:E,isThreadListOpen:g,isArtifactDrawerOpen:C,allArtifacts:I,activePreviewArtifact:L,messagesLoading:j}=_();if(!t)return null;const D=n.Header,y=n.Composer,h=n.ThreadList;return e.jsxs("div",{className:"sa-panel",children:[D?e.jsx(D,{title:r,onClose:a,onToggleThreadList:m}):e.jsx(de,{title:r,onClose:a,onToggleThreadList:m,artifactCount:c?I.length:0,onToggleArtifactDrawer:c?w:void 0}),h&&g?e.jsx(h,{conversations:f,activeSessionId:x,onSwitch:v,onNew:z,onDelete:S,onRename:E}):e.jsx(ue,{}),e.jsxs("div",{className:"sa-panel-content",children:[j?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):e.jsx(V,{slots:n,welcomeMessage:s,suggestedPrompts:i,avatar:l,artifactPreview:c}),c&&C&&e.jsx(je,{artifacts:I,initialArtifact:L,onClose:w})]}),y?e.jsx(y,{status:d,onSend:p,onStop:u}):e.jsx(X,{})]})}function Ze({conversations:t,activeSessionId:a,onSwitch:r,onNew:n,onDelete:s,onRename:i,isCollapsed:l,onToggleCollapse:c,hasMore:d,onLoadMore:p,conversationsLoading:u}){const[m,w]=o.useState(null),[f,x]=o.useState(null),[v,z]=o.useState(null),[S,E]=o.useState(""),g=o.useCallback((y,h)=>{h.stopPropagation(),f===y?(s(y),x(null)):(x(y),setTimeout(()=>x(null),3e3))},[f,s]),C=o.useCallback((y,h,$)=>{$.stopPropagation(),z(y),E(h??"")},[]),I=o.useCallback(y=>{S.trim()&&i(y,S.trim()),z(null)},[S,i]),L=o.useRef(null),j=o.useCallback(()=>{const y=L.current;!y||!d||!p||y.scrollHeight-y.scrollTop-y.clientHeight<50&&p()},[d,p]),D=(()=>{const y=Date.now(),h=[],$=[],M=[];for(const R of t){const b=y-new Date(R.updateTime).getTime();b<864e5?h.push(R):b<6048e5?$.push(R):M.push(R)}const k=[];return h.length&&k.push({label:"今天",items:h}),$.length&&k.push({label:"最近 7 天",items:$}),M.length&&k.push({label:"更早",items:M}),k})();return l?e.jsxs("div",{className:"sa-fp-sidebar sa-fp-sidebar-collapsed",children:[e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:c,title:"展开",children:e.jsx(N,{name:"panel-left",size:18})}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:()=>{n(),c()},title:"新会话",style:{marginTop:4},children:e.jsx(N,{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:n,children:[e.jsx(N,{name:"plus",size:15})," ",e.jsx("span",{children:"新会话"})]}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:c,title:"收起侧边栏",children:e.jsx(N,{name:"panel-left-close",size:18})})]}),e.jsxs("div",{className:"sa-fp-sidebar-list",ref:L,onScroll:j,children:[u&&t.length===0&&e.jsx("div",{className:"sa-thread-list-loading",children:"加载中..."}),!u&&t.length===0&&e.jsx("div",{className:"sa-fp-sidebar-empty",children:"开始你的第一个对话"}),D.map(y=>e.jsxs("div",{children:[e.jsx("div",{className:"sa-fp-sidebar-group",children:y.label}),y.items.map(h=>{const $=h.sessionId===a,M=m===h.sessionId,k=f===h.sessionId;return e.jsxs("div",{className:`sa-fp-sidebar-item ${$?"active":""}`,onClick:()=>{v!==h.sessionId&&r(h.sessionId)},onMouseEnter:()=>w(h.sessionId),onMouseLeave:()=>w(null),children:[v===h.sessionId?e.jsx("input",{className:"sa-fp-sidebar-item-edit",value:S,onChange:R=>E(R.target.value),onBlur:()=>I(h.sessionId),onKeyDown:R=>{R.key==="Enter"&&I(h.sessionId),R.key==="Escape"&&z(null)},onClick:R=>R.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"sa-fp-sidebar-item-title",children:h.title||"新会话"}),e.jsxs("div",{className:`sa-fp-sidebar-item-actions ${M&&v!==h.sessionId?"visible":""}`,children:[e.jsx("button",{className:"sa-fp-sidebar-item-action",onClick:R=>C(h.sessionId,h.title,R),title:"重命名",children:e.jsx(N,{name:"pen",size:14})}),e.jsx("button",{className:`sa-fp-sidebar-item-action ${k?"danger":""}`,onClick:R=>g(h.sessionId,R),title:k?"确认删除":"删除",children:e.jsx(N,{name:k?"x":"trash2",size:14})})]})]},h.sessionId)})]},y.label)),d&&e.jsx("div",{className:"sa-thread-list-loading",children:"加载更多..."})]})]})}function Ce({title:t,slots:a,welcomeMessage:r,suggestedPrompts:n,sidebarDefaultOpen:s=!0,onClose:i,avatar:l,artifactPreview:c}){const{status:d,sendMessage:p,stop:u,conversations:m,activeConversationId:w,switchConversation:f,newConversation:x,deleteConversation:v,renameConversation:z,toggleArtifactDrawer:S,isArtifactDrawerOpen:E,allArtifacts:g,activePreviewArtifact:C,hasMore:I,loadMoreConversations:L,conversationsLoading:j,messagesLoading:D}=_(),[y,h]=o.useState(s),$=o.useCallback(()=>h(R=>!R),[]),M=a.ThreadList,k=a.Composer;return e.jsxs("div",{className:"sa-fullpage",children:[M?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${y?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(M,{conversations:m,activeSessionId:w,onSwitch:f,onNew:x,onDelete:v,onRename:z,hasMore:I,onLoadMore:L})}):e.jsx(Ze,{conversations:m,activeSessionId:w,onSwitch:f,onNew:x,onDelete:v,onRename:z,isCollapsed:!y,onToggleCollapse:$,hasMore:I,onLoadMore:L,conversationsLoading:j}),e.jsxs("div",{className:"sa-fp-main",children:[e.jsxs("div",{className:"sa-fp-header",children:[!y&&!M&&e.jsx("button",{className:"sa-fp-header-btn",onClick:$,title:"展开侧边栏",children:e.jsx(N,{name:"panel-left",size:18})}),e.jsx("div",{className:"sa-fp-header-title",children:t}),e.jsxs("div",{className:"sa-fp-header-actions",children:[c&&g.length>0&&e.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:S,title:"会话产物",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{children:"产物"})]}),i&&e.jsx("button",{className:"sa-fp-header-btn",onClick:i,title:"关闭",children:e.jsx(N,{name:"x",size:18})})]})]}),e.jsxs("div",{className:"sa-fp-content-row",children:[D?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):e.jsx(V,{slots:a,welcomeMessage:r,suggestedPrompts:n,avatar:l,artifactPreview:c}),c&&E&&e.jsx(je,{artifacts:g,initialArtifact:C,onClose:S})]}),k?e.jsx(k,{status:d,onSend:p,onStop:u}):e.jsx(X,{})]})]})}function Ne(t){const{sdk:a,mode:r="floating",slots:n={},hooks:s={},welcomeMessage:i,suggestedPrompts:l,title:c="AI Assistant",initialOpen:d=!1,onOpenChange:p,sidebarDefaultOpen:u,avatar:m,artifactPreview:w}=t,[f,x]=o.useState(d);o.useEffect(()=>{x(d)},[d]);const v=o.useCallback(()=>{var g,C;const E=!f;x(E),p==null||p(E),E?(g=s.onOpen)==null||g.call(s):(C=s.onClose)==null||C.call(s)},[f,s,p]),z=o.useCallback(()=>{var E;x(!1),p==null||p(!1),(E=s.onClose)==null||E.call(s)},[s,p]),S=n.Trigger??ce;return r==="fullpage"?f?e.jsx(U,{sdk:a,hooks:s,children:e.jsx(Ce,{title:c,slots:n,welcomeMessage:i,suggestedPrompts:l,sidebarDefaultOpen:u,onClose:z,avatar:m,artifactPreview:w})}):null:e.jsxs(U,{sdk:a,hooks:s,children:[e.jsx(S,{isOpen:f,onClick:v}),e.jsx(Je,{isOpen:f,onClose:z,title:c,slots:n,welcomeMessage:i,suggestedPrompts:l,avatar:m,artifactPreview:w})]})}const ze=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),lt=require("react-dom/client"),e=require("react/jsx-runtime");function Se(t){const{sdk:a,sessionId:n,onSessionCreated:i,onStreamStart:r,onStreamEnd:o,onError:d,onMessageSend:l}=t,[c,p]=s.useState([]),[f,x]=s.useState("ready"),[m,b]=s.useState(null),y=s.useRef(null),u=s.useRef(!1),h=s.useRef(null),k=s.useRef(n),T=s.useRef(!0);k.current=n,T.current=c.length===0;const v=s.useCallback(w=>{if(u.current)return;u.current=!0,l==null||l(w);const z={id:`user_${Date.now()}`,role:"user",parts:[{type:"text",content:w}],timestamp:Date.now()},A=`assistant_${Date.now()}`,R={id:A,role:"assistant",parts:[],timestamp:Date.now()},$=T.current;p(M=>[...M,z,R]),x("submitted"),b(null);const L=M=>{let E="",g="",N=[],_=!1;const F=()=>{const C=[...N];if(E){const P=C.findIndex(H=>H.type==="thinking");P>=0?C[P]={type:"thinking",content:E}:C.unshift({type:"thinking",content:E})}if(g){const P=C[C.length-1];(P==null?void 0:P.type)==="text"?C[C.length-1]={type:"text",content:g}:C.push({type:"text",content:g})}p(P=>P.map(H=>H.id===A?{...H,parts:C}:H))};y.current=a.chat({sessionId:M,message:w,stream:!0,onMessage:C=>{switch(_||(_=!0,x("streaming")),C.type){case"thinking":E+=C.content;break;case"ai":g+=C.content;break;case"tool_call":g&&(N.push({type:"text",content:g}),g=""),N.push({type:"tool_call",toolName:C.toolName,toolCallId:C.toolCallId,args:C.args??"{}"});break;case"tool_result":g&&(N.push({type:"text",content:g}),g=""),N.push({type:"tool_result",toolName:C.toolName??"",toolCallId:C.toolCallId,content:C.content,artifacts:C.artifacts,renderMode:C.renderMode,html:C.html});break;case"interrupt":g&&(N.push({type:"text",content:g}),g=""),C.interrupt&&N.push({type:"interrupt",interrupt:C.interrupt,resolved:!1});break;case"stop":C.content&&(g=C.content),F();return}F()},onDone:C=>{(g||N.length>0||E)&&F(),C.sessionId&&C.sessionId!==k.current&&(i==null||i(C.sessionId));const P=()=>{h.current&&(clearTimeout(h.current),h.current=null),o==null||o(C.sessionId||M),x("ready"),u.current=!1,y.current=null};if($){const H=w.slice(0,30),Y=C.sessionId||M;a.renameConversation(Y,H).catch(()=>{}).finally(P)}else P()},onError:C=>{N.push({type:"error",content:C.message}),F(),h.current&&(clearTimeout(h.current),h.current=null),b(C),x("error"),d==null||d(C),u.current=!1,y.current=null}}),r==null||r(M)};k.current?L(k.current):a.createSession().then(M=>{k.current=M,i==null||i(M),L(M)}).catch(M=>{b(M instanceof Error?M:new Error(String(M))),x("error"),d==null||d(M instanceof Error?M:new Error(String(M))),u.current=!1})},[a,i,r,o,d,l]),j=s.useCallback(()=>{const w=k.current;w&&(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{var z;h.current=null,(z=y.current)==null||z.abort(),y.current=null,u.current=!1,x("ready")},8e3),a.stopGeneration(w).catch(()=>{}))},[a]),I=s.useCallback(()=>{if(u.current)return;const w=c.findLastIndex(A=>A.role==="user");if(w<0)return;const z=c[w].parts.filter(A=>A.type==="text").map(A=>A.content).join("");p(A=>A.slice(0,w)),v(z)},[c,v]),S=s.useCallback((w,z)=>{p(g=>g.map(N=>({...N,parts:N.parts.map(_=>_.type==="interrupt"&&_.interrupt.interruptId===w?{..._,resolved:!0,response:z}:_)})));const A=k.current;if(!A)return;let R=0;p(g=>g.length>0&&g[g.length-1].role==="assistant"?(R=g[g.length-1].parts.length,g):(R=0,[...g,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),x("streaming");let $="",L="",M=[];const E=()=>{const g=[...M];if($){const N=g.findIndex(_=>_.type==="thinking");N>=0?g[N]={type:"thinking",content:$}:g.unshift({type:"thinking",content:$})}if(L){const N=g[g.length-1];(N==null?void 0:N.type)==="text"?g[g.length-1]={type:"text",content:L}:g.push({type:"text",content:L})}p(N=>{const _=N.findLastIndex(F=>F.role==="assistant");return _<0?N:N.map((F,C)=>C===_?{...F,parts:[...F.parts.slice(0,R),...g]}:F)})};a.respondInterrupt(w,A,z,g=>{switch(g.type){case"thinking":$+=g.content;break;case"ai":L+=g.content;break;case"tool_call":L&&(M.push({type:"text",content:L}),L=""),M.push({type:"tool_call",toolName:g.toolName,toolCallId:g.toolCallId,args:g.args??"{}"});break;case"tool_result":L&&(M.push({type:"text",content:L}),L=""),M.push({type:"tool_result",toolName:g.toolName??"",toolCallId:g.toolCallId,content:g.content,artifacts:g.artifacts,renderMode:g.renderMode,html:g.html});break;case"interrupt":L&&(M.push({type:"text",content:L}),L=""),g.interrupt&&M.push({type:"interrupt",interrupt:g.interrupt,resolved:!1});break;case"done":o==null||o(A),x("ready");break}E()},g=>{M.push({type:"error",content:g.message}),E(),b(g),x("error"),d==null||d(g)}).catch(g=>{d==null||d(g instanceof Error?g:new Error(String(g))),x("error")})},[a,d,o]);return{messages:c,status:f,error:m,sendMessage:v,stop:j,regenerate:I,setMessages:p,respondToInterrupt:S}}const Ee="sa_active_conversation",ne=20;function ke(t){try{return localStorage.getItem(`${Ee}_${t}`)}catch{return null}}function ct(t,a){try{const n=`${Ee}_${t}`;a?localStorage.setItem(n,a):localStorage.removeItem(n)}catch{}}function Te(t){const{sdk:a,onConversationChange:n}=t,i=a.botId,[r,o]=s.useState([]),[d,l]=s.useState(()=>ke(i)),[c,p]=s.useState(!1),[f,x]=s.useState(!0),m=s.useRef(!0),b=s.useRef(1),y=s.useRef(!1);s.useEffect(()=>()=>{m.current=!1},[]);const u=s.useCallback(w=>{l(w),ct(i,w),w&&(n==null||n(w))},[i,n]),h=s.useCallback(async()=>{if(!y.current){y.current=!0,p(!0);try{b.current=1;const w=await a.listConversations({page:1,size:ne});if(!m.current)return;o(w.items),x(w.items.length<w.total);const z=ke(i);z&&!w.items.find(A=>A.sessionId===z)&&u(null)}catch{}finally{y.current=!1,m.current&&p(!1)}}},[a,u]),k=s.useCallback(async()=>{if(!(y.current||!f)){y.current=!0,p(!0);try{const w=b.current+1,z=await a.listConversations({page:w,size:ne});if(!m.current)return;b.current=w,o(R=>{const $=new Set(R.map(M=>M.sessionId)),L=z.items.filter(M=>!$.has(M.sessionId));return[...R,...L]});const A=b.current*ne;x(A<z.total)}catch{}finally{y.current=!1,m.current&&p(!1)}}},[a,f]),T=s.useCallback(async w=>(u(w),await a.getMessages(w)),[a,u]),v=s.useCallback(async()=>{try{const w=await a.createSession(),z=new Date().toISOString();o(A=>[{sessionId:w,botId:0,title:"新对话",createTime:z,updateTime:z},...A]),u(w)}catch{u(null)}},[a,u]),j=s.useCallback(async w=>{o(z=>z.filter(A=>A.sessionId!==w)),d===w&&u(null);try{await a.deleteConversation(w)}catch{}},[a,d,u]),I=s.useCallback(async(w,z)=>{await a.renameConversation(w,z),o(A=>A.map(R=>R.sessionId===w?{...R,title:z}:R))},[a]),{enabled:S=!0}=t;return s.useEffect(()=>{S&&h()},[S,h]),{conversations:r,activeConversationId:d,loading:c,hasMore:f,loadConversations:h,loadMore:k,switchConversation:T,newConversation:v,deleteConversation:j,renameConversation:I,setActiveConversationId:u}}function Ie(t){return!t&&t!==0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Me(t){return t==="pdf"?"PDF":t==="docx"?"DOC":t==="html"?"HTM":t.slice(0,3).toUpperCase()||"FILE"}function Ae(t){if(!t)return[];const a=[];for(const n of t)n.type==="file"&&n.data&&a.push({id:n.data.id??"",type:n.data.fileType??n.data.type??"",filename:n.data.name??n.data.filename??"",url:n.data.url??"",mime:n.data.mime,size:n.data.size,summary:n.data.summary});return a}async function ae(t){try{const a=await fetch(t.url);if(!a.ok)throw new Error(`HTTP ${a.status}`);const n=await a.blob(),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=t.filename,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),4e3)}catch{const a=document.createElement("a");a.href=t.url,a.download=t.filename,a.target="_blank",document.body.appendChild(a),a.click(),a.remove()}}const Re=s.createContext(null);function U(){const t=s.useContext(Re);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}function ie({sdk:t,hooks:a,children:n}){const[i,r]=s.useState(!1),[o,d]=s.useState(!1),[l,c]=s.useState(null),[p,f]=s.useState(null),[x,m]=s.useState(!1),[b,y]=s.useState(!1);s.useEffect(()=>{t.getToken().then(()=>{m(!0)}).catch(()=>{m(!0)})},[t]);const u=Te({sdk:t,onConversationChange:a==null?void 0:a.onConversationChange,enabled:x}),h=Se({sdk:t,sessionId:u.activeConversationId,onSessionCreated:g=>{u.setActiveConversationId(g)},onStreamStart:a==null?void 0:a.onStreamStart,onStreamEnd:g=>{var N;(N=a==null?void 0:a.onStreamEnd)==null||N.call(a,g),u.loadConversations()},onError:a==null?void 0:a.onError,onMessageSend:a==null?void 0:a.onMessageSend}),k=s.useCallback(g=>{if(g.type==="link"){window.open(g.url,g.target??"_blank","noopener");return}f(g)},[]),T=s.useCallback(()=>f(null),[]),v=s.useCallback(async g=>{y(!0);try{const N=await u.switchConversation(g);h.setMessages(N)}finally{y(!1)}},[u,h]),j=s.useCallback(async()=>{h.setMessages([]),await u.newConversation()},[u,h]),I=s.useCallback(async g=>{u.activeConversationId===g&&h.setMessages([]),await u.deleteConversation(g)},[u,h]);s.useEffect(()=>{u.activeConversationId&&h.messages.length===0&&(y(!0),t.getMessages(u.activeConversationId).then(g=>{h.setMessages(g)}).catch(()=>{}).finally(()=>y(!1)))},[]);const S=s.useCallback(()=>{r(g=>!g)},[]),w=s.useCallback(g=>{r(g)},[]),z=s.useCallback(()=>{d(g=>!g),c(g=>null)},[]),A=s.useCallback(g=>{c(g),d(!0)},[]),R=s.useMemo(()=>{const g=new Set,N=[];for(const _ of h.messages)for(const F of _.parts)if(F.type==="tool_result"&&F.artifacts)for(const C of Ae(F.artifacts)){const P=C.id||`${C.url}:${C.filename}`;g.has(P)||(g.add(P),N.push(C))}return N},[h.messages]),$=s.useCallback(async()=>{const g=u.activeConversationId;if(!g)return null;try{const N=await t.getMessages(g);h.setMessages(N);const _=N.findLast(F=>F.role==="assistant");return(_==null?void 0:_.id)??null}catch{return null}},[t,u.activeConversationId,h]),L=s.useCallback((g,N,_)=>{if(/^\d+$/.test(g)){t.feedback(g,N,_).catch(()=>{});return}$().then(F=>{F&&t.feedback(F,N,_).catch(()=>{})})},[t,$]),M=s.useCallback(g=>{if(/^\d+$/.test(g)){t.cancelFeedback(g).catch(()=>{});return}$().then(N=>{N&&t.cancelFeedback(N).catch(()=>{})})},[t,$]),E=s.useMemo(()=>({sdk:t,status:h.status,error:h.error,messages:h.messages,conversations:u.conversations,activeConversationId:u.activeConversationId,isThreadListOpen:i,isArtifactDrawerOpen:o,allArtifacts:R,activePreviewArtifact:l,activePanel:p,hasMore:u.hasMore,conversationsLoading:u.loading,messagesLoading:b,sendMessage:h.sendMessage,stop:h.stop,regenerate:h.regenerate,switchConversation:v,newConversation:j,deleteConversation:I,renameConversation:u.renameConversation,loadMoreConversations:u.loadMore,toggleThreadList:S,setThreadListOpen:w,toggleArtifactDrawer:z,openArtifactPreview:A,openPanel:k,closePanel:T,feedback:L,cancelFeedback:M,respondToInterrupt:h.respondToInterrupt}),[t,h.status,h.error,h.messages,h.sendMessage,h.stop,h.regenerate,h.respondToInterrupt,u.conversations,u.activeConversationId,u.renameConversation,u.hasMore,u.loadMore,u.loading,i,o,R,l,p,b,v,j,I,S,w,z,A,k,T,L,M]);return e.jsx(Re.Provider,{value:E,children:n})}const B="https://ehr-web.netease.com/ehr-web/erh-super-agent",W={recently:`${B}/recently.svg`,home:`${B}/home.svg`,mergeWindow:`${B}/merge_window.svg`,spiltWindow:`${B}/spilt_window.svg`,close:`${B}/close.svg`,message:`${B}/message.svg`,messageCreate:`${B}/message_create.svg`,customerService:`${B}/customer_service.svg`,sendSolid:`${B}/send_solid.svg`,capabilityIcons:[`${B}/icon1.png`,`${B}/icon2.png`,`${B}/icon3.png`],triggerLogo:`${B}/HRlogo.png`,logo:`${B}/HRlogo2.png`,assistantAvatarGenerating:`${B}/profile0.gif`,assistantAvatar:`${B}/profile1.png`},O={TRIGGER_SIZE:56,TRIGGER_RIGHT:20,TRIGGER_BOTTOM:80,DEFAULT_WIDTH:400,DEFAULT_HEIGHT:648,MIN_WIDTH:360,MAX_WIDTH:800,MAX_HEIGHT_RATIO:.95};function dt({defaultWidth:t=O.DEFAULT_WIDTH,defaultHeight:a=O.DEFAULT_HEIGHT,sidebarWidth:n=0}={}){const[i,r]=s.useState(t),[o,d]=s.useState({x:0,y:0}),[l,c]=s.useState(!1),[p,f]=s.useState(!1),[x,m]=s.useState(null),[b,y]=s.useState(()=>typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),u=s.useRef(!1),h=s.useRef(0),k=s.useRef(i),T=s.useRef(!1),v=s.useRef({x:0,y:0}),j=s.useRef({x:0,y:0}),I=s.useRef(!1),S=s.useRef(null);s.useEffect(()=>{const E=()=>y({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]),s.useEffect(()=>()=>{var E;(E=S.current)==null||E.call(S)},[]);const w=Math.floor(b.height*O.MAX_HEIGHT_RATIO),z=Math.min(x||a,w),A=i+n;s.useEffect(()=>{if(!l){const E=b.width-A-20,g=b.height-z-20;d(N=>N.x===E&&N.y===g?N:{x:E,y:g})}},[l,A,z,b]);const R=s.useCallback(E=>{if(p||E.target.closest("button, input, textarea"))return;T.current=!0,I.current=!1,v.current={x:E.clientX,y:E.clientY},j.current={...o};const g=F=>{if(!T.current)return;const C=F.clientX-v.current.x,P=F.clientY-v.current.y;(Math.abs(C)>3||Math.abs(P)>3)&&(I.current=!0),I.current&&(c(!0),d({x:Math.max(-200,Math.min(j.current.x+C,window.innerWidth-100)),y:Math.max(0,Math.min(j.current.y+P,window.innerHeight-48))}))},N=()=>{T.current=!1,_()},_=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",N),S.current=null};document.addEventListener("mousemove",g),document.addEventListener("mouseup",N),S.current=_},[p,o]),$=s.useCallback(E=>{E.preventDefault(),E.stopPropagation(),u.current=!0,h.current=E.clientX,k.current=i;const g=o.x+i,N=o.y,_=P=>{if(!u.current)return;const H=P.clientX-h.current;let Y=k.current-H;if(Y>O.MAX_WIDTH){u.current=!1,f(!0),C();return}Y=Math.max(O.MIN_WIDTH,Y),r(Y),d({x:g-Y,y:N})},F=()=>{u.current=!1,C()},C=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",F),S.current=null};document.addEventListener("mousemove",_),document.addEventListener("mouseup",F),S.current=C},[i,o]),L=s.useCallback(()=>{p&&r(t),f(E=>!E)},[p,t]),M=s.useCallback(()=>{f(!1),r(t),c(!1),m(null)},[t]);return{width:i,position:o,hasCustomPosition:l,isMaximized:p,lockedHeight:x,viewport:b,defaultHeight:a,totalWidth:A,windowHeight:z,startWindowDrag:R,startResize:$,toggleMaximize:L,setIsMaximized:f,setLockedHeight:m,setHasCustomPosition:c,reset:M}}function pt(t){const{enabled:a,contentSelector:n,defaultHeight:i,onHeightChange:r}=t,o=s.useRef(null);return s.useEffect(()=>{if(!a||!o.current)return;const l=o.current.querySelector(n);if(!l)return;const c=()=>{const x=o.current;if(!x)return;const m=x.querySelector(n);if(!m)return;const b=x.offsetHeight-m.clientHeight,y=m.scrollHeight+b,u=Math.floor(window.innerHeight*O.MAX_HEIGHT_RATIO),h=Math.max(i,Math.min(y,u));r(k=>k===h?k:h)};c();const p=new ResizeObserver(()=>c());Array.from(l.children).forEach(x=>p.observe(x));const f=new MutationObserver(()=>{Array.from(l.children).forEach(x=>p.observe(x)),c()});return f.observe(l,{childList:!0,subtree:!0,characterData:!0}),()=>{p.disconnect(),f.disconnect()}},[a,n,i,r]),o}function ut(t,a){const n=O.TRIGGER_SIZE;return{x:Math.max(8,Math.min(t,window.innerWidth-n-8)),y:Math.max(8,Math.min(a,window.innerHeight-n-8))}}function $e({isOpen:t,onClick:a,triggerLogo:n}){const[i,r]=s.useState(null),o=s.useRef(!1),d=s.useRef(!1),l=s.useRef({x:0,y:0}),c=s.useRef({x:0,y:0}),p=s.useRef(null);s.useEffect(()=>()=>{var b;(b=p.current)==null||b.call(p)},[]);const f=s.useCallback(b=>{if(b.button!==0)return;o.current=!0,d.current=!1,l.current={x:b.clientX,y:b.clientY};const y=b.currentTarget.getBoundingClientRect();c.current={x:y.left,y:y.top};const u=k=>{if(!o.current)return;const T=k.clientX-l.current.x,v=k.clientY-l.current.y;(Math.abs(T)>4||Math.abs(v)>4)&&(d.current=!0),d.current&&r(ut(c.current.x+T,c.current.y+v))},h=()=>{o.current=!1,document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h),p.current=null};document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),p.current=h},[]),x=s.useCallback(()=>{if(d.current){d.current=!1;return}a()},[a]),m=i?{left:i.x,top:i.y,width:O.TRIGGER_SIZE,height:O.TRIGGER_SIZE}:{right:O.TRIGGER_RIGHT,bottom:O.TRIGGER_BOTTOM,width:O.TRIGGER_SIZE,height:O.TRIGGER_SIZE};return e.jsx("button",{type:"button",className:`fixed z-[10000] flex items-center justify-center border-none bg-transparent p-0 transition-transform duration-200 ease-out hover:scale-[1.08] active:scale-95 ${t?"pointer-events-none scale-50 opacity-0":"opacity-100"}`,style:m,onMouseDown:f,onClick:x,"aria-label":"打开 AI 助手",title:"AI 助手",children:e.jsx("img",{src:n||W.triggerLogo,alt:"AI 助手",className:"block h-full w-full",draggable:!1})})}function V({tooltip:t,onClick:a,children:n}){return e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white active:bg-[#F5F5F5]","data-tooltip":t,"aria-label":t,onClick:a,children:n})}function De({onClose:t,onToggleThreadList:a,isMaximized:n=!1,onToggleMaximize:i,showHome:r=!1,onHome:o,showClose:d=!0,artifactCount:l=0,onToggleArtifactDrawer:c}){return e.jsxs("div",{className:"relative z-20 flex h-9 shrink-0 select-none items-center justify-between px-[15px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(V,{tooltip:"历史记录",onClick:a,children:e.jsx("img",{src:W.recently,alt:"",width:20,height:20})}),r&&o&&e.jsx(V,{tooltip:"回到首页",onClick:o,children:e.jsx("img",{src:W.home,alt:"",width:20,height:20})})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[l>0&&c&&e.jsx(V,{tooltip:"会话产物",onClick:c,children:e.jsxs("span",{className:"relative flex items-center gap-1",children:[e.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),l>0&&e.jsx("span",{className:"absolute -right-2 -top-1.5 min-w-[14px] rounded-full bg-[var(--sa-primary)] px-0.5 text-center text-[9px] font-medium leading-[14px] text-white",children:l>99?"99+":l})]})}),i&&e.jsx(V,{tooltip:n?"小窗":"大窗",onClick:i,children:e.jsx("img",{src:n?W.spiltWindow:W.mergeWindow,alt:"",width:20,height:20})}),d&&e.jsx(V,{tooltip:"关闭",onClick:t,children:e.jsx("img",{src:W.close,alt:"",width:20,height:20})})]})]})}const K=t=>String(t).padStart(2,"0");function gt(t){if(!t)return"";const a=new Date(t);return isNaN(a.getTime())?"":`${a.getFullYear()}-${K(a.getMonth()+1)}-${K(a.getDate())} ${K(a.getHours())}:${K(a.getMinutes())}:${K(a.getSeconds())}`}function Le(t){const a=new Date,n=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=n-6*864e5,r=[],o=[],d=[];for(const c of t){const p=new Date(c.updateTime).getTime();p>=n?r.push(c):p>=i?o.push(c):d.push(c)}const l=[];return r.length&&l.push({label:"今天",items:r}),o.length&&l.push({label:"最近 7 天",items:o}),d.length&&l.push({label:"更早",items:d}),l}function oe({width:t}){const{conversations:a,activeConversationId:n,switchConversation:i,newConversation:r,deleteConversation:o,renameConversation:d,hasMore:l,loadMoreConversations:c,conversationsLoading:p}=U(),[f,x]=s.useState(null),[m,b]=s.useState(""),[y,u]=s.useState(null),h=s.useRef(null),k=s.useCallback((I,S)=>{x(I),b(S??"")},[]),T=s.useCallback(I=>{m.trim()&&d(I,m.trim()),x(null)},[m,d]),v=s.useCallback(()=>{const I=h.current;!I||!l||I.scrollHeight-I.scrollTop-I.clientHeight<50&&c()},[l,c]),j=s.useMemo(()=>Le(a),[a]);return e.jsxs("div",{className:"relative z-[5] flex h-full shrink-0 flex-col overflow-visible border-r border-[#ECECEC] bg-[#FAFAFA] p-3 animate-sa-history-in",style:{width:t??200},children:[e.jsxs("button",{type:"button",className:"sa-new-chat mb-4 flex h-8 w-full shrink-0 items-center justify-center gap-2 rounded-md text-[14px] font-medium transition-colors",onClick:r,children:[e.jsx("img",{src:W.messageCreate,alt:"",width:18,height:18}),e.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),e.jsxs("div",{className:"px-1 pb-2.5",children:[e.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),e.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),e.jsxs("div",{ref:h,className:"flex-1 overflow-y-auto",onScroll:v,children:[p&&a.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!p&&a.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),j.map(I=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:I.label}),I.items.map(S=>e.jsx("div",{className:`group relative mb-0.5 flex h-8 w-full cursor-pointer items-center gap-1 rounded-md px-0.5 text-[13px] transition-colors ${S.sessionId===n?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{f!==S.sessionId&&i(S.sessionId)},onMouseEnter:w=>{if(f===S.sessionId)return;const z=w.currentTarget.getBoundingClientRect();u({text:S.title||"新会话",x:z.right+8,y:z.top+z.height/2})},onMouseLeave:()=>u(null),children:f===S.sessionId?e.jsx("input",{className:"w-full rounded border border-[var(--sa-primary)] bg-white px-1.5 py-0.5 text-[12px] outline-none",value:m,onChange:w=>b(w.target.value),onBlur:()=>T(S.sessionId),onKeyDown:w=>{w.key==="Enter"&&T(S.sessionId),w.key==="Escape"&&x(null)},onClick:w=>w.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:W.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:S.title||"新会话"}),e.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[e.jsx("button",{type:"button",className:"flex h-5 w-5 items-center justify-center rounded text-[#999] hover:bg-white/70 hover:text-[var(--sa-primary)]",onClick:w=>{w.stopPropagation(),k(S.sessionId,S.title)},title:"重命名",children:e.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})}),e.jsx("button",{type:"button",className:"flex h-5 w-5 items-center justify-center rounded text-[#999] hover:bg-white/70 hover:text-[#ef4444]",onClick:w=>{w.stopPropagation(),o(S.sessionId)},title:"删除",children:e.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})})})]})]})},S.sessionId))]},I.label)),p&&a.length>0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:l?"加载更多...":"加载中..."}),!p&&l&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),y&&e.jsx("div",{className:"pointer-events-none fixed z-[10001] whitespace-nowrap rounded border border-[#E8E8E8] bg-white px-2.5 py-1.5 text-[12px] leading-[1.4] text-[#333] shadow-[0_2px_8px_rgba(0,0,0,0.12)]",style:{left:y.x,top:y.y,transform:"translateY(-50%)"},children:y.text})]})}function _e(t){const a=s.useRef(null),n=s.useRef(!1),i=s.useRef(0),r=s.useCallback(()=>{const d=a.current;if(!d)return;const{scrollTop:l,scrollHeight:c,clientHeight:p}=d,f=c-l-p<40;l<i.current&&!f&&(n.current=!0),f&&(n.current=!1),i.current=l},[]);s.useEffect(()=>{const d=a.current;if(d)return d.addEventListener("scroll",r,{passive:!0}),()=>d.removeEventListener("scroll",r)},[r]),s.useEffect(()=>{if(n.current)return;const d=a.current;d&&requestAnimationFrame(()=>{d.scrollTop=d.scrollHeight})},t);const o=s.useCallback(()=>{n.current=!1;const d=a.current;d&&(d.scrollTop=d.scrollHeight)},[]);return{containerRef:a,scrollToBottom:o}}function X(t){return t.value++}function q(t,a){const n=[],i=[],r=()=>{i.length>0&&(n.push(i.join("")),i.length=0)};let o=0;for(;o<t.length;){const d=t[o];if(d==="`"){const l=t.indexOf("`",o+1);if(l!==-1){r(),n.push(e.jsx("code",{className:"sa-inline-code",children:t.slice(o+1,l)},X(a))),o=l+1;continue}}else if(d==="*"&&t[o+1]==="*"){const l=t.indexOf("**",o+2);if(l!==-1){r(),n.push(e.jsx("strong",{children:q(t.slice(o+2,l),a)},X(a))),o=l+2;continue}}else if(d==="*"){const l=t.indexOf("*",o+1);if(l!==-1){r(),n.push(e.jsx("em",{children:q(t.slice(o+1,l),a)},X(a))),o=l+1;continue}}else if(d==="["){const l=t.indexOf("]",o+1);if(l!==-1&&t[l+1]==="("){const c=t.indexOf(")",l+2);if(c!==-1){const p=t.slice(o+1,l),f=t.slice(l+2,c);r(),n.push(e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",children:q(p,a)},X(a))),o=c+1;continue}}}i.push(d),o++}return r(),n}function ft(t,a){const n=[],i=t.split(`
2
+ `);let r=0;const o=c=>c.trim()==="",d=c=>/^#{1,6}\s+\S/.test(c.trim()),l=c=>/^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());for(;r<i.length;){const c=i[r],p=c.trim();if(o(c)){r++;continue}if(d(c)){const x=p.match(/^(#{1,6})\s+(.*)$/);if(x){const b=`h${Math.min(x[1].length,6)}`;n.push(s.createElement(b,{key:X(a)},q(x[2],a)))}r++;continue}if(l(c)){const x=/^\d+[.)]/.test(p),m=[];for(;r<i.length&&l(i[r]);){const b=i[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);b&&m.push(e.jsx("li",{children:q(b[1],a)},X(a))),r++}n.push(x?e.jsx("ol",{className:"sa-list",children:m},X(a)):e.jsx("ul",{className:"sa-list",children:m},X(a)));continue}const f=[];for(;r<i.length&&!o(i[r])&&!d(i[r])&&!l(i[r]);)f.push(i[r]),r++;n.push(e.jsx("p",{className:"sa-text-paragraph",children:q(f.join(" "),a)},X(a)))}return n}function xt(t){const a={value:0},n=[],i=t.split("```");for(let r=0;r<i.length;r++)if(r%2===0)n.push(...ft(i[r],a));else if(i[r].trim()!==""){let o=i[r].replace(/^\r?\n/,"");o=o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/,""),o=o.replace(/\r?\n$/,""),n.push(e.jsx("pre",{className:"sa-code-block",children:e.jsx("code",{children:o})},X(a)))}return n}function Fe({content:t}){return e.jsx("div",{className:"sa-text-part",children:xt(t)})}const ht="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let je=!1;function He(t=ht){if(je||typeof document>"u")return;je=!0;const a=t.split("?")[0].split("/").pop();if(a&&document.querySelector(`script[src*="${a}"]`))return;const n=document.createElement("script");n.src=t,document.head.appendChild(n)}He();function D({name:t,size:a=16,color:n="currentColor",className:i,style:r}){return e.jsx("svg",{className:i,style:{width:a,height:a,fill:n,verticalAlign:"middle",...r},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${t}`})})}function Pe({content:t}){const[a,n]=s.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>n(!a),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(D,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${a?"expanded":""}`,children:e.jsx(D,{name:"chevron-right",size:12})})]}),a&&e.jsx("div",{className:"sa-thinking-content",children:t})]})}function Be({toolName:t,toolCallId:a,args:n}){const[i,r]=s.useState(!1),[o,d]=s.useState(!1);let l=n;try{l=JSON.stringify(JSON.parse(n),null,2)}catch{}const c=s.useCallback(()=>{var p;(p=navigator.clipboard)==null||p.writeText(l).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>{})},[l]);return e.jsxs("div",{className:"sa-tool-call-part",children:[e.jsxs("div",{className:"sa-tool-call-header",onClick:()=>r(!i),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(D,{name:"zap",size:14})}),e.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",t]}),e.jsx("span",{className:`sa-thinking-arrow ${i?"expanded":""}`,children:e.jsx(D,{name:"chevron-right",size:12})})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-args",children:l}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsxs("button",{className:"sa-action-btn",onClick:c,title:"复制",children:[e.jsx(D,{name:o?"circle-check":"copy",size:14})," ",o?"已复制":"复制"]})})]})]})}function Ce({text:t}){const[a,n]=s.useState(!1),i=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return e.jsxs("button",{className:"sa-action-btn",onClick:i,title:"复制",children:[e.jsx(D,{name:a?"circle-check":"copy",size:14})," ",a?"已复制":"复制"]})}function mt({html:t}){const[a,n]=s.useState(null);return s.useEffect(()=>{let i=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(r=>{i||n(r.default.sanitize(t,{FORCE_BODY:!0,ADD_ATTR:["target"]}))}),()=>{i=!0}},[t]),a===null?null:e.jsx("div",{className:"sa-tool-result-html-scroll",children:e.jsx("div",{className:"sa-tool-result-html sa-text-part",dangerouslySetInnerHTML:{__html:a}})})}function Oe({toolName:t,content:a,artifacts:n,renderMode:i,html:r,artifactPreview:o}){const{openArtifactPreview:d}=U(),l=Ae(n);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(D,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:t||"工具返回"})]}),i==="html"&&r?e.jsxs(e.Fragment,{children:[e.jsx(mt,{html:r}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Ce,{text:r})})]}):a?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-result-content",children:a}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Ce,{text:a})})]}):e.jsx("pre",{className:"sa-tool-result-content",children:"—"}),l.length>0&&e.jsx("ul",{className:"sa-artifact-file-list",role:"list",children:l.map((c,p)=>e.jsxs("li",{className:"sa-artifact-file-card",onClick:o?()=>d(c):void 0,onKeyDown:o?f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),d(c))}:void 0,tabIndex:o?0:void 0,role:o?"button":void 0,"aria-label":o?`预览 ${c.filename}`:void 0,style:o?{cursor:"pointer"}:void 0,children:[e.jsx("div",{className:"sa-artifact-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:Me(c.type)})}),e.jsxs("div",{className:"sa-artifact-file-info",children:[e.jsx("span",{className:"sa-artifact-file-name",children:c.filename}),c.size!=null&&e.jsx("span",{className:"sa-artifact-file-size",children:Ie(c.size)})]}),o&&e.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${c.filename}`,onClick:f=>{f.stopPropagation(),ae(c)},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},c.id||`art-${p}`))})]})}function We({content:t,onRetry:a}){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(D,{name:"triangle-alert",size:14})}),e.jsx("span",{children:t||"发生错误"})]}),a&&e.jsx("button",{className:"sa-error-retry",onClick:a,children:"重试"})]})}function wt({interrupt:t,onRespond:a,disabled:n,answeredAction:i}){var l,c;const r=t.options,o=(typeof(r==null?void 0:r[0])=="string"?r[0]:(l=r==null?void 0:r[0])==null?void 0:l.label)||"确认",d=(typeof(r==null?void 0:r[1])=="string"?r[1]:(c=r==null?void 0:r[1])==null?void 0:c.label)||"取消";return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${i==="confirm"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"confirm"}),children:[e.jsx(D,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${i==="cancel"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"cancel"}),children:[e.jsx(D,{name:"x",size:14})," ",d]})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function bt({interrupt:t,onRespond:a,disabled:n,answeredAction:i}){var p,f,x,m;const r=t.options,o=(typeof(r==null?void 0:r[0])=="string"?r[0]:(p=r==null?void 0:r[0])==null?void 0:p.label)||"批准",d=(typeof(r==null?void 0:r[1])=="string"?r[1]:(f=r==null?void 0:r[1])==null?void 0:f.label)||"拒绝",l=(typeof(r==null?void 0:r[2])=="string"?r[2]:(x=r==null?void 0:r[2])==null?void 0:x.label)||"跳过",c=((m=t.metadata)==null?void 0:m.showSkip)!==!1;return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${i==="approve"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"approve"}),children:[e.jsx(D,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-danger ${i==="reject"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"reject"}),children:[e.jsx(D,{name:"x",size:14})," ",d]}),c&&e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${i==="skip"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"skip"}),children:[e.jsx(D,{name:"chevron-right",size:14})," ",l]})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function vt(t){return typeof t=="string"?{value:t,label:t}:t}function yt({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=(t.options??[]).map(vt);return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"list",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(o=>{const d=i===o.value;return e.jsxs("button",{className:`sa-interrupt-option ${o.danger?"sa-interrupt-option-danger":""} ${d?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>a({action:"select",value:o.value}),children:[e.jsx(D,{name:d?"circle-check":"circle",size:14}),o.icon&&e.jsx(D,{name:o.icon,size:14}),e.jsx("span",{children:o.label}),o.description&&e.jsx("span",{className:"sa-interrupt-option-desc",children:o.description})]},o.value)})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function kt(t){return typeof t=="string"?{value:t,label:t}:t}function jt({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=(t.options??[]).map(kt),[o,d]=s.useState(()=>new Set(Array.isArray(i)?i:[])),l=c=>{n||d(p=>{const f=new Set(p);return f.has(c)?f.delete(c):f.add(c),f})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"list-checks",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(c=>e.jsxs("button",{className:`sa-interrupt-option ${o.has(c.value)?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>l(c.value),children:[e.jsx(D,{name:o.has(c.value)?"square-check":"square",size:14}),e.jsx("span",{children:c.label})]},c.value))}),!n&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:o.size===0,onClick:()=>a({action:"submit",value:Array.from(o)}),children:[e.jsx(D,{name:"check",size:14})," 确认 (",o.size,")"]})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Ct({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const[r,o]=s.useState(i??""),d=t.inputType??"text",l=d==="textarea",c=()=>{n||t.required&&!r.trim()||a({action:"submit",value:r.trim()})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"text-cursor-input",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-input-area",children:l?e.jsx("textarea",{className:"sa-interrupt-textarea",value:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,rows:3,disabled:n}):e.jsx("input",{className:"sa-interrupt-input",type:d,value:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,onKeyDown:p=>p.key==="Enter"&&c(),disabled:n})}),!n&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:t.required?!r.trim():!1,onClick:c,children:[e.jsx(D,{name:"check",size:14})," 提交"]})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Nt({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=t.fields??[],[o,d]=s.useState(()=>{const f={};for(const x of r)f[x.name]=(i==null?void 0:i[x.name])??x.defaultValue??"";return f}),l=(f,x)=>{n||d(m=>({...m,[f]:x}))},c=!n&&r.every(f=>!f.required||o[f.name]),p=()=>{c&&a({action:"submit",value:o})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(D,{name:"file-text",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-form",children:r.map(f=>e.jsxs("div",{className:"sa-interrupt-form-field",children:[e.jsxs("label",{className:"sa-interrupt-form-label",children:[f.label,f.required&&e.jsx("span",{className:"sa-interrupt-form-required",children:"*"})]}),zt(f,o[f.name],x=>l(f.name,x),n)]},f.name))}),!n&&e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:!c,onClick:p,children:[e.jsx(D,{name:"check",size:14})," 提交"]}),e.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>a({action:"cancel"}),children:"取消"})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Ne(t){return typeof t=="string"?{value:t,label:t}:t}function zt(t,a,n,i){switch(t.type){case"textarea":return e.jsx("textarea",{className:"sa-interrupt-textarea",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,rows:3,disabled:i});case"select":{const r=(t.options??[]).map(Ne);return e.jsxs("select",{className:"sa-interrupt-select",value:a,onChange:o=>n(o.target.value),disabled:i,children:[e.jsx("option",{value:"",children:"请选择"}),r.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))]})}case"multiSelect":{const r=(t.options??[]).map(Ne),o=Array.isArray(a)?a:[],d=l=>{i||n(o.includes(l)?o.filter(c=>c!==l):[...o,l])};return e.jsx("div",{className:"sa-interrupt-options",children:r.map(l=>e.jsx("button",{type:"button",className:`sa-interrupt-option ${o.includes(l.value)?"sa-interrupt-option-selected":""}`,disabled:i,onClick:()=>d(l.value),children:l.label},l.value))})}case"password":return e.jsx("input",{className:"sa-interrupt-input",type:"password",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,disabled:i});default:return e.jsx("input",{className:"sa-interrupt-input",type:t.type==="number"?"number":t.type==="date"?"date":"text",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,disabled:i})}}function Ye({interrupt:t,resolved:a,response:n,onRespond:i}){const r=a,o=n==null?void 0:n.value;switch(t.interruptType){case"confirm":return e.jsx(wt,{interrupt:t,onRespond:i,disabled:r,answeredAction:n==null?void 0:n.action});case"approve":return e.jsx(bt,{interrupt:t,onRespond:i,disabled:r,answeredAction:n==null?void 0:n.action});case"select":return e.jsx(yt,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"multiSelect":return e.jsx(jt,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"input":return e.jsx(Ct,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"form":return e.jsx(Nt,{interrupt:t,onRespond:i,disabled:r,initialValue:o});default:return e.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",t.interruptType]})}}const St=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function Ge({message:t,onCopy:a,onRegenerate:n,onFeedback:i}){const{status:r,cancelFeedback:o}=U(),[d,l]=s.useState(null),[c,p]=s.useState(!1),[f,x]=s.useState(!1),m=s.useRef(null),b=s.useCallback(()=>{a(),p(!0),setTimeout(()=>p(!1),2e3)},[a]),y=s.useCallback(()=>{d==="like"?(l(null),o(t.id)):(l("like"),x(!1),i==null||i(t.id,"like"))},[d,t.id,i,o]),u=s.useCallback(()=>{d==="dislike"?(l(null),x(!1),o(t.id)):x(!0)},[d,t.id,o]),h=s.useCallback((T,v)=>{l("dislike"),x(!1),i==null||i(t.id,"dislike",{reason:T,remark:(v==null?void 0:v.trim())||void 0})},[t.id,i]),k=s.useCallback(()=>{x(!1)},[]);return s.useEffect(()=>{if(!f)return;const T=j=>{m.current&&!m.current.contains(j.target)&&x(!1)},v=j=>{j.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",T),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",v)}},[f]),r!=="ready"&&r!=="error"?null:e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:b,title:"复制",children:[e.jsx(D,{name:c?"circle-check":"copy",size:14})," ",c?"已复制":"复制"]}),n&&e.jsxs("button",{className:"sa-action-btn",onClick:n,title:"重新生成",children:[e.jsx(D,{name:"refresh-cw",size:14})," 重新生成"]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sa-action-divider"}),e.jsx("button",{className:`sa-action-btn ${d==="like"?"sa-action-btn-active":""}`,onClick:y,title:"有用","aria-label":"点赞",children:e.jsx(D,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${d==="dislike"?"sa-action-btn-active":""}`,onClick:u,title:"无用","aria-label":"踩","aria-expanded":f,"aria-haspopup":"dialog",children:e.jsx(D,{name:"thumbs-down",size:14})})]}),f&&e.jsx("div",{ref:m,children:e.jsx(Et,{onSubmit:h,onCancel:k})})]})}function Et({onSubmit:t,onCancel:a}){const[n,i]=s.useState(void 0),[r,o]=s.useState("");return e.jsxs("div",{className:"sa-dislike-panel",children:[e.jsx("div",{className:"sa-dislike-panel-title",children:"请选择不满意的原因(可选)"}),e.jsx("div",{className:"sa-dislike-reasons",children:St.map(d=>e.jsx("button",{className:`sa-dislike-reason-btn ${n===d.value?"active":""}`,onClick:()=>i(n===d.value?void 0:d.value),children:d.label},d.value))}),e.jsx("textarea",{className:"sa-dislike-remark",placeholder:"补充描述(选填,≤500 字)",maxLength:500,value:r,onChange:d=>o(d.target.value),rows:2}),e.jsxs("div",{className:"sa-dislike-actions",children:[e.jsx("button",{className:"sa-dislike-submit",onClick:()=>t(n,r||void 0),children:"提交"}),e.jsx("button",{className:"sa-dislike-cancel",onClick:a,children:"取消"})]})]})}const Tt=/^(https?:\/\/|data:|blob:|\/\/|\/|\.\/|\.\.\/)/;function ze({src:t,alt:a}){return t?Tt.test(t)?e.jsx("img",{src:t,alt:a??"",className:"sa-msg-avatar",draggable:!1}):e.jsx("span",{className:"sa-msg-avatar sa-msg-avatar-text",children:t}):null}function Xe({message:t,isStreaming:a,isLast:n,slots:i,avatar:r,artifactPreview:o,showTimestamp:d}){const{regenerate:l,feedback:c,respondToInterrupt:p}=U(),f=s.useCallback(()=>{var I;const j=t.parts.filter(S=>S.type==="text").map(S=>S.content).join(`
3
+ `);(I=navigator.clipboard)==null||I.writeText(j).catch(()=>{})},[t]),x=t.role==="user",m=i.Message;if(m)return e.jsx(m,{message:t,isStreaming:a,isLast:n,avatar:r,slots:i,onCopy:f,onRegenerate:l,onFeedback:c,showTimestamp:d});const b=i.TextPart??Fe,y=i.ThinkingPart??Pe,u=i.ToolCallPart??Be,h=i.ToolResultPart??Oe,k=i.ErrorPart??We,T=i.ActionBar??Ge,v=!x&&t.parts.some(j=>j.type==="text"&&j.content);return e.jsxs("div",{className:`sa-message ${x?"sa-message-user":"sa-message-assistant"}`,children:[!x&&e.jsx(ze,{src:(r==null?void 0:r.assistant)||(a&&n?W.assistantAvatarGenerating:W.assistantAvatar),alt:"AI"}),e.jsxs("div",{className:"sa-message-content",children:[d&&e.jsx("span",{className:`sa-message-time ${x?"sa-message-time-right":""}`,children:gt(t.timestamp)}),e.jsxs("div",{className:"sa-message-body",children:[t.parts.map((j,I)=>{switch(j.type){case"text":return e.jsx(b,{content:j.content},I);case"thinking":return e.jsx(y,{content:j.content},I);case"tool_call":return e.jsx(u,{toolName:j.toolName,toolCallId:j.toolCallId,args:j.args},I);case"tool_result":return e.jsx(h,{toolName:j.toolName,toolCallId:j.toolCallId,content:j.content,artifacts:j.artifacts,renderMode:j.renderMode,html:j.html,artifactPreview:o},I);case"error":return e.jsx(k,{content:j.content,onRetry:l},I);case"interrupt":return e.jsx(Ye,{interrupt:j.interrupt,resolved:j.resolved??!1,response:j.response,onRespond:S=>p(j.interrupt.interruptId,S)},I);default:return null}}),a&&n&&!x&&!v&&e.jsx("span",{className:"sa-thinking-indicator",children:"思考中…"}),!x&&!a&&v&&e.jsx(T,{message:t,onCopy:f,onRegenerate:n?l:void 0,onFeedback:c})]})]}),x&&(r==null?void 0:r.user)&&e.jsx(ze,{src:r.user,alt:"用户"})]})}function Ue({message:t,suggestedPrompts:a,onPromptClick:n,capabilities:i,quickLinks:r,logo:o,openPanel:d}){const l=c=>{if(c.onClick){c.onClick();return}const p=c.action;if(!p){c.prompt&&n(c.prompt);return}d==null||d(p.type==="link"?p:{...p,title:p.title??c.label})};return e.jsxs("div",{className:"flex flex-col gap-8 py-2",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 opacity-0 animate-sa-home-fade-in",children:[e.jsx("img",{src:o||W.logo,alt:"AI 助手",className:"block max-w-16 shrink-0 animate-sa-logo-float",draggable:!1}),e.jsx("h3",{className:"sa-shimmer-text m-0 mb-1 text-[18px] font-bold leading-[1.3] text-[#333] animate-sa-title-shimmer",children:t||"你好!有什么可以帮你的?"})]}),i&&i.length>0&&e.jsx("div",{className:"flex flex-col items-start gap-4 opacity-0 animate-sa-home-fade-in",style:{animationDelay:"150ms"},children:i.map(c=>e.jsxs("div",{className:"inline-flex w-full max-w-full min-w-0 items-center gap-[7px]",children:[c.icon&&e.jsx("img",{src:c.icon,alt:"",className:"h-[18px] w-[18px] shrink-0 object-contain",draggable:!1}),e.jsx("span",{className:"shrink-0 text-[14px] leading-[1.4] text-[#333]",children:c.label}),c.desc&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-[13px] w-px shrink-0 bg-[#DCDCDC]"}),e.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[14px] leading-[1.4] text-[#9A9A9A]",children:c.desc})]})]},c.label))}),a&&a.length>0&&e.jsx("div",{className:"flex flex-col items-start gap-3",children:a.map((c,p)=>e.jsxs("button",{type:"button",className:"sa-chip inline-flex h-7 items-center gap-1 rounded-md px-3 text-[14px] leading-none text-[#333] opacity-0 transition-colors animate-sa-chip-in",style:{animationDelay:`${300+p*130}ms`},onClick:()=>n(c),children:[e.jsx("span",{className:"sa-chip-text overflow-hidden text-ellipsis whitespace-nowrap",children:c}),e.jsx("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",className:"shrink-0 text-[#9A9A9A]","aria-hidden":"true",children:e.jsx("path",{d:"M5 3L9 7L5 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${c}-${p}`))}),r&&r.length>0&&e.jsxs("div",{className:"opacity-0 animate-sa-home-fade-in",style:{animationDelay:"420ms"},children:[e.jsx("div",{className:"mb-3 text-[14px] leading-none text-[#A0A0A0]",children:"快速查看"}),e.jsx("div",{className:"flex flex-wrap items-center gap-[22px]",children:r.map(c=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-[7px] rounded-md px-1 py-1 transition-colors hover:bg-[#F5F5F5]",onClick:()=>l(c),children:[c.icon&&e.jsx("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center opacity-70",children:e.jsx("img",{src:c.icon,alt:"",width:18,height:18,draggable:!1})}),e.jsx("span",{className:"text-[14px] leading-none text-[#333] transition-colors hover:text-[#1881F0]",children:c.label})]},c.label))})]})]})}function le({slots:t,welcomeMessage:a,suggestedPrompts:n,avatar:i,artifactPreview:r,capabilities:o,quickLinks:d,logo:l,showTimestamp:c}){const{messages:p,status:f,sendMessage:x,openPanel:m}=U(),{containerRef:b}=_e([p]),y=f==="streaming",u=t.WelcomeScreen??Ue,h=t.AppendContainer;return p.length===0?e.jsxs("div",{className:"sa-thread",ref:b,children:[e.jsx(u,{message:a,suggestedPrompts:n,onPromptClick:x,capabilities:o,quickLinks:d,logo:l,openPanel:m}),h&&e.jsx(h,{openPanel:m})]}):e.jsx("div",{className:"sa-thread",ref:b,children:p.map((k,T)=>e.jsx(Xe,{message:k,isStreaming:y,isLast:T===p.length-1,slots:t,avatar:i,artifactPreview:r,showTimestamp:c},k.id))})}function It({items:t,activeIndex:a,onSelect:n}){const i=s.useRef(null);return s.useEffect(()=>{var o;const r=(o=i.current)==null?void 0:o.children[a];r==null||r.scrollIntoView({block:"nearest"})},[a]),t.length===0?e.jsx("div",{className:"sa-slash-menu",children:e.jsx("div",{className:"sa-slash-menu-empty",children:"没有匹配的技能"})}):e.jsx("div",{className:"sa-slash-menu",ref:i,children:t.map((r,o)=>e.jsxs("div",{className:`sa-slash-menu-item${o===a?" sa-slash-menu-item--active":""}`,onMouseDown:d=>{d.preventDefault(),n(r)},children:[e.jsxs("span",{className:"sa-slash-menu-item-name",children:["/",r.name]}),(r.displayName||r.description)&&e.jsx("span",{className:"sa-slash-menu-item-desc",children:r.displayName||r.description})]},r.code))})}function Mt({sdk:t,input:a,onSelect:n}){const[i,r]=s.useState([]),[o,d]=s.useState(!1),[l,c]=s.useState(0),p=s.useRef(!1);s.useEffect(()=>{p.current||(p.current=!0,t.listSkills().then(r).catch(()=>r([])))},[t]);const f=/^\/\S*$/.test(a);s.useEffect(()=>{d(f)},[f]),s.useEffect(()=>{f&&c(0)},[a,f]);const x=a.startsWith("/")?a.slice(1).toLowerCase():"",m=s.useMemo(()=>i.filter(v=>!x||v.code.toLowerCase().includes(x)||v.name.toLowerCase().includes(x)||v.displayName&&v.displayName.toLowerCase().includes(x)),[i,x]),b=s.useRef(o),y=s.useRef(m),u=s.useRef(l),h=s.useRef(n);b.current=o,y.current=m,u.current=l,h.current=n;const k=s.useCallback(v=>{if(!b.current||y.current.length===0)return!1;switch(v.key){case"ArrowDown":return v.preventDefault(),c(j=>(j+1)%y.current.length),!0;case"ArrowUp":return v.preventDefault(),c(j=>(j-1+y.current.length)%y.current.length),!0;case"Enter":case"Tab":return v.preventDefault(),h.current(y.current[u.current]),d(!1),!0;case"Escape":return v.preventDefault(),d(!1),!0;default:return!1}},[]),T=s.useCallback(()=>d(!1),[]);return{isOpen:o,items:m,activeIndex:l,handleKeyDown:k,close:T}}function ce(){const{status:t,sendMessage:a,stop:n,sdk:i}=U(),[r,o]=s.useState(""),d=s.useRef(null),l=t==="streaming"||t==="submitted",c=!!r.trim()||l,p=s.useCallback(u=>{o(`/${u.name} `),setTimeout(()=>{const h=d.current;h&&(h.focus(),h.selectionStart=h.selectionEnd=h.value.length)},0)},[]),f=Mt({sdk:i,input:r,onSelect:p}),x=s.useCallback(()=>{const u=r.trim();!u||l||(a(u),o(""),d.current&&(d.current.style.height="auto"))},[r,l,a]),m=s.useCallback(u=>{f.handleKeyDown(u)||u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),x())},[x,f.handleKeyDown]),b=s.useCallback(u=>{o(u.target.value);const h=u.target;h.style.height="auto",h.style.height=Math.min(h.scrollHeight,90)+"px"},[]),y=s.useCallback(()=>{var u;l||(u=d.current)==null||u.focus()},[l]);return e.jsxs("div",{className:"relative z-[2] shrink-0 px-[15px] pb-2.5",children:[f.isOpen&&e.jsx(It,{items:f.items,activeIndex:f.activeIndex,onSelect:p}),e.jsxs("form",{className:`sa-input-form flex min-h-[70px] cursor-text items-start gap-2 rounded-[5px] p-2 ${c?"sa-input-form-active":""}`,onClick:y,onSubmit:u=>{u.preventDefault(),x()},children:[e.jsx("textarea",{ref:d,className:"sa-input-field flex-1 resize-none border-none bg-transparent p-0 text-[14px] leading-[1.5] text-[#333] outline-none placeholder:text-[#B8B8B8]",value:r,onChange:b,onKeyDown:m,placeholder:"请输入你想要了解的关键词",rows:1,disabled:l}),l?e.jsx("button",{type:"button",className:"sa-send-btn sa-send-btn-active","aria-label":"停止生成",title:"停止生成",onClick:n,children:e.jsx("span",{className:"sa-stop-icon"})}):e.jsx("button",{type:"submit",className:`sa-send-btn ${r.trim()?"sa-send-btn-active":""}`,"aria-label":"发送",title:"发送",children:e.jsx("img",{src:W.sendSolid,alt:"发送",width:14,height:14,draggable:!1})})]}),e.jsx("div",{className:"mt-3 text-center text-[11px] leading-none text-[#B8B8B8]",children:"所有内容均由AI生成仅供参考"})]})}function At({artifact:t}){const[a,n]=s.useState(null),[i,r]=s.useState(!0),[o,d]=s.useState(null);return s.useEffect(()=>{let l=!1;r(!0),d(null),n(null);async function c(){try{if(t.type==="pdf"){l||r(!1);return}if(t.type==="html"){const p=await fetch(t.url);if(!p.ok)throw new Error(`HTTP ${p.status}`);const f=await p.text(),x=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;l||(n(x.sanitize(f,{FORCE_BODY:!0,ADD_ATTR:["target"]})),r(!1));return}if(t.type==="docx"){const p=await fetch(t.url);if(!p.ok)throw new Error(`HTTP ${p.status}`);const f=await p.arrayBuffer(),m=await(await Promise.resolve().then(()=>require("./mammoth.browser-DiAPPO3x.cjs")).then(y=>y.mammoth_browser)).convertToHtml({arrayBuffer:f}),b=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;l||(n(b.sanitize(m.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),r(!1));return}l||(r(!1),d(`不支持预览「${t.type}」类型`))}catch(p){l||(r(!1),d(p instanceof Error?p.message:"加载失败"))}}return c(),()=>{l=!0}},[t]),i?e.jsx("div",{className:"sa-drawer-preview-loading",children:"加载中"}):o?e.jsxs("div",{className:"sa-drawer-preview-error",children:[o,e.jsx("button",{className:"sa-drawer-btn-sm",onClick:()=>void ae(t),children:"下载查看"})]}):t.type==="pdf"?e.jsx("iframe",{src:t.url,title:t.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):a!==null?e.jsx("div",{className:"sa-drawer-preview-html-scroll",children:e.jsx("div",{className:"sa-drawer-preview-html sa-text-part",dangerouslySetInnerHTML:{__html:a}})}):null}function Rt({artifacts:t,initialArtifact:a,onClose:n}){const[i,r]=s.useState(a?{mode:"preview",artifact:a}:{mode:"list"}),[o,d]=s.useState(!1),l=s.useRef(null),[c,p]=s.useState(340),f=s.useRef(null);s.useEffect(()=>{a&&(l.current&&(clearTimeout(l.current),l.current=null,d(!1)),r({mode:"preview",artifact:a}))},[a]);const x=s.useCallback(()=>{d(!0),l.current=setTimeout(()=>{l.current=null,n()},240)},[n]);s.useEffect(()=>()=>{var u;l.current&&clearTimeout(l.current),(u=f.current)==null||u.call(f)},[]);const m=s.useCallback(u=>{r({mode:"preview",artifact:u})},[]),b=s.useCallback(()=>{r({mode:"list"})},[]);s.useEffect(()=>{const u=h=>{h.key==="Escape"&&x()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[x]);const y=s.useCallback(u=>{u.preventDefault();const h=u.clientX,k=c,T=j=>{const I=h-j.clientX;p(Math.max(240,Math.min(window.innerWidth*.7,k+I)))},v=()=>{document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect="",f.current=null};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",T),document.addEventListener("mouseup",v),f.current=v},[c]);return e.jsxs("div",{className:`sa-artifact-drawer ${o?"sa-drawer-closing":""}`,style:{width:c},children:[e.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:y}),e.jsxs("div",{className:"sa-artifact-drawer-header",children:[i.mode==="preview"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"sa-drawer-btn",onClick:b,title:"返回列表","aria-label":"返回列表",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsx("span",{className:"sa-artifact-drawer-title",children:i.artifact.filename})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"sa-artifact-drawer-title",children:"会话产物"})]}),e.jsx("div",{style:{flex:1}}),i.mode==="preview"&&e.jsx("button",{className:"sa-drawer-btn",onClick:()=>void ae(i.artifact),title:"下载","aria-label":"下载",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),e.jsx("button",{className:"sa-drawer-btn",onClick:x,title:"关闭","aria-label":"关闭",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"sa-artifact-drawer-body",children:i.mode==="list"?t.length===0?e.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):e.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:t.map((u,h)=>e.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>m(u),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),m(u))},tabIndex:0,role:"button","aria-label":`预览 ${u.filename}`,children:[e.jsx("div",{className:"sa-drawer-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:Me(u.type)})}),e.jsxs("div",{className:"sa-drawer-file-info",children:[e.jsx("span",{className:"sa-drawer-file-name",children:u.filename}),e.jsx("span",{className:"sa-drawer-file-size",children:Ie(u.size)})]}),e.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${u.filename}`,onClick:k=>{k.stopPropagation(),ae(u)},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},u.id||`artifact-${h}`))}):e.jsx("div",{className:"sa-drawer-view-enter",children:e.jsx(At,{artifact:i.artifact})})})]})}function qe({page:t,onBack:a,centered:n}){s.useEffect(()=>{const r=o=>{o.key==="Escape"&&a()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[a]);const i=s.isValidElement(t.component)?s.cloneElement(t.component,{close:a}):s.createElement(t.component,{close:a});return e.jsxs("div",{className:`sa-page-overlay ${n?"sa-page-overlay-centered":""}`,children:[e.jsxs("div",{className:"sa-page-overlay-bar",children:[e.jsx("button",{className:"sa-drawer-btn",onClick:a,title:"返回","aria-label":"返回",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),t.title&&e.jsx("span",{className:"sa-page-overlay-title",children:t.title})]}),e.jsx("div",{className:"sa-page-overlay-body",children:i})]})}const $t="mx-auto w-full max-w-[800px]";function Ve({contentClassName:t,centered:a,composerClassName:n,thread:i,composer:r,artifactPreview:o}){const{activePanel:d,closePanel:l,messagesLoading:c,isArtifactDrawerOpen:p,allArtifacts:f,activePreviewArtifact:x,toggleArtifactDrawer:m}=U();if(d)return e.jsx(qe,{page:d,onBack:l,centered:a});const b=a?$t:"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`${t} ${b}`,children:[c?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):i,o&&p&&e.jsx(Rt,{artifacts:f,initialArtifact:x,onClose:m})]}),n?e.jsx("div",{className:`${n} ${b}`,children:r}):r]})}function Dt({isOpen:t,onClose:a,title:n,slots:i,welcomeMessage:r,suggestedPrompts:o,avatar:d,artifactPreview:l,capabilities:c,quickLinks:p,logo:f,defaultWidth:x,defaultHeight:m,showTimestamp:b}){const{status:y,sendMessage:u,stop:h,toggleThreadList:k,setThreadListOpen:T,isThreadListOpen:v,toggleArtifactDrawer:j,allArtifacts:I,activePanel:S,closePanel:w,messages:z,messagesLoading:A,conversations:R,activeConversationId:$,switchConversation:L,newConversation:M,deleteConversation:E,renameConversation:g,hasMore:N,loadMoreConversations:_}=U(),{width:F,position:C,hasCustomPosition:P,isMaximized:H,totalWidth:Y,windowHeight:de,startWindowDrag:tt,startResize:at,toggleMaximize:rt,reset:pe,setLockedHeight:re}=dt({defaultWidth:x??O.DEFAULT_WIDTH,defaultHeight:m??O.DEFAULT_HEIGHT,sidebarWidth:0}),ue=s.useRef(null),ge=s.useRef(null),se=!A&&z.length===0,Z=!A&&z.length>0,J=!!S;s.useEffect(()=>{t||(pe(),w())},[t,pe,w]),s.useEffect(()=>{T(H?ue.current??!0:ge.current??!1)},[H,T]),s.useEffect(()=>{Z||re(null)},[Z,re]);const st=pt({enabled:t&&Z&&!H&&!J,contentSelector:".sa-panel-content",defaultHeight:m??O.DEFAULT_HEIGHT,onHeightChange:re});if(!t)return null;const fe=i.Header,xe=i.Composer,Q=i.ThreadList,nt=()=>{const te=!v;k(),H?ue.current=te:ge.current=te},he=200,me=v&&!H,G="var(--sa-radius, 16px)",we=me?`0px ${G} ${G} 0px`:`${G} ${G} ${G} ${G}`,it=P?C.x:window.innerWidth-Y-20,ee=Math.min(he,Math.max(0,it-1)),ot=P?{width:`${Y}px`,height:`${de}px`,left:`${C.x}px`,top:`${C.y}px`}:{width:`${Y}px`,height:`${de}px`,right:"20px",bottom:"20px"},be={title:n,onClose:a,onToggleThreadList:nt,isMaximized:H,onToggleMaximize:rt,showHome:Z&&!J,onHome:M,artifactCount:J||!l?0:I.length,onToggleArtifactDrawer:J||!l?void 0:j},ve={conversations:R,activeSessionId:$,onSwitch:L,onNew:M,onDelete:E,onRename:g,hasMore:N,onLoadMore:_},ye=e.jsxs("div",{className:`relative flex min-w-0 flex-col bg-white ${H?"flex-1":"h-full shrink-0"}`,style:H?void 0:{width:`${F}px`,borderRadius:we,overflow:"hidden"},children:[se&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-home-gradient pointer-events-none absolute inset-x-0 top-0 z-0 h-[238px] opacity-10"}),e.jsx("div",{className:"sa-home-gradient-fade pointer-events-none absolute inset-x-0 top-0 z-[1] h-[238px]"})]}),e.jsx("div",{className:`relative z-20 ${se||H?"":"bg-white"} ${H?"cursor-default":"cursor-grab active:cursor-grabbing"}`,onMouseDown:H?void 0:tt,children:fe?e.jsx(fe,{...be}):e.jsx(De,{...be})}),e.jsx(Ve,{contentClassName:`sa-panel-content relative z-[2] ${se?"sa-home-view":""}`,centered:H,composerClassName:"shrink-0",artifactPreview:l,thread:e.jsx(le,{slots:i,welcomeMessage:r,suggestedPrompts:o,avatar:d,artifactPreview:l,capabilities:c,quickLinks:p,logo:f,showTimestamp:b}),composer:xe?e.jsx(xe,{status:y,onSend:u,onStop:h}):e.jsx(ce,{})})]});return H?e.jsx("div",{className:"fixed inset-0 z-[var(--sa-z-index,9999)] flex animate-sa-fade-in flex-col justify-end bg-black/30",children:e.jsxs("div",{className:"flex h-[calc(100%_-_48px)] w-full animate-sa-slide-up-full flex-row overflow-hidden bg-[#F5F5F5] shadow-[0_-12px_48px_rgba(0,0,0,0.25)]",style:{borderRadius:"var(--sa-radius, 16px) var(--sa-radius, 16px) 0px 0px"},children:[v&&(Q?e.jsx(Q,{...ve}):e.jsx(oe,{width:220})),ye]})}):e.jsxs("div",{ref:st,className:"fixed z-[var(--sa-z-index,9999)] flex animate-sa-window-in flex-row overflow-visible border border-[#DADADA] bg-white shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{...ot,borderRadius:we},children:[e.jsx("div",{className:"sa-resize-handle absolute bottom-0 left-[-3px] top-0 z-20 w-[6px] cursor-col-resize",onMouseDown:te=>at(te)}),me&&(Q?e.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{width:ee,transform:`translateX(-${ee}px)`,borderRadius:`${G} 0px 0px ${G}`},children:e.jsx(Q,{...ve})}):e.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{width:ee,transform:`translateX(-${ee}px)`,borderRadius:`${G} 0px 0px ${G}`},children:e.jsx(oe,{width:he})})),ye]})}const Lt=()=>{};function _t({conversations:t,activeSessionId:a,onSwitch:n,onNew:i,onDelete:r,onRename:o,isCollapsed:d,onToggleCollapse:l,hasMore:c,onLoadMore:p,conversationsLoading:f}){const[x,m]=s.useState(null),[b,y]=s.useState(null),[u,h]=s.useState(""),[k,T]=s.useState(null),v=s.useRef(null);s.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const j=s.useCallback((R,$)=>{$.stopPropagation(),x===R?(r(R),m(null)):(m(R),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>m(null),3e3))},[x,r]),I=s.useCallback((R,$,L)=>{L.stopPropagation(),y(R),h($??"")},[]),S=s.useCallback(R=>{u.trim()&&o(R,u.trim()),y(null)},[u,o]),w=s.useRef(null),z=s.useCallback(()=>{const R=w.current;!R||!c||!p||R.scrollHeight-R.scrollTop-R.clientHeight<50&&p()},[c,p]),A=s.useMemo(()=>Le(t),[t]);return d?e.jsxs("div",{className:"flex w-12 shrink-0 flex-col items-center gap-1 border-r border-[#ECECEC] bg-[#FAFAFA] py-3",children:[e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white","data-tooltip":"展开",onClick:l,children:e.jsx(D,{name:"panel-left",size:18})}),e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white","data-tooltip":"新建对话",onClick:()=>{i(),l()},children:e.jsx("img",{src:W.messageCreate,alt:"",width:18,height:18})})]}):e.jsxs("div",{className:"relative flex w-[220px] shrink-0 flex-col border-r border-[#ECECEC] bg-[#FAFAFA] p-3",children:[e.jsxs("div",{className:"mb-4 flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",className:"sa-new-chat flex h-8 flex-1 items-center justify-center gap-2 rounded-md text-[14px] font-medium transition-colors",onClick:i,children:[e.jsx("img",{src:W.messageCreate,alt:"",width:18,height:18}),e.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white","data-tooltip":"收起侧边栏",onClick:l,children:e.jsx(D,{name:"panel-left-close",size:16})})]}),e.jsxs("div",{className:"px-1 pb-2.5",children:[e.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),e.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),e.jsxs("div",{ref:w,className:"flex-1 overflow-y-auto",onScroll:z,children:[f&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!f&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),A.map(R=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:R.label}),R.items.map($=>{const L=$.sessionId===a,M=x===$.sessionId;return e.jsx("div",{className:`group relative mb-0.5 flex h-8 w-full cursor-pointer items-center gap-1 rounded-md px-0.5 text-[13px] transition-colors ${L?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{b!==$.sessionId&&n($.sessionId)},onMouseEnter:E=>{if(b===$.sessionId)return;const g=E.currentTarget.getBoundingClientRect();T({text:$.title||"新会话",x:g.right+8,y:g.top+g.height/2})},onMouseLeave:()=>T(null),children:b===$.sessionId?e.jsx("input",{className:"w-full rounded border border-[var(--sa-primary)] bg-white px-1.5 py-0.5 text-[12px] outline-none",value:u,onChange:E=>h(E.target.value),onBlur:()=>S($.sessionId),onKeyDown:E=>{E.key==="Enter"&&S($.sessionId),E.key==="Escape"&&y(null)},onClick:E=>E.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:W.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:$.title||"新会话"}),e.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[e.jsx("button",{type:"button",className:"flex h-5 w-5 items-center justify-center rounded text-[#999] hover:bg-white/70 hover:text-[var(--sa-primary)]",onClick:E=>I($.sessionId,$.title,E),title:"重命名",children:e.jsx(D,{name:"pen",size:12})}),e.jsx("button",{type:"button",className:`flex h-5 w-5 items-center justify-center rounded ${M?"bg-[#fee2e2] text-[#ef4444]":"text-[#999] hover:bg-white/70 hover:text-[#ef4444]"}`,onClick:E=>j($.sessionId,E),title:M?"确认删除":"删除",children:e.jsx(D,{name:M?"x":"trash2",size:12})})]})]})},$.sessionId)})]},R.label)),c&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),k&&e.jsx("div",{className:"pointer-events-none fixed z-[10001] whitespace-nowrap rounded border border-[#E8E8E8] bg-white px-2.5 py-1.5 text-[12px] leading-[1.4] text-[#333] shadow-[0_2px_8px_rgba(0,0,0,0.12)]",style:{left:k.x,top:k.y,transform:"translateY(-50%)"},children:k.text})]})}function Ke({title:t,slots:a,welcomeMessage:n,suggestedPrompts:i,capabilities:r,quickLinks:o,logo:d,sidebarDefaultOpen:l=!0,onClose:c,avatar:p,artifactPreview:f,showTimestamp:x}){const{status:m,sendMessage:b,stop:y,conversations:u,activeConversationId:h,switchConversation:k,newConversation:T,deleteConversation:v,renameConversation:j,toggleArtifactDrawer:I,allArtifacts:S,activePanel:w,closePanel:z,hasMore:A,loadMoreConversations:R,conversationsLoading:$}=U(),[L,M]=s.useState(l),E=s.useCallback(()=>M(C=>!C),[]),g=!!w;s.useEffect(()=>()=>z(),[z]);const N=a.ThreadList,_=a.Composer,F=a.Header;return e.jsxs("div",{className:"sa-fullpage",children:[N?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${L?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(N,{conversations:u,activeSessionId:h,onSwitch:k,onNew:T,onDelete:v,onRename:j,hasMore:A,onLoadMore:R})}):e.jsx(_t,{conversations:u,activeSessionId:h,onSwitch:k,onNew:T,onDelete:v,onRename:j,isCollapsed:!L,onToggleCollapse:E,hasMore:A,onLoadMore:R,conversationsLoading:$}),e.jsxs("div",{className:"sa-fp-main",children:[F?e.jsx(F,{title:t,onClose:c??Lt,onToggleThreadList:E,artifactCount:g||!f?0:S.length,onToggleArtifactDrawer:g||!f?void 0:I}):e.jsxs("div",{className:"sa-fp-header",children:[e.jsx("div",{className:"sa-fp-header-title",children:t}),e.jsx("div",{className:"sa-fp-header-actions",children:!g&&f&&S.length>0&&e.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:I,title:"会话产物",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{children:"产物"})]})})]}),e.jsx(Ve,{contentClassName:"sa-fp-content-row",artifactPreview:f,thread:e.jsx(le,{slots:a,welcomeMessage:n,suggestedPrompts:i,capabilities:r,quickLinks:o,logo:d,avatar:p,artifactPreview:f,showTimestamp:x}),composer:_?e.jsx(_,{status:m,onSend:b,onStop:y}):e.jsx(ce,{})})]})]})}function Ze(t){const{sdk:a,mode:n="floating",slots:i={},hooks:r={},welcomeMessage:o,suggestedPrompts:d,title:l="AI Assistant",initialOpen:c=!1,onOpenChange:p,sidebarDefaultOpen:f,avatar:x,artifactPreview:m,capabilities:b,quickLinks:y,logo:u,triggerLogo:h,theme:k,showTimestamp:T}=t,[v,j]=s.useState(c);s.useEffect(()=>{j(c)},[c]);const I=s.useCallback(()=>{var A,R;const z=!v;j(z),p==null||p(z),z?(A=r.onOpen)==null||A.call(r):(R=r.onClose)==null||R.call(r)},[v,r,p]),S=s.useCallback(()=>{var z;j(!1),p==null||p(!1),(z=r.onClose)==null||z.call(r)},[r,p]),w=i.Trigger??$e;return n==="fullpage"?v?e.jsx(ie,{sdk:a,hooks:r,children:e.jsx(Ke,{title:l,slots:i,welcomeMessage:o,suggestedPrompts:d,capabilities:b,quickLinks:y,logo:u,sidebarDefaultOpen:f,onClose:S,avatar:x,artifactPreview:m,showTimestamp:T})}):null:e.jsxs(ie,{sdk:a,hooks:r,children:[e.jsx(w,{isOpen:v,onClick:I,triggerLogo:h}),e.jsx(Dt,{isOpen:v,onClose:S,title:l,slots:i,welcomeMessage:o,suggestedPrompts:d,avatar:x,artifactPreview:m,capabilities:b,quickLinks:y,logo:u,defaultWidth:k==null?void 0:k.panelWidth,defaultHeight:k==null?void 0:k.panelHeight,showTimestamp:T})]})}const Je=`
4
4
  [data-super-agent-widget] {
5
5
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
6
6
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -18,147 +18,35 @@
18
18
  text-rendering: optimizeLegibility;
19
19
  }
20
20
 
21
+ /* 迷你 preflight(scoped):Tailwind preflight 已禁用(避免污染宿主页),
22
+ 但 border 工具类只输出 border-width、无 border-style(CSS 初始值 none → 边框不渲染),
23
+ button/ul 也会吃到浏览器原生样式。此处补齐等价复位:
24
+ - 特异性 (0,1,0),低于 scoped utility (0,2,0),靠源顺序让位于后置的 sa-* plain 类
25
+ - 两条注入顺序固定为 widgetStyles + tailwindStyles(mount.ts),utility 恒在其后 */
21
26
  [data-super-agent-widget] *,
22
27
  [data-super-agent-widget] *::before,
23
28
  [data-super-agent-widget] *::after {
24
29
  box-sizing: border-box;
25
30
  margin: 0;
26
31
  padding: 0;
32
+ border-width: 0;
33
+ border-style: solid;
34
+ border-color: var(--sa-border, #e5e7eb);
27
35
  }
28
36
 
29
- [data-super-agent-widget] button {
37
+ /* :where() 零特异性贡献:plain-CSS 组件类(如 .sa-new-chat 的渐变底)不受影响 */
38
+ [data-super-agent-widget] :where(button) {
30
39
  font-family: inherit;
31
- }
32
-
33
- /* ── Trigger ─────────────────────────────────────────────── */
34
-
35
- .sa-trigger {
36
- position: fixed;
37
- bottom: 24px;
38
- right: 24px;
39
- width: 56px;
40
- height: 56px;
41
- border: none;
42
- border-radius: 50%;
40
+ background-color: transparent;
41
+ background-image: none;
43
42
  cursor: pointer;
44
- display: flex;
45
- align-items: center;
46
- justify-content: center;
47
- background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
48
- color: #ffffff;
49
- font-size: 24px;
50
- box-shadow: 0 8px 24px color-mix(in srgb, var(--sa-primary) 35%, transparent);
51
- z-index: var(--sa-z-index, 9999);
52
- transition: transform 0.2s ease, box-shadow 0.2s ease;
53
- }
54
-
55
- .sa-trigger:hover {
56
- transform: scale(1.08);
57
- box-shadow: 0 12px 32px color-mix(in srgb, var(--sa-primary) 45%, transparent);
58
- }
59
-
60
- .sa-trigger:active {
61
- transform: scale(0.94);
62
- }
63
-
64
- .sa-trigger-open {
65
- transform: rotate(90deg);
66
- }
67
-
68
- /* ── Panel ───────────────────────────────────────────────── */
69
-
70
- .sa-panel {
71
- position: fixed;
72
- bottom: 96px;
73
- right: 24px;
74
- width: var(--sa-panel-width, 380px);
75
- height: var(--sa-panel-height, 520px);
76
- max-height: calc(100vh - 120px);
77
- display: flex;
78
- flex-direction: column;
79
- overflow: hidden;
80
- background: var(--sa-bg);
81
- border: 1px solid var(--sa-border);
82
- border-radius: var(--sa-radius, 16px);
83
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
84
- z-index: var(--sa-z-index, 9999);
85
- animation: sa-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
86
- }
87
-
88
- /* ── Header ──────────────────────────────────────────────── */
89
-
90
- .sa-header {
91
- display: flex;
92
- align-items: center;
93
- gap: 10px;
94
- padding: 14px 16px;
95
- color: #ffffff;
96
- background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
97
- flex-shrink: 0;
98
- }
99
-
100
- .sa-header-left {
101
- display: flex;
102
- align-items: center;
103
- gap: 10px;
104
- flex: 1;
105
- }
106
-
107
- .sa-header-avatar {
108
- width: 28px;
109
- height: 28px;
110
- border-radius: 50%;
111
- background: rgba(255,255,255,0.2);
112
- display: flex;
113
- align-items: center;
114
- justify-content: center;
115
- font-size: 12px;
116
- font-weight: 600;
117
- }
118
-
119
- .sa-header-info {
120
- display: flex;
121
- flex-direction: column;
122
- }
123
-
124
- .sa-header-status {
125
- font-size: 11px;
126
- opacity: 0.8;
127
- color: #a5f3a6;
128
- }
129
-
130
- .sa-header-actions {
131
- display: flex;
132
- gap: 4px;
133
- }
134
-
135
- .sa-header-title {
136
- flex: 1;
137
- font-size: 16px;
138
- font-weight: 600;
139
- white-space: nowrap;
140
- overflow: hidden;
141
- text-overflow: ellipsis;
142
43
  }
143
44
 
144
- .sa-header-btn {
145
- width: 30px;
146
- height: 30px;
147
- border: none;
148
- border-radius: 8px;
149
- background: transparent;
150
- color: #ffffff;
151
- font-size: 16px;
152
- cursor: pointer;
153
- display: flex;
154
- align-items: center;
155
- justify-content: center;
156
- transition: background 0.15s ease;
45
+ [data-super-agent-widget] :where(ul, ol) {
46
+ list-style: none;
157
47
  }
158
48
 
159
- .sa-header-btn:hover {
160
- background: rgba(255, 255, 255, 0.18);
161
- }
49
+ /* ── Trigger / Panel / Header(浮窗框架已改用 Tailwind 实现,见 tailwind.css) ── */
162
50
 
163
51
  /* ── Thread / messages ───────────────────────────────────── */
164
52
 
@@ -166,7 +54,7 @@
166
54
  flex: 1;
167
55
  display: flex;
168
56
  flex-direction: column;
169
- gap: 14px;
57
+ gap: 16px;
170
58
  overflow-y: auto;
171
59
  padding: 16px;
172
60
  background: var(--sa-surface);
@@ -186,6 +74,9 @@
186
74
  background: rgba(0, 0, 0, 0.24);
187
75
  }
188
76
 
77
+ /* ── Message:浮窗默认 hr-for-help 风格(AI 头像独占一行);
78
+ fullpage 模式在 .sa-fp-content-row 下恢复原横排布局,互不影响 ── */
79
+
189
80
  .sa-message {
190
81
  display: flex;
191
82
  align-items: flex-start;
@@ -197,6 +88,13 @@
197
88
  justify-content: flex-end;
198
89
  }
199
90
 
91
+ /* AI 消息:列布局,头像独占一行(仅浮窗,对齐 hr-for-help msgAi) */
92
+ .sa-message-assistant {
93
+ flex-direction: column;
94
+ align-items: flex-start;
95
+ gap: 6px;
96
+ }
97
+
200
98
  .sa-message-content {
201
99
  max-width: 78%;
202
100
  display: flex;
@@ -204,33 +102,42 @@
204
102
  gap: 4px;
205
103
  }
206
104
 
105
+ .sa-message-user .sa-message-content {
106
+ max-width: 90%;
107
+ }
108
+
109
+ .sa-message-assistant .sa-message-content {
110
+ max-width: 100%;
111
+ min-width: 0;
112
+ width: 100%;
113
+ }
114
+
207
115
  .sa-message-body {
208
116
  display: flex;
209
117
  flex-direction: column;
210
118
  gap: 4px;
211
119
  }
212
120
 
121
+ /* 浮窗气泡:用户浅蓝、AI 白底描边(对齐 hr-for-help) */
213
122
  .sa-message-user .sa-message-body {
214
- padding: 10px 14px;
215
- border-radius: 16px;
216
- border-bottom-right-radius: 4px;
217
- background: var(--sa-primary);
218
- color: #ffffff;
123
+ padding: 8px 12px;
124
+ border-radius: 8px 8px 0 8px;
125
+ background: #E8F1FE;
126
+ color: #333333;
219
127
  font-size: 14px;
220
- line-height: 1.55;
128
+ line-height: 1.6;
221
129
  word-break: break-word;
222
130
  }
223
131
 
224
132
  .sa-message-assistant .sa-message-body {
225
- padding: 10px 14px;
226
- border-radius: 16px;
227
- border-bottom-left-radius: 4px;
133
+ padding: 10px 12px;
134
+ border-radius: 8px;
228
135
  background: #ffffff;
136
+ border: 1px solid #E0E0E0;
229
137
  color: var(--sa-text);
230
138
  font-size: 14px;
231
- line-height: 1.55;
139
+ line-height: 1.5;
232
140
  word-break: break-word;
233
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
234
141
  }
235
142
 
236
143
  .sa-message-time {
@@ -243,26 +150,72 @@
243
150
  text-align: right;
244
151
  }
245
152
 
246
- .sa-avatar {
247
- width: 28px;
248
- height: 28px;
249
- flex-shrink: 0;
153
+ /* 消息头像:裸展示,无背景色(对齐 hr-for-help msgAvatar) */
154
+ .sa-msg-avatar {
155
+ width: 24px;
156
+ height: 24px;
250
157
  border-radius: 50%;
251
- display: flex;
158
+ object-fit: cover;
159
+ flex-shrink: 0;
160
+ display: block;
161
+ }
162
+
163
+ .sa-msg-avatar-text {
164
+ display: inline-flex;
252
165
  align-items: center;
253
166
  justify-content: center;
254
- color: #ffffff;
255
- font-size: 12px;
256
- font-weight: 600;
257
- overflow: hidden;
167
+ font-size: 18px;
168
+ font-weight: 400;
258
169
  }
259
170
 
260
- .sa-avatar-assistant {
261
- background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
171
+ /* ── fullpage 覆盖:恢复横排头像 + 经典气泡(不受浮窗 hr-for-help 改版影响) ── */
172
+
173
+ .sa-fp-content-row .sa-message-assistant {
174
+ flex-direction: row;
175
+ gap: 10px;
176
+ }
177
+
178
+ .sa-fp-content-row .sa-message-assistant .sa-message-content {
179
+ max-width: 88%;
180
+ width: auto;
181
+ }
182
+
183
+ .sa-fp-content-row .sa-message-user .sa-message-content {
184
+ max-width: 78%;
262
185
  }
263
186
 
264
- .sa-avatar-user {
265
- background: linear-gradient(135deg, #64748b, #475569);
187
+ // .sa-fp-content-row .sa-message-user .sa-message-body {
188
+ // padding: 10px 14px;
189
+ // border-radius: 16px;
190
+ // border-bottom-right-radius: 4px;
191
+ // background: var(--sa-primary);
192
+ // color: #ffffff;
193
+ // font-size: 14px;
194
+ // line-height: 1.55;
195
+ // word-break: break-word;
196
+ // }
197
+
198
+ .sa-fp-content-row .sa-message-assistant .sa-message-body {
199
+ padding: 10px 14px;
200
+ border-radius: 16px;
201
+ background: #ffffff;
202
+ color: var(--sa-text);
203
+ font-size: 14px;
204
+ line-height: 1.55;
205
+ word-break: break-word;
206
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
207
+ }
208
+
209
+ .sa-fp-content-row .sa-msg-avatar {
210
+ width: 24px;
211
+ height: 24px;
212
+ }
213
+
214
+ .sa-fp-content-row .sa-msg-avatar-text {
215
+ background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
216
+ color: #ffffff;
217
+ font-size: 12px;
218
+ font-weight: 600;
266
219
  }
267
220
 
268
221
  /* ── Text part (markdown) ────────────────────────────────── */
@@ -638,84 +591,7 @@
638
591
  }
639
592
  .sa-dislike-cancel:hover { background: var(--sa-surface); }
640
593
 
641
- /* ── Composer ────────────────────────────────────────────── */
642
-
643
- .sa-composer {
644
- position: relative;
645
- display: flex;
646
- align-items: flex-end;
647
- gap: 10px;
648
- padding: 12px 14px;
649
- border-top: 1px solid var(--sa-border);
650
- background: var(--sa-bg);
651
- flex-shrink: 0;
652
- }
653
-
654
- .sa-composer-input {
655
- flex: 1;
656
- min-height: 38px;
657
- max-height: 120px;
658
- padding: 9px 14px;
659
- border: 1px solid var(--sa-border);
660
- border-radius: 19px;
661
- background: var(--sa-surface);
662
- color: var(--sa-text);
663
- font-family: var(--sa-font);
664
- font-size: 14px;
665
- line-height: 1.5;
666
- resize: none;
667
- outline: none;
668
- transition: border-color 0.2s ease, background 0.2s ease;
669
- }
670
-
671
- .sa-composer-input::placeholder {
672
- color: #9ca3af;
673
- }
674
-
675
- .sa-composer-input:focus {
676
- border-color: var(--sa-primary);
677
- background: #ffffff;
678
- }
679
-
680
- .sa-composer-send,
681
- .sa-composer-stop {
682
- width: 38px;
683
- height: 38px;
684
- flex-shrink: 0;
685
- border: none;
686
- border-radius: 50%;
687
- cursor: pointer;
688
- display: flex;
689
- align-items: center;
690
- justify-content: center;
691
- color: #ffffff;
692
- font-size: 16px;
693
- transition: transform 0.15s ease, background 0.2s ease;
694
- }
695
-
696
- .sa-composer-send {
697
- background: var(--sa-primary);
698
- }
699
-
700
- .sa-composer-send:hover {
701
- background: var(--sa-primary-dark);
702
- transform: scale(1.05);
703
- }
704
-
705
- .sa-composer-send:disabled {
706
- opacity: 0.5;
707
- cursor: not-allowed;
708
- transform: none;
709
- }
710
-
711
- .sa-composer-stop {
712
- background: #ef4444;
713
- }
714
-
715
- .sa-composer-stop:hover {
716
- background: #dc2626;
717
- transform: scale(1.05);
718
- }
594
+ /* ── Composer(输入区改用 Tailwind 实现,见 tailwind.css 的 .sa-input-form/.sa-send-btn) ── */
719
595
 
720
596
  /* ── Slash Menu ─────────────────────────────────────────── */
721
597
 
@@ -773,89 +649,7 @@
773
649
  min-width: 0;
774
650
  }
775
651
 
776
- /* ── Thread list ─────────────────────────────────────────── */
777
-
778
- .sa-thread-list-overlay {
779
- position: absolute;
780
- inset: 0;
781
- background: rgba(0,0,0,0.3);
782
- z-index: 19;
783
- }
784
-
785
- .sa-thread-list {
786
- position: absolute;
787
- top: 0;
788
- left: 0;
789
- bottom: 0;
790
- width: 100%;
791
- display: flex;
792
- flex-direction: column;
793
- background: #ffffff;
794
- z-index: 20;
795
- box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
796
- animation: sa-slide-in-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
797
- }
798
-
799
- .sa-thread-list-header {
800
- display: flex;
801
- align-items: center;
802
- justify-content: space-between;
803
- padding: 20px 20px 16px;
804
- flex-shrink: 0;
805
- }
806
-
807
- .sa-thread-list-title {
808
- font-size: 17px;
809
- font-weight: 700;
810
- color: #18181b;
811
- letter-spacing: -0.2px;
812
- }
813
-
814
- .sa-thread-list-new {
815
- display: flex;
816
- align-items: center;
817
- gap: 6px;
818
- padding: 8px 16px;
819
- border: none;
820
- border-radius: 20px;
821
- background: #f4f4f5;
822
- color: #3f3f46;
823
- font-size: 13px;
824
- font-weight: 500;
825
- cursor: pointer;
826
- transition: background 0.15s;
827
- }
828
-
829
- .sa-thread-list-new:hover {
830
- background: #e4e4e7;
831
- }
832
-
833
- .sa-thread-list-items {
834
- flex: 1;
835
- overflow-y: auto;
836
- padding: 0 12px 12px;
837
- }
838
-
839
- .sa-thread-list-empty {
840
- padding: 48px 16px;
841
- text-align: center;
842
- color: var(--sa-text-muted);
843
- font-size: 14px;
844
- }
845
-
846
- .sa-thread-list-loading {
847
- padding: 12px 16px;
848
- text-align: center;
849
- color: #9ca3af;
850
- font-size: 13px;
851
- }
852
-
853
- .sa-thread-list-hint {
854
- padding: 8px 16px 12px;
855
- text-align: center;
856
- color: #d1d5db;
857
- font-size: 12px;
858
- }
652
+ /* ── Thread list(内嵌侧边栏改用 Tailwind 实现,见 FullpageLayout.tsx / ThreadList.tsx) ── */
859
653
 
860
654
  /* 消息区加载态 */
861
655
  .sa-messages-loading {
@@ -882,155 +676,12 @@
882
676
  to { transform: rotate(360deg); }
883
677
  }
884
678
 
885
- .sa-thread-group-label {
886
- padding: 16px 8px 6px;
887
- font-size: 12px;
888
- font-weight: 500;
889
- color: #a1a1aa;
890
- }
891
-
892
- .sa-thread-item {
893
- display: flex;
894
- align-items: center;
895
- justify-content: space-between;
896
- gap: 8px;
897
- padding: 10px 12px;
898
- margin: 2px 0;
899
- border-radius: 8px;
900
- color: #374151;
901
- font-size: 14px;
902
- cursor: pointer;
903
- transition: background 0.15s ease;
904
- }
905
-
906
- .sa-thread-item:hover {
907
- background: #f9fafb;
908
- }
909
-
910
- .sa-thread-item.active {
911
- background: var(--sa-primary-light);
912
- color: var(--sa-primary-dark);
913
- font-weight: 500;
914
- }
915
-
916
- .sa-thread-item-info {
917
- flex: 1;
918
- overflow: hidden;
919
- display: flex;
920
- flex-direction: column;
921
- gap: 2px;
922
- }
923
-
924
- .sa-thread-item-title {
925
- overflow: hidden;
926
- white-space: nowrap;
927
- text-overflow: ellipsis;
928
- }
929
-
930
- .sa-thread-item-time {
931
- font-size: 11px;
932
- color: var(--sa-text-light);
933
- white-space: nowrap;
934
- }
935
-
936
- .sa-thread-item-edit {
937
- width: 100%;
938
- padding: 4px 8px;
939
- border: 1px solid var(--sa-primary);
940
- border-radius: 6px;
941
- font-size: 13px;
942
- outline: none;
943
- background: var(--sa-bg);
944
- color: var(--sa-text);
945
- }
946
-
947
- /* 操作按钮组:始终占位(visibility 控制),hover 时显示,高度不变 */
948
- .sa-thread-item-actions {
949
- display: flex;
950
- gap: 2px;
951
- flex-shrink: 0;
952
- visibility: hidden;
953
- }
954
-
955
- .sa-thread-item:hover .sa-thread-item-actions {
956
- visibility: visible;
957
- }
958
-
959
- .sa-thread-item-action-btn {
960
- border: none;
961
- background: transparent;
962
- color: var(--sa-text-muted);
963
- cursor: pointer;
964
- padding: 2px;
965
- border-radius: 4px;
966
- display: inline-flex;
967
- align-items: center;
968
- transition: color 0.15s ease, background 0.15s ease;
969
- }
970
-
971
- .sa-thread-item-action-btn:hover {
972
- color: var(--sa-primary);
973
- background: rgba(99,102,241,0.08);
974
- }
975
-
976
- /* ── Welcome ─────────────────────────────────────────────── */
679
+ /* ── Welcome(首页改用 Tailwind 实现,见 tailwind.css) ── */
977
680
 
978
- .sa-welcome {
979
- flex: 1;
980
- display: flex;
981
- flex-direction: column;
982
- align-items: center;
983
- justify-content: center;
984
- padding: 24px;
985
- text-align: center;
986
- }
987
-
988
- .sa-welcome-icon {
989
- font-size: 40px;
990
- margin-bottom: 12px;
991
- }
992
-
993
- .sa-welcome-message {
994
- margin-bottom: 20px;
681
+ .sa-thinking-indicator {
682
+ color: #9ca3af;
995
683
  font-size: 14px;
996
- color: var(--sa-text-muted);
997
- line-height: 1.6;
998
- }
999
-
1000
- .sa-welcome-prompts {
1001
- display: flex;
1002
- flex-direction: column;
1003
- gap: 8px;
1004
- width: 100%;
1005
- }
1006
-
1007
- .sa-welcome-prompt {
1008
- padding: 10px 16px;
1009
- border: 1px solid var(--sa-border);
1010
- border-radius: 999px;
1011
- background: #ffffff;
1012
- color: #374151;
1013
- font-size: 13px;
1014
- cursor: pointer;
1015
- transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
1016
- }
1017
-
1018
- .sa-welcome-prompt:hover {
1019
- border-color: var(--sa-primary);
1020
- background: var(--sa-primary-light);
1021
- color: var(--sa-primary-dark);
1022
- }
1023
-
1024
- /* ── Streaming cursor ────────────────────────────────────── */
1025
-
1026
- .sa-streaming-cursor {
1027
- display: inline-block;
1028
- width: 2px;
1029
- height: 1em;
1030
- margin-left: 2px;
1031
- background: var(--sa-primary);
1032
- vertical-align: text-bottom;
1033
- animation: sa-blink 1s steps(2, start) infinite;
684
+ animation: sa-blink 1.2s ease-in-out infinite;
1034
685
  }
1035
686
 
1036
687
  /* ── Interrupt cards ──────────────────────────────────────── */
@@ -1247,17 +898,6 @@
1247
898
 
1248
899
  /* ── Animations ──────────────────────────────────────────── */
1249
900
 
1250
- @keyframes sa-slide-up {
1251
- from {
1252
- opacity: 0;
1253
- transform: translateY(16px) scale(0.98);
1254
- }
1255
- to {
1256
- opacity: 1;
1257
- transform: translateY(0) scale(1);
1258
- }
1259
- }
1260
-
1261
901
  @keyframes sa-blink {
1262
902
  0%,
1263
903
  100% {
@@ -1268,17 +908,6 @@
1268
908
  }
1269
909
  }
1270
910
 
1271
- @keyframes sa-slide-in-left {
1272
- from {
1273
- opacity: 0;
1274
- transform: translateX(-100%);
1275
- }
1276
- to {
1277
- opacity: 1;
1278
- transform: translateX(0);
1279
- }
1280
- }
1281
-
1282
911
  /* ── Fullpage Layout (DeepSeek-style) ────────────────────────── */
1283
912
 
1284
913
  .sa-fullpage {
@@ -1289,208 +918,21 @@
1289
918
  background: var(--sa-bg, #ffffff);
1290
919
  }
1291
920
 
1292
- /* Sidebar */
1293
- .sa-fp-sidebar {
1294
- width: 260px;
1295
- display: flex;
1296
- flex-direction: column;
1297
- background: var(--sa-surface, #ffffff);
1298
- flex-shrink: 0;
1299
- transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
1300
- overflow: hidden;
1301
- border-right: 1px solid #e8e8ea;
1302
- }
1303
-
1304
- .sa-fp-sidebar-collapsed {
1305
- width: 52px;
1306
- align-items: center;
1307
- padding-top: 12px;
1308
- gap: 4px;
1309
- border-right: 1px solid #e8e8ea;
1310
- }
1311
-
1312
- .sa-fp-sidebar-header {
1313
- display: flex;
1314
- align-items: center;
1315
- gap: 8px;
1316
- padding: 12px 12px 8px;
1317
- flex-shrink: 0;
1318
- }
1319
-
1320
- .sa-fp-sidebar-toggle {
1321
- width: 32px;
1322
- height: 32px;
1323
- border: none;
1324
- border-radius: 8px;
1325
- background: transparent;
1326
- color: #71717a;
1327
- cursor: pointer;
1328
- display: flex;
1329
- align-items: center;
1330
- justify-content: center;
1331
- transition: background 0.12s, color 0.12s;
1332
- flex-shrink: 0;
1333
- }
1334
-
1335
- .sa-fp-sidebar-toggle:hover {
1336
- background: #e4e4e7;
1337
- color: #18181b;
1338
- }
1339
-
1340
- .sa-fp-sidebar-new {
1341
- flex: 1;
1342
- padding: 7px 12px;
1343
- border: 1px solid #d4d4d8;
1344
- border-radius: 8px;
1345
- background: #fff;
1346
- color: #3f3f46;
1347
- font-size: 13px;
1348
- font-weight: 500;
1349
- cursor: pointer;
1350
- display: flex;
1351
- align-items: center;
1352
- gap: 6px;
1353
- transition: border-color 0.12s, box-shadow 0.12s;
1354
- }
1355
-
1356
- .sa-fp-sidebar-new:hover {
1357
- border-color: #a1a1aa;
1358
- box-shadow: 0 1px 3px rgba(0,0,0,0.06);
1359
- }
1360
-
1361
- .sa-fp-sidebar-new span {
1362
- font-size: 13px;
1363
- }
1364
-
1365
- .sa-fp-sidebar-list {
1366
- flex: 1;
1367
- overflow-y: auto;
1368
- padding: 4px 8px 12px;
1369
- }
1370
-
1371
- .sa-fp-sidebar-list::-webkit-scrollbar {
1372
- width: 4px;
1373
- }
1374
-
1375
- .sa-fp-sidebar-list::-webkit-scrollbar-thumb {
1376
- background: rgba(0,0,0,0.08);
1377
- border-radius: 2px;
1378
- }
1379
-
1380
- .sa-fp-sidebar-list::-webkit-scrollbar-thumb:hover {
1381
- background: rgba(0,0,0,0.15);
1382
- }
1383
-
1384
- .sa-fp-sidebar-group {
1385
- padding: 12px 8px 4px;
1386
- font-size: 11px;
1387
- font-weight: 500;
1388
- color: #a1a1aa;
1389
- letter-spacing: 0.3px;
1390
- }
1391
-
1392
- .sa-fp-sidebar-item {
1393
- display: flex;
1394
- align-items: center;
1395
- gap: 8px;
1396
- padding: 8px 10px;
1397
- margin: 1px 0;
1398
- border-radius: 8px;
1399
- cursor: pointer;
1400
- color: #3f3f46;
1401
- font-size: 13px;
1402
- line-height: 1.4;
1403
- transition: background 0.1s;
1404
- }
1405
-
1406
- .sa-fp-sidebar-item:hover {
1407
- background: #e8e8ea;
1408
- }
921
+ /* Sidebar(fullpage 默认侧边栏改用 Tailwind 实现,对齐浮窗历史对话样式,见 FullpageLayout.tsx) */
1409
922
 
1410
- .sa-fp-sidebar-item.active {
1411
- background: #e4e4e7;
1412
- color: #18181b;
1413
- font-weight: 500;
1414
- }
1415
-
1416
- .sa-fp-sidebar-item-title {
1417
- flex: 1;
1418
- overflow: hidden;
1419
- white-space: nowrap;
1420
- text-overflow: ellipsis;
1421
- }
1422
-
1423
- .sa-fp-sidebar-item-edit {
1424
- flex: 1;
1425
- min-width: 0;
1426
- padding: 2px 6px;
1427
- border: 1px solid var(--sa-primary, #6366f1);
1428
- border-radius: 4px;
1429
- font-size: 13px;
1430
- color: #27272a;
1431
- background: #fff;
1432
- outline: none;
1433
- }
1434
-
1435
- .sa-fp-sidebar-item-actions {
1436
- display: flex;
1437
- gap: 2px;
1438
- flex-shrink: 0;
1439
- visibility: hidden;
1440
- }
1441
-
1442
- .sa-fp-sidebar-item-actions.visible {
1443
- visibility: visible;
1444
- }
1445
-
1446
- .sa-fp-sidebar-item-action {
1447
- width: 24px;
1448
- height: 24px;
1449
- border: none;
1450
- border-radius: 6px;
1451
- background: transparent;
1452
- color: #a1a1aa;
1453
- cursor: pointer;
1454
- display: flex;
1455
- align-items: center;
1456
- justify-content: center;
1457
- flex-shrink: 0;
1458
- transition: color 0.1s, background 0.1s;
1459
- }
1460
-
1461
- .sa-fp-sidebar-item-action:hover {
1462
- color: #71717a;
1463
- background: rgba(0,0,0,0.05);
1464
- }
1465
-
1466
- .sa-fp-sidebar-item-action.danger {
1467
- color: #ef4444;
1468
- }
1469
-
1470
- .sa-fp-sidebar-item-action.danger:hover {
1471
- color: #dc2626;
1472
- background: rgba(239,68,68,0.08);
1473
- }
1474
-
1475
- .sa-fp-sidebar-empty {
1476
- padding: 32px 12px;
1477
- text-align: center;
1478
- color: #a1a1aa;
1479
- font-size: 13px;
1480
- }
1481
-
1482
- /* Sidebar wrapper (for custom ThreadList slot) */
923
+ /* Sidebar wrapper (for custom ThreadList slot):宽度与默认侧边栏 220px 对齐 */
1483
924
  .sa-fp-sidebar-wrapper {
1484
- width: 260px;
925
+ width: 220px;
1485
926
  flex-shrink: 0;
1486
927
  overflow: hidden;
1487
- border-right: 1px solid #e8e8ea;
1488
- background: #f2f2f3;
928
+ border-right: 1px solid #ECECEC;
929
+ background: #FAFAFA;
1489
930
  transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
1490
931
  }
1491
932
 
1492
933
  .sa-fp-sidebar-wrapper-collapsed {
1493
934
  width: 0;
935
+ border-right: none;
1494
936
  }
1495
937
 
1496
938
  /* Main area */
@@ -1552,26 +994,6 @@
1552
994
  padding: 24px 24px;
1553
995
  }
1554
996
 
1555
- .sa-fp-main .sa-composer {
1556
- margin: 0 auto;
1557
- width: 100%;
1558
- padding: 12px 24px 20px;
1559
- border-top: none;
1560
- background: transparent;
1561
- }
1562
-
1563
- .sa-fp-main .sa-composer-input {
1564
- background: #f7f7f8;
1565
- border: 1px solid #e4e4e7;
1566
- box-shadow: none;
1567
- }
1568
-
1569
- .sa-fp-main .sa-composer-input:focus {
1570
- background: #fff;
1571
- border-color: #d4d4d8;
1572
- box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
1573
- }
1574
-
1575
997
  /* ── Artifact file cards (in ToolResultPart) ── */
1576
998
  .sa-artifact-file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
1577
999
  .sa-artifact-file-card {
@@ -1657,7 +1079,8 @@
1657
1079
  transition: background 0.15s ease, border-color 0.15s ease;
1658
1080
  }
1659
1081
  .sa-drawer-btn-sm:hover { background: var(--sa-surface); border-color: var(--sa-primary); }
1660
- .sa-artifact-drawer-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
1082
+ /* flex 列容器:让 .sa-drawer-view-enter(flex:1)与内层滚动/iframe 有真实高度链 */
1083
+ .sa-artifact-drawer-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
1661
1084
  .sa-drawer-empty { padding: 48px 24px; text-align: center; color: var(--sa-text-muted); font-size: 14px; }
1662
1085
  .sa-drawer-file-list { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
1663
1086
  .sa-drawer-file-card {
@@ -1680,6 +1103,9 @@
1680
1103
 
1681
1104
  /* ── Drawer preview ── */
1682
1105
  .sa-drawer-preview-iframe { width: 100%; height: 100%; border: none; background: #fff; animation: sa-fade-in 0.3s ease both; }
1106
+ /* html/docx 内联预览:与消息流 ToolResultPart 一致(无 iframe) */
1107
+ .sa-drawer-preview-html-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px; background: #fff; animation: sa-fade-in 0.3s ease both; }
1108
+ .sa-drawer-preview-html { max-width: none; }
1683
1109
  .sa-drawer-preview-loading {
1684
1110
  display: flex; flex-direction: column; align-items: center; justify-content: center;
1685
1111
  height: 100%; gap: 12px; color: var(--sa-text-muted); font-size: 14px;
@@ -1696,7 +1122,9 @@
1696
1122
  }
1697
1123
 
1698
1124
  /* ── Drawer view transition ── */
1699
- .sa-drawer-view-enter { animation: sa-drawer-view-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
1125
+ /* flex 列 + flex:1 撑满 drawer body,让内层 .sa-drawer-preview-html-scroll
1126
+ flex:1/min-height:0 与 pdf iframe 的 height:100% 有真实高度链 */
1127
+ .sa-drawer-view-enter { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: sa-drawer-view-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
1700
1128
 
1701
1129
  /* ── Layout helpers for drawer alongside thread ── */
1702
1130
  .sa-panel-content { display: flex; flex: 1; min-height: 0; overflow: hidden; }
@@ -1705,6 +1133,24 @@
1705
1133
  .sa-fp-content-row { display: flex; flex: 1; min-height: 0; overflow: hidden; }
1706
1134
  .sa-fp-content-row .sa-thread { flex: 1; min-width: 0; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
1707
1135
 
1136
+ /* ── Page overlay(面板级整屏页面:替换内容区 + 输入区,Header 保留) ── */
1137
+ .sa-page-overlay {
1138
+ display: flex; flex-direction: column; flex: 1; min-height: 0;
1139
+ position: relative; z-index: 2; background: #fff; overflow: hidden;
1140
+ animation: sa-page-in 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
1141
+ }
1142
+ /* 大窗态与内容区/输入区一致的 800px 居中 */
1143
+ .sa-page-overlay-centered { width: 100%; max-width: 800px; margin: 0 auto; }
1144
+ .sa-page-overlay-bar {
1145
+ display: flex; align-items: center; gap: 8px; flex-shrink: 0;
1146
+ padding: 10px 14px; border-bottom: 1px solid var(--sa-border);
1147
+ background: var(--sa-surface); color: var(--sa-text);
1148
+ font-size: 15px; font-weight: 600;
1149
+ }
1150
+ .sa-page-overlay-back-label { font-size: 13px; font-weight: 400; }
1151
+ .sa-page-overlay-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1152
+ /* 滚动归 SDK,业务页不写滚动容器 */
1153
+ .sa-page-overlay-body { flex: 1; min-height: 0; overflow-y: auto; }
1708
1154
  /* ── Artifact keyframes ── */
1709
1155
  @keyframes sa-slide-in-right {
1710
1156
  from { opacity: 0; transform: translateX(100%); }
@@ -1733,4 +1179,9 @@
1733
1179
  from { opacity: 0; transform: translateX(12px); }
1734
1180
  to { opacity: 1; transform: translateX(0); }
1735
1181
  }
1736
- `,Se={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:380,panelHeight:520,zIndex:9999};function Qe(t,a){const r=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),s=parseInt(t.slice(5,7),16),i=1-a;return`#${Math.round(r*i).toString(16).padStart(2,"0")}${Math.round(n*i).toString(16).padStart(2,"0")}${Math.round(s*i).toString(16).padStart(2,"0")}`}function et(t,a){const r=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),s=parseInt(t.slice(5,7),16);return`#${Math.round(r+(255-r)*a).toString(16).padStart(2,"0")}${Math.round(n+(255-n)*a).toString(16).padStart(2,"0")}${Math.round(s+(255-s)*a).toString(16).padStart(2,"0")}`}function Ie(t){const a={...Se,...t},r=a.primaryColor,n=a.backgroundColor;return[`--sa-primary: ${r}`,`--sa-bg: ${n}`,`--sa-font: ${a.fontFamily}`,`--sa-radius: ${a.borderRadius}px`,`--sa-panel-width: ${a.panelWidth}px`,`--sa-panel-height: ${a.panelHeight}px`,`--sa-z-index: ${a.zIndex}`,`--sa-primary-dark: ${Qe(r,.15)}`,`--sa-primary-light: ${et(r,.9)}`,`--sa-surface: ${n}`,"--sa-border: #e5e7eb","--sa-hover: #f4f4f5","--sa-text: #374151","--sa-text-muted: #9ca3af","--sa-text-light: #6b7280"].join("; ")}function tt(t,a){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(`Target element not found: ${t}`);const n=document.createElement("div");n.setAttribute("data-super-agent-widget","");const s=Ie(a.theme??{});if(n.setAttribute("style",`${s}; height: 100%;`),r.appendChild(n),!document.getElementById("sa-widget-styles")){const d=document.createElement("style");d.id="sa-widget-styles",d.textContent=ze,document.head.appendChild(d)}let i=Me.createRoot(n),l=!1;const c=d=>{i&&i.render(o.createElement(Ne,{...a,initialOpen:d??l,onOpenChange:p=>{l=p}}))};return c(!1),{open(){l=!0,c(!0)},close(){l=!1,c(!1)},destroy(){i&&(i.unmount(),i=null),n.remove()}}}exports.ActionBar=we;exports.ChatProvider=U;exports.ChatWidget=Ne;exports.Composer=X;exports.ErrorPart=be;exports.FullpageLayout=Ce;exports.Header=de;exports.Icon=N;exports.InterruptCard=ve;exports.Message=ye;exports.TextPart=xe;exports.ThinkingPart=me;exports.Thread=V;exports.ThreadList=ue;exports.ToolCallPart=he;exports.ToolResultPart=ge;exports.Trigger=ce;exports.WelcomeScreen=ke;exports.defaultTheme=Se;exports.ensureIconFont=le;exports.mount=tt;exports.themeToCSSVars=Ie;exports.useAutoScroll=fe;exports.useChat=te;exports.useChatContext=_;exports.useConversations=se;exports.widgetStyles=ze;
1182
+ @keyframes sa-page-in {
1183
+ from { opacity: 0; transform: translateY(10px); }
1184
+ to { opacity: 1; transform: translateY(0); }
1185
+ }
1186
+ `,Ft='[data-super-agent-widget] .pointer-events-none{pointer-events:none}[data-super-agent-widget] .collapse{visibility:collapse}[data-super-agent-widget] .fixed{position:fixed}[data-super-agent-widget] .absolute{position:absolute}[data-super-agent-widget] .relative{position:relative}[data-super-agent-widget] .inset-0{top:0;right:0;bottom:0;left:0}[data-super-agent-widget] .inset-x-0{left:0;right:0}[data-super-agent-widget] .-bottom-px{bottom:-1px}[data-super-agent-widget] .-left-px{left:-1px}[data-super-agent-widget] .-right-2{right:-.5rem}[data-super-agent-widget] .-top-1\\.5{top:-.375rem}[data-super-agent-widget] .-top-px{top:-1px}[data-super-agent-widget] .bottom-0{bottom:0}[data-super-agent-widget] .left-\\[-3px\\]{left:-3px}[data-super-agent-widget] .top-0{top:0}[data-super-agent-widget] .z-0{z-index:0}[data-super-agent-widget] .z-10{z-index:10}[data-super-agent-widget] .z-20{z-index:20}[data-super-agent-widget] .z-\\[10000\\]{z-index:10000}[data-super-agent-widget] .z-\\[10001\\]{z-index:10001}[data-super-agent-widget] .z-\\[1\\]{z-index:1}[data-super-agent-widget] .z-\\[2\\]{z-index:2}[data-super-agent-widget] .z-\\[5\\]{z-index:5}[data-super-agent-widget] .z-\\[var\\(--sa-z-index\\,9999\\)\\]{z-index:var(--sa-z-index,9999)}[data-super-agent-widget] .m-0{margin:0}[data-super-agent-widget] .mx-auto{margin-left:auto;margin-right:auto}[data-super-agent-widget] .mb-0\\.5{margin-bottom:.125rem}[data-super-agent-widget] .mb-1{margin-bottom:.25rem}[data-super-agent-widget] .mb-3{margin-bottom:.75rem}[data-super-agent-widget] .mb-4{margin-bottom:1rem}[data-super-agent-widget] .mt-3{margin-top:.75rem}[data-super-agent-widget] .block{display:block}[data-super-agent-widget] .inline{display:inline}[data-super-agent-widget] .flex{display:flex}[data-super-agent-widget] .inline-flex{display:inline-flex}[data-super-agent-widget] .table{display:table}[data-super-agent-widget] .hidden{display:none}[data-super-agent-widget] .h-5{height:1.25rem}[data-super-agent-widget] .h-7{height:1.75rem}[data-super-agent-widget] .h-8{height:2rem}[data-super-agent-widget] .h-9{height:2.25rem}[data-super-agent-widget] .h-\\[13px\\]{height:13px}[data-super-agent-widget] .h-\\[18px\\]{height:18px}[data-super-agent-widget] .h-\\[238px\\]{height:238px}[data-super-agent-widget] .h-\\[calc\\(100\\%_-_48px\\)\\]{height:calc(100% - 48px)}[data-super-agent-widget] .h-full{height:100%}[data-super-agent-widget] .min-h-\\[70px\\]{min-height:70px}[data-super-agent-widget] .w-12{width:3rem}[data-super-agent-widget] .w-5{width:1.25rem}[data-super-agent-widget] .w-7{width:1.75rem}[data-super-agent-widget] .w-\\[18px\\]{width:18px}[data-super-agent-widget] .w-\\[220px\\]{width:220px}[data-super-agent-widget] .w-\\[6px\\]{width:6px}[data-super-agent-widget] .w-full{width:100%}[data-super-agent-widget] .w-px{width:1px}[data-super-agent-widget] .min-w-0{min-width:0px}[data-super-agent-widget] .min-w-\\[14px\\]{min-width:14px}[data-super-agent-widget] .max-w-16{max-width:4rem}[data-super-agent-widget] .max-w-\\[800px\\]{max-width:800px}[data-super-agent-widget] .max-w-full{max-width:100%}[data-super-agent-widget] .flex-1{flex:1 1 0%}[data-super-agent-widget] .flex-shrink{flex-shrink:1}[data-super-agent-widget] .shrink-0{flex-shrink:0}[data-super-agent-widget] .border-collapse{border-collapse:collapse}[data-super-agent-widget] .scale-50{--tw-scale-x: .5;--tw-scale-y: .5;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .cursor-col-resize{cursor:col-resize}[data-super-agent-widget] .cursor-default{cursor:default}[data-super-agent-widget] .cursor-grab{cursor:grab}[data-super-agent-widget] .cursor-pointer{cursor:pointer}[data-super-agent-widget] .cursor-text{cursor:text}[data-super-agent-widget] .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}[data-super-agent-widget] .resize-none{resize:none}[data-super-agent-widget] .resize{resize:both}[data-super-agent-widget] .flex-row{flex-direction:row}[data-super-agent-widget] .flex-col{flex-direction:column}[data-super-agent-widget] .flex-wrap{flex-wrap:wrap}[data-super-agent-widget] .items-start{align-items:flex-start}[data-super-agent-widget] .items-center{align-items:center}[data-super-agent-widget] .justify-end{justify-content:flex-end}[data-super-agent-widget] .justify-center{justify-content:center}[data-super-agent-widget] .justify-between{justify-content:space-between}[data-super-agent-widget] .gap-0\\.5{gap:.125rem}[data-super-agent-widget] .gap-1{gap:.25rem}[data-super-agent-widget] .gap-1\\.5{gap:.375rem}[data-super-agent-widget] .gap-2{gap:.5rem}[data-super-agent-widget] .gap-2\\.5{gap:.625rem}[data-super-agent-widget] .gap-3{gap:.75rem}[data-super-agent-widget] .gap-4{gap:1rem}[data-super-agent-widget] .gap-8{gap:2rem}[data-super-agent-widget] .gap-\\[22px\\]{gap:22px}[data-super-agent-widget] .gap-\\[7px\\]{gap:7px}[data-super-agent-widget] .overflow-hidden{overflow:hidden}[data-super-agent-widget] .overflow-visible{overflow:visible}[data-super-agent-widget] .overflow-y-auto{overflow-y:auto}[data-super-agent-widget] .text-ellipsis{text-overflow:ellipsis}[data-super-agent-widget] .whitespace-nowrap{white-space:nowrap}[data-super-agent-widget] .rounded{border-radius:.25rem}[data-super-agent-widget] .rounded-\\[5px\\]{border-radius:5px}[data-super-agent-widget] .rounded-full{border-radius:9999px}[data-super-agent-widget] .rounded-md{border-radius:.375rem}[data-super-agent-widget] .border{border-width:1px}[data-super-agent-widget] .border-r{border-right-width:1px}[data-super-agent-widget] .border-r-0{border-right-width:0px}[data-super-agent-widget] .border-none{border-style:none}[data-super-agent-widget] .border-\\[\\#DADADA\\]{--tw-border-opacity: 1;border-color:rgb(218 218 218 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[\\#E8E8E8\\]{--tw-border-opacity: 1;border-color:rgb(232 232 232 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[\\#ECECEC\\]{--tw-border-opacity: 1;border-color:rgb(236 236 236 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[var\\(--sa-primary\\)\\]{border-color:var(--sa-primary)}[data-super-agent-widget] .bg-\\[\\#DCDCDC\\]{--tw-bg-opacity: 1;background-color:rgb(220 220 220 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#E8F1FE\\]{--tw-bg-opacity: 1;background-color:rgb(232 241 254 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#F5F5F5\\]{--tw-bg-opacity: 1;background-color:rgb(245 245 245 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#FAFAFA\\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#fee2e2\\]{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[var\\(--sa-primary\\)\\]{background-color:var(--sa-primary)}[data-super-agent-widget] .bg-black\\/30{background-color:#0000004d}[data-super-agent-widget] .bg-transparent{background-color:transparent}[data-super-agent-widget] .bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .object-contain{-o-object-fit:contain;object-fit:contain}[data-super-agent-widget] .p-0{padding:0}[data-super-agent-widget] .p-2{padding:.5rem}[data-super-agent-widget] .p-3{padding:.75rem}[data-super-agent-widget] .px-0\\.5{padding-left:.125rem;padding-right:.125rem}[data-super-agent-widget] .px-1{padding-left:.25rem;padding-right:.25rem}[data-super-agent-widget] .px-1\\.5{padding-left:.375rem;padding-right:.375rem}[data-super-agent-widget] .px-2\\.5{padding-left:.625rem;padding-right:.625rem}[data-super-agent-widget] .px-3{padding-left:.75rem;padding-right:.75rem}[data-super-agent-widget] .px-\\[15px\\]{padding-left:15px;padding-right:15px}[data-super-agent-widget] .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}[data-super-agent-widget] .py-1{padding-top:.25rem;padding-bottom:.25rem}[data-super-agent-widget] .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}[data-super-agent-widget] .py-2{padding-top:.5rem;padding-bottom:.5rem}[data-super-agent-widget] .py-3{padding-top:.75rem;padding-bottom:.75rem}[data-super-agent-widget] .pb-1{padding-bottom:.25rem}[data-super-agent-widget] .pb-2\\.5{padding-bottom:.625rem}[data-super-agent-widget] .pt-2{padding-top:.5rem}[data-super-agent-widget] .text-left{text-align:left}[data-super-agent-widget] .text-center{text-align:center}[data-super-agent-widget] .text-\\[11px\\]{font-size:11px}[data-super-agent-widget] .text-\\[12px\\]{font-size:12px}[data-super-agent-widget] .text-\\[13px\\]{font-size:13px}[data-super-agent-widget] .text-\\[14px\\]{font-size:14px}[data-super-agent-widget] .text-\\[18px\\]{font-size:18px}[data-super-agent-widget] .text-\\[9px\\]{font-size:9px}[data-super-agent-widget] .font-bold{font-weight:700}[data-super-agent-widget] .font-medium{font-weight:500}[data-super-agent-widget] .font-semibold{font-weight:600}[data-super-agent-widget] .italic{font-style:italic}[data-super-agent-widget] .leading-\\[1\\.3\\]{line-height:1.3}[data-super-agent-widget] .leading-\\[1\\.4\\]{line-height:1.4}[data-super-agent-widget] .leading-\\[1\\.5\\]{line-height:1.5}[data-super-agent-widget] .leading-\\[14px\\]{line-height:14px}[data-super-agent-widget] .leading-none{line-height:1}[data-super-agent-widget] .text-\\[\\#333\\]{--tw-text-opacity: 1;color:rgb(51 51 51 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#666\\]{--tw-text-opacity: 1;color:rgb(102 102 102 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#999\\]{--tw-text-opacity: 1;color:rgb(153 153 153 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#9A9A9A\\]{--tw-text-opacity: 1;color:rgb(154 154 154 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#A0A0A0\\]{--tw-text-opacity: 1;color:rgb(160 160 160 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#B8B8B8\\]{--tw-text-opacity: 1;color:rgb(184 184 184 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#C0C0C0\\]{--tw-text-opacity: 1;color:rgb(192 192 192 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#ef4444\\]{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .underline{text-decoration-line:underline}[data-super-agent-widget] .antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[data-super-agent-widget] .opacity-0{opacity:0}[data-super-agent-widget] .opacity-10{opacity:.1}[data-super-agent-widget] .opacity-100{opacity:1}[data-super-agent-widget] .opacity-60{opacity:.6}[data-super-agent-widget] .opacity-70{opacity:.7}[data-super-agent-widget] .shadow-\\[0_-12px_48px_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 -12px 48px rgba(0,0,0,.25);--tw-shadow-colored: 0 -12px 48px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .shadow-\\[0_12px_36px_rgba\\(0\\,0\\,0\\,0\\.18\\)\\]{--tw-shadow: 0 12px 36px rgba(0,0,0,.18);--tw-shadow-colored: 0 12px 36px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .shadow-\\[0_2px_8px_rgba\\(0\\,0\\,0\\,0\\.12\\)\\]{--tw-shadow: 0 2px 8px rgba(0,0,0,.12);--tw-shadow-colored: 0 2px 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .outline-none{outline:2px solid transparent;outline-offset:2px}[data-super-agent-widget] .outline{outline-style:solid}[data-super-agent-widget] .blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}[data-super-agent-widget] .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}[data-super-agent-widget] .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .duration-200{transition-duration:.2s}[data-super-agent-widget] .ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}[data-super-agent-widget] .ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes sa-window-in{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes sa-slide-up-full{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes sa-home-fade-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}@keyframes sa-chip-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes sa-logo-float{0%,to{transform:translateY(0)}50%{transform:translateY(-3px)}}@keyframes sa-title-shimmer{0%{background-position:100% 0}to{background-position:-100% 0}}@keyframes sa-history-in{0%{opacity:0;transform:translate(-10px)}to{opacity:1;transform:translate(0)}}[data-super-agent-widget] .animate-sa-window-in{animation:sa-window-in .3s cubic-bezier(.16,1,.3,1)}[data-super-agent-widget] .animate-sa-slide-up-full{animation:sa-slide-up-full .3s cubic-bezier(.16,1,.3,1)}[data-super-agent-widget] .animate-sa-fade-in{animation:sa-fade-in .2s ease}[data-super-agent-widget] .animate-sa-home-fade-in{animation:sa-home-fade-in .4s ease forwards}[data-super-agent-widget] .animate-sa-chip-in{animation:sa-chip-in .4s cubic-bezier(.22,1,.36,1) forwards}[data-super-agent-widget] .animate-sa-logo-float{animation:sa-logo-float 3s ease-in-out infinite}[data-super-agent-widget] .animate-sa-title-shimmer{animation:sa-title-shimmer 2.5s ease forwards}[data-super-agent-widget] .animate-sa-history-in{animation:sa-history-in .2s ease}[data-super-agent-widget] .sa-tip{position:relative}[data-super-agent-widget] .sa-tip:before,[data-super-agent-widget] .sa-tip:after{position:absolute;top:100%;left:50%;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:100}[data-super-agent-widget] .sa-tip:before{content:attr(data-tooltip);transform:translate(-50%);margin-top:6px;padding:4px 8px;background:#fff;color:#333;font-size:12px;line-height:1.4;white-space:nowrap;border-radius:4px;box-shadow:0 2px 8px #0000001f;border:1px solid #e8e8e8}[data-super-agent-widget] .sa-tip:after{content:"";transform:translate(-50%);margin-top:2px;border:4px solid transparent;border-bottom-color:#fff;filter:drop-shadow(0 -1px 1px rgba(0,0,0,.06))}[data-super-agent-widget] .sa-tip:hover:before,[data-super-agent-widget] .sa-tip:hover:after{opacity:1}[data-super-agent-widget] .sa-chip{background:linear-gradient(#fff,#fff) padding-box,linear-gradient(#e0e0e0,#e0e0e0) border-box;border:1px solid transparent}[data-super-agent-widget] .sa-chip:hover{background:linear-gradient(#fff,#fff) padding-box,linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7) border-box}[data-super-agent-widget] .sa-chip:hover .sa-chip-text{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-shimmer-text{background:linear-gradient(90deg,#333,#333 35%,#00d4ff 40%,#1881f0,#2b52ee,#d116ea,#ff2e7e 56%,#333 61%,#333);background-size:300% 100%;background-position:100% 0;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-new-chat{background:linear-gradient(258deg,#ff2e7e1a -4%,#d116ea1a 16%,#2b52ee1a 53%,#1881f01a 81%,#00d4ff1a 106%)}[data-super-agent-widget] .sa-new-chat:hover{background:linear-gradient(258deg,#ff2e7e29 -4%,#d116ea29 16%,#2b52ee29 53%,#1881f029 81%,#00d4ff29 106%)}[data-super-agent-widget] .sa-new-chat .sa-new-chat-text{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-home-gradient{background:linear-gradient(239deg,#ff2e7e -3%,#d116ea 17%,#2b52ee 54%,#1881f0 82%,#00d4ff 107%)}[data-super-agent-widget] .sa-home-gradient-fade{background:linear-gradient(180deg,#fff0,#fff)}[data-super-agent-widget] .sa-home-view .sa-thread{background:transparent}[data-super-agent-widget] .sa-resize-handle:hover{background:color-mix(in srgb,var(--sa-primary) 30%,transparent)}[data-super-agent-widget] .sa-input-form{border:1px solid transparent;background-color:#fff;background-image:linear-gradient(#fff,#fff),linear-gradient(110deg,#03b5ff80,#285cff80 47%,#ff28a780);background-origin:border-box;background-clip:padding-box,border-box;transition:background .15s ease}[data-super-agent-widget] .sa-input-form-active,[data-super-agent-widget] .sa-input-form:focus-within{background-image:linear-gradient(#fff,#fff),linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7)}[data-super-agent-widget] .sa-send-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border:none;border-radius:9999px;background:linear-gradient(110deg,#03b5ff80,#285cff80 47%,#ff28a780);cursor:pointer;flex-shrink:0;align-self:flex-end;transition:background .15s ease,opacity .15s ease}[data-super-agent-widget] .sa-send-btn-active,[data-super-agent-widget] .sa-input-form:focus-within .sa-send-btn{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7)}[data-super-agent-widget] .sa-send-btn:hover{opacity:.9}[data-super-agent-widget] .sa-send-btn:active{opacity:.7}[data-super-agent-widget] .sa-send-btn img{display:block;width:14px;height:14px;filter:brightness(0) invert(1)}[data-super-agent-widget] .sa-stop-icon{display:block;width:8px;height:8px;border-radius:2px;background:#fff}[data-super-agent-widget] .placeholder\\:text-\\[\\#B8B8B8\\]::-moz-placeholder{--tw-text-opacity: 1;color:rgb(184 184 184 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .placeholder\\:text-\\[\\#B8B8B8\\]::placeholder{--tw-text-opacity: 1;color:rgb(184 184 184 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .hover\\:scale-\\[1\\.08\\]:hover{--tw-scale-x: 1.08;--tw-scale-y: 1.08;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .hover\\:bg-\\[\\#E8F1FE\\]:hover{--tw-bg-opacity: 1;background-color:rgb(232 241 254 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .hover\\:bg-\\[\\#F5F5F5\\]:hover{--tw-bg-opacity: 1;background-color:rgb(245 245 245 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .hover\\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .hover\\:bg-white\\/70:hover{background-color:#ffffffb3}[data-super-agent-widget] .hover\\:text-\\[\\#1881F0\\]:hover{--tw-text-opacity: 1;color:rgb(24 129 240 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .hover\\:text-\\[\\#ef4444\\]:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .hover\\:text-\\[var\\(--sa-primary\\)\\]:hover{color:var(--sa-primary)}[data-super-agent-widget] .active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .active\\:cursor-grabbing:active{cursor:grabbing}[data-super-agent-widget] .active\\:bg-\\[\\#F5F5F5\\]:active{--tw-bg-opacity: 1;background-color:rgb(245 245 245 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] :is(.group:hover .group-hover\\:flex){display:flex}',Qe={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:400,panelHeight:648,zIndex:9999};function Ht(t,a){const n=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16),o=1-a;return`#${Math.round(n*o).toString(16).padStart(2,"0")}${Math.round(i*o).toString(16).padStart(2,"0")}${Math.round(r*o).toString(16).padStart(2,"0")}`}function Pt(t,a){const n=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16);return`#${Math.round(n+(255-n)*a).toString(16).padStart(2,"0")}${Math.round(i+(255-i)*a).toString(16).padStart(2,"0")}${Math.round(r+(255-r)*a).toString(16).padStart(2,"0")}`}function et(t){const a={...Qe,...t},n=a.primaryColor,i=a.backgroundColor;return[`--sa-primary: ${n}`,`--sa-bg: ${i}`,`--sa-font: ${a.fontFamily}`,`--sa-radius: ${a.borderRadius}px`,`--sa-panel-width: ${a.panelWidth}px`,`--sa-panel-height: ${a.panelHeight}px`,`--sa-z-index: ${a.zIndex}`,`--sa-primary-dark: ${Ht(n,.15)}`,`--sa-primary-light: ${Pt(n,.9)}`,`--sa-surface: ${i}`,"--sa-border: #e5e7eb","--sa-hover: #f4f4f5","--sa-text: #374151","--sa-text-muted: #9ca3af","--sa-text-light: #6b7280"].join("; ")}function Bt(t,a){const n=typeof t=="string"?document.querySelector(t):t;if(!n)throw new Error(`Target element not found: ${t}`);const i=document.createElement("div");i.setAttribute("data-super-agent-widget","");const r=et(a.theme??{});if(i.setAttribute("style",`${r}; height: 100%;`),n.appendChild(i),!document.getElementById("sa-widget-styles")){const c=document.createElement("style");c.id="sa-widget-styles",c.textContent=`${Je}
1187
+ ${Ft}`,document.head.appendChild(c)}let o=lt.createRoot(i),d=!1;const l=c=>{o&&o.render(s.createElement(Ze,{...a,initialOpen:c??d,onOpenChange:p=>{d=p}}))};return l(!1),{open(){d=!0,l(!0)},close(){d=!1,l(!1)},destroy(){o&&(o.unmount(),o=null),i.remove()}}}exports.ASSETS=W;exports.ActionBar=Ge;exports.ChatProvider=ie;exports.ChatWidget=Ze;exports.Composer=ce;exports.ErrorPart=We;exports.FullpageLayout=Ke;exports.Header=De;exports.Icon=D;exports.InterruptCard=Ye;exports.Message=Xe;exports.PageOverlay=qe;exports.TextPart=Fe;exports.ThinkingPart=Pe;exports.Thread=le;exports.ThreadList=oe;exports.ToolCallPart=Be;exports.ToolResultPart=Oe;exports.Trigger=$e;exports.WelcomeScreen=Ue;exports.defaultTheme=Qe;exports.ensureIconFont=He;exports.mount=Bt;exports.themeToCSSVars=et;exports.useAutoScroll=_e;exports.useChat=Se;exports.useChatContext=U;exports.useConversations=Te;exports.widgetStyles=Je;