super-agent-sdk 1.0.7 → 1.0.9
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/README.md +242 -93
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +90 -85
- package/dist/widget.cjs +136 -666
- package/dist/widget.d.ts +126 -12
- package/dist/widget.mjs +2093 -2018
- package/package.json +4 -1
package/dist/widget.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),Se=require("react-dom/client"),e=require("react/jsx-runtime");function ee(a){const{sdk:s,sessionId:r,onSessionCreated:n,onStreamStart:t,onStreamEnd:i,onError:l,onMessageSend:c}=a,[d,u]=o.useState([]),[f,p]=o.useState("ready"),[x,h]=o.useState(null),g=o.useRef(null),w=o.useRef(!1),S=o.useRef(r),E=o.useRef(!0);S.current=r,E.current=d.length===0;const M=o.useCallback(y=>{if(w.current)return;w.current=!0,c==null||c(y);const b={id:`user_${Date.now()}`,role:"user",parts:[{type:"text",content:y}],timestamp:Date.now()},v=`assistant_${Date.now()}`,j={id:v,role:"assistant",parts:[],timestamp:Date.now()},R=E.current;u(z=>[...z,b,j]),p("submitted"),h(null);const $=z=>{let D="",A="",N=[],P=!1;const L=()=>{const T=[...N];if(D){const H=T.findIndex(O=>O.type==="thinking");H>=0?T[H]={type:"thinking",content:D}:T.unshift({type:"thinking",content:D})}if(A){const H=T.findLastIndex(O=>O.type==="text");H>=0?T[H]={type:"text",content:A}:T.push({type:"text",content:A})}u(H=>H.map(O=>O.id===v?{...O,parts:T}:O))};g.current=s.chat({sessionId:z,message:y,stream:!0,onMessage:T=>{switch(P||(P=!0,p("streaming")),T.type){case"thinking":D+=T.content;break;case"ai":A+=T.content;break;case"tool_call":N.push({type:"tool_call",toolName:T.toolName,toolCallId:T.toolCallId,args:T.args??"{}"});break;case"tool_result":N.push({type:"tool_result",toolName:T.toolName??"",toolCallId:T.toolCallId,content:T.content,artifacts:T.artifacts,renderMode:T.renderMode,html:T.html}),A&&(N.push({type:"text",content:A}),A="");break;case"interrupt":T.interrupt&&N.push({type:"interrupt",interrupt:T.interrupt,resolved:!1});break;case"stop":T.content&&(A=T.content),L();return}L()},onDone:T=>{(A||N.length>0||D)&&L(),T.messageId&&u(O=>O.map(W=>W.id===v?{...W,id:T.messageId}:W)),T.sessionId&&T.sessionId!==S.current&&(n==null||n(T.sessionId));const H=()=>{i==null||i(T.sessionId||z),p("ready"),w.current=!1,g.current=null};if(R){const O=y.slice(0,30),W=T.sessionId||z;s.renameConversation(W,O).catch(()=>{}).finally(H)}else H()},onError:T=>{N.push({type:"error",content:T.message}),L(),h(T),p("error"),l==null||l(T),w.current=!1,g.current=null}}),t==null||t(z)};S.current?$(S.current):s.createSession().then(z=>{S.current=z,n==null||n(z),$(z)}).catch(z=>{h(z instanceof Error?z:new Error(String(z))),p("error"),l==null||l(z instanceof Error?z:new Error(String(z))),w.current=!1})},[s,n,t,i,l,c]),k=o.useCallback(()=>{var b;const y=S.current;(b=g.current)==null||b.abort(),g.current=null,p("ready"),w.current=!1,y&&s.stopGeneration(y).catch(()=>{})},[s]),m=o.useCallback(()=>{if(w.current)return;const y=d.findLastIndex(v=>v.role==="user");if(y<0)return;const b=d[y].parts.filter(v=>v.type==="text").map(v=>v.content).join("");u(v=>v.slice(0,y)),M(b)},[d,M]),I=o.useCallback((y,b)=>{u(N=>N.map(P=>({...P,parts:P.parts.map(L=>L.type==="interrupt"&&L.interrupt.interruptId===y?{...L,resolved:!0,response:b}:L)})));const v=S.current;if(!v)return;const j=`assistant_${Date.now()}`,R={id:j,role:"assistant",parts:[],timestamp:Date.now()};u(N=>[...N,R]),p("streaming");let $="",z="",D=[];const A=()=>{const N=[...D];if($){const P=N.findIndex(L=>L.type==="thinking");P>=0?N[P]={type:"thinking",content:$}:N.unshift({type:"thinking",content:$})}if(z){const P=N.findLastIndex(L=>L.type==="text");P>=0?N[P]={type:"text",content:z}:N.push({type:"text",content:z})}u(P=>P.map(L=>L.id===j?{...L,parts:N}:L))};s.respondInterrupt(y,v,b,N=>{switch(N.type){case"thinking":$+=N.content;break;case"ai":z+=N.content;break;case"tool_call":D.push({type:"tool_call",toolName:N.toolName,toolCallId:N.toolCallId,args:N.args??"{}"});break;case"tool_result":D.push({type:"tool_result",toolName:N.toolName??"",toolCallId:N.toolCallId,content:N.content,artifacts:N.artifacts,renderMode:N.renderMode,html:N.html}),z&&(D.push({type:"text",content:z}),z="");break;case"interrupt":N.interrupt&&D.push({type:"interrupt",interrupt:N.interrupt,resolved:!1});break;case"done":N.messageId&&u(P=>P.map(L=>L.id===j?{...L,id:N.messageId}:L)),p("ready");break}A()},N=>{D.push({type:"error",content:N.message}),A(),h(N),p("error"),l==null||l(N)}).catch(N=>{l==null||l(N instanceof Error?N:new Error(String(N))),p("error")})},[s,l]);return{messages:d,status:f,error:x,sendMessage:M,stop:k,regenerate:m,setMessages:u,respondToInterrupt:I}}const U="sa_active_conversation",Y=20;function J(){try{return localStorage.getItem(U)}catch{return null}}function Ie(a){try{a?localStorage.setItem(U,a):localStorage.removeItem(U)}catch{}}function ae(a){const{sdk:s,onConversationChange:r}=a,[n,t]=o.useState([]),[i,l]=o.useState(()=>J()),[c,d]=o.useState(!1),[u,f]=o.useState(!0),p=o.useRef(!0),x=o.useRef(1),h=o.useRef(!1);o.useEffect(()=>()=>{p.current=!1},[]);const g=o.useCallback(y=>{l(y),Ie(y),y&&(r==null||r(y))},[r]),w=o.useCallback(async()=>{if(!h.current){h.current=!0,d(!0);try{x.current=1;const y=await s.listConversations({page:1,size:Y});if(!p.current)return;t(y.items),f(y.items.length<y.total);const b=J();b&&!y.items.find(v=>v.sessionId===b)&&g(null)}catch{}finally{h.current=!1,p.current&&d(!1)}}},[s,g]),S=o.useCallback(async()=>{if(!(h.current||!u)){h.current=!0,d(!0);try{const y=x.current+1,b=await s.listConversations({page:y,size:Y});if(!p.current)return;x.current=y,t(j=>{const R=new Set(j.map(z=>z.sessionId)),$=b.items.filter(z=>!R.has(z.sessionId));return[...j,...$]});const v=x.current*Y;f(v<b.total)}catch{}finally{h.current=!1,p.current&&d(!1)}}},[s,u]),E=o.useCallback(async y=>(g(y),await s.getMessages(y)),[s,g]),M=o.useCallback(async()=>{try{const y=await s.createSession(),b=new Date().toISOString();t(v=>[{sessionId:y,botId:0,title:"新对话",createTime:b,updateTime:b},...v]),g(y)}catch{g(null)}},[s,g]),k=o.useCallback(async y=>{await s.deleteConversation(y),t(b=>b.filter(v=>v.sessionId!==y)),i===y&&g(null)},[s,i,g]),m=o.useCallback(async(y,b)=>{await s.renameConversation(y,b),t(v=>v.map(j=>j.sessionId===y?{...j,title:b}:j))},[s]),{enabled:I=!0}=a;return o.useEffect(()=>{I&&w()},[I,w]),{conversations:n,activeConversationId:i,loading:c,hasMore:u,loadConversations:w,loadMore:S,switchConversation:E,newConversation:M,deleteConversation:k,renameConversation:m,setActiveConversationId:g}}function te(a){return!a&&a!==0?"":a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/1024/1024).toFixed(1)} MB`}function se(a){return a==="pdf"?"PDF":a==="docx"?"DOC":a==="html"?"HTM":a.slice(0,3).toUpperCase()||"FILE"}function re(a){if(!a)return[];const s=[];for(const r of a)r.type==="file"&&r.data&&s.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 s}async function K(a){try{const s=await fetch(a.url);if(!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.blob(),n=URL.createObjectURL(r),t=document.createElement("a");t.href=n,t.download=a.filename,document.body.appendChild(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(n),4e3)}catch{const s=document.createElement("a");s.href=a.url,s.download=a.filename,s.target="_blank",document.body.appendChild(s),s.click(),s.remove()}}const ne=o.createContext(null);function _(){const a=o.useContext(ne);if(!a)throw new Error("useChatContext must be used within ChatProvider");return a}function V({sdk:a,hooks:s,children:r}){const[n,t]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(null),[u,f]=o.useState(!1);o.useEffect(()=>{a.getToken().then(()=>{f(!0)}).catch(()=>{f(!0)})},[a]);const p=ae({sdk:a,onConversationChange:s==null?void 0:s.onConversationChange,enabled:u}),x=ee({sdk:a,sessionId:p.activeConversationId,onSessionCreated:b=>{p.setActiveConversationId(b)},onStreamStart:s==null?void 0:s.onStreamStart,onStreamEnd:b=>{var v;(v=s==null?void 0:s.onStreamEnd)==null||v.call(s,b),p.loadConversations()},onError:s==null?void 0:s.onError,onMessageSend:s==null?void 0:s.onMessageSend}),h=o.useCallback(async b=>{const v=await p.switchConversation(b);x.setMessages(v),t(!1)},[p,x]),g=o.useCallback(async()=>{x.setMessages([]),t(!1),await p.newConversation()},[p,x]),w=o.useCallback(async b=>{await p.deleteConversation(b),p.activeConversationId===b&&x.setMessages([])},[p,x]);o.useEffect(()=>{p.activeConversationId&&x.messages.length===0&&a.getMessages(p.activeConversationId).then(b=>{x.setMessages(b)}).catch(()=>{})},[]);const S=o.useCallback(()=>{t(b=>!b)},[]),E=o.useCallback(()=>{l(b=>!b),d(b=>null)},[]),M=o.useCallback(b=>{d(b),l(!0)},[]),k=o.useMemo(()=>{const b=new Set,v=[];for(const j of x.messages)for(const R of j.parts)if(R.type==="tool_result"&&R.artifacts)for(const $ of re(R.artifacts)){const z=$.id||`${$.url}:${$.filename}`;b.has(z)||(b.add(z),v.push($))}return v},[x.messages]),m=o.useCallback((b,v,j)=>{a.feedback(b,v,j).catch(()=>{})},[a]),I=o.useCallback(b=>{a.cancelFeedback(b).catch(()=>{})},[a]),y=o.useMemo(()=>({sdk:a,status:x.status,error:x.error,messages:x.messages,conversations:p.conversations,activeConversationId:p.activeConversationId,isThreadListOpen:n,isArtifactDrawerOpen:i,allArtifacts:k,activePreviewArtifact:c,hasMore:p.hasMore,sendMessage:x.sendMessage,stop:x.stop,regenerate:x.regenerate,switchConversation:h,newConversation:g,deleteConversation:w,renameConversation:p.renameConversation,loadMoreConversations:p.loadMore,toggleThreadList:S,toggleArtifactDrawer:E,openArtifactPreview:M,feedback:m,cancelFeedback:I,respondToInterrupt:x.respondToInterrupt}),[a,x.status,x.error,x.messages,x.sendMessage,x.stop,x.regenerate,x.respondToInterrupt,p.conversations,p.activeConversationId,p.renameConversation,p.hasMore,p.loadMore,n,i,k,c,h,g,w,S,E,M,m,I]);return e.jsx(ne.Provider,{value:y,children:r})}const Te="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let Z=!1;function ie(a=Te){if(Z||typeof document>"u")return;Z=!0;const s=a.split("?")[0].split("/").pop();if(s&&document.querySelector(`script[src*="${s}"]`))return;const r=document.createElement("script");r.src=a,document.head.appendChild(r)}ie();function C({name:a,size:s=16,color:r="currentColor",className:n,style:t}){return e.jsx("svg",{className:n,style:{width:s,height:s,fill:r,verticalAlign:"middle",...t},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${a}`})})}function oe({isOpen:a,onClick:s}){return e.jsx("button",{className:`sa-trigger ${a?"sa-trigger-open":""}`,onClick:s,children:a?e.jsx(C,{name:"x",size:24,color:"#fff"}):e.jsx(C,{name:"message-square",size:24,color:"#fff"})})}function le({title:a,onClose:s,onToggleThreadList:r,showClose:n=!0,artifactCount:t=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:a}),e.jsx("div",{className:"sa-header-status",children:"● Online"})]})]}),e.jsxs("div",{className:"sa-header-actions",children:[t>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(C,{name:"menu",size:16})}),n&&e.jsx("button",{className:"sa-header-btn",onClick:s,title:"关闭",children:e.jsx(C,{name:"x",size:16})})]})]})}const q=a=>String(a).padStart(2,"0");function ce(a){if(!a)return"";const s=new Date(a);return isNaN(s.getTime())?"":`${s.getFullYear()}-${q(s.getMonth()+1)}-${q(s.getDate())} ${q(s.getHours())}:${q(s.getMinutes())}:${q(s.getSeconds())}`}function Me(a){const s=new Date,r=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),n=r-6*864e5,t=[],i=[],l=[];for(const d of a){const u=new Date(d.updateTime).getTime();u>=r?t.push(d):u>=n?i.push(d):l.push(d)}const c=[];return t.length&&c.push({label:"今天",items:t}),i.length&&c.push({label:"最近 7 天",items:i}),l.length&&c.push({label:"更早",items:l}),c}function de(){const{conversations:a,activeConversationId:s,switchConversation:r,newConversation:n,deleteConversation:t,renameConversation:i,isThreadListOpen:l,toggleThreadList:c,hasMore:d,loadMoreConversations:u}=_(),[f,p]=o.useState(null),[x,h]=o.useState(""),g=o.useRef(null),w=o.useCallback((k,m)=>{p(k),h(m??"")},[]),S=o.useCallback(k=>{x.trim()&&i(k,x.trim()),p(null)},[x,i]),E=o.useCallback(()=>{const k=g.current;!k||!d||k.scrollHeight-k.scrollTop-k.clientHeight<50&&u()},[d,u]),M=o.useMemo(()=>Me(a),[a]);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(C,{name:"plus",size:14})," 新会话"]})]}),e.jsxs("div",{className:"sa-thread-list-items",ref:g,onScroll:E,children:[a.length===0&&e.jsx("div",{className:"sa-thread-list-empty",children:"暂无会话"}),M.map(k=>e.jsxs("div",{className:"sa-thread-group",children:[e.jsx("div",{className:"sa-thread-group-label",children:k.label}),k.items.map(m=>e.jsxs("div",{className:`sa-thread-item ${m.sessionId===s?"active":""}`,onClick:()=>{f!==m.sessionId&&r(m.sessionId)},children:[f===m.sessionId?e.jsx("input",{className:"sa-thread-item-edit",value:x,onChange:I=>h(I.target.value),onBlur:()=>S(m.sessionId),onKeyDown:I=>{I.key==="Enter"&&S(m.sessionId),I.key==="Escape"&&p(null)},onClick:I=>I.stopPropagation(),autoFocus:!0}):e.jsxs("div",{className:"sa-thread-item-info",children:[e.jsx("span",{className:"sa-thread-item-title",children:m.title||"新会话"}),e.jsx("span",{className:"sa-thread-item-time",children:ce(m.updateTime)})]}),e.jsxs("div",{className:"sa-thread-item-actions",children:[e.jsx("button",{className:"sa-thread-item-action-btn",onClick:I=>{I.stopPropagation(),w(m.sessionId,m.title)},title:"重命名",children:e.jsx(C,{name:"pen",size:13})}),e.jsx("button",{className:"sa-thread-item-action-btn",onClick:I=>{I.stopPropagation(),t(m.sessionId)},title:"删除",children:e.jsx(C,{name:"trash2",size:13})})]})]},m.sessionId))]},k.label)),d&&e.jsx("div",{className:"sa-thread-list-loading",children:"加载更多..."})]})]})]}):null}function pe(a){const s=o.useRef(null),r=o.useRef(!1),n=o.useRef(0),t=o.useCallback(()=>{const l=s.current;if(!l)return;const{scrollTop:c,scrollHeight:d,clientHeight:u}=l,f=d-c-u<40;c<n.current&&!f&&(r.current=!0),f&&(r.current=!1),n.current=c},[]);o.useEffect(()=>{const l=s.current;if(l)return l.addEventListener("scroll",t,{passive:!0}),()=>l.removeEventListener("scroll",t)},[t]),o.useEffect(()=>{if(r.current)return;const l=s.current;l&&requestAnimationFrame(()=>{l.scrollTop=l.scrollHeight})},a);const i=o.useCallback(()=>{r.current=!1;const l=s.current;l&&(l.scrollTop=l.scrollHeight)},[]);return{containerRef:s,scrollToBottom:i}}function B(a){return a.value++}function F(a,s){const r=[],n=[],t=()=>{n.length>0&&(r.push(n.join("")),n.length=0)};let i=0;for(;i<a.length;){const l=a[i];if(l==="`"){const c=a.indexOf("`",i+1);if(c!==-1){t(),r.push(e.jsx("code",{className:"sa-inline-code",children:a.slice(i+1,c)},B(s))),i=c+1;continue}}else if(l==="*"&&a[i+1]==="*"){const c=a.indexOf("**",i+2);if(c!==-1){t(),r.push(e.jsx("strong",{children:F(a.slice(i+2,c),s)},B(s))),i=c+2;continue}}else if(l==="*"){const c=a.indexOf("*",i+1);if(c!==-1){t(),r.push(e.jsx("em",{children:F(a.slice(i+1,c),s)},B(s))),i=c+1;continue}}else if(l==="["){const c=a.indexOf("]",i+1);if(c!==-1&&a[c+1]==="("){const d=a.indexOf(")",c+2);if(d!==-1){const u=a.slice(i+1,c),f=a.slice(c+2,d);t(),r.push(e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",children:F(u,s)},B(s))),i=d+1;continue}}}n.push(l),i++}return t(),r}function Ee(a,s){const r=[],n=a.split(`
|
|
2
|
-
`);let t=0;const i=d=>d.trim()==="",l=d=>/^#{1,6}\s+\S/.test(d.trim()),c=d=>/^(?:[-*+]|\d+[.)])\s+\S/.test(d.trim());for(;t<n.length;){const d=n[t],u=d.trim();if(i(d)){t++;continue}if(l(d)){const p=u.match(/^(#{1,6})\s+(.*)$/);if(p){const h=`h${Math.min(p[1].length,6)}`;r.push(o.createElement(h,{key:B(s)},F(p[2],s)))}t++;continue}if(c(d)){const p=/^\d+[.)]/.test(u),x=[];for(;t<n.length&&c(n[t]);){const h=n[t].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);h&&x.push(e.jsx("li",{children:F(h[1],s)},B(s))),t++}r.push(p?e.jsx("ol",{className:"sa-list",children:x},B(s)):e.jsx("ul",{className:"sa-list",children:x},B(s)));continue}const f=[];for(;t<n.length&&!i(n[t])&&!l(n[t])&&!c(n[t]);)f.push(n[t]),t++;r.push(e.jsx("p",{className:"sa-text-paragraph",children:F(f.join(" "),s)},B(s)))}return r}function De(a){const s={value:0},r=[],n=a.split("```");for(let t=0;t<n.length;t++)if(t%2===0)r.push(...Ee(n[t],s));else if(n[t].trim()!==""){let i=n[t].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})},B(s)))}return r}function ue({content:a}){return e.jsx("div",{className:"sa-text-part",children:De(a)})}function fe({content:a}){const[s,r]=o.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>r(!s),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(C,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${s?"expanded":""}`,children:e.jsx(C,{name:"chevron-right",size:12})})]}),s&&e.jsx("div",{className:"sa-thinking-content",children:a})]})}function xe({toolName:a,toolCallId:s,args:r}){const[n,t]=o.useState(!1);let i=r;try{i=JSON.stringify(JSON.parse(r),null,2)}catch{}return e.jsxs("div",{className:"sa-tool-call-part",children:[e.jsxs("div",{className:"sa-tool-call-header",onClick:()=>t(!n),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(C,{name:"zap",size:14})}),e.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",a]}),e.jsx("span",{className:`sa-thinking-arrow ${n?"expanded":""}`,children:e.jsx(C,{name:"chevron-right",size:12})})]}),n&&e.jsx("pre",{className:"sa-tool-args",children:i})]})}function $e({html:a}){const[s,r]=o.useState(null),n=o.useRef(null);o.useEffect(()=>{let i=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(l=>{i||r(l.default.sanitize(a,{FORCE_BODY:!0}))}),()=>{i=!0}},[a]);const t=o.useCallback(()=>{var l;const i=n.current;if(i)try{const c=i.contentDocument||((l=i.contentWindow)==null?void 0:l.document);if(!(c!=null&&c.body))return;const d=c.body.scrollHeight;i.style.height=Math.min(d,500)+"px"}catch{}},[]);return o.useEffect(()=>{const i=n.current;if(!(!i||s===null))return i.addEventListener("load",t),()=>i.removeEventListener("load",t)},[s,t]),s===null?null:e.jsx("div",{className:"sa-tool-result-html",children:e.jsx("iframe",{ref:n,srcDoc:s,className:"sa-tool-result-html-iframe",sandbox:"allow-same-origin",title:"HTML 产物"})})}function me({toolName:a,content:s,artifacts:r,renderMode:n,html:t,artifactPreview:i}){const{openArtifactPreview:l}=_(),c=re(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(C,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:a||"工具返回"})]}),n==="html"&&t?e.jsx($e,{html:t}):s?e.jsx("div",{className:"sa-tool-result-content",children:s}):null,c.length>0&&e.jsx("ul",{className:"sa-artifact-file-list",role:"list",children:c.map((d,u)=>e.jsxs("li",{className:"sa-artifact-file-card",onClick:i?()=>l(d):void 0,onKeyDown:i?f=>{(f.key==="Enter"||f.key===" ")&&(f.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:se(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:te(d.size)})]}),i&&e.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${d.filename}`,onClick:f=>{f.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-${u}`))})]})}function he({content:a,onRetry:s}){return e.jsxs("div",{className:"sa-error-part",children:[e.jsxs("div",{className:"sa-error-content",children:[e.jsx("span",{className:"sa-error-icon",children:e.jsx(C,{name:"triangle-alert",size:14})}),e.jsx("span",{children:a})]}),s&&e.jsx("button",{className:"sa-error-retry",onClick:s,children:"重试"})]})}function Re({interrupt:a,onRespond:s,disabled:r,answeredAction:n}){var c,d;const t=a.options,i=(typeof(t==null?void 0:t[0])=="string"?t[0]:(c=t==null?void 0:t[0])==null?void 0:c.label)||"确认",l=(typeof(t==null?void 0:t[1])=="string"?t[1]:(d=t==null?void 0:t[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(C,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:a.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:()=>s({action:"confirm"}),children:[e.jsx(C,{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:()=>s({action:"cancel"}),children:[e.jsx(C,{name:"x",size:14})," ",l]})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Le({interrupt:a,onRespond:s,disabled:r,answeredAction:n}){var u,f,p,x;const t=a.options,i=(typeof(t==null?void 0:t[0])=="string"?t[0]:(u=t==null?void 0:t[0])==null?void 0:u.label)||"批准",l=(typeof(t==null?void 0:t[1])=="string"?t[1]:(f=t==null?void 0:t[1])==null?void 0:f.label)||"拒绝",c=(typeof(t==null?void 0:t[2])=="string"?t[2]:(p=t==null?void 0:t[2])==null?void 0:p.label)||"跳过",d=((x=a.metadata)==null?void 0:x.showSkip)!==!1;return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(C,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:a.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:()=>s({action:"approve"}),children:[e.jsx(C,{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:()=>s({action:"reject"}),children:[e.jsx(C,{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:()=>s({action:"skip"}),children:[e.jsx(C,{name:"chevron-right",size:14})," ",c]})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Ae(a){return typeof a=="string"?{value:a,label:a}:a}function Pe({interrupt:a,onRespond:s,disabled:r,initialValue:n}){const t=(a.options??[]).map(Ae);return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(C,{name:"list",size:16,color:"#6366f1"}),e.jsx("span",{children:a.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:t.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:()=>s({action:"select",value:i.value}),children:[e.jsx(C,{name:l?"circle-check":"circle",size:14}),i.icon&&e.jsx(C,{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 Oe(a){return typeof a=="string"?{value:a,label:a}:a}function He({interrupt:a,onRespond:s,disabled:r,initialValue:n}){const t=(a.options??[]).map(Oe),[i,l]=o.useState(()=>new Set(Array.isArray(n)?n:[])),c=d=>{r||l(u=>{const f=new Set(u);return f.has(d)?f.delete(d):f.add(d),f})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(C,{name:"list-checks",size:16,color:"#6366f1"}),e.jsx("span",{children:a.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:t.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(C,{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:()=>s({action:"submit",value:Array.from(i)}),children:[e.jsx(C,{name:"check",size:14})," 确认 (",i.size,")"]})}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Be({interrupt:a,onRespond:s,disabled:r,initialValue:n}){const[t,i]=o.useState(n??""),l=a.inputType??"text",c=l==="textarea",d=()=>{r||a.required&&!t.trim()||s({action:"submit",value:t.trim()})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(C,{name:"text-cursor-input",size:16,color:"#6366f1"}),e.jsx("span",{children:a.content})]}),e.jsx("div",{className:"sa-interrupt-input-area",children:c?e.jsx("textarea",{className:"sa-interrupt-textarea",value:t,onChange:u=>i(u.target.value),placeholder:a.placeholder,maxLength:a.maxLength,rows:3,disabled:r}):e.jsx("input",{className:"sa-interrupt-input",type:l,value:t,onChange:u=>i(u.target.value),placeholder:a.placeholder,maxLength:a.maxLength,onKeyDown:u=>u.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:a.required?!t.trim():!1,onClick:d,children:[e.jsx(C,{name:"check",size:14})," 提交"]})}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function _e({interrupt:a,onRespond:s,disabled:r,initialValue:n}){const t=a.fields??[],[i,l]=o.useState(()=>{const f={};for(const p of t)f[p.name]=(n==null?void 0:n[p.name])??p.defaultValue??"";return f}),c=(f,p)=>{r||l(x=>({...x,[f]:p}))},d=!r&&t.every(f=>!f.required||i[f.name]),u=()=>{d&&s({action:"submit",value:i})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(C,{name:"file-text",size:16,color:"#6366f1"}),e.jsx("span",{children:a.content})]}),e.jsx("div",{className:"sa-interrupt-form",children:t.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:"*"})]}),Fe(f,i[f.name],p=>c(f.name,p),r)]},f.name))}),!r&&e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:!d,onClick:u,children:[e.jsx(C,{name:"check",size:14})," 提交"]}),e.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>s({action:"cancel"}),children:"取消"})]}),r&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Fe(a,s,r,n){switch(a.type){case"textarea":return e.jsx("textarea",{className:"sa-interrupt-textarea",value:s,onChange:t=>r(t.target.value),placeholder:a.placeholder,rows:3,disabled:n});case"select":return e.jsxs("select",{className:"sa-interrupt-select",value:s,onChange:t=>r(t.target.value),disabled:n,children:[e.jsx("option",{value:"",children:"请选择"}),(a.options??[]).map(t=>e.jsx("option",{value:t,children:t},t))]});default:return e.jsx("input",{className:"sa-interrupt-input",type:a.type,value:s,onChange:t=>r(t.target.value),placeholder:a.placeholder,disabled:n})}}function ge({interrupt:a,resolved:s,response:r,onRespond:n}){const t=s,i=r==null?void 0:r.value;switch(a.interruptType){case"confirm":return e.jsx(Re,{interrupt:a,onRespond:n,disabled:t,answeredAction:r==null?void 0:r.action});case"approve":return e.jsx(Le,{interrupt:a,onRespond:n,disabled:t,answeredAction:r==null?void 0:r.action});case"select":return e.jsx(Pe,{interrupt:a,onRespond:n,disabled:t,initialValue:i});case"multiSelect":return e.jsx(He,{interrupt:a,onRespond:n,disabled:t,initialValue:i});case"input":return e.jsx(Be,{interrupt:a,onRespond:n,disabled:t,initialValue:i});case"form":return e.jsx(_e,{interrupt:a,onRespond:n,disabled:t,initialValue:i});default:return e.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",a.interruptType]})}}const We=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function be({message:a,onCopy:s,onRegenerate:r,onFeedback:n}){const{status:t,cancelFeedback:i}=_(),[l,c]=o.useState(null),[d,u]=o.useState(!1),[f,p]=o.useState(!1),x=o.useRef(null),h=o.useCallback(()=>{s(),u(!0),setTimeout(()=>u(!1),2e3)},[s]),g=o.useCallback(()=>{l==="like"?(c(null),i(a.id)):(c("like"),p(!1),n==null||n(a.id,"like"))},[l,a.id,n,i]),w=o.useCallback(()=>{l==="dislike"?(c(null),p(!1),i(a.id)):p(!0)},[l,a.id,i]),S=o.useCallback((M,k)=>{c("dislike"),p(!1),n==null||n(a.id,"dislike",{reason:M,remark:(k==null?void 0:k.trim())||void 0})},[a.id,n]),E=o.useCallback(()=>{p(!1)},[]);return o.useEffect(()=>{if(!f)return;const M=m=>{x.current&&!x.current.contains(m.target)&&p(!1)},k=m=>{m.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",M),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",k)}},[f]),t!=="ready"&&t!=="error"?null:e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:h,title:"复制",children:[e.jsx(C,{name:d?"circle-check":"copy",size:14})," ",d?"已复制":"复制"]}),r&&e.jsxs("button",{className:"sa-action-btn",onClick:r,title:"重新生成",children:[e.jsx(C,{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:g,title:"有用","aria-label":"点赞",children:e.jsx(C,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${l==="dislike"?"sa-action-btn-active":""}`,onClick:w,title:"无用","aria-label":"踩","aria-expanded":f,"aria-haspopup":"dialog",children:e.jsx(C,{name:"thumbs-down",size:14})})]}),f&&e.jsx("div",{ref:x,children:e.jsx(qe,{onSubmit:S,onCancel:E})})]})}function qe({onSubmit:a,onCancel:s}){const[r,n]=o.useState(void 0),[t,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:We.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:t,onChange:l=>i(l.target.value),rows:2}),e.jsxs("div",{className:"sa-dislike-actions",children:[e.jsx("button",{className:"sa-dislike-submit",onClick:()=>a(r,t||void 0),children:"提交"}),e.jsx("button",{className:"sa-dislike-cancel",onClick:s,children:"取消"})]})]})}function Q({src:a,role:s}){const r=s==="assistant"?"A":"U";return a?a.startsWith("http")||a.startsWith("/")||a.startsWith("data:")?e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:e.jsx("img",{src:a,alt:s,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}})}):e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:a}):e.jsx("div",{className:`sa-avatar sa-avatar-${s}`,children:r})}function ve({message:a,isStreaming:s,isLast:r,slots:n,avatar:t,artifactPreview:i}){const{regenerate:l,feedback:c,respondToInterrupt:d}=_(),u=o.useCallback(()=>{var I;const m=a.parts.filter(y=>y.type==="text").map(y=>y.content).join(`
|
|
3
|
-
`);(I=navigator.clipboard)==null||I.writeText(m).catch(()=>{})},[a]),f=a.role==="user",p=n.Message;if(p)return e.jsx(p,{message:a,isStreaming:s,isLast:r,avatar:t,slots:n,onCopy:u,onRegenerate:l,onFeedback:c});const x=n.TextPart??ue,h=n.ThinkingPart??fe,g=n.ToolCallPart??xe,w=n.ToolResultPart??me,S=n.ErrorPart??he,E=n.ActionBar??be,M=!f&&a.parts.some(m=>m.type==="text"&&m.content),k=!a.id.startsWith("assistant_")&&!a.id.startsWith("user_");return e.jsxs("div",{className:`sa-message ${f?"sa-message-user":"sa-message-assistant"}`,children:[!f&&e.jsx(Q,{src:t==null?void 0:t.assistant,role:"assistant"}),e.jsxs("div",{className:"sa-message-content",children:[e.jsx("span",{className:`sa-message-time ${f?"sa-message-time-right":""}`,children:ce(a.timestamp)}),e.jsxs("div",{className:"sa-message-body",children:[a.parts.map((m,I)=>{switch(m.type){case"text":return e.jsx(x,{content:m.content},I);case"thinking":return e.jsx(h,{content:m.content},I);case"tool_call":return e.jsx(g,{toolName:m.toolName,toolCallId:m.toolCallId,args:m.args},I);case"tool_result":return e.jsx(w,{toolName:m.toolName,toolCallId:m.toolCallId,content:m.content,artifacts:m.artifacts,renderMode:m.renderMode,html:m.html,artifactPreview:i},I);case"error":return e.jsx(S,{content:m.content,onRetry:l},I);case"interrupt":return e.jsx(ge,{interrupt:m.interrupt,resolved:m.resolved??!1,response:m.response,onRespond:y=>d(m.interrupt.interruptId,y)},I);default:return null}}),s&&r&&!f&&e.jsx("span",{className:"sa-streaming-cursor",children:"|"}),!f&&!s&&M&&e.jsx(E,{message:a,onCopy:u,onRegenerate:r?l:void 0,onFeedback:k?c:void 0})]})]}),f&&e.jsx(Q,{src:t==null?void 0:t.user,role:"user"})]})}function we({message:a,suggestedPrompts:s,onPromptClick:r}){return e.jsxs("div",{className:"sa-welcome",children:[e.jsx("div",{className:"sa-welcome-icon",children:e.jsx(C,{name:"sparkles",size:40})}),e.jsx("p",{className:"sa-welcome-message",children:a||"你好!有什么可以帮你的?"}),s&&s.length>0&&e.jsx("div",{className:"sa-welcome-prompts",children:s.map((n,t)=>e.jsx("button",{className:"sa-welcome-prompt",onClick:()=>r(n),children:n},t))})]})}function X({slots:a,welcomeMessage:s,suggestedPrompts:r,avatar:n,artifactPreview:t}){const{messages:i,status:l,sendMessage:c}=_(),{containerRef:d}=pe([i]),u=l==="streaming",f=a.WelcomeScreen??we;return i.length===0?e.jsx("div",{className:"sa-thread",ref:d,children:e.jsx(f,{message:s,suggestedPrompts:r,onPromptClick:c})}):e.jsx("div",{className:"sa-thread",ref:d,children:i.map((p,x)=>e.jsx(ve,{message:p,isStreaming:u,isLast:x===i.length-1,slots:a,avatar:n,artifactPreview:t},p.id))})}function Ke({items:a,activeIndex:s,onSelect:r}){const n=o.useRef(null);return o.useEffect(()=>{var i;const t=(i=n.current)==null?void 0:i.children[s];t==null||t.scrollIntoView({block:"nearest"})},[s]),a.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:a.map((t,i)=>e.jsxs("div",{className:`sa-slash-menu-item${i===s?" sa-slash-menu-item--active":""}`,onMouseDown:l=>{l.preventDefault(),r(t)},children:[e.jsxs("span",{className:"sa-slash-menu-item-name",children:["/",t.name]}),(t.displayName||t.description)&&e.jsx("span",{className:"sa-slash-menu-item-desc",children:t.displayName||t.description})]},t.code))})}function Ye({sdk:a,input:s,onSelect:r}){const[n,t]=o.useState([]),[i,l]=o.useState(!1),[c,d]=o.useState(0),u=o.useRef(!1);o.useEffect(()=>{u.current||(u.current=!0,a.listSkills().then(t).catch(()=>t([])))},[a]);const f=/^\/\S*$/.test(s);o.useEffect(()=>{l(f)},[f]),o.useEffect(()=>{f&&d(0)},[s,f]);const p=s.startsWith("/")?s.slice(1).toLowerCase():"",x=o.useMemo(()=>n.filter(k=>!p||k.code.toLowerCase().includes(p)||k.name.toLowerCase().includes(p)||k.displayName&&k.displayName.toLowerCase().includes(p)),[n,p]),h=o.useRef(i),g=o.useRef(x),w=o.useRef(c),S=o.useRef(r);h.current=i,g.current=x,w.current=c,S.current=r;const E=o.useCallback(k=>{if(!h.current||g.current.length===0)return!1;switch(k.key){case"ArrowDown":return k.preventDefault(),d(m=>(m+1)%g.current.length),!0;case"ArrowUp":return k.preventDefault(),d(m=>(m-1+g.current.length)%g.current.length),!0;case"Enter":case"Tab":return k.preventDefault(),S.current(g.current[w.current]),l(!1),!0;case"Escape":return k.preventDefault(),l(!1),!0;default:return!1}},[]),M=o.useCallback(()=>l(!1),[]);return{isOpen:i,items:x,activeIndex:c,handleKeyDown:E,close:M}}function G(){const{status:a,sendMessage:s,stop:r,sdk:n}=_(),[t,i]=o.useState(""),l=o.useRef(null),c=a==="streaming"||a==="submitted",d=o.useCallback(h=>{i(`/${h.name} `),setTimeout(()=>{const g=l.current;g&&(g.focus(),g.selectionStart=g.selectionEnd=g.value.length)},0)},[]),u=Ye({sdk:n,input:t,onSelect:d}),f=o.useCallback(()=>{const h=t.trim();!h||c||(s(h),i(""),l.current&&(l.current.style.height="auto"))},[t,c,s]),p=o.useCallback(h=>{u.handleKeyDown(h)||h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),f())},[f,u.handleKeyDown]),x=o.useCallback(h=>{i(h.target.value);const g=h.target;g.style.height="auto",g.style.height=Math.min(g.scrollHeight,120)+"px"},[]);return e.jsxs("div",{className:"sa-composer",children:[u.isOpen&&e.jsx(Ke,{items:u.items,activeIndex:u.activeIndex,onSelect:d}),e.jsx("textarea",{ref:l,className:"sa-composer-input",value:t,onChange:x,onKeyDown:p,placeholder:"输入消息,按 / 选择技能...",rows:1,disabled:a==="submitted"}),c?e.jsx("button",{className:"sa-composer-stop",onClick:r,title:"停止",children:e.jsx(C,{name:"circle-stop",size:16,color:"#fff"})}):e.jsx("button",{className:"sa-composer-send",onClick:f,disabled:!t.trim(),title:"发送",children:e.jsx(C,{name:"arrow-up",size:16,color:"#fff"})})]})}function Ue({artifact:a}){const[s,r]=o.useState(null),[n,t]=o.useState(!0),[i,l]=o.useState(null);return o.useEffect(()=>{let c=!1;t(!0),l(null),r(null);async function d(){try{if(a.type==="pdf"){c||t(!1);return}if(a.type==="html"){const u=await fetch(a.url);if(!u.ok)throw new Error(`HTTP ${u.status}`);const f=await u.text(),p=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(r(p.sanitize(f,{FORCE_BODY:!0,ADD_ATTR:["target"]})),t(!1));return}if(a.type==="docx"){const u=await fetch(a.url);if(!u.ok)throw new Error(`HTTP ${u.status}`);const f=await u.arrayBuffer(),x=await(await Promise.resolve().then(()=>require("./mammoth.browser-DiAPPO3x.cjs")).then(g=>g.mammoth_browser)).convertToHtml({arrayBuffer:f}),h=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(r(h.sanitize(x.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),t(!1));return}c||(t(!1),l(`不支持预览「${a.type}」类型`))}catch(u){c||(t(!1),l(u instanceof Error?u.message:"加载失败"))}}return d(),()=>{c=!0}},[a]),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(a),children:"下载查看"})]}):a.type==="pdf"?e.jsx("iframe",{src:a.url,title:a.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):s!==null?e.jsx("iframe",{srcDoc:s,title:a.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-same-origin"}):null}function ye({artifacts:a,initialArtifact:s,onClose:r}){const[n,t]=o.useState(s?{mode:"preview",artifact:s}:{mode:"list"}),[i,l]=o.useState(!1),c=o.useRef(null),[d,u]=o.useState(340),f=o.useRef(null);o.useEffect(()=>{s&&(c.current&&(clearTimeout(c.current),c.current=null,l(!1)),t({mode:"preview",artifact:s}))},[s]);const p=o.useCallback(()=>{l(!0),c.current=setTimeout(()=>{c.current=null,r()},240)},[r]);o.useEffect(()=>()=>{var w;c.current&&clearTimeout(c.current),(w=f.current)==null||w.call(f)},[]);const x=o.useCallback(w=>{t({mode:"preview",artifact:w})},[]),h=o.useCallback(()=>{t({mode:"list"})},[]);o.useEffect(()=>{const w=S=>{S.key==="Escape"&&p()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[p]);const g=o.useCallback(w=>{w.preventDefault();const S=w.clientX,E=d,M=m=>{const I=S-m.clientX;u(Math.max(240,Math.min(window.innerWidth*.7,E+I)))},k=()=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",k),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",M),document.addEventListener("mouseup",k),f.current=k},[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:g}),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:h,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:p,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"?a.length===0?e.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):e.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:a.map((w,S)=>e.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>x(w),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),x(w))},tabIndex:0,role:"button","aria-label":`预览 ${w.filename}`,children:[e.jsx("div",{className:"sa-drawer-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:se(w.type)})}),e.jsxs("div",{className:"sa-drawer-file-info",children:[e.jsx("span",{className:"sa-drawer-file-name",children:w.filename}),e.jsx("span",{className:"sa-drawer-file-size",children:te(w.size)})]}),e.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${w.filename}`,onClick:E=>{E.stopPropagation(),K(w)},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"})})})]},w.id||`artifact-${S}`))}):e.jsx("div",{className:"sa-drawer-view-enter",children:e.jsx(Ue,{artifact:n.artifact})})})]})}function Ve({isOpen:a,onClose:s,title:r,slots:n,welcomeMessage:t,suggestedPrompts:i,avatar:l,artifactPreview:c}){const{status:d,sendMessage:u,stop:f,toggleThreadList:p,toggleArtifactDrawer:x,conversations:h,activeConversationId:g,switchConversation:w,newConversation:S,deleteConversation:E,renameConversation:M,isThreadListOpen:k,isArtifactDrawerOpen:m,allArtifacts:I,activePreviewArtifact:y}=_();if(!a)return null;const b=n.Header,v=n.Composer,j=n.ThreadList;return e.jsxs("div",{className:"sa-panel",children:[b?e.jsx(b,{title:r,onClose:s,onToggleThreadList:p}):e.jsx(le,{title:r,onClose:s,onToggleThreadList:p,artifactCount:c?I.length:0,onToggleArtifactDrawer:c?x:void 0}),j&&k?e.jsx(j,{conversations:h,activeSessionId:g,onSwitch:w,onNew:S,onDelete:E,onRename:M}):e.jsx(de,{}),e.jsxs("div",{className:"sa-panel-content",children:[e.jsx(X,{slots:n,welcomeMessage:t,suggestedPrompts:i,avatar:l,artifactPreview:c}),c&&m&&e.jsx(ye,{artifacts:I,initialArtifact:y,onClose:x})]}),v?e.jsx(v,{status:d,onSend:u,onStop:f}):e.jsx(G,{})]})}function Xe({conversations:a,activeSessionId:s,onSwitch:r,onNew:n,onDelete:t,onRename:i,isCollapsed:l,onToggleCollapse:c,hasMore:d,onLoadMore:u}){const[f,p]=o.useState(null),[x,h]=o.useState(null),[g,w]=o.useState(null),[S,E]=o.useState(""),M=o.useCallback((v,j)=>{j.stopPropagation(),x===v?(t(v),h(null)):(h(v),setTimeout(()=>h(null),3e3))},[x,t]),k=o.useCallback((v,j,R)=>{R.stopPropagation(),w(v),E(j??"")},[]),m=o.useCallback(v=>{S.trim()&&i(v,S.trim()),w(null)},[S,i]),I=o.useRef(null),y=o.useCallback(()=>{const v=I.current;!v||!d||!u||v.scrollHeight-v.scrollTop-v.clientHeight<50&&u()},[d,u]),b=(()=>{const v=Date.now(),j=[],R=[],$=[];for(const D of a){const A=v-new Date(D.updateTime).getTime();A<864e5?j.push(D):A<6048e5?R.push(D):$.push(D)}const z=[];return j.length&&z.push({label:"今天",items:j}),R.length&&z.push({label:"最近 7 天",items:R}),$.length&&z.push({label:"更早",items:$}),z})();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(C,{name:"panel-left",size:18})}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:n,title:"新会话",style:{marginTop:4},children:e.jsx(C,{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(C,{name:"plus",size:15})," ",e.jsx("span",{children:"新会话"})]}),e.jsx("button",{className:"sa-fp-sidebar-toggle",onClick:c,title:"收起侧边栏",children:e.jsx(C,{name:"panel-left-close",size:18})})]}),e.jsxs("div",{className:"sa-fp-sidebar-list",ref:I,onScroll:y,children:[a.length===0&&e.jsx("div",{className:"sa-fp-sidebar-empty",children:"开始你的第一个对话"}),b.map(v=>e.jsxs("div",{children:[e.jsx("div",{className:"sa-fp-sidebar-group",children:v.label}),v.items.map(j=>{const R=j.sessionId===s,$=f===j.sessionId,z=x===j.sessionId;return e.jsxs("div",{className:`sa-fp-sidebar-item ${R?"active":""}`,onClick:()=>{g!==j.sessionId&&r(j.sessionId)},onMouseEnter:()=>p(j.sessionId),onMouseLeave:()=>p(null),children:[g===j.sessionId?e.jsx("input",{className:"sa-fp-sidebar-item-edit",value:S,onChange:D=>E(D.target.value),onBlur:()=>m(j.sessionId),onKeyDown:D=>{D.key==="Enter"&&m(j.sessionId),D.key==="Escape"&&w(null)},onClick:D=>D.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"sa-fp-sidebar-item-title",children:j.title||"新会话"}),e.jsxs("div",{className:`sa-fp-sidebar-item-actions ${$&&g!==j.sessionId?"visible":""}`,children:[e.jsx("button",{className:"sa-fp-sidebar-item-action",onClick:D=>k(j.sessionId,j.title,D),title:"重命名",children:e.jsx(C,{name:"pen",size:14})}),e.jsx("button",{className:`sa-fp-sidebar-item-action ${z?"danger":""}`,onClick:D=>M(j.sessionId,D),title:z?"确认删除":"删除",children:e.jsx(C,{name:z?"x":"trash2",size:14})})]})]},j.sessionId)})]},v.label)),d&&e.jsx("div",{className:"sa-thread-list-loading",children:"加载更多..."})]})]})}function ke({title:a,slots:s,welcomeMessage:r,suggestedPrompts:n,sidebarDefaultOpen:t=!0,onClose:i,avatar:l,artifactPreview:c}){const{status:d,sendMessage:u,stop:f,conversations:p,activeConversationId:x,switchConversation:h,newConversation:g,deleteConversation:w,renameConversation:S,toggleArtifactDrawer:E,isArtifactDrawerOpen:M,allArtifacts:k,activePreviewArtifact:m,hasMore:I,loadMoreConversations:y}=_(),[b,v]=o.useState(t),j=o.useCallback(()=>v(z=>!z),[]),R=s.ThreadList,$=s.Composer;return e.jsxs("div",{className:"sa-fullpage",children:[R?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${b?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(R,{conversations:p,activeSessionId:x,onSwitch:h,onNew:g,onDelete:w,onRename:S,hasMore:I,onLoadMore:y})}):e.jsx(Xe,{conversations:p,activeSessionId:x,onSwitch:h,onNew:g,onDelete:w,onRename:S,isCollapsed:!b,onToggleCollapse:j,hasMore:I,onLoadMore:y}),e.jsxs("div",{className:"sa-fp-main",children:[e.jsxs("div",{className:"sa-fp-header",children:[!b&&!R&&e.jsx("button",{className:"sa-fp-header-btn",onClick:j,title:"展开侧边栏",children:e.jsx(C,{name:"panel-left",size:18})}),e.jsx("div",{className:"sa-fp-header-title",children:a}),e.jsxs("div",{className:"sa-fp-header-actions",children:[c&&k.length>0&&e.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:E,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(C,{name:"x",size:18})})]})]}),e.jsxs("div",{className:"sa-fp-content-row",children:[e.jsx(X,{slots:s,welcomeMessage:r,suggestedPrompts:n,avatar:l,artifactPreview:c}),c&&M&&e.jsx(ye,{artifacts:k,initialArtifact:m,onClose:E})]}),$?e.jsx($,{status:d,onSend:u,onStop:f}):e.jsx(G,{})]})]})}function je(a){const{sdk:s,mode:r="floating",slots:n={},hooks:t={},welcomeMessage:i,suggestedPrompts:l,title:c="AI Assistant",initialOpen:d=!1,onOpenChange:u,sidebarDefaultOpen:f,avatar:p,artifactPreview:x}=a,[h,g]=o.useState(d);o.useEffect(()=>{g(d)},[d]);const w=o.useCallback(()=>{var k,m;const M=!h;g(M),u==null||u(M),M?(k=t.onOpen)==null||k.call(t):(m=t.onClose)==null||m.call(t)},[h,t,u]),S=o.useCallback(()=>{var M;g(!1),u==null||u(!1),(M=t.onClose)==null||M.call(t)},[t,u]),E=n.Trigger??oe;return r==="fullpage"?h?e.jsx(V,{sdk:s,hooks:t,children:e.jsx(ke,{title:c,slots:n,welcomeMessage:i,suggestedPrompts:l,sidebarDefaultOpen:f,onClose:S,avatar:p,artifactPreview:x})}):null:e.jsxs(V,{sdk:s,hooks:t,children:[e.jsx(E,{isOpen:h,onClick:w}),e.jsx(Ve,{isOpen:h,onClose:S,title:c,slots:n,welcomeMessage:i,suggestedPrompts:l,avatar:p,artifactPreview:x})]})}const Ce=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),et=require("react-dom/client"),e=require("react/jsx-runtime");function ke(t){const{sdk:a,sessionId:s,onSessionCreated:n,onStreamStart:r,onStreamEnd:o,onError:l,onMessageSend:c}=t,[d,p]=i.useState([]),[u,g]=i.useState("ready"),[b,h]=i.useState(null),m=i.useRef(null),f=i.useRef(!1),y=i.useRef(null),C=i.useRef(s),D=i.useRef(!0);C.current=s,D.current=d.length===0;const k=i.useCallback(w=>{if(f.current)return;f.current=!0,c==null||c(w);const S={id:`user_${Date.now()}`,role:"user",parts:[{type:"text",content:w}],timestamp:Date.now()},M=`assistant_${Date.now()}`,A={id:M,role:"assistant",parts:[],timestamp:Date.now()},v=D.current;p(N=>[...N,S,A]),g("submitted"),h(null);const E=N=>{let $="",x="",R=[],F=!1;const H=()=>{const z=[...R];if($){const P=z.findIndex(_=>_.type==="thinking");P>=0?z[P]={type:"thinking",content:$}:z.unshift({type:"thinking",content:$})}if(x){const P=z[z.length-1];(P==null?void 0:P.type)==="text"?z[z.length-1]={type:"text",content:x}:z.push({type:"text",content:x})}p(P=>P.map(_=>_.id===M?{..._,parts:z}:_))};m.current=a.chat({sessionId:N,message:w,stream:!0,onMessage:z=>{switch(F||(F=!0,g("streaming")),z.type){case"thinking":$+=z.content;break;case"ai":x+=z.content;break;case"tool_call":x&&(R.push({type:"text",content:x}),x=""),R.push({type:"tool_call",toolName:z.toolName,toolCallId:z.toolCallId,args:z.args??"{}"});break;case"tool_result":x&&(R.push({type:"text",content:x}),x=""),R.push({type:"tool_result",toolName:z.toolName??"",toolCallId:z.toolCallId,content:z.content,artifacts:z.artifacts,renderMode:z.renderMode,html:z.html});break;case"interrupt":x&&(R.push({type:"text",content:x}),x=""),z.interrupt&&R.push({type:"interrupt",interrupt:z.interrupt,resolved:!1});break;case"stop":z.content&&(x=z.content),H();return}H()},onDone:z=>{(x||R.length>0||$)&&H(),z.sessionId&&z.sessionId!==C.current&&(n==null||n(z.sessionId));const P=()=>{y.current&&(clearTimeout(y.current),y.current=null),o==null||o(z.sessionId||N),g("ready"),f.current=!1,m.current=null};if(v){const _=w.slice(0,30),G=z.sessionId||N;a.renameConversation(G,_).catch(()=>{}).finally(P)}else P()},onError:z=>{R.push({type:"error",content:z.message}),H(),y.current&&(clearTimeout(y.current),y.current=null),h(z),g("error"),l==null||l(z),f.current=!1,m.current=null}}),r==null||r(N)};C.current?E(C.current):a.createSession().then(N=>{C.current=N,n==null||n(N),E(N)}).catch(N=>{h(N instanceof Error?N:new Error(String(N))),g("error"),l==null||l(N instanceof Error?N:new Error(String(N))),f.current=!1})},[a,n,r,o,l,c]),j=i.useCallback(()=>{const w=C.current;w&&(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{var S;y.current=null,(S=m.current)==null||S.abort(),m.current=null,f.current=!1,g("ready")},8e3),a.stopGeneration(w).catch(()=>{}))},[a]),T=i.useCallback(()=>{if(f.current)return;const w=d.findLastIndex(M=>M.role==="user");if(w<0)return;const S=d[w].parts.filter(M=>M.type==="text").map(M=>M.content).join("");p(M=>M.slice(0,w)),k(S)},[d,k]),I=i.useCallback((w,S)=>{p(x=>x.map(R=>({...R,parts:R.parts.map(F=>F.type==="interrupt"&&F.interrupt.interruptId===w?{...F,resolved:!0,response:S}:F)})));const M=C.current;if(!M)return;let A=0;p(x=>x.length>0&&x[x.length-1].role==="assistant"?(A=x[x.length-1].parts.length,x):(A=0,[...x,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),g("streaming");let v="",E="",N=[];const $=()=>{const x=[...N];if(v){const R=x.findIndex(F=>F.type==="thinking");R>=0?x[R]={type:"thinking",content:v}:x.unshift({type:"thinking",content:v})}if(E){const R=x[x.length-1];(R==null?void 0:R.type)==="text"?x[x.length-1]={type:"text",content:E}:x.push({type:"text",content:E})}p(R=>{const F=R.findLastIndex(H=>H.role==="assistant");return F<0?R:R.map((H,z)=>z===F?{...H,parts:[...H.parts.slice(0,A),...x]}:H)})};a.respondInterrupt(w,M,S,x=>{switch(x.type){case"thinking":v+=x.content;break;case"ai":E+=x.content;break;case"tool_call":E&&(N.push({type:"text",content:E}),E=""),N.push({type:"tool_call",toolName:x.toolName,toolCallId:x.toolCallId,args:x.args??"{}"});break;case"tool_result":E&&(N.push({type:"text",content:E}),E=""),N.push({type:"tool_result",toolName:x.toolName??"",toolCallId:x.toolCallId,content:x.content,artifacts:x.artifacts,renderMode:x.renderMode,html:x.html});break;case"interrupt":E&&(N.push({type:"text",content:E}),E=""),x.interrupt&&N.push({type:"interrupt",interrupt:x.interrupt,resolved:!1});break;case"done":o==null||o(M),g("ready");break}$()},x=>{N.push({type:"error",content:x.message}),$(),h(x),g("error"),l==null||l(x)}).catch(x=>{l==null||l(x instanceof Error?x:new Error(String(x))),g("error")})},[a,l,o]);return{messages:d,status:u,error:b,sendMessage:k,stop:j,regenerate:T,setMessages:p,respondToInterrupt:I}}const je="sa_active_conversation",ae=20;function me(t){try{return localStorage.getItem(`${je}_${t}`)}catch{return null}}function tt(t,a){try{const s=`${je}_${t}`;a?localStorage.setItem(s,a):localStorage.removeItem(s)}catch{}}function Ce(t){const{sdk:a,onConversationChange:s}=t,n=a.botId,[r,o]=i.useState([]),[l,c]=i.useState(()=>me(n)),[d,p]=i.useState(!1),[u,g]=i.useState(!0),b=i.useRef(!0),h=i.useRef(1),m=i.useRef(!1);i.useEffect(()=>()=>{b.current=!1},[]);const f=i.useCallback(w=>{c(w),tt(n,w),w&&(s==null||s(w))},[n,s]),y=i.useCallback(async()=>{if(!m.current){m.current=!0,p(!0);try{h.current=1;const w=await a.listConversations({page:1,size:ae});if(!b.current)return;o(w.items),g(w.items.length<w.total);const S=me(n);S&&!w.items.find(M=>M.sessionId===S)&&f(null)}catch{}finally{m.current=!1,b.current&&p(!1)}}},[a,f]),C=i.useCallback(async()=>{if(!(m.current||!u)){m.current=!0,p(!0);try{const w=h.current+1,S=await a.listConversations({page:w,size:ae});if(!b.current)return;h.current=w,o(A=>{const v=new Set(A.map(N=>N.sessionId)),E=S.items.filter(N=>!v.has(N.sessionId));return[...A,...E]});const M=h.current*ae;g(M<S.total)}catch{}finally{m.current=!1,b.current&&p(!1)}}},[a,u]),D=i.useCallback(async w=>(f(w),await a.getMessages(w)),[a,f]),k=i.useCallback(async()=>{try{const w=await a.createSession(),S=new Date().toISOString();o(M=>[{sessionId:w,botId:0,title:"新对话",createTime:S,updateTime:S},...M]),f(w)}catch{f(null)}},[a,f]),j=i.useCallback(async w=>{o(S=>S.filter(M=>M.sessionId!==w)),l===w&&f(null);try{await a.deleteConversation(w)}catch{}},[a,l,f]),T=i.useCallback(async(w,S)=>{await a.renameConversation(w,S),o(M=>M.map(A=>A.sessionId===w?{...A,title:S}:A))},[a]),{enabled:I=!0}=t;return i.useEffect(()=>{I&&y()},[I,y]),{conversations:r,activeConversationId:l,loading:d,hasMore:u,loadConversations:y,loadMore:C,switchConversation:D,newConversation:k,deleteConversation:j,renameConversation:T,setActiveConversationId:f}}function Ne(t){return!t&&t!==0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function ze(t){return t==="pdf"?"PDF":t==="docx"?"DOC":t==="html"?"HTM":t.slice(0,3).toUpperCase()||"FILE"}function Se(t){if(!t)return[];const a=[];for(const s of t)s.type==="file"&&s.data&&a.push({id:s.data.id??"",type:s.data.fileType??s.data.type??"",filename:s.data.name??s.data.filename??"",url:s.data.url??"",mime:s.data.mime,size:s.data.size,summary:s.data.summary});return a}async function Q(t){try{const a=await fetch(t.url);if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.blob(),n=URL.createObjectURL(s),r=document.createElement("a");r.href=n,r.download=t.filename,document.body.appendChild(r),r.click(),r.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 Te=i.createContext(null);function X(){const t=i.useContext(Te);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}function re({sdk:t,hooks:a,children:s}){const[n,r]=i.useState(!1),[o,l]=i.useState(!1),[c,d]=i.useState(null),[p,u]=i.useState(!1),[g,b]=i.useState(!1);i.useEffect(()=>{t.getToken().then(()=>{u(!0)}).catch(()=>{u(!0)})},[t]);const h=Ce({sdk:t,onConversationChange:a==null?void 0:a.onConversationChange,enabled:p}),m=ke({sdk:t,sessionId:h.activeConversationId,onSessionCreated:v=>{h.setActiveConversationId(v)},onStreamStart:a==null?void 0:a.onStreamStart,onStreamEnd:v=>{var E;(E=a==null?void 0:a.onStreamEnd)==null||E.call(a,v),h.loadConversations()},onError:a==null?void 0:a.onError,onMessageSend:a==null?void 0:a.onMessageSend}),f=i.useCallback(async v=>{b(!0);try{const E=await h.switchConversation(v);m.setMessages(E)}finally{b(!1)}},[h,m]),y=i.useCallback(async()=>{m.setMessages([]),await h.newConversation()},[h,m]),C=i.useCallback(async v=>{h.activeConversationId===v&&m.setMessages([]),await h.deleteConversation(v)},[h,m]);i.useEffect(()=>{h.activeConversationId&&m.messages.length===0&&(b(!0),t.getMessages(h.activeConversationId).then(v=>{m.setMessages(v)}).catch(()=>{}).finally(()=>b(!1)))},[]);const D=i.useCallback(()=>{r(v=>!v)},[]),k=i.useCallback(v=>{r(v)},[]),j=i.useCallback(()=>{l(v=>!v),d(v=>null)},[]),T=i.useCallback(v=>{d(v),l(!0)},[]),I=i.useMemo(()=>{const v=new Set,E=[];for(const N of m.messages)for(const $ of N.parts)if($.type==="tool_result"&&$.artifacts)for(const x of Se($.artifacts)){const R=x.id||`${x.url}:${x.filename}`;v.has(R)||(v.add(R),E.push(x))}return E},[m.messages]),w=i.useCallback(async()=>{const v=h.activeConversationId;if(!v)return null;try{const E=await t.getMessages(v);m.setMessages(E);const N=E.findLast($=>$.role==="assistant");return(N==null?void 0:N.id)??null}catch{return null}},[t,h.activeConversationId,m]),S=i.useCallback((v,E,N)=>{if(/^\d+$/.test(v)){t.feedback(v,E,N).catch(()=>{});return}w().then($=>{$&&t.feedback($,E,N).catch(()=>{})})},[t,w]),M=i.useCallback(v=>{if(/^\d+$/.test(v)){t.cancelFeedback(v).catch(()=>{});return}w().then(E=>{E&&t.cancelFeedback(E).catch(()=>{})})},[t,w]),A=i.useMemo(()=>({sdk:t,status:m.status,error:m.error,messages:m.messages,conversations:h.conversations,activeConversationId:h.activeConversationId,isThreadListOpen:n,isArtifactDrawerOpen:o,allArtifacts:I,activePreviewArtifact:c,hasMore:h.hasMore,conversationsLoading:h.loading,messagesLoading:g,sendMessage:m.sendMessage,stop:m.stop,regenerate:m.regenerate,switchConversation:f,newConversation:y,deleteConversation:C,renameConversation:h.renameConversation,loadMoreConversations:h.loadMore,toggleThreadList:D,setThreadListOpen:k,toggleArtifactDrawer:j,openArtifactPreview:T,feedback:S,cancelFeedback:M,respondToInterrupt:m.respondToInterrupt}),[t,m.status,m.error,m.messages,m.sendMessage,m.stop,m.regenerate,m.respondToInterrupt,h.conversations,h.activeConversationId,h.renameConversation,h.hasMore,h.loadMore,h.loading,n,o,I,c,g,f,y,C,D,k,j,T,S,M]);return e.jsx(Te.Provider,{value:A,children:s})}const B="https://ehr-web.netease.com/ehr-web/erh-super-agent",O={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`},W={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 at({defaultWidth:t=W.DEFAULT_WIDTH,defaultHeight:a=W.DEFAULT_HEIGHT,sidebarWidth:s=0}={}){const[n,r]=i.useState(t),[o,l]=i.useState({x:0,y:0}),[c,d]=i.useState(!1),[p,u]=i.useState(!1),[g,b]=i.useState(null),[h,m]=i.useState(()=>typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),f=i.useRef(!1),y=i.useRef(0),C=i.useRef(n),D=i.useRef("right"),k=i.useRef(!1),j=i.useRef({x:0,y:0}),T=i.useRef({x:0,y:0}),I=i.useRef(!1),w=i.useRef(null);i.useEffect(()=>{const x=()=>m({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]),i.useEffect(()=>()=>{var x;(x=w.current)==null||x.call(w)},[]);const S=Math.floor(h.height*W.MAX_HEIGHT_RATIO),M=Math.min(g||a,S),A=n+s;i.useEffect(()=>{if(!c){const x=h.width-A-20,R=h.height-M-20;l(F=>F.x===x&&F.y===R?F:{x,y:R})}},[c,A,M,h]);const v=i.useCallback(x=>{if(p||x.target.closest("button, input, textarea"))return;k.current=!0,I.current=!1,j.current={x:x.clientX,y:x.clientY},T.current={...o};const R=z=>{if(!k.current)return;const P=z.clientX-j.current.x,_=z.clientY-j.current.y;(Math.abs(P)>3||Math.abs(_)>3)&&(I.current=!0),I.current&&(d(!0),l({x:Math.max(-200,Math.min(T.current.x+P,window.innerWidth-100)),y:Math.max(0,Math.min(T.current.y+_,window.innerHeight-48))}))},F=()=>{k.current=!1,H()},H=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",F),w.current=null};document.addEventListener("mousemove",R),document.addEventListener("mouseup",F),w.current=H},[p,o]),E=i.useCallback((x,R)=>{x.preventDefault(),x.stopPropagation(),f.current=!0,y.current=x.clientX,C.current=n,D.current=R;const F=P=>{if(!f.current)return;const _=P.clientX-y.current;let G=D.current==="right"?C.current+_:C.current-_;if(G>W.MAX_WIDTH){f.current=!1,u(!0),z();return}G=Math.max(W.MIN_WIDTH,G),r(G)},H=()=>{f.current=!1,z()},z=()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H),w.current=null};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H),w.current=z},[n]),N=i.useCallback(()=>{p&&r(t),u(x=>!x)},[p,t]),$=i.useCallback(()=>{u(!1),r(t),d(!1),b(null)},[t]);return{width:n,position:o,hasCustomPosition:c,isMaximized:p,lockedHeight:g,viewport:h,defaultHeight:a,totalWidth:A,windowHeight:M,startWindowDrag:v,startResize:E,toggleMaximize:N,setIsMaximized:u,setLockedHeight:b,setHasCustomPosition:d,reset:$}}function rt(t){const{enabled:a,contentSelector:s,defaultHeight:n,onHeightChange:r}=t,o=i.useRef(null);return i.useEffect(()=>{if(!a||!o.current)return;const c=o.current.querySelector(s);if(!c)return;const d=()=>{const g=o.current;if(!g)return;const b=g.querySelector(s);if(!b)return;const h=g.offsetHeight-b.clientHeight,m=b.scrollHeight+h,f=Math.floor(window.innerHeight*W.MAX_HEIGHT_RATIO),y=Math.max(n,Math.min(m,f));r(C=>C===y?C:y)};d();const p=new ResizeObserver(()=>d());Array.from(c.children).forEach(g=>p.observe(g));const u=new MutationObserver(()=>{Array.from(c.children).forEach(g=>p.observe(g)),d()});return u.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{p.disconnect(),u.disconnect()}},[a,s,n,r]),o}function Ee({isOpen:t,onClick:a,triggerLogo:s}){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:{right:W.TRIGGER_RIGHT,bottom:W.TRIGGER_BOTTOM,width:W.TRIGGER_SIZE,height:W.TRIGGER_SIZE},onClick:a,"aria-label":"打开 AI 助手",title:"AI 助手",children:e.jsx("img",{src:s||O.triggerLogo,alt:"AI 助手",className:"block h-14 w-14",draggable:!1})})}function V({tooltip:t,onClick:a,children:s}){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:s})}function Ie({onClose:t,onToggleThreadList:a,isMaximized:s=!1,onToggleMaximize:n,showHome:r=!1,onHome:o,showClose:l=!0,artifactCount:c=0,onToggleArtifactDrawer:d}){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:O.recently,alt:"",width:20,height:20})}),r&&o&&e.jsx(V,{tooltip:"回到首页",onClick:o,children:e.jsx("img",{src:O.home,alt:"",width:20,height:20})})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[c>0&&d&&e.jsx(V,{tooltip:"会话产物",onClick:d,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"})]}),c>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:c>99?"99+":c})]})}),n&&e.jsx(V,{tooltip:s?"小窗":"大窗",onClick:n,children:e.jsx("img",{src:s?O.spiltWindow:O.mergeWindow,alt:"",width:20,height:20})}),l&&e.jsx(V,{tooltip:"关闭",onClick:t,children:e.jsx("img",{src:O.close,alt:"",width:20,height:20})})]})]})}const K=t=>String(t).padStart(2,"0");function st(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 Me(t){const a=new Date,s=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),n=s-6*864e5,r=[],o=[],l=[];for(const d of t){const p=new Date(d.updateTime).getTime();p>=s?r.push(d):p>=n?o.push(d):l.push(d)}const c=[];return r.length&&c.push({label:"今天",items:r}),o.length&&c.push({label:"最近 7 天",items:o}),l.length&&c.push({label:"更早",items:l}),c}function se({width:t}){const{conversations:a,activeConversationId:s,switchConversation:n,newConversation:r,deleteConversation:o,renameConversation:l,hasMore:c,loadMoreConversations:d,conversationsLoading:p}=X(),[u,g]=i.useState(null),[b,h]=i.useState(""),[m,f]=i.useState(null),y=i.useRef(null),C=i.useCallback((T,I)=>{g(T),h(I??"")},[]),D=i.useCallback(T=>{b.trim()&&l(T,b.trim()),g(null)},[b,l]),k=i.useCallback(()=>{const T=y.current;!T||!c||T.scrollHeight-T.scrollTop-T.clientHeight<50&&d()},[c,d]),j=i.useMemo(()=>Me(a),[a]);return e.jsxs("div",{className:"relative z-[5] flex 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:O.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:y,className:"flex-1 overflow-y-auto",onScroll:k,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(T=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:T.label}),T.items.map(I=>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 ${I.sessionId===s?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{u!==I.sessionId&&n(I.sessionId)},onMouseEnter:w=>{if(u===I.sessionId)return;const S=w.currentTarget.getBoundingClientRect();f({text:I.title||"新会话",x:S.right+8,y:S.top+S.height/2})},onMouseLeave:()=>f(null),children:u===I.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:b,onChange:w=>h(w.target.value),onBlur:()=>D(I.sessionId),onKeyDown:w=>{w.key==="Enter"&&D(I.sessionId),w.key==="Escape"&&g(null)},onClick:w=>w.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:O.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:I.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(),C(I.sessionId,I.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(I.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"})})})]})]})},I.sessionId))]},T.label)),p&&a.length>0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:c?"加载更多...":"加载中..."}),!p&&c&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),m&&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:m.x,top:m.y,transform:"translateY(-50%)"},children:m.text})]})}function Ae(t){const a=i.useRef(null),s=i.useRef(!1),n=i.useRef(0),r=i.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&&(s.current=!0),u&&(s.current=!1),n.current=c},[]);i.useEffect(()=>{const l=a.current;if(l)return l.addEventListener("scroll",r,{passive:!0}),()=>l.removeEventListener("scroll",r)},[r]),i.useEffect(()=>{if(s.current)return;const l=a.current;l&&requestAnimationFrame(()=>{l.scrollTop=l.scrollHeight})},t);const o=i.useCallback(()=>{s.current=!1;const l=a.current;l&&(l.scrollTop=l.scrollHeight)},[]);return{containerRef:a,scrollToBottom:o}}function Y(t){return t.value++}function q(t,a){const s=[],n=[],r=()=>{n.length>0&&(s.push(n.join("")),n.length=0)};let o=0;for(;o<t.length;){const l=t[o];if(l==="`"){const c=t.indexOf("`",o+1);if(c!==-1){r(),s.push(e.jsx("code",{className:"sa-inline-code",children:t.slice(o+1,c)},Y(a))),o=c+1;continue}}else if(l==="*"&&t[o+1]==="*"){const c=t.indexOf("**",o+2);if(c!==-1){r(),s.push(e.jsx("strong",{children:q(t.slice(o+2,c),a)},Y(a))),o=c+2;continue}}else if(l==="*"){const c=t.indexOf("*",o+1);if(c!==-1){r(),s.push(e.jsx("em",{children:q(t.slice(o+1,c),a)},Y(a))),o=c+1;continue}}else if(l==="["){const c=t.indexOf("]",o+1);if(c!==-1&&t[c+1]==="("){const d=t.indexOf(")",c+2);if(d!==-1){const p=t.slice(o+1,c),u=t.slice(c+2,d);r(),s.push(e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:q(p,a)},Y(a))),o=d+1;continue}}}n.push(l),o++}return r(),s}function nt(t,a){const s=[],n=t.split(`
|
|
2
|
+
`);let r=0;const o=d=>d.trim()==="",l=d=>/^#{1,6}\s+\S/.test(d.trim()),c=d=>/^(?:[-*+]|\d+[.)])\s+\S/.test(d.trim());for(;r<n.length;){const d=n[r],p=d.trim();if(o(d)){r++;continue}if(l(d)){const g=p.match(/^(#{1,6})\s+(.*)$/);if(g){const h=`h${Math.min(g[1].length,6)}`;s.push(i.createElement(h,{key:Y(a)},q(g[2],a)))}r++;continue}if(c(d)){const g=/^\d+[.)]/.test(p),b=[];for(;r<n.length&&c(n[r]);){const h=n[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);h&&b.push(e.jsx("li",{children:q(h[1],a)},Y(a))),r++}s.push(g?e.jsx("ol",{className:"sa-list",children:b},Y(a)):e.jsx("ul",{className:"sa-list",children:b},Y(a)));continue}const u=[];for(;r<n.length&&!o(n[r])&&!l(n[r])&&!c(n[r]);)u.push(n[r]),r++;s.push(e.jsx("p",{className:"sa-text-paragraph",children:q(u.join(" "),a)},Y(a)))}return s}function it(t){const a={value:0},s=[],n=t.split("```");for(let r=0;r<n.length;r++)if(r%2===0)s.push(...nt(n[r],a));else if(n[r].trim()!==""){let o=n[r].replace(/^\r?\n/,"");o=o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/,""),o=o.replace(/\r?\n$/,""),s.push(e.jsx("pre",{className:"sa-code-block",children:e.jsx("code",{children:o})},Y(a)))}return s}function Re({content:t}){return e.jsx("div",{className:"sa-text-part",children:it(t)})}const ot="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let we=!1;function De(t=ot){if(we||typeof document>"u")return;we=!0;const a=t.split("?")[0].split("/").pop();if(a&&document.querySelector(`script[src*="${a}"]`))return;const s=document.createElement("script");s.src=t,document.head.appendChild(s)}De();function L({name:t,size:a=16,color:s="currentColor",className:n,style:r}){return e.jsx("svg",{className:n,style:{width:a,height:a,fill:s,verticalAlign:"middle",...r},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${t}`})})}function $e({content:t}){const[a,s]=i.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>s(!a),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(L,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${a?"expanded":""}`,children:e.jsx(L,{name:"chevron-right",size:12})})]}),a&&e.jsx("div",{className:"sa-thinking-content",children:t})]})}function Le({toolName:t,toolCallId:a,args:s}){const[n,r]=i.useState(!1),[o,l]=i.useState(!1);let c=s;try{c=JSON.stringify(JSON.parse(s),null,2)}catch{}const d=i.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:()=>r(!n),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(L,{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(L,{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(L,{name:o?"circle-check":"copy",size:14})," ",o?"已复制":"复制"]})})]})]})}function be({text:t}){const[a,s]=i.useState(!1),n=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)}).catch(()=>{})};return e.jsxs("button",{className:"sa-action-btn",onClick:n,title:"复制",children:[e.jsx(L,{name:a?"circle-check":"copy",size:14})," ",a?"已复制":"复制"]})}function lt({html:t}){const[a,s]=i.useState(null);return i.useEffect(()=>{let n=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(r=>{n||s(r.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 Fe({toolName:t,content:a,artifacts:s,renderMode:n,html:r,artifactPreview:o}){const{openArtifactPreview:l}=X(),c=Se(s);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(L,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:t||"工具返回"})]}),n==="html"&&r?e.jsxs(e.Fragment,{children:[e.jsx(lt,{html:r}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(be,{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(be,{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:o?()=>l(d):void 0,onKeyDown:o?u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l(d))}:void 0,tabIndex:o?0:void 0,role:o?"button":void 0,"aria-label":o?`预览 ${d.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:ze(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:Ne(d.size)})]}),o&&e.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${d.filename}`,onClick:u=>{u.stopPropagation(),Q(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 _e({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(L,{name:"triangle-alert",size:14})}),e.jsx("span",{children:t||"发生错误"})]}),a&&e.jsx("button",{className:"sa-error-retry",onClick:a,children:"重试"})]})}function ct({interrupt:t,onRespond:a,disabled:s,answeredAction:n}){var c,d;const r=t.options,o=(typeof(r==null?void 0:r[0])=="string"?r[0]:(c=r==null?void 0:r[0])==null?void 0:c.label)||"确认",l=(typeof(r==null?void 0:r[1])=="string"?r[1]:(d=r==null?void 0:r[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(L,{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:s,onClick:()=>a({action:"confirm"}),children:[e.jsx(L,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${n==="cancel"?"sa-interrupt-btn-answered":""}`,disabled:s,onClick:()=>a({action:"cancel"}),children:[e.jsx(L,{name:"x",size:14})," ",l]})]}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function dt({interrupt:t,onRespond:a,disabled:s,answeredAction:n}){var p,u,g,b;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)||"批准",l=(typeof(r==null?void 0:r[1])=="string"?r[1]:(u=r==null?void 0:r[1])==null?void 0:u.label)||"拒绝",c=(typeof(r==null?void 0:r[2])=="string"?r[2]:(g=r==null?void 0:r[2])==null?void 0:g.label)||"跳过",d=((b=t.metadata)==null?void 0:b.showSkip)!==!1;return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(L,{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:s,onClick:()=>a({action:"approve"}),children:[e.jsx(L,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-danger ${n==="reject"?"sa-interrupt-btn-answered":""}`,disabled:s,onClick:()=>a({action:"reject"}),children:[e.jsx(L,{name:"x",size:14})," ",l]}),d&&e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${n==="skip"?"sa-interrupt-btn-answered":""}`,disabled:s,onClick:()=>a({action:"skip"}),children:[e.jsx(L,{name:"chevron-right",size:14})," ",c]})]}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function pt(t){return typeof t=="string"?{value:t,label:t}:t}function ut({interrupt:t,onRespond:a,disabled:s,initialValue:n}){const r=(t.options??[]).map(pt);return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(L,{name:"list",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(o=>{const l=n===o.value;return e.jsxs("button",{className:`sa-interrupt-option ${o.danger?"sa-interrupt-option-danger":""} ${l?"sa-interrupt-option-selected":""}`,disabled:s,onClick:()=>a({action:"select",value:o.value}),children:[e.jsx(L,{name:l?"circle-check":"circle",size:14}),o.icon&&e.jsx(L,{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)})}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function gt(t){return typeof t=="string"?{value:t,label:t}:t}function ft({interrupt:t,onRespond:a,disabled:s,initialValue:n}){const r=(t.options??[]).map(gt),[o,l]=i.useState(()=>new Set(Array.isArray(n)?n:[])),c=d=>{s||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(L,{name:"list-checks",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(d=>e.jsxs("button",{className:`sa-interrupt-option ${o.has(d.value)?"sa-interrupt-option-selected":""}`,disabled:s,onClick:()=>c(d.value),children:[e.jsx(L,{name:o.has(d.value)?"square-check":"square",size:14}),e.jsx("span",{children:d.label})]},d.value))}),!s&&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(L,{name:"check",size:14})," 确认 (",o.size,")"]})}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function xt({interrupt:t,onRespond:a,disabled:s,initialValue:n}){const[r,o]=i.useState(n??""),l=t.inputType??"text",c=l==="textarea",d=()=>{s||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(L,{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:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,rows:3,disabled:s}):e.jsx("input",{className:"sa-interrupt-input",type:l,value:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,onKeyDown:p=>p.key==="Enter"&&d(),disabled:s})}),!s&&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:d,children:[e.jsx(L,{name:"check",size:14})," 提交"]})}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function ht({interrupt:t,onRespond:a,disabled:s,initialValue:n}){const r=t.fields??[],[o,l]=i.useState(()=>{const u={};for(const g of r)u[g.name]=(n==null?void 0:n[g.name])??g.defaultValue??"";return u}),c=(u,g)=>{s||l(b=>({...b,[u]:g}))},d=!s&&r.every(u=>!u.required||o[u.name]),p=()=>{d&&a({action:"submit",value:o})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(L,{name:"file-text",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-form",children:r.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:"*"})]}),mt(u,o[u.name],g=>c(u.name,g),s)]},u.name))}),!s&&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(L,{name:"check",size:14})," 提交"]}),e.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>a({action:"cancel"}),children:"取消"})]}),s&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function ve(t){return typeof t=="string"?{value:t,label:t}:t}function mt(t,a,s,n){switch(t.type){case"textarea":return e.jsx("textarea",{className:"sa-interrupt-textarea",value:a,onChange:r=>s(r.target.value),placeholder:t.placeholder,rows:3,disabled:n});case"select":{const r=(t.options??[]).map(ve);return e.jsxs("select",{className:"sa-interrupt-select",value:a,onChange:o=>s(o.target.value),disabled:n,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(ve),o=Array.isArray(a)?a:[],l=c=>{n||s(o.includes(c)?o.filter(d=>d!==c):[...o,c])};return e.jsx("div",{className:"sa-interrupt-options",children:r.map(c=>e.jsx("button",{type:"button",className:`sa-interrupt-option ${o.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:r=>s(r.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:r=>s(r.target.value),placeholder:t.placeholder,disabled:n})}}function He({interrupt:t,resolved:a,response:s,onRespond:n}){const r=a,o=s==null?void 0:s.value;switch(t.interruptType){case"confirm":return e.jsx(ct,{interrupt:t,onRespond:n,disabled:r,answeredAction:s==null?void 0:s.action});case"approve":return e.jsx(dt,{interrupt:t,onRespond:n,disabled:r,answeredAction:s==null?void 0:s.action});case"select":return e.jsx(ut,{interrupt:t,onRespond:n,disabled:r,initialValue:o});case"multiSelect":return e.jsx(ft,{interrupt:t,onRespond:n,disabled:r,initialValue:o});case"input":return e.jsx(xt,{interrupt:t,onRespond:n,disabled:r,initialValue:o});case"form":return e.jsx(ht,{interrupt:t,onRespond:n,disabled:r,initialValue:o});default:return e.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",t.interruptType]})}}const wt=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function Pe({message:t,onCopy:a,onRegenerate:s,onFeedback:n}){const{status:r,cancelFeedback:o}=X(),[l,c]=i.useState(null),[d,p]=i.useState(!1),[u,g]=i.useState(!1),b=i.useRef(null),h=i.useCallback(()=>{a(),p(!0),setTimeout(()=>p(!1),2e3)},[a]),m=i.useCallback(()=>{l==="like"?(c(null),o(t.id)):(c("like"),g(!1),n==null||n(t.id,"like"))},[l,t.id,n,o]),f=i.useCallback(()=>{l==="dislike"?(c(null),g(!1),o(t.id)):g(!0)},[l,t.id,o]),y=i.useCallback((D,k)=>{c("dislike"),g(!1),n==null||n(t.id,"dislike",{reason:D,remark:(k==null?void 0:k.trim())||void 0})},[t.id,n]),C=i.useCallback(()=>{g(!1)},[]);return i.useEffect(()=>{if(!u)return;const D=j=>{b.current&&!b.current.contains(j.target)&&g(!1)},k=j=>{j.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",k)}},[u]),r!=="ready"&&r!=="error"?null:e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:h,title:"复制",children:[e.jsx(L,{name:d?"circle-check":"copy",size:14})," ",d?"已复制":"复制"]}),s&&e.jsxs("button",{className:"sa-action-btn",onClick:s,title:"重新生成",children:[e.jsx(L,{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:m,title:"有用","aria-label":"点赞",children:e.jsx(L,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${l==="dislike"?"sa-action-btn-active":""}`,onClick:f,title:"无用","aria-label":"踩","aria-expanded":u,"aria-haspopup":"dialog",children:e.jsx(L,{name:"thumbs-down",size:14})})]}),u&&e.jsx("div",{ref:b,children:e.jsx(bt,{onSubmit:y,onCancel:C})})]})}function bt({onSubmit:t,onCancel:a}){const[s,n]=i.useState(void 0),[r,o]=i.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:wt.map(l=>e.jsx("button",{className:`sa-dislike-reason-btn ${s===l.value?"active":""}`,onClick:()=>n(s===l.value?void 0:l.value),children:l.label},l.value))}),e.jsx("textarea",{className:"sa-dislike-remark",placeholder:"补充描述(选填,≤500 字)",maxLength:500,value:r,onChange:l=>o(l.target.value),rows:2}),e.jsxs("div",{className:"sa-dislike-actions",children:[e.jsx("button",{className:"sa-dislike-submit",onClick:()=>t(s,r||void 0),children:"提交"}),e.jsx("button",{className:"sa-dislike-cancel",onClick:a,children:"取消"})]})]})}const vt=/^(https?:\/\/|data:|blob:|\/\/|\/|\.\/|\.\.\/)/;function ye({src:t,alt:a}){return t?vt.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 Be({message:t,isStreaming:a,isLast:s,slots:n,avatar:r,artifactPreview:o,showTimestamp:l}){const{regenerate:c,feedback:d,respondToInterrupt:p}=X(),u=i.useCallback(()=>{var T;const j=t.parts.filter(I=>I.type==="text").map(I=>I.content).join(`
|
|
3
|
+
`);(T=navigator.clipboard)==null||T.writeText(j).catch(()=>{})},[t]),g=t.role==="user",b=n.Message;if(b)return e.jsx(b,{message:t,isStreaming:a,isLast:s,avatar:r,slots:n,onCopy:u,onRegenerate:c,onFeedback:d,showTimestamp:l});const h=n.TextPart??Re,m=n.ThinkingPart??$e,f=n.ToolCallPart??Le,y=n.ToolResultPart??Fe,C=n.ErrorPart??_e,D=n.ActionBar??Pe,k=!g&&t.parts.some(j=>j.type==="text"&&j.content);return e.jsxs("div",{className:`sa-message ${g?"sa-message-user":"sa-message-assistant"}`,children:[!g&&e.jsx(ye,{src:(r==null?void 0:r.assistant)||(a&&s?O.assistantAvatarGenerating:O.assistantAvatar),alt:"AI"}),e.jsxs("div",{className:"sa-message-content",children:[l&&e.jsx("span",{className:`sa-message-time ${g?"sa-message-time-right":""}`,children:st(t.timestamp)}),e.jsxs("div",{className:"sa-message-body",children:[t.parts.map((j,T)=>{switch(j.type){case"text":return e.jsx(h,{content:j.content},T);case"thinking":return e.jsx(m,{content:j.content},T);case"tool_call":return e.jsx(f,{toolName:j.toolName,toolCallId:j.toolCallId,args:j.args},T);case"tool_result":return e.jsx(y,{toolName:j.toolName,toolCallId:j.toolCallId,content:j.content,artifacts:j.artifacts,renderMode:j.renderMode,html:j.html,artifactPreview:o},T);case"error":return e.jsx(C,{content:j.content,onRetry:c},T);case"interrupt":return e.jsx(He,{interrupt:j.interrupt,resolved:j.resolved??!1,response:j.response,onRespond:I=>p(j.interrupt.interruptId,I)},T);default:return null}}),a&&s&&!g&&!k&&e.jsx("span",{className:"sa-thinking-indicator",children:"思考中…"}),!g&&!a&&k&&e.jsx(D,{message:t,onCopy:u,onRegenerate:s?c:void 0,onFeedback:d})]})]}),g&&(r==null?void 0:r.user)&&e.jsx(ye,{src:r.user,alt:"用户"})]})}function Oe({message:t,suggestedPrompts:a,onPromptClick:s,capabilities:n,quickLinks:r,logo:o}){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||O.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||"你好!有什么可以帮你的?"})]}),n&&n.length>0&&e.jsx("div",{className:"flex flex-col items-start gap-4 opacity-0 animate-sa-home-fade-in",style:{animationDelay:"150ms"},children:n.map(l=>e.jsxs("div",{className:"inline-flex w-full max-w-full min-w-0 items-center gap-[7px]",children:[l.icon&&e.jsx("img",{src:l.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:l.label}),l.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:l.desc})]})]},l.label))}),a&&a.length>0&&e.jsx("div",{className:"flex flex-col items-start gap-3",children:a.map((l,c)=>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+c*130}ms`},onClick:()=>s(l),children:[e.jsx("span",{className:"sa-chip-text overflow-hidden text-ellipsis whitespace-nowrap",children:l}),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"})})]},`${l}-${c}`))}),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(l=>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.onClick?l.onClick():l.prompt&&s(l.prompt)},children:[l.icon&&e.jsx("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center opacity-70",children:e.jsx("img",{src:l.icon,alt:"",width:18,height:18,draggable:!1})}),e.jsx("span",{className:"text-[14px] leading-none text-[#333] transition-colors hover:text-[#1881F0]",children:l.label})]},l.label))})]})]})}function ne({slots:t,welcomeMessage:a,suggestedPrompts:s,avatar:n,artifactPreview:r,capabilities:o,quickLinks:l,logo:c,showTimestamp:d}){const{messages:p,status:u,sendMessage:g}=X(),{containerRef:b}=Ae([p]),h=u==="streaming",m=t.WelcomeScreen??Oe;return p.length===0?e.jsx("div",{className:"sa-thread",ref:b,children:e.jsx(m,{message:a,suggestedPrompts:s,onPromptClick:g,capabilities:o,quickLinks:l,logo:c})}):e.jsx("div",{className:"sa-thread",ref:b,children:p.map((f,y)=>e.jsx(Be,{message:f,isStreaming:h,isLast:y===p.length-1,slots:t,avatar:n,artifactPreview:r,showTimestamp:d},f.id))})}function yt({items:t,activeIndex:a,onSelect:s}){const n=i.useRef(null);return i.useEffect(()=>{var o;const r=(o=n.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:n,children:t.map((r,o)=>e.jsxs("div",{className:`sa-slash-menu-item${o===a?" sa-slash-menu-item--active":""}`,onMouseDown:l=>{l.preventDefault(),s(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 kt({sdk:t,input:a,onSelect:s}){const[n,r]=i.useState([]),[o,l]=i.useState(!1),[c,d]=i.useState(0),p=i.useRef(!1);i.useEffect(()=>{p.current||(p.current=!0,t.listSkills().then(r).catch(()=>r([])))},[t]);const u=/^\/\S*$/.test(a);i.useEffect(()=>{l(u)},[u]),i.useEffect(()=>{u&&d(0)},[a,u]);const g=a.startsWith("/")?a.slice(1).toLowerCase():"",b=i.useMemo(()=>n.filter(k=>!g||k.code.toLowerCase().includes(g)||k.name.toLowerCase().includes(g)||k.displayName&&k.displayName.toLowerCase().includes(g)),[n,g]),h=i.useRef(o),m=i.useRef(b),f=i.useRef(c),y=i.useRef(s);h.current=o,m.current=b,f.current=c,y.current=s;const C=i.useCallback(k=>{if(!h.current||m.current.length===0)return!1;switch(k.key){case"ArrowDown":return k.preventDefault(),d(j=>(j+1)%m.current.length),!0;case"ArrowUp":return k.preventDefault(),d(j=>(j-1+m.current.length)%m.current.length),!0;case"Enter":case"Tab":return k.preventDefault(),y.current(m.current[f.current]),l(!1),!0;case"Escape":return k.preventDefault(),l(!1),!0;default:return!1}},[]),D=i.useCallback(()=>l(!1),[]);return{isOpen:o,items:b,activeIndex:c,handleKeyDown:C,close:D}}function ie(){const{status:t,sendMessage:a,stop:s,sdk:n}=X(),[r,o]=i.useState(""),l=i.useRef(null),c=t==="streaming"||t==="submitted",d=!!r.trim()||c,p=i.useCallback(f=>{o(`/${f.name} `),setTimeout(()=>{const y=l.current;y&&(y.focus(),y.selectionStart=y.selectionEnd=y.value.length)},0)},[]),u=kt({sdk:n,input:r,onSelect:p}),g=i.useCallback(()=>{const f=r.trim();!f||c||(a(f),o(""),l.current&&(l.current.style.height="auto"))},[r,c,a]),b=i.useCallback(f=>{u.handleKeyDown(f)||f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),g())},[g,u.handleKeyDown]),h=i.useCallback(f=>{o(f.target.value);const y=f.target;y.style.height="auto",y.style.height=Math.min(y.scrollHeight,90)+"px"},[]),m=i.useCallback(()=>{var f;c||(f=l.current)==null||f.focus()},[c]);return e.jsxs("div",{className:"relative z-[2] shrink-0 px-[15px] pb-2.5",children:[u.isOpen&&e.jsx(yt,{items:u.items,activeIndex:u.activeIndex,onSelect:p}),e.jsxs("form",{className:`sa-input-form flex min-h-[70px] cursor-text items-start gap-2 rounded-[5px] p-2 ${d?"sa-input-form-active":""}`,onClick:m,onSubmit:f=>{f.preventDefault(),g()},children:[e.jsx("textarea",{ref:l,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:h,onKeyDown:b,placeholder:"请输入你想要了解的关键词",rows:1,disabled:c}),c?e.jsx("button",{type:"button",className:"sa-send-btn sa-send-btn-active","aria-label":"停止生成",title:"停止生成",onClick:s,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:O.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 jt({artifact:t}){const[a,s]=i.useState(null),[n,r]=i.useState(!0),[o,l]=i.useState(null);return i.useEffect(()=>{let c=!1;r(!0),l(null),s(null);async function d(){try{if(t.type==="pdf"){c||r(!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(),g=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(s(g.sanitize(u,{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 u=await p.arrayBuffer(),b=await(await Promise.resolve().then(()=>require("./mammoth.browser-DiAPPO3x.cjs")).then(m=>m.mammoth_browser)).convertToHtml({arrayBuffer:u}),h=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;c||(s(h.sanitize(b.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),r(!1));return}c||(r(!1),l(`不支持预览「${t.type}」类型`))}catch(p){c||(r(!1),l(p instanceof Error?p.message:"加载失败"))}}return d(),()=>{c=!0}},[t]),n?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 Q(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 We({artifacts:t,initialArtifact:a,onClose:s}){const[n,r]=i.useState(a?{mode:"preview",artifact:a}:{mode:"list"}),[o,l]=i.useState(!1),c=i.useRef(null),[d,p]=i.useState(340),u=i.useRef(null);i.useEffect(()=>{a&&(c.current&&(clearTimeout(c.current),c.current=null,l(!1)),r({mode:"preview",artifact:a}))},[a]);const g=i.useCallback(()=>{l(!0),c.current=setTimeout(()=>{c.current=null,s()},240)},[s]);i.useEffect(()=>()=>{var f;c.current&&clearTimeout(c.current),(f=u.current)==null||f.call(u)},[]);const b=i.useCallback(f=>{r({mode:"preview",artifact:f})},[]),h=i.useCallback(()=>{r({mode:"list"})},[]);i.useEffect(()=>{const f=y=>{y.key==="Escape"&&g()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[g]);const m=i.useCallback(f=>{f.preventDefault();const y=f.clientX,C=d,D=j=>{const T=y-j.clientX;p(Math.max(240,Math.min(window.innerWidth*.7,C+T)))},k=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",k),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",D),document.addEventListener("mouseup",k),u.current=k},[d]);return e.jsxs("div",{className:`sa-artifact-drawer ${o?"sa-drawer-closing":""}`,style:{width:d},children:[e.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:m}),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:h,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 Q(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:g,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((f,y)=>e.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>b(f),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),b(f))},tabIndex:0,role:"button","aria-label":`预览 ${f.filename}`,children:[e.jsx("div",{className:"sa-drawer-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:ze(f.type)})}),e.jsxs("div",{className:"sa-drawer-file-info",children:[e.jsx("span",{className:"sa-drawer-file-name",children:f.filename}),e.jsx("span",{className:"sa-drawer-file-size",children:Ne(f.size)})]}),e.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${f.filename}`,onClick:C=>{C.stopPropagation(),Q(f)},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"})})})]},f.id||`artifact-${y}`))}):e.jsx("div",{className:"sa-drawer-view-enter",children:e.jsx(jt,{artifact:n.artifact})})})]})}function Ct({isOpen:t,onClose:a,title:s,slots:n,welcomeMessage:r,suggestedPrompts:o,avatar:l,artifactPreview:c,capabilities:d,quickLinks:p,logo:u,defaultWidth:g,defaultHeight:b,showTimestamp:h}){const{status:m,sendMessage:f,stop:y,toggleThreadList:C,setThreadListOpen:D,isThreadListOpen:k,toggleArtifactDrawer:j,isArtifactDrawerOpen:T,allArtifacts:I,activePreviewArtifact:w,messages:S,messagesLoading:M,conversations:A,activeConversationId:v,switchConversation:E,newConversation:N,deleteConversation:$,renameConversation:x,hasMore:R,loadMoreConversations:F}=X(),{width:H,position:z,hasCustomPosition:P,isMaximized:_,totalWidth:G,windowHeight:oe,startWindowDrag:Ve,startResize:le,toggleMaximize:Ke,reset:ce,setLockedHeight:ee}=at({defaultWidth:g??W.DEFAULT_WIDTH,defaultHeight:b??W.DEFAULT_HEIGHT,sidebarWidth:k?200:0}),de=i.useRef(null),pe=i.useRef(null),te=!M&&S.length===0,Z=!M&&S.length>0;i.useEffect(()=>{t||ce()},[t,ce]),i.useEffect(()=>{D(_?de.current??!0:pe.current??!1)},[_,D]),i.useEffect(()=>{Z||ee(null)},[Z,ee]);const Ze=rt({enabled:t&&Z&&!_,contentSelector:".sa-panel-content",defaultHeight:b??W.DEFAULT_HEIGHT,onHeightChange:ee});if(!t)return null;const ue=n.Header,ge=n.Composer,J=n.ThreadList,Je=()=>{const U=!k;C(),_?de.current=U:pe.current=U},Qe=P?{width:`${G}px`,height:`${oe}px`,left:`${z.x}px`,top:`${z.y}px`}:{width:`${G}px`,height:`${oe}px`,right:"20px",bottom:"20px"},fe={title:s,onClose:a,onToggleThreadList:Je,isMaximized:_,onToggleMaximize:Ke,showHome:Z,onHome:N,artifactCount:c?I.length:0,onToggleArtifactDrawer:c?j:void 0},xe={conversations:A,activeSessionId:v,onSwitch:E,onNew:N,onDelete:$,onRename:x,hasMore:R,onLoadMore:F},he=e.jsxs("div",{className:`relative flex min-w-0 flex-col bg-white ${_?"flex-1":"h-full shrink-0"}`,style:_?void 0:{width:`${H}px`},children:[te&&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 ${te||_?"":"bg-white"} ${_?"cursor-default":"cursor-grab active:cursor-grabbing"}`,onMouseDown:_?void 0:Ve,children:ue?e.jsx(ue,{...fe}):e.jsx(Ie,{...fe})}),e.jsxs("div",{className:`sa-panel-content relative z-[2] ${te?"sa-home-view":""} ${_?"mx-auto w-full max-w-[800px]":""}`,children:[M?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):e.jsx(ne,{slots:n,welcomeMessage:r,suggestedPrompts:o,avatar:l,artifactPreview:c,capabilities:d,quickLinks:p,logo:u,showTimestamp:h}),c&&T&&e.jsx(We,{artifacts:I,initialArtifact:w,onClose:j})]}),e.jsx("div",{className:`shrink-0 ${_?"mx-auto w-full max-w-[800px]":""}`,children:ge?e.jsx(ge,{status:m,onSend:f,onStop:y}):e.jsx(ie,{})})]});return _?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 rounded-t-2xl bg-[#F5F5F5] shadow-[0_-12px_48px_rgba(0,0,0,0.25)]",children:[k&&(J?e.jsx(J,{...xe}):e.jsx(se,{width:220})),he]})}):e.jsxs("div",{ref:Ze,className:"fixed z-[var(--sa-z-index,9999)] flex animate-sa-window-in flex-row overflow-hidden rounded-xl border border-[#DADADA] bg-white shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:Qe,children:[e.jsx("div",{className:"sa-resize-handle absolute bottom-0 left-[-3px] top-0 z-10 w-[6px] cursor-col-resize",onMouseDown:U=>le(U,"left")}),e.jsx("div",{className:"sa-resize-handle absolute bottom-0 right-[-3px] top-0 z-10 w-[6px] cursor-col-resize",onMouseDown:U=>le(U,"right")}),k&&(J?e.jsx(J,{...xe}):e.jsx(se,{width:200})),he]})}const Nt=()=>{};function zt({conversations:t,activeSessionId:a,onSwitch:s,onNew:n,onDelete:r,onRename:o,isCollapsed:l,onToggleCollapse:c,hasMore:d,onLoadMore:p,conversationsLoading:u}){const[g,b]=i.useState(null),[h,m]=i.useState(null),[f,y]=i.useState(""),[C,D]=i.useState(null),k=i.useRef(null);i.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const j=i.useCallback((A,v)=>{v.stopPropagation(),g===A?(r(A),b(null)):(b(A),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>b(null),3e3))},[g,r]),T=i.useCallback((A,v,E)=>{E.stopPropagation(),m(A),y(v??"")},[]),I=i.useCallback(A=>{f.trim()&&o(A,f.trim()),m(null)},[f,o]),w=i.useRef(null),S=i.useCallback(()=>{const A=w.current;!A||!d||!p||A.scrollHeight-A.scrollTop-A.clientHeight<50&&p()},[d,p]),M=i.useMemo(()=>Me(t),[t]);return l?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:c,children:e.jsx(L,{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:()=>{n(),c()},children:e.jsx("img",{src:O.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:n,children:[e.jsx("img",{src:O.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:c,children:e.jsx(L,{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:S,children:[u&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!u&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),M.map(A=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:A.label}),A.items.map(v=>{const E=v.sessionId===a,N=g===v.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 ${E?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{h!==v.sessionId&&s(v.sessionId)},onMouseEnter:$=>{if(h===v.sessionId)return;const x=$.currentTarget.getBoundingClientRect();D({text:v.title||"新会话",x:x.right+8,y:x.top+x.height/2})},onMouseLeave:()=>D(null),children:h===v.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:f,onChange:$=>y($.target.value),onBlur:()=>I(v.sessionId),onKeyDown:$=>{$.key==="Enter"&&I(v.sessionId),$.key==="Escape"&&m(null)},onClick:$=>$.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:O.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:v.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:$=>T(v.sessionId,v.title,$),title:"重命名",children:e.jsx(L,{name:"pen",size:12})}),e.jsx("button",{type:"button",className:`flex h-5 w-5 items-center justify-center rounded ${N?"bg-[#fee2e2] text-[#ef4444]":"text-[#999] hover:bg-white/70 hover:text-[#ef4444]"}`,onClick:$=>j(v.sessionId,$),title:N?"确认删除":"删除",children:e.jsx(L,{name:N?"x":"trash2",size:12})})]})]})},v.sessionId)})]},A.label)),d&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),C&&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:C.x,top:C.y,transform:"translateY(-50%)"},children:C.text})]})}function Ye({title:t,slots:a,welcomeMessage:s,suggestedPrompts:n,capabilities:r,quickLinks:o,logo:l,sidebarDefaultOpen:c=!0,onClose:d,avatar:p,artifactPreview:u,showTimestamp:g}){const{status:b,sendMessage:h,stop:m,conversations:f,activeConversationId:y,switchConversation:C,newConversation:D,deleteConversation:k,renameConversation:j,toggleArtifactDrawer:T,isArtifactDrawerOpen:I,allArtifacts:w,activePreviewArtifact:S,hasMore:M,loadMoreConversations:A,conversationsLoading:v,messagesLoading:E}=X(),[N,$]=i.useState(c),x=i.useCallback(()=>$(z=>!z),[]),R=a.ThreadList,F=a.Composer,H=a.Header;return e.jsxs("div",{className:"sa-fullpage",children:[R?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${N?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(R,{conversations:f,activeSessionId:y,onSwitch:C,onNew:D,onDelete:k,onRename:j,hasMore:M,onLoadMore:A})}):e.jsx(zt,{conversations:f,activeSessionId:y,onSwitch:C,onNew:D,onDelete:k,onRename:j,isCollapsed:!N,onToggleCollapse:x,hasMore:M,onLoadMore:A,conversationsLoading:v}),e.jsxs("div",{className:"sa-fp-main",children:[H?e.jsx(H,{title:t,onClose:d??Nt,onToggleThreadList:x,artifactCount:u?w.length:0,onToggleArtifactDrawer:u?T:void 0}):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:u&&w.length>0&&e.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:T,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.jsxs("div",{className:"sa-fp-content-row",children:[E?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):e.jsx(ne,{slots:a,welcomeMessage:s,suggestedPrompts:n,capabilities:r,quickLinks:o,logo:l,avatar:p,artifactPreview:u,showTimestamp:g}),u&&I&&e.jsx(We,{artifacts:w,initialArtifact:S,onClose:T})]}),F?e.jsx(F,{status:b,onSend:h,onStop:m}):e.jsx(ie,{})]})]})}function Ge(t){const{sdk:a,mode:s="floating",slots:n={},hooks:r={},welcomeMessage:o,suggestedPrompts:l,title:c="AI Assistant",initialOpen:d=!1,onOpenChange:p,sidebarDefaultOpen:u,avatar:g,artifactPreview:b,capabilities:h,quickLinks:m,logo:f,triggerLogo:y,theme:C,showTimestamp:D}=t,[k,j]=i.useState(d);i.useEffect(()=>{j(d)},[d]);const T=i.useCallback(()=>{var M,A;const S=!k;j(S),p==null||p(S),S?(M=r.onOpen)==null||M.call(r):(A=r.onClose)==null||A.call(r)},[k,r,p]),I=i.useCallback(()=>{var S;j(!1),p==null||p(!1),(S=r.onClose)==null||S.call(r)},[r,p]),w=n.Trigger??Ee;return s==="fullpage"?k?e.jsx(re,{sdk:a,hooks:r,children:e.jsx(Ye,{title:c,slots:n,welcomeMessage:o,suggestedPrompts:l,capabilities:h,quickLinks:m,logo:f,sidebarDefaultOpen:u,onClose:I,avatar:g,artifactPreview:b,showTimestamp:D})}):null:e.jsxs(re,{sdk:a,hooks:r,children:[e.jsx(w,{isOpen:k,onClick:T,triggerLogo:y}),e.jsx(Ct,{isOpen:k,onClose:I,title:c,slots:n,welcomeMessage:o,suggestedPrompts:l,avatar:g,artifactPreview:b,capabilities:h,quickLinks:m,logo:f,defaultWidth:C==null?void 0:C.panelWidth,defaultHeight:C==null?void 0:C.panelHeight,showTimestamp:D})]})}const Xe=`
|
|
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);
|
|
@@ -30,135 +30,7 @@
|
|
|
30
30
|
font-family: inherit;
|
|
31
31
|
}
|
|
32
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%;
|
|
43
|
-
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
|
-
}
|
|
143
|
-
|
|
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;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.sa-header-btn:hover {
|
|
160
|
-
background: rgba(255, 255, 255, 0.18);
|
|
161
|
-
}
|
|
33
|
+
/* ── Trigger / Panel / Header(浮窗框架已改用 Tailwind 实现,见 tailwind.css) ── */
|
|
162
34
|
|
|
163
35
|
/* ── Thread / messages ───────────────────────────────────── */
|
|
164
36
|
|
|
@@ -166,7 +38,7 @@
|
|
|
166
38
|
flex: 1;
|
|
167
39
|
display: flex;
|
|
168
40
|
flex-direction: column;
|
|
169
|
-
gap:
|
|
41
|
+
gap: 16px;
|
|
170
42
|
overflow-y: auto;
|
|
171
43
|
padding: 16px;
|
|
172
44
|
background: var(--sa-surface);
|
|
@@ -186,6 +58,9 @@
|
|
|
186
58
|
background: rgba(0, 0, 0, 0.24);
|
|
187
59
|
}
|
|
188
60
|
|
|
61
|
+
/* ── Message:浮窗默认 hr-for-help 风格(AI 头像独占一行);
|
|
62
|
+
fullpage 模式在 .sa-fp-content-row 下恢复原横排布局,互不影响 ── */
|
|
63
|
+
|
|
189
64
|
.sa-message {
|
|
190
65
|
display: flex;
|
|
191
66
|
align-items: flex-start;
|
|
@@ -197,6 +72,13 @@
|
|
|
197
72
|
justify-content: flex-end;
|
|
198
73
|
}
|
|
199
74
|
|
|
75
|
+
/* AI 消息:列布局,头像独占一行(仅浮窗,对齐 hr-for-help msgAi) */
|
|
76
|
+
.sa-message-assistant {
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
align-items: flex-start;
|
|
79
|
+
gap: 6px;
|
|
80
|
+
}
|
|
81
|
+
|
|
200
82
|
.sa-message-content {
|
|
201
83
|
max-width: 78%;
|
|
202
84
|
display: flex;
|
|
@@ -204,33 +86,42 @@
|
|
|
204
86
|
gap: 4px;
|
|
205
87
|
}
|
|
206
88
|
|
|
89
|
+
.sa-message-user .sa-message-content {
|
|
90
|
+
max-width: 90%;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sa-message-assistant .sa-message-content {
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
width: 100%;
|
|
97
|
+
}
|
|
98
|
+
|
|
207
99
|
.sa-message-body {
|
|
208
100
|
display: flex;
|
|
209
101
|
flex-direction: column;
|
|
210
102
|
gap: 4px;
|
|
211
103
|
}
|
|
212
104
|
|
|
105
|
+
/* 浮窗气泡:用户浅蓝、AI 白底描边(对齐 hr-for-help) */
|
|
213
106
|
.sa-message-user .sa-message-body {
|
|
214
|
-
padding:
|
|
215
|
-
border-radius:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
color: #ffffff;
|
|
107
|
+
padding: 8px 12px;
|
|
108
|
+
border-radius: 8px 8px 0 8px;
|
|
109
|
+
background: #E8F1FE;
|
|
110
|
+
color: #333333;
|
|
219
111
|
font-size: 14px;
|
|
220
|
-
line-height: 1.
|
|
112
|
+
line-height: 1.6;
|
|
221
113
|
word-break: break-word;
|
|
222
114
|
}
|
|
223
115
|
|
|
224
116
|
.sa-message-assistant .sa-message-body {
|
|
225
|
-
padding: 10px
|
|
226
|
-
border-radius:
|
|
227
|
-
border-bottom-left-radius: 4px;
|
|
117
|
+
padding: 10px 12px;
|
|
118
|
+
border-radius: 8px;
|
|
228
119
|
background: #ffffff;
|
|
120
|
+
border: 1px solid #E0E0E0;
|
|
229
121
|
color: var(--sa-text);
|
|
230
122
|
font-size: 14px;
|
|
231
|
-
line-height: 1.
|
|
123
|
+
line-height: 1.5;
|
|
232
124
|
word-break: break-word;
|
|
233
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
234
125
|
}
|
|
235
126
|
|
|
236
127
|
.sa-message-time {
|
|
@@ -243,26 +134,72 @@
|
|
|
243
134
|
text-align: right;
|
|
244
135
|
}
|
|
245
136
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
137
|
+
/* 消息头像:裸展示,无背景色(对齐 hr-for-help msgAvatar) */
|
|
138
|
+
.sa-msg-avatar {
|
|
139
|
+
width: 24px;
|
|
140
|
+
height: 24px;
|
|
250
141
|
border-radius: 50%;
|
|
251
|
-
|
|
142
|
+
object-fit: cover;
|
|
143
|
+
flex-shrink: 0;
|
|
144
|
+
display: block;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.sa-msg-avatar-text {
|
|
148
|
+
display: inline-flex;
|
|
252
149
|
align-items: center;
|
|
253
150
|
justify-content: center;
|
|
254
|
-
|
|
255
|
-
font-
|
|
256
|
-
font-weight: 600;
|
|
257
|
-
overflow: hidden;
|
|
151
|
+
font-size: 18px;
|
|
152
|
+
font-weight: 400;
|
|
258
153
|
}
|
|
259
154
|
|
|
260
|
-
|
|
261
|
-
|
|
155
|
+
/* ── fullpage 覆盖:恢复横排头像 + 经典气泡(不受浮窗 hr-for-help 改版影响) ── */
|
|
156
|
+
|
|
157
|
+
.sa-fp-content-row .sa-message-assistant {
|
|
158
|
+
flex-direction: row;
|
|
159
|
+
gap: 10px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.sa-fp-content-row .sa-message-assistant .sa-message-content {
|
|
163
|
+
max-width: 88%;
|
|
164
|
+
width: auto;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.sa-fp-content-row .sa-message-user .sa-message-content {
|
|
168
|
+
max-width: 78%;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// .sa-fp-content-row .sa-message-user .sa-message-body {
|
|
172
|
+
// padding: 10px 14px;
|
|
173
|
+
// border-radius: 16px;
|
|
174
|
+
// border-bottom-right-radius: 4px;
|
|
175
|
+
// background: var(--sa-primary);
|
|
176
|
+
// color: #ffffff;
|
|
177
|
+
// font-size: 14px;
|
|
178
|
+
// line-height: 1.55;
|
|
179
|
+
// word-break: break-word;
|
|
180
|
+
// }
|
|
181
|
+
|
|
182
|
+
.sa-fp-content-row .sa-message-assistant .sa-message-body {
|
|
183
|
+
padding: 10px 14px;
|
|
184
|
+
border-radius: 16px;
|
|
185
|
+
background: #ffffff;
|
|
186
|
+
color: var(--sa-text);
|
|
187
|
+
font-size: 14px;
|
|
188
|
+
line-height: 1.55;
|
|
189
|
+
word-break: break-word;
|
|
190
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
262
191
|
}
|
|
263
192
|
|
|
264
|
-
.sa-
|
|
265
|
-
|
|
193
|
+
.sa-fp-content-row .sa-msg-avatar {
|
|
194
|
+
width: 24px;
|
|
195
|
+
height: 24px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.sa-fp-content-row .sa-msg-avatar-text {
|
|
199
|
+
background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
|
|
200
|
+
color: #ffffff;
|
|
201
|
+
font-size: 12px;
|
|
202
|
+
font-weight: 600;
|
|
266
203
|
}
|
|
267
204
|
|
|
268
205
|
/* ── Text part (markdown) ────────────────────────────────── */
|
|
@@ -488,14 +425,24 @@
|
|
|
488
425
|
}
|
|
489
426
|
|
|
490
427
|
.sa-tool-result-content {
|
|
491
|
-
max-height:
|
|
492
|
-
overflow
|
|
428
|
+
max-height: 256px;
|
|
429
|
+
overflow: auto;
|
|
430
|
+
margin: 8px 0 0;
|
|
493
431
|
padding: 10px 12px;
|
|
494
432
|
color: #4b5563;
|
|
495
433
|
font-size: 13px;
|
|
496
434
|
line-height: 1.55;
|
|
497
435
|
white-space: pre-wrap;
|
|
498
436
|
word-break: break-word;
|
|
437
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
438
|
+
background: #f9fafb;
|
|
439
|
+
border-radius: 8px;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.sa-tool-result-actions {
|
|
443
|
+
display: flex;
|
|
444
|
+
gap: 8px;
|
|
445
|
+
margin: 4px 0;
|
|
499
446
|
}
|
|
500
447
|
|
|
501
448
|
/* ── Error part ──────────────────────────────────────────── */
|
|
@@ -628,84 +575,7 @@
|
|
|
628
575
|
}
|
|
629
576
|
.sa-dislike-cancel:hover { background: var(--sa-surface); }
|
|
630
577
|
|
|
631
|
-
/* ── Composer
|
|
632
|
-
|
|
633
|
-
.sa-composer {
|
|
634
|
-
position: relative;
|
|
635
|
-
display: flex;
|
|
636
|
-
align-items: flex-end;
|
|
637
|
-
gap: 10px;
|
|
638
|
-
padding: 12px 14px;
|
|
639
|
-
border-top: 1px solid var(--sa-border);
|
|
640
|
-
background: var(--sa-bg);
|
|
641
|
-
flex-shrink: 0;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
.sa-composer-input {
|
|
645
|
-
flex: 1;
|
|
646
|
-
min-height: 38px;
|
|
647
|
-
max-height: 120px;
|
|
648
|
-
padding: 9px 14px;
|
|
649
|
-
border: 1px solid var(--sa-border);
|
|
650
|
-
border-radius: 19px;
|
|
651
|
-
background: var(--sa-surface);
|
|
652
|
-
color: var(--sa-text);
|
|
653
|
-
font-family: var(--sa-font);
|
|
654
|
-
font-size: 14px;
|
|
655
|
-
line-height: 1.5;
|
|
656
|
-
resize: none;
|
|
657
|
-
outline: none;
|
|
658
|
-
transition: border-color 0.2s ease, background 0.2s ease;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
.sa-composer-input::placeholder {
|
|
662
|
-
color: #9ca3af;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
.sa-composer-input:focus {
|
|
666
|
-
border-color: var(--sa-primary);
|
|
667
|
-
background: #ffffff;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
.sa-composer-send,
|
|
671
|
-
.sa-composer-stop {
|
|
672
|
-
width: 38px;
|
|
673
|
-
height: 38px;
|
|
674
|
-
flex-shrink: 0;
|
|
675
|
-
border: none;
|
|
676
|
-
border-radius: 50%;
|
|
677
|
-
cursor: pointer;
|
|
678
|
-
display: flex;
|
|
679
|
-
align-items: center;
|
|
680
|
-
justify-content: center;
|
|
681
|
-
color: #ffffff;
|
|
682
|
-
font-size: 16px;
|
|
683
|
-
transition: transform 0.15s ease, background 0.2s ease;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
.sa-composer-send {
|
|
687
|
-
background: var(--sa-primary);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
.sa-composer-send:hover {
|
|
691
|
-
background: var(--sa-primary-dark);
|
|
692
|
-
transform: scale(1.05);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
.sa-composer-send:disabled {
|
|
696
|
-
opacity: 0.5;
|
|
697
|
-
cursor: not-allowed;
|
|
698
|
-
transform: none;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
.sa-composer-stop {
|
|
702
|
-
background: #ef4444;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
.sa-composer-stop:hover {
|
|
706
|
-
background: #dc2626;
|
|
707
|
-
transform: scale(1.05);
|
|
708
|
-
}
|
|
578
|
+
/* ── Composer(输入区改用 Tailwind 实现,见 tailwind.css 的 .sa-input-form/.sa-send-btn) ── */
|
|
709
579
|
|
|
710
580
|
/* ── Slash Menu ─────────────────────────────────────────── */
|
|
711
581
|
|
|
@@ -763,232 +633,39 @@
|
|
|
763
633
|
min-width: 0;
|
|
764
634
|
}
|
|
765
635
|
|
|
766
|
-
/* ── Thread list
|
|
636
|
+
/* ── Thread list(内嵌侧边栏改用 Tailwind 实现,见 FullpageLayout.tsx / ThreadList.tsx) ── */
|
|
767
637
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
inset: 0;
|
|
771
|
-
background: rgba(0,0,0,0.3);
|
|
772
|
-
z-index: 19;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
.sa-thread-list {
|
|
776
|
-
position: absolute;
|
|
777
|
-
top: 0;
|
|
778
|
-
left: 0;
|
|
779
|
-
bottom: 0;
|
|
780
|
-
width: 100%;
|
|
781
|
-
display: flex;
|
|
782
|
-
flex-direction: column;
|
|
783
|
-
background: #ffffff;
|
|
784
|
-
z-index: 20;
|
|
785
|
-
box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
|
|
786
|
-
animation: sa-slide-in-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
.sa-thread-list-header {
|
|
790
|
-
display: flex;
|
|
791
|
-
align-items: center;
|
|
792
|
-
justify-content: space-between;
|
|
793
|
-
padding: 20px 20px 16px;
|
|
794
|
-
flex-shrink: 0;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
.sa-thread-list-title {
|
|
798
|
-
font-size: 17px;
|
|
799
|
-
font-weight: 700;
|
|
800
|
-
color: #18181b;
|
|
801
|
-
letter-spacing: -0.2px;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
.sa-thread-list-new {
|
|
805
|
-
display: flex;
|
|
806
|
-
align-items: center;
|
|
807
|
-
gap: 6px;
|
|
808
|
-
padding: 8px 16px;
|
|
809
|
-
border: none;
|
|
810
|
-
border-radius: 20px;
|
|
811
|
-
background: #f4f4f5;
|
|
812
|
-
color: #3f3f46;
|
|
813
|
-
font-size: 13px;
|
|
814
|
-
font-weight: 500;
|
|
815
|
-
cursor: pointer;
|
|
816
|
-
transition: background 0.15s;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
.sa-thread-list-new:hover {
|
|
820
|
-
background: #e4e4e7;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
.sa-thread-list-items {
|
|
638
|
+
/* 消息区加载态 */
|
|
639
|
+
.sa-messages-loading {
|
|
824
640
|
flex: 1;
|
|
825
|
-
overflow-y: auto;
|
|
826
|
-
padding: 0 12px 12px;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
.sa-thread-list-empty {
|
|
830
|
-
padding: 48px 16px;
|
|
831
|
-
text-align: center;
|
|
832
|
-
color: var(--sa-text-muted);
|
|
833
|
-
font-size: 14px;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
.sa-thread-list-loading {
|
|
837
|
-
padding: 12px 16px;
|
|
838
|
-
text-align: center;
|
|
839
|
-
color: #9ca3af;
|
|
840
|
-
font-size: 13px;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
.sa-thread-group-label {
|
|
844
|
-
padding: 16px 8px 6px;
|
|
845
|
-
font-size: 12px;
|
|
846
|
-
font-weight: 500;
|
|
847
|
-
color: #a1a1aa;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
.sa-thread-item {
|
|
851
641
|
display: flex;
|
|
852
642
|
align-items: center;
|
|
853
|
-
justify-content:
|
|
643
|
+
justify-content: center;
|
|
854
644
|
gap: 8px;
|
|
855
|
-
|
|
856
|
-
margin: 2px 0;
|
|
857
|
-
border-radius: 8px;
|
|
858
|
-
color: #374151;
|
|
645
|
+
color: #9ca3af;
|
|
859
646
|
font-size: 14px;
|
|
860
|
-
cursor: pointer;
|
|
861
|
-
transition: background 0.15s ease;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
.sa-thread-item:hover {
|
|
865
|
-
background: #f9fafb;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
.sa-thread-item.active {
|
|
869
|
-
background: var(--sa-primary-light);
|
|
870
|
-
color: var(--sa-primary-dark);
|
|
871
|
-
font-weight: 500;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
.sa-thread-item-info {
|
|
875
|
-
flex: 1;
|
|
876
|
-
overflow: hidden;
|
|
877
|
-
display: flex;
|
|
878
|
-
flex-direction: column;
|
|
879
|
-
gap: 2px;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
.sa-thread-item-title {
|
|
883
|
-
overflow: hidden;
|
|
884
|
-
white-space: nowrap;
|
|
885
|
-
text-overflow: ellipsis;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
.sa-thread-item-time {
|
|
889
|
-
font-size: 11px;
|
|
890
|
-
color: var(--sa-text-light);
|
|
891
|
-
white-space: nowrap;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
.sa-thread-item-edit {
|
|
895
|
-
width: 100%;
|
|
896
|
-
padding: 4px 8px;
|
|
897
|
-
border: 1px solid var(--sa-primary);
|
|
898
|
-
border-radius: 6px;
|
|
899
|
-
font-size: 13px;
|
|
900
|
-
outline: none;
|
|
901
|
-
background: var(--sa-bg);
|
|
902
|
-
color: var(--sa-text);
|
|
903
647
|
}
|
|
904
648
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
649
|
+
.sa-loading-spinner {
|
|
650
|
+
width: 16px;
|
|
651
|
+
height: 16px;
|
|
652
|
+
border: 2px solid var(--sa-border, #e5e7eb);
|
|
653
|
+
border-top-color: var(--sa-primary, #6366f1);
|
|
654
|
+
border-radius: 50%;
|
|
655
|
+
animation: sa-spin 0.8s linear infinite;
|
|
909
656
|
flex-shrink: 0;
|
|
910
|
-
visibility: hidden;
|
|
911
657
|
}
|
|
912
658
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
.sa-thread-item-action-btn {
|
|
918
|
-
border: none;
|
|
919
|
-
background: transparent;
|
|
920
|
-
color: var(--sa-text-muted);
|
|
921
|
-
cursor: pointer;
|
|
922
|
-
padding: 2px;
|
|
923
|
-
border-radius: 4px;
|
|
924
|
-
display: inline-flex;
|
|
925
|
-
align-items: center;
|
|
926
|
-
transition: color 0.15s ease, background 0.15s ease;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
.sa-thread-item-action-btn:hover {
|
|
930
|
-
color: var(--sa-primary);
|
|
931
|
-
background: rgba(99,102,241,0.08);
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
/* ── Welcome ─────────────────────────────────────────────── */
|
|
935
|
-
|
|
936
|
-
.sa-welcome {
|
|
937
|
-
flex: 1;
|
|
938
|
-
display: flex;
|
|
939
|
-
flex-direction: column;
|
|
940
|
-
align-items: center;
|
|
941
|
-
justify-content: center;
|
|
942
|
-
padding: 24px;
|
|
943
|
-
text-align: center;
|
|
659
|
+
@keyframes sa-spin {
|
|
660
|
+
to { transform: rotate(360deg); }
|
|
944
661
|
}
|
|
945
662
|
|
|
946
|
-
.
|
|
947
|
-
font-size: 40px;
|
|
948
|
-
margin-bottom: 12px;
|
|
949
|
-
}
|
|
663
|
+
/* ── Welcome(首页改用 Tailwind 实现,见 tailwind.css) ── */
|
|
950
664
|
|
|
951
|
-
.sa-
|
|
952
|
-
|
|
665
|
+
.sa-thinking-indicator {
|
|
666
|
+
color: #9ca3af;
|
|
953
667
|
font-size: 14px;
|
|
954
|
-
|
|
955
|
-
line-height: 1.6;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
.sa-welcome-prompts {
|
|
959
|
-
display: flex;
|
|
960
|
-
flex-direction: column;
|
|
961
|
-
gap: 8px;
|
|
962
|
-
width: 100%;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
.sa-welcome-prompt {
|
|
966
|
-
padding: 10px 16px;
|
|
967
|
-
border: 1px solid var(--sa-border);
|
|
968
|
-
border-radius: 999px;
|
|
969
|
-
background: #ffffff;
|
|
970
|
-
color: #374151;
|
|
971
|
-
font-size: 13px;
|
|
972
|
-
cursor: pointer;
|
|
973
|
-
transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
.sa-welcome-prompt:hover {
|
|
977
|
-
border-color: var(--sa-primary);
|
|
978
|
-
background: var(--sa-primary-light);
|
|
979
|
-
color: var(--sa-primary-dark);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
/* ── Streaming cursor ────────────────────────────────────── */
|
|
983
|
-
|
|
984
|
-
.sa-streaming-cursor {
|
|
985
|
-
display: inline-block;
|
|
986
|
-
width: 2px;
|
|
987
|
-
height: 1em;
|
|
988
|
-
margin-left: 2px;
|
|
989
|
-
background: var(--sa-primary);
|
|
990
|
-
vertical-align: text-bottom;
|
|
991
|
-
animation: sa-blink 1s steps(2, start) infinite;
|
|
668
|
+
animation: sa-blink 1.2s ease-in-out infinite;
|
|
992
669
|
}
|
|
993
670
|
|
|
994
671
|
/* ── Interrupt cards ──────────────────────────────────────── */
|
|
@@ -1205,17 +882,6 @@
|
|
|
1205
882
|
|
|
1206
883
|
/* ── Animations ──────────────────────────────────────────── */
|
|
1207
884
|
|
|
1208
|
-
@keyframes sa-slide-up {
|
|
1209
|
-
from {
|
|
1210
|
-
opacity: 0;
|
|
1211
|
-
transform: translateY(16px) scale(0.98);
|
|
1212
|
-
}
|
|
1213
|
-
to {
|
|
1214
|
-
opacity: 1;
|
|
1215
|
-
transform: translateY(0) scale(1);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
885
|
@keyframes sa-blink {
|
|
1220
886
|
0%,
|
|
1221
887
|
100% {
|
|
@@ -1226,17 +892,6 @@
|
|
|
1226
892
|
}
|
|
1227
893
|
}
|
|
1228
894
|
|
|
1229
|
-
@keyframes sa-slide-in-left {
|
|
1230
|
-
from {
|
|
1231
|
-
opacity: 0;
|
|
1232
|
-
transform: translateX(-100%);
|
|
1233
|
-
}
|
|
1234
|
-
to {
|
|
1235
|
-
opacity: 1;
|
|
1236
|
-
transform: translateX(0);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
895
|
/* ── Fullpage Layout (DeepSeek-style) ────────────────────────── */
|
|
1241
896
|
|
|
1242
897
|
.sa-fullpage {
|
|
@@ -1247,208 +902,21 @@
|
|
|
1247
902
|
background: var(--sa-bg, #ffffff);
|
|
1248
903
|
}
|
|
1249
904
|
|
|
1250
|
-
/* Sidebar */
|
|
1251
|
-
.sa-fp-sidebar {
|
|
1252
|
-
width: 260px;
|
|
1253
|
-
display: flex;
|
|
1254
|
-
flex-direction: column;
|
|
1255
|
-
background: var(--sa-surface, #ffffff);
|
|
1256
|
-
flex-shrink: 0;
|
|
1257
|
-
transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
|
|
1258
|
-
overflow: hidden;
|
|
1259
|
-
border-right: 1px solid #e8e8ea;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
.sa-fp-sidebar-collapsed {
|
|
1263
|
-
width: 52px;
|
|
1264
|
-
align-items: center;
|
|
1265
|
-
padding-top: 12px;
|
|
1266
|
-
gap: 4px;
|
|
1267
|
-
border-right: 1px solid #e8e8ea;
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
.sa-fp-sidebar-header {
|
|
1271
|
-
display: flex;
|
|
1272
|
-
align-items: center;
|
|
1273
|
-
gap: 8px;
|
|
1274
|
-
padding: 12px 12px 8px;
|
|
1275
|
-
flex-shrink: 0;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
.sa-fp-sidebar-toggle {
|
|
1279
|
-
width: 32px;
|
|
1280
|
-
height: 32px;
|
|
1281
|
-
border: none;
|
|
1282
|
-
border-radius: 8px;
|
|
1283
|
-
background: transparent;
|
|
1284
|
-
color: #71717a;
|
|
1285
|
-
cursor: pointer;
|
|
1286
|
-
display: flex;
|
|
1287
|
-
align-items: center;
|
|
1288
|
-
justify-content: center;
|
|
1289
|
-
transition: background 0.12s, color 0.12s;
|
|
1290
|
-
flex-shrink: 0;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
.sa-fp-sidebar-toggle:hover {
|
|
1294
|
-
background: #e4e4e7;
|
|
1295
|
-
color: #18181b;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
.sa-fp-sidebar-new {
|
|
1299
|
-
flex: 1;
|
|
1300
|
-
padding: 7px 12px;
|
|
1301
|
-
border: 1px solid #d4d4d8;
|
|
1302
|
-
border-radius: 8px;
|
|
1303
|
-
background: #fff;
|
|
1304
|
-
color: #3f3f46;
|
|
1305
|
-
font-size: 13px;
|
|
1306
|
-
font-weight: 500;
|
|
1307
|
-
cursor: pointer;
|
|
1308
|
-
display: flex;
|
|
1309
|
-
align-items: center;
|
|
1310
|
-
gap: 6px;
|
|
1311
|
-
transition: border-color 0.12s, box-shadow 0.12s;
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
.sa-fp-sidebar-new:hover {
|
|
1315
|
-
border-color: #a1a1aa;
|
|
1316
|
-
box-shadow: 0 1px 3px rgba(0,0,0,0.06);
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
.sa-fp-sidebar-new span {
|
|
1320
|
-
font-size: 13px;
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
.sa-fp-sidebar-list {
|
|
1324
|
-
flex: 1;
|
|
1325
|
-
overflow-y: auto;
|
|
1326
|
-
padding: 4px 8px 12px;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
.sa-fp-sidebar-list::-webkit-scrollbar {
|
|
1330
|
-
width: 4px;
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
.sa-fp-sidebar-list::-webkit-scrollbar-thumb {
|
|
1334
|
-
background: rgba(0,0,0,0.08);
|
|
1335
|
-
border-radius: 2px;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
.sa-fp-sidebar-list::-webkit-scrollbar-thumb:hover {
|
|
1339
|
-
background: rgba(0,0,0,0.15);
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
.sa-fp-sidebar-group {
|
|
1343
|
-
padding: 12px 8px 4px;
|
|
1344
|
-
font-size: 11px;
|
|
1345
|
-
font-weight: 500;
|
|
1346
|
-
color: #a1a1aa;
|
|
1347
|
-
letter-spacing: 0.3px;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
.sa-fp-sidebar-item {
|
|
1351
|
-
display: flex;
|
|
1352
|
-
align-items: center;
|
|
1353
|
-
gap: 8px;
|
|
1354
|
-
padding: 8px 10px;
|
|
1355
|
-
margin: 1px 0;
|
|
1356
|
-
border-radius: 8px;
|
|
1357
|
-
cursor: pointer;
|
|
1358
|
-
color: #3f3f46;
|
|
1359
|
-
font-size: 13px;
|
|
1360
|
-
line-height: 1.4;
|
|
1361
|
-
transition: background 0.1s;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
.sa-fp-sidebar-item:hover {
|
|
1365
|
-
background: #e8e8ea;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
.sa-fp-sidebar-item.active {
|
|
1369
|
-
background: #e4e4e7;
|
|
1370
|
-
color: #18181b;
|
|
1371
|
-
font-weight: 500;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
.sa-fp-sidebar-item-title {
|
|
1375
|
-
flex: 1;
|
|
1376
|
-
overflow: hidden;
|
|
1377
|
-
white-space: nowrap;
|
|
1378
|
-
text-overflow: ellipsis;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
.sa-fp-sidebar-item-edit {
|
|
1382
|
-
flex: 1;
|
|
1383
|
-
min-width: 0;
|
|
1384
|
-
padding: 2px 6px;
|
|
1385
|
-
border: 1px solid var(--sa-primary, #6366f1);
|
|
1386
|
-
border-radius: 4px;
|
|
1387
|
-
font-size: 13px;
|
|
1388
|
-
color: #27272a;
|
|
1389
|
-
background: #fff;
|
|
1390
|
-
outline: none;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
.sa-fp-sidebar-item-actions {
|
|
1394
|
-
display: flex;
|
|
1395
|
-
gap: 2px;
|
|
1396
|
-
flex-shrink: 0;
|
|
1397
|
-
visibility: hidden;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
.sa-fp-sidebar-item-actions.visible {
|
|
1401
|
-
visibility: visible;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
.sa-fp-sidebar-item-action {
|
|
1405
|
-
width: 24px;
|
|
1406
|
-
height: 24px;
|
|
1407
|
-
border: none;
|
|
1408
|
-
border-radius: 6px;
|
|
1409
|
-
background: transparent;
|
|
1410
|
-
color: #a1a1aa;
|
|
1411
|
-
cursor: pointer;
|
|
1412
|
-
display: flex;
|
|
1413
|
-
align-items: center;
|
|
1414
|
-
justify-content: center;
|
|
1415
|
-
flex-shrink: 0;
|
|
1416
|
-
transition: color 0.1s, background 0.1s;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
.sa-fp-sidebar-item-action:hover {
|
|
1420
|
-
color: #71717a;
|
|
1421
|
-
background: rgba(0,0,0,0.05);
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
.sa-fp-sidebar-item-action.danger {
|
|
1425
|
-
color: #ef4444;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
.sa-fp-sidebar-item-action.danger:hover {
|
|
1429
|
-
color: #dc2626;
|
|
1430
|
-
background: rgba(239,68,68,0.08);
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
.sa-fp-sidebar-empty {
|
|
1434
|
-
padding: 32px 12px;
|
|
1435
|
-
text-align: center;
|
|
1436
|
-
color: #a1a1aa;
|
|
1437
|
-
font-size: 13px;
|
|
1438
|
-
}
|
|
905
|
+
/* Sidebar(fullpage 默认侧边栏改用 Tailwind 实现,对齐浮窗历史对话样式,见 FullpageLayout.tsx) */
|
|
1439
906
|
|
|
1440
|
-
/* Sidebar wrapper (for custom ThreadList slot) */
|
|
907
|
+
/* Sidebar wrapper (for custom ThreadList slot):宽度与默认侧边栏 220px 对齐 */
|
|
1441
908
|
.sa-fp-sidebar-wrapper {
|
|
1442
|
-
width:
|
|
909
|
+
width: 220px;
|
|
1443
910
|
flex-shrink: 0;
|
|
1444
911
|
overflow: hidden;
|
|
1445
|
-
border-right: 1px solid #
|
|
1446
|
-
background: #
|
|
912
|
+
border-right: 1px solid #ECECEC;
|
|
913
|
+
background: #FAFAFA;
|
|
1447
914
|
transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
|
|
1448
915
|
}
|
|
1449
916
|
|
|
1450
917
|
.sa-fp-sidebar-wrapper-collapsed {
|
|
1451
918
|
width: 0;
|
|
919
|
+
border-right: none;
|
|
1452
920
|
}
|
|
1453
921
|
|
|
1454
922
|
/* Main area */
|
|
@@ -1560,8 +1028,9 @@
|
|
|
1560
1028
|
.sa-artifact-file-download:active { transform: scale(0.9); }
|
|
1561
1029
|
|
|
1562
1030
|
/* ── Inline HTML rendering (render_mode=html) ── */
|
|
1563
|
-
|
|
1564
|
-
.sa-tool-result-html-
|
|
1031
|
+
/* HTML 工具结果:外层滚动容器 + 内层内容层(与 Playground 一致,无 iframe) */
|
|
1032
|
+
.sa-tool-result-html-scroll { margin-top: 8px; max-height: 60vh; overflow: auto; border: 1px solid var(--sa-border); border-radius: 8px; }
|
|
1033
|
+
.sa-tool-result-html { padding: 12px; background: #fff; min-width: 100%; width: max-content; }
|
|
1565
1034
|
|
|
1566
1035
|
/* ── Header artifact button ── */
|
|
1567
1036
|
.sa-header-btn-artifact {
|
|
@@ -1690,4 +1159,5 @@
|
|
|
1690
1159
|
from { opacity: 0; transform: translateX(12px); }
|
|
1691
1160
|
to { opacity: 1; transform: translateX(0); }
|
|
1692
1161
|
}
|
|
1693
|
-
`,Ne={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:380,panelHeight:520,zIndex:9999};function Ge(a,s){const r=parseInt(a.slice(1,3),16),n=parseInt(a.slice(3,5),16),t=parseInt(a.slice(5,7),16),i=1-s;return`#${Math.round(r*i).toString(16).padStart(2,"0")}${Math.round(n*i).toString(16).padStart(2,"0")}${Math.round(t*i).toString(16).padStart(2,"0")}`}function Je(a,s){const r=parseInt(a.slice(1,3),16),n=parseInt(a.slice(3,5),16),t=parseInt(a.slice(5,7),16);return`#${Math.round(r+(255-r)*s).toString(16).padStart(2,"0")}${Math.round(n+(255-n)*s).toString(16).padStart(2,"0")}${Math.round(t+(255-t)*s).toString(16).padStart(2,"0")}`}function ze(a){const s={...Ne,...a},r=s.primaryColor,n=s.backgroundColor;return[`--sa-primary: ${r}`,`--sa-bg: ${n}`,`--sa-font: ${s.fontFamily}`,`--sa-radius: ${s.borderRadius}px`,`--sa-panel-width: ${s.panelWidth}px`,`--sa-panel-height: ${s.panelHeight}px`,`--sa-z-index: ${s.zIndex}`,`--sa-primary-dark: ${Ge(r,.15)}`,`--sa-primary-light: ${Je(r,.9)}`,`--sa-surface: ${n}`,"--sa-border: #e5e7eb","--sa-hover: #f4f4f5","--sa-text: #374151","--sa-text-muted: #9ca3af","--sa-text-light: #6b7280"].join("; ")}function Ze(a,s){const r=typeof a=="string"?document.querySelector(a):a;if(!r)throw new Error(`Target element not found: ${a}`);const n=document.createElement("div");n.setAttribute("data-super-agent-widget","");const t=ze(s.theme??{});if(n.setAttribute("style",`${t}; height: 100%;`),r.appendChild(n),!document.getElementById("sa-widget-styles")){const d=document.createElement("style");d.id="sa-widget-styles",d.textContent=Ce,document.head.appendChild(d)}let i=Se.createRoot(n),l=!1;const c=d=>{i&&i.render(o.createElement(je,{...s,initialOpen:d??l,onOpenChange:u=>{l=u}}))};return c(!1),{open(){l=!0,c(!0)},close(){l=!1,c(!1)},destroy(){i&&(i.unmount(),i=null),n.remove()}}}exports.ActionBar=be;exports.ChatProvider=V;exports.ChatWidget=je;exports.Composer=G;exports.ErrorPart=he;exports.FullpageLayout=ke;exports.Header=le;exports.Icon=C;exports.InterruptCard=ge;exports.Message=ve;exports.TextPart=ue;exports.ThinkingPart=fe;exports.Thread=X;exports.ThreadList=de;exports.ToolCallPart=xe;exports.ToolResultPart=me;exports.Trigger=oe;exports.WelcomeScreen=we;exports.defaultTheme=Ne;exports.ensureIconFont=ie;exports.mount=Ze;exports.themeToCSSVars=ze;exports.useAutoScroll=pe;exports.useChat=ee;exports.useChatContext=_;exports.useConversations=ae;exports.widgetStyles=Ce;
|
|
1162
|
+
`,St='[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] .-right-2{right:-.5rem}[data-super-agent-widget] .-top-1\\.5{top:-.375rem}[data-super-agent-widget] .bottom-0{bottom:0}[data-super-agent-widget] .left-\\[-3px\\]{left:-3px}[data-super-agent-widget] .right-\\[-3px\\]{right:-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-14{height:3.5rem}[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-14{width:3.5rem}[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] .rounded-xl{border-radius:.75rem}[data-super-agent-widget] .rounded-t-2xl{border-top-left-radius:1rem;border-top-right-radius:1rem}[data-super-agent-widget] .border{border-width:1px}[data-super-agent-widget] .border-r{border-right-width:1px}[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}',Ue={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:400,panelHeight:648,zIndex:9999};function Tt(t,a){const s=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16),o=1-a;return`#${Math.round(s*o).toString(16).padStart(2,"0")}${Math.round(n*o).toString(16).padStart(2,"0")}${Math.round(r*o).toString(16).padStart(2,"0")}`}function Et(t,a){const s=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16);return`#${Math.round(s+(255-s)*a).toString(16).padStart(2,"0")}${Math.round(n+(255-n)*a).toString(16).padStart(2,"0")}${Math.round(r+(255-r)*a).toString(16).padStart(2,"0")}`}function qe(t){const a={...Ue,...t},s=a.primaryColor,n=a.backgroundColor;return[`--sa-primary: ${s}`,`--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: ${Tt(s,.15)}`,`--sa-primary-light: ${Et(s,.9)}`,`--sa-surface: ${n}`,"--sa-border: #e5e7eb","--sa-hover: #f4f4f5","--sa-text: #374151","--sa-text-muted: #9ca3af","--sa-text-light: #6b7280"].join("; ")}function It(t,a){const s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`Target element not found: ${t}`);const n=document.createElement("div");n.setAttribute("data-super-agent-widget","");const r=qe(a.theme??{});if(n.setAttribute("style",`${r}; height: 100%;`),s.appendChild(n),!document.getElementById("sa-widget-styles")){const d=document.createElement("style");d.id="sa-widget-styles",d.textContent=`${Xe}
|
|
1163
|
+
${St}`,document.head.appendChild(d)}let o=et.createRoot(n),l=!1;const c=d=>{o&&o.render(i.createElement(Ge,{...a,initialOpen:d??l,onOpenChange:p=>{l=p}}))};return c(!1),{open(){l=!0,c(!0)},close(){l=!1,c(!1)},destroy(){o&&(o.unmount(),o=null),n.remove()}}}exports.ASSETS=O;exports.ActionBar=Pe;exports.ChatProvider=re;exports.ChatWidget=Ge;exports.Composer=ie;exports.ErrorPart=_e;exports.FullpageLayout=Ye;exports.Header=Ie;exports.Icon=L;exports.InterruptCard=He;exports.Message=Be;exports.TextPart=Re;exports.ThinkingPart=$e;exports.Thread=ne;exports.ThreadList=se;exports.ToolCallPart=Le;exports.ToolResultPart=Fe;exports.Trigger=Ee;exports.WelcomeScreen=Oe;exports.defaultTheme=Ue;exports.ensureIconFont=De;exports.mount=It;exports.themeToCSSVars=qe;exports.useAutoScroll=Ae;exports.useChat=ke;exports.useChatContext=X;exports.useConversations=Ce;exports.widgetStyles=Xe;
|