super-agent-sdk 1.0.9 → 1.0.11
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 +170 -6
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +40 -0
- package/dist/index.mjs +204 -170
- package/dist/{mammoth.browser-DiAPPO3x.cjs → mammoth.browser-BX8glWVC.cjs} +24 -24
- package/dist/{mammoth.browser-COPV53yV.js → mammoth.browser-Czw2m8xL.js} +133 -139
- package/dist/nosUploader-C94D61NK.js +4712 -0
- package/dist/nosUploader-KkzFK5EW.cjs +13 -0
- package/dist/widget.cjs +52 -28
- package/dist/widget.d.ts +126 -8
- package/dist/widget.mjs +1678 -1401
- package/package.json +5 -1
package/dist/widget.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),ct=require("react-dom/client"),e=require("react/jsx-runtime"),dt=require("./nosUploader-KkzFK5EW.cjs");function Se(t){const{sdk:a,sessionId:n,onSessionCreated:i,onStreamStart:r,onStreamEnd:o,onError:c,onMessageSend:d}=t,[l,p]=s.useState([]),[g,f]=s.useState("ready"),[y,b]=s.useState(null),S=s.useRef(null),h=s.useRef(!1),z=s.useRef(null),x=s.useRef(n),v=s.useRef(!0);x.current=n,v.current=l.length===0;const N=s.useCallback((w,A)=>{if(h.current)return;h.current=!0,d==null||d(w);const D={id:`user_${Date.now()}`,role:"user",parts:[...(A??[]).map(j=>({type:"attachment",attachment:j})),{type:"text",content:w}],timestamp:Date.now()},u=`assistant_${Date.now()}`,T={id:u,role:"assistant",parts:[],timestamp:Date.now()},L=v.current;p(j=>[...j,D,T]),f("submitted"),b(null);const _=j=>{let m="",R="",k=[],$=!1;const H=()=>{const C=[...k];if(m){const P=C.findIndex(B=>B.type==="thinking");P>=0?C[P]={type:"thinking",content:m}:C.unshift({type:"thinking",content:m})}if(R){const P=C[C.length-1];(P==null?void 0:P.type)==="text"?C[C.length-1]={type:"text",content:R}:C.push({type:"text",content:R})}p(P=>P.map(B=>B.id===u?{...B,parts:C}:B))};S.current=a.chat({sessionId:j,message:w,attachments:A&&A.length>0?A:void 0,stream:!0,onMessage:C=>{switch($||($=!0,f("streaming")),C.type){case"thinking":m+=C.content;break;case"ai":R+=C.content;break;case"tool_call":R&&(k.push({type:"text",content:R}),R=""),k.push({type:"tool_call",toolName:C.toolName,toolCallId:C.toolCallId,args:C.args??"{}"});break;case"tool_result":R&&(k.push({type:"text",content:R}),R=""),k.push({type:"tool_result",toolName:C.toolName??"",toolCallId:C.toolCallId,content:C.content,artifacts:C.artifacts,renderMode:C.renderMode,html:C.html});break;case"interrupt":R&&(k.push({type:"text",content:R}),R=""),C.interrupt&&k.push({type:"interrupt",interrupt:C.interrupt,resolved:!1});break;case"stop":C.content&&(R=C.content),H();return}H()},onDone:C=>{(R||k.length>0||m)&&H(),C.sessionId&&C.sessionId!==x.current&&(i==null||i(C.sessionId));const P=()=>{z.current&&(clearTimeout(z.current),z.current=null),o==null||o(C.sessionId||j),f("ready"),h.current=!1,S.current=null};if(L){const B=w.slice(0,30),Z=C.sessionId||j;a.renameConversation(Z,B).catch(()=>{}).finally(P)}else P()},onError:C=>{k.push({type:"error",content:C.message}),H(),z.current&&(clearTimeout(z.current),z.current=null),b(C),f("error"),c==null||c(C),h.current=!1,S.current=null}}),r==null||r(j)};x.current?_(x.current):a.createSession().then(j=>{x.current=j,i==null||i(j),_(j)}).catch(j=>{b(j instanceof Error?j:new Error(String(j))),f("error"),c==null||c(j instanceof Error?j:new Error(String(j))),h.current=!1})},[a,i,r,o,c,d]),E=s.useCallback(()=>{const w=x.current;w&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{var A;z.current=null,(A=S.current)==null||A.abort(),S.current=null,h.current=!1,f("ready")},8e3),a.stopGeneration(w).catch(()=>{}))},[a]),M=s.useCallback(()=>{if(h.current)return;const w=l.findLastIndex(u=>u.role==="user");if(w<0)return;const A=l[w].parts.filter(u=>u.type==="text").map(u=>u.content).join(""),D=l[w].parts.filter(u=>u.type==="attachment").map(u=>u.attachment);p(u=>u.slice(0,w)),N(A,D.length>0?D:void 0)},[l,N]),I=s.useCallback((w,A)=>{p(m=>m.map(R=>({...R,parts:R.parts.map(k=>k.type==="interrupt"&&k.interrupt.interruptId===w?{...k,resolved:!0,response:A}:k)})));const D=x.current;if(!D)return;let u=0;p(m=>m.length>0&&m[m.length-1].role==="assistant"?(u=m[m.length-1].parts.length,m):(u=0,[...m,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),f("streaming");let T="",L="",_=[];const j=()=>{const m=[..._];if(T){const R=m.findIndex(k=>k.type==="thinking");R>=0?m[R]={type:"thinking",content:T}:m.unshift({type:"thinking",content:T})}if(L){const R=m[m.length-1];(R==null?void 0:R.type)==="text"?m[m.length-1]={type:"text",content:L}:m.push({type:"text",content:L})}p(R=>{const k=R.findLastIndex($=>$.role==="assistant");return k<0?R:R.map(($,H)=>H===k?{...$,parts:[...$.parts.slice(0,u),...m]}:$)})};a.respondInterrupt(w,D,A,m=>{switch(m.type){case"thinking":T+=m.content;break;case"ai":L+=m.content;break;case"tool_call":L&&(_.push({type:"text",content:L}),L=""),_.push({type:"tool_call",toolName:m.toolName,toolCallId:m.toolCallId,args:m.args??"{}"});break;case"tool_result":L&&(_.push({type:"text",content:L}),L=""),_.push({type:"tool_result",toolName:m.toolName??"",toolCallId:m.toolCallId,content:m.content,artifacts:m.artifacts,renderMode:m.renderMode,html:m.html});break;case"interrupt":L&&(_.push({type:"text",content:L}),L=""),m.interrupt&&_.push({type:"interrupt",interrupt:m.interrupt,resolved:!1});break;case"done":o==null||o(D),f("ready");break}j()},m=>{_.push({type:"error",content:m.message}),j(),b(m),f("error"),c==null||c(m)}).catch(m=>{c==null||c(m instanceof Error?m:new Error(String(m))),f("error")})},[a,c,o]);return{messages:l,status:g,error:y,sendMessage:N,stop:E,regenerate:M,setMessages:p,respondToInterrupt:I}}const Ee="sa_active_conversation",ie=20;function ke(t){try{return localStorage.getItem(`${Ee}_${t}`)}catch{return null}}function pt(t,a){try{const n=`${Ee}_${t}`;a?localStorage.setItem(n,a):localStorage.removeItem(n)}catch{}}function Te(t){const{sdk:a,onConversationChange:n}=t,i=a.botId,[r,o]=s.useState([]),[c,d]=s.useState(()=>ke(i)),[l,p]=s.useState(!1),[g,f]=s.useState(!0),y=s.useRef(!0),b=s.useRef(1),S=s.useRef(!1);s.useEffect(()=>()=>{y.current=!1},[]);const h=s.useCallback(w=>{d(w),pt(i,w),w&&(n==null||n(w))},[i,n]),z=s.useCallback(async()=>{if(!S.current){S.current=!0,p(!0);try{b.current=1;const w=await a.listConversations({page:1,size:ie});if(!y.current)return;o(w.items),f(w.items.length<w.total);const A=ke(i);A&&!w.items.find(D=>D.sessionId===A)&&h(null)}catch{}finally{S.current=!1,y.current&&p(!1)}}},[a,h]),x=s.useCallback(async()=>{if(!(S.current||!g)){S.current=!0,p(!0);try{const w=b.current+1,A=await a.listConversations({page:w,size:ie});if(!y.current)return;b.current=w,o(u=>{const T=new Set(u.map(_=>_.sessionId)),L=A.items.filter(_=>!T.has(_.sessionId));return[...u,...L]});const D=b.current*ie;f(D<A.total)}catch{}finally{S.current=!1,y.current&&p(!1)}}},[a,g]),v=s.useCallback(async w=>(h(w),await a.getMessages(w)),[a,h]),N=s.useCallback(async()=>{try{const w=await a.createSession(),A=new Date().toISOString();o(D=>[{sessionId:w,botId:0,title:"新对话",createTime:A,updateTime:A},...D]),h(w)}catch{h(null)}},[a,h]),E=s.useCallback(async w=>{o(A=>A.filter(D=>D.sessionId!==w)),c===w&&h(null);try{await a.deleteConversation(w)}catch{}},[a,c,h]),M=s.useCallback(async(w,A)=>{await a.renameConversation(w,A),o(D=>D.map(u=>u.sessionId===w?{...u,title:A}:u))},[a]),{enabled:I=!0}=t;return s.useEffect(()=>{I&&z()},[I,z]),{conversations:r,activeConversationId:c,loading:l,hasMore:g,loadConversations:z,loadMore:x,switchConversation:v,newConversation:N,deleteConversation:E,renameConversation:M,setActiveConversationId:h}}function Ie(t){return!t&&t!==0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Me(t){return t==="pdf"?"PDF":t==="docx"?"DOC":t==="html"?"HTM":t.slice(0,3).toUpperCase()||"FILE"}function Ae(t){if(!t)return[];const a=[];for(const n of t)n.type==="file"&&n.data&&a.push({id:n.data.id??"",type:n.data.fileType??n.data.type??"",filename:n.data.name??n.data.filename??"",url:n.data.url??"",mime:n.data.mime,size:n.data.size,summary:n.data.summary});return a}async function re(t){try{const a=await fetch(t.url);if(!a.ok)throw new Error(`HTTP ${a.status}`);const n=await a.blob(),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=t.filename,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),4e3)}catch{const a=document.createElement("a");a.href=t.url,a.download=t.filename,a.target="_blank",document.body.appendChild(a),a.click(),a.remove()}}const Re=s.createContext(null);function X(){const t=s.useContext(Re);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}function oe({sdk:t,hooks:a,attachmentUploader:n,nosUpload:i,children:r}){const[o,c]=s.useState(!1),[d,l]=s.useState(!1),[p,g]=s.useState(null),[f,y]=s.useState(null),[b,S]=s.useState(!1),[h,z]=s.useState(!1);s.useEffect(()=>{t.getToken().then(()=>{S(!0)}).catch(()=>{S(!0)})},[t]);const x=Te({sdk:t,onConversationChange:a==null?void 0:a.onConversationChange,enabled:b}),v=Se({sdk:t,sessionId:x.activeConversationId,onSessionCreated:k=>{x.setActiveConversationId(k)},onStreamStart:a==null?void 0:a.onStreamStart,onStreamEnd:k=>{var $;($=a==null?void 0:a.onStreamEnd)==null||$.call(a,k),x.loadConversations()},onError:a==null?void 0:a.onError,onMessageSend:a==null?void 0:a.onMessageSend}),N=s.useCallback(k=>{if(k.type==="link"){window.open(k.url,k.target??"_blank","noopener");return}y(k)},[]),E=s.useCallback(()=>y(null),[]),M=s.useCallback(async k=>{z(!0);try{const $=await x.switchConversation(k);v.setMessages($)}finally{z(!1)}},[x,v]),I=s.useCallback(async()=>{v.setMessages([]),await x.newConversation()},[x,v]),w=s.useCallback(async k=>{x.activeConversationId===k&&v.setMessages([]),await x.deleteConversation(k)},[x,v]);s.useEffect(()=>{x.activeConversationId&&v.messages.length===0&&(z(!0),t.getMessages(x.activeConversationId).then(k=>{v.setMessages(k)}).catch(()=>{}).finally(()=>z(!1)))},[]);const A=s.useCallback(()=>{c(k=>!k)},[]),D=s.useCallback(k=>{c(k)},[]),u=s.useCallback(()=>{l(k=>!k),g(k=>null)},[]),T=s.useCallback(k=>{g(k),l(!0)},[]),L=s.useMemo(()=>{const k=new Set,$=[];for(const H of v.messages)for(const C of H.parts)if(C.type==="tool_result"&&C.artifacts)for(const P of Ae(C.artifacts)){const B=P.id||`${P.url}:${P.filename}`;k.has(B)||(k.add(B),$.push(P))}return $},[v.messages]),_=s.useCallback(async()=>{const k=x.activeConversationId;if(!k)return null;try{const $=await t.getMessages(k);v.setMessages($);const H=$.findLast(C=>C.role==="assistant");return(H==null?void 0:H.id)??null}catch{return null}},[t,x.activeConversationId,v]),j=s.useCallback((k,$,H)=>{if(/^\d+$/.test(k)){t.feedback(k,$,H).catch(()=>{});return}_().then(C=>{C&&t.feedback(C,$,H).catch(()=>{})})},[t,_]),m=s.useCallback(k=>{if(/^\d+$/.test(k)){t.cancelFeedback(k).catch(()=>{});return}_().then($=>{$&&t.cancelFeedback($).catch(()=>{})})},[t,_]),R=s.useMemo(()=>({sdk:t,status:v.status,error:v.error,messages:v.messages,conversations:x.conversations,activeConversationId:x.activeConversationId,isThreadListOpen:o,isArtifactDrawerOpen:d,allArtifacts:L,activePreviewArtifact:p,activePanel:f,hasMore:x.hasMore,conversationsLoading:x.loading,messagesLoading:h,sendMessage:v.sendMessage,attachmentUploader:n??null,nosUpload:i??null,stop:v.stop,regenerate:v.regenerate,switchConversation:M,newConversation:I,deleteConversation:w,renameConversation:x.renameConversation,loadMoreConversations:x.loadMore,toggleThreadList:A,setThreadListOpen:D,toggleArtifactDrawer:u,openArtifactPreview:T,openPanel:N,closePanel:E,feedback:j,cancelFeedback:m,respondToInterrupt:v.respondToInterrupt}),[t,v.status,v.error,v.messages,v.sendMessage,v.stop,v.regenerate,v.respondToInterrupt,n,i,x.conversations,x.activeConversationId,x.renameConversation,x.hasMore,x.loadMore,x.loading,o,d,L,p,f,h,M,I,w,A,D,u,T,N,E,j,m]);return e.jsx(Re.Provider,{value:R,children:r})}const O="https://ehr-web.netease.com/ehr-web/erh-super-agent",Y={recently:`${O}/recently.svg`,home:`${O}/home.svg`,mergeWindow:`${O}/merge_window.svg`,spiltWindow:`${O}/spilt_window.svg`,close:`${O}/close.svg`,message:`${O}/message.svg`,messageCreate:`${O}/message_create.svg`,customerService:`${O}/customer_service.svg`,sendSolid:`${O}/send_solid.svg`,capabilityIcons:[`${O}/icon1.png`,`${O}/icon2.png`,`${O}/icon3.png`],triggerLogo:`${O}/HRlogo.png`,logo:`${O}/HRlogo2.png`,assistantAvatarGenerating:`${O}/profile0.gif`,assistantAvatar:`${O}/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 ut({defaultWidth:t=W.DEFAULT_WIDTH,defaultHeight:a=W.DEFAULT_HEIGHT,sidebarWidth:n=0}={}){const[i,r]=s.useState(t),[o,c]=s.useState({x:0,y:0}),[d,l]=s.useState(!1),[p,g]=s.useState(!1),[f,y]=s.useState(null),[b,S]=s.useState(()=>typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),h=s.useRef(!1),z=s.useRef(0),x=s.useRef(i),v=s.useRef(!1),N=s.useRef({x:0,y:0}),E=s.useRef({x:0,y:0}),M=s.useRef(!1),I=s.useRef(null);s.useEffect(()=>{const j=()=>S({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),s.useEffect(()=>()=>{var j;(j=I.current)==null||j.call(I)},[]);const w=Math.floor(b.height*W.MAX_HEIGHT_RATIO),A=Math.min(f||a,w),D=i+n;s.useEffect(()=>{if(!d){const j=b.width-D-20,m=b.height-A-20;c(R=>R.x===j&&R.y===m?R:{x:j,y:m})}},[d,D,A,b]);const u=s.useCallback(j=>{if(p||j.target.closest("button, input, textarea"))return;v.current=!0,M.current=!1,N.current={x:j.clientX,y:j.clientY},E.current={...o};const m=$=>{if(!v.current)return;const H=$.clientX-N.current.x,C=$.clientY-N.current.y;(Math.abs(H)>3||Math.abs(C)>3)&&(M.current=!0),M.current&&(l(!0),c({x:Math.max(-200,Math.min(E.current.x+H,window.innerWidth-100)),y:Math.max(0,Math.min(E.current.y+C,window.innerHeight-48))}))},R=()=>{v.current=!1,k()},k=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",R),I.current=null};document.addEventListener("mousemove",m),document.addEventListener("mouseup",R),I.current=k},[p,o]),T=s.useCallback(j=>{j.preventDefault(),j.stopPropagation(),h.current=!0,z.current=j.clientX,x.current=i;const m=o.x+i,R=o.y,k=C=>{if(!h.current)return;const P=C.clientX-z.current;let B=x.current-P;if(B>W.MAX_WIDTH){h.current=!1,g(!0),H();return}B=Math.max(W.MIN_WIDTH,B),r(B),c({x:m-B,y:R})},$=()=>{h.current=!1,H()},H=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",$),I.current=null};document.addEventListener("mousemove",k),document.addEventListener("mouseup",$),I.current=H},[i,o]),L=s.useCallback(()=>{p&&r(t),g(j=>!j)},[p,t]),_=s.useCallback(()=>{g(!1),r(t),l(!1),y(null)},[t]);return{width:i,position:o,hasCustomPosition:d,isMaximized:p,lockedHeight:f,viewport:b,defaultHeight:a,totalWidth:D,windowHeight:A,startWindowDrag:u,startResize:T,toggleMaximize:L,setIsMaximized:g,setLockedHeight:y,setHasCustomPosition:l,reset:_}}function gt(t){const{enabled:a,contentSelector:n,defaultHeight:i,onHeightChange:r}=t,o=s.useRef(null);return s.useEffect(()=>{if(!a||!o.current)return;const d=o.current.querySelector(n);if(!d)return;const l=()=>{const f=o.current;if(!f)return;const y=f.querySelector(n);if(!y)return;const b=f.offsetHeight-y.clientHeight,S=y.scrollHeight+b,h=Math.floor(window.innerHeight*W.MAX_HEIGHT_RATIO),z=Math.max(i,Math.min(S,h));r(x=>x===z?x:z)};l();const p=new ResizeObserver(()=>l());Array.from(d.children).forEach(f=>p.observe(f));const g=new MutationObserver(()=>{Array.from(d.children).forEach(f=>p.observe(f)),l()});return g.observe(d,{childList:!0,subtree:!0,characterData:!0}),()=>{p.disconnect(),g.disconnect()}},[a,n,i,r]),o}function ft(t,a){const n=W.TRIGGER_SIZE;return{x:Math.max(8,Math.min(t,window.innerWidth-n-8)),y:Math.max(8,Math.min(a,window.innerHeight-n-8))}}function $e({isOpen:t,onClick:a,triggerLogo:n}){const[i,r]=s.useState(null),o=s.useRef(!1),c=s.useRef(!1),d=s.useRef({x:0,y:0}),l=s.useRef({x:0,y:0}),p=s.useRef(null);s.useEffect(()=>()=>{var b;(b=p.current)==null||b.call(p)},[]);const g=s.useCallback(b=>{if(b.button!==0)return;o.current=!0,c.current=!1,d.current={x:b.clientX,y:b.clientY};const S=b.currentTarget.getBoundingClientRect();l.current={x:S.left,y:S.top};const h=x=>{if(!o.current)return;const v=x.clientX-d.current.x,N=x.clientY-d.current.y;(Math.abs(v)>4||Math.abs(N)>4)&&(c.current=!0),c.current&&r(ft(l.current.x+v,l.current.y+N))},z=()=>{o.current=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",z),p.current=null};document.addEventListener("mousemove",h),document.addEventListener("mouseup",z),p.current=z},[]),f=s.useCallback(()=>{if(c.current){c.current=!1;return}a()},[a]),y=i?{left:i.x,top:i.y,width:W.TRIGGER_SIZE,height:W.TRIGGER_SIZE}:{right:W.TRIGGER_RIGHT,bottom:W.TRIGGER_BOTTOM,width:W.TRIGGER_SIZE,height:W.TRIGGER_SIZE};return e.jsx("button",{type:"button",className:`fixed z-[10000] flex items-center justify-center border-none bg-transparent p-0 transition-transform duration-200 ease-out hover:scale-[1.08] active:scale-95 ${t?"pointer-events-none scale-50 opacity-0":"opacity-100"}`,style:y,onMouseDown:g,onClick:f,"aria-label":"打开 AI 助手",title:"AI 助手",children:e.jsx("img",{src:n||Y.triggerLogo,alt:"AI 助手",className:"block h-full w-full",draggable:!1})})}function V({tooltip:t,onClick:a,children:n}){return e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white active:bg-[#F5F5F5]","data-tooltip":t,"aria-label":t,onClick:a,children:n})}function Le({onClose:t,onToggleThreadList:a,isMaximized:n=!1,onToggleMaximize:i,showHome:r=!1,onHome:o,showClose:c=!0,artifactCount:d=0,onToggleArtifactDrawer:l}){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:Y.recently,alt:"",width:20,height:20})}),r&&o&&e.jsx(V,{tooltip:"回到首页",onClick:o,children:e.jsx("img",{src:Y.home,alt:"",width:20,height:20})})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[d>0&&l&&e.jsx(V,{tooltip:"会话产物",onClick:l,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"})]}),d>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:d>99?"99+":d})]})}),i&&e.jsx(V,{tooltip:n?"小窗":"大窗",onClick:i,children:e.jsx("img",{src:n?Y.spiltWindow:Y.mergeWindow,alt:"",width:20,height:20})}),c&&e.jsx(V,{tooltip:"关闭",onClick:t,children:e.jsx("img",{src:Y.close,alt:"",width:20,height:20})})]})]})}const K=t=>String(t).padStart(2,"0");function xt(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 De(t){const a=new Date,n=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=n-6*864e5,r=[],o=[],c=[];for(const l of t){const p=new Date(l.updateTime).getTime();p>=n?r.push(l):p>=i?o.push(l):c.push(l)}const d=[];return r.length&&d.push({label:"今天",items:r}),o.length&&d.push({label:"最近 7 天",items:o}),c.length&&d.push({label:"更早",items:c}),d}function le({width:t}){const{conversations:a,activeConversationId:n,switchConversation:i,newConversation:r,deleteConversation:o,renameConversation:c,hasMore:d,loadMoreConversations:l,conversationsLoading:p}=X(),[g,f]=s.useState(null),[y,b]=s.useState(""),[S,h]=s.useState(null),z=s.useRef(null),x=s.useCallback((M,I)=>{f(M),b(I??"")},[]),v=s.useCallback(M=>{y.trim()&&c(M,y.trim()),f(null)},[y,c]),N=s.useCallback(()=>{const M=z.current;!M||!d||M.scrollHeight-M.scrollTop-M.clientHeight<50&&l()},[d,l]),E=s.useMemo(()=>De(a),[a]);return e.jsxs("div",{className:"relative z-[5] flex h-full shrink-0 flex-col overflow-visible border-r border-[#ECECEC] bg-[#FAFAFA] p-3 animate-sa-history-in",style:{width:t??200},children:[e.jsxs("button",{type:"button",className:"sa-new-chat mb-4 flex h-8 w-full shrink-0 items-center justify-center gap-2 rounded-md text-[14px] font-medium transition-colors",onClick:r,children:[e.jsx("img",{src:Y.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:z,className:"flex-1 overflow-y-auto",onScroll:N,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:"暂无记录"}),E.map(M=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:M.label}),M.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===n?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{g!==I.sessionId&&i(I.sessionId)},onMouseEnter:w=>{if(g===I.sessionId)return;const A=w.currentTarget.getBoundingClientRect();h({text:I.title||"新会话",x:A.right+8,y:A.top+A.height/2})},onMouseLeave:()=>h(null),children:g===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:y,onChange:w=>b(w.target.value),onBlur:()=>v(I.sessionId),onKeyDown:w=>{w.key==="Enter"&&v(I.sessionId),w.key==="Escape"&&f(null)},onClick:w=>w.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Y.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(),x(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))]},M.label)),p&&a.length>0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:d?"加载更多...":"加载中..."}),!p&&d&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),S&&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:S.x,top:S.y,transform:"translateY(-50%)"},children:S.text})]})}function Fe(t){const a=s.useRef(null),n=s.useRef(!1),i=s.useRef(0),r=s.useCallback(()=>{const c=a.current;if(!c)return;const{scrollTop:d,scrollHeight:l,clientHeight:p}=c,g=l-d-p<40;d<i.current&&!g&&(n.current=!0),g&&(n.current=!1),i.current=d},[]);s.useEffect(()=>{const c=a.current;if(c)return c.addEventListener("scroll",r,{passive:!0}),()=>c.removeEventListener("scroll",r)},[r]),s.useEffect(()=>{if(n.current)return;const c=a.current;c&&requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},t);const o=s.useCallback(()=>{n.current=!1;const c=a.current;c&&(c.scrollTop=c.scrollHeight)},[]);return{containerRef:a,scrollToBottom:o}}function U(t){return t.value++}function q(t,a){const n=[],i=[],r=()=>{i.length>0&&(n.push(i.join("")),i.length=0)};let o=0;for(;o<t.length;){const c=t[o];if(c==="`"){const d=t.indexOf("`",o+1);if(d!==-1){r(),n.push(e.jsx("code",{className:"sa-inline-code",children:t.slice(o+1,d)},U(a))),o=d+1;continue}}else if(c==="*"&&t[o+1]==="*"){const d=t.indexOf("**",o+2);if(d!==-1){r(),n.push(e.jsx("strong",{children:q(t.slice(o+2,d),a)},U(a))),o=d+2;continue}}else if(c==="*"){const d=t.indexOf("*",o+1);if(d!==-1){r(),n.push(e.jsx("em",{children:q(t.slice(o+1,d),a)},U(a))),o=d+1;continue}}else if(c==="["){const d=t.indexOf("]",o+1);if(d!==-1&&t[d+1]==="("){const l=t.indexOf(")",d+2);if(l!==-1){const p=t.slice(o+1,d),g=t.slice(d+2,l);r(),n.push(e.jsx("a",{href:g,target:"_blank",rel:"noreferrer",children:q(p,a)},U(a))),o=l+1;continue}}}i.push(c),o++}return r(),n}function ht(t,a){const n=[],i=t.split(`
|
|
2
|
+
`);let r=0;const o=l=>l.trim()==="",c=l=>/^#{1,6}\s+\S/.test(l.trim()),d=l=>/^(?:[-*+]|\d+[.)])\s+\S/.test(l.trim());for(;r<i.length;){const l=i[r],p=l.trim();if(o(l)){r++;continue}if(c(l)){const f=p.match(/^(#{1,6})\s+(.*)$/);if(f){const b=`h${Math.min(f[1].length,6)}`;n.push(s.createElement(b,{key:U(a)},q(f[2],a)))}r++;continue}if(d(l)){const f=/^\d+[.)]/.test(p),y=[];for(;r<i.length&&d(i[r]);){const b=i[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);b&&y.push(e.jsx("li",{children:q(b[1],a)},U(a))),r++}n.push(f?e.jsx("ol",{className:"sa-list",children:y},U(a)):e.jsx("ul",{className:"sa-list",children:y},U(a)));continue}const g=[];for(;r<i.length&&!o(i[r])&&!c(i[r])&&!d(i[r]);)g.push(i[r]),r++;n.push(e.jsx("p",{className:"sa-text-paragraph",children:q(g.join(" "),a)},U(a)))}return n}function mt(t){const a={value:0},n=[],i=t.split("```");for(let r=0;r<i.length;r++)if(r%2===0)n.push(...ht(i[r],a));else if(i[r].trim()!==""){let o=i[r].replace(/^\r?\n/,"");o=o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/,""),o=o.replace(/\r?\n$/,""),n.push(e.jsx("pre",{className:"sa-code-block",children:e.jsx("code",{children:o})},U(a)))}return n}function _e({content:t}){return e.jsx("div",{className:"sa-text-part",children:mt(t)})}const wt="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let je=!1;function He(t=wt){if(je||typeof document>"u")return;je=!0;const a=t.split("?")[0].split("/").pop();if(a&&document.querySelector(`script[src*="${a}"]`))return;const n=document.createElement("script");n.src=t,document.head.appendChild(n)}He();function F({name:t,size:a=16,color:n="currentColor",className:i,style:r}){return e.jsx("svg",{className:i,style:{width:a,height:a,fill:n,verticalAlign:"middle",...r},"aria-hidden":"true",children:e.jsx("use",{href:`#icon-${t}`})})}function Pe({content:t}){const[a,n]=s.useState(!1);return e.jsxs("div",{className:"sa-thinking-part",onClick:()=>n(!a),children:[e.jsxs("div",{className:"sa-thinking-header",children:[e.jsx("span",{className:"sa-thinking-icon",children:e.jsx(F,{name:"brain",size:14})}),e.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),e.jsx("span",{className:`sa-thinking-arrow ${a?"expanded":""}`,children:e.jsx(F,{name:"chevron-right",size:12})})]}),a&&e.jsx("div",{className:"sa-thinking-content",children:t})]})}function Be({toolName:t,toolCallId:a,args:n}){const[i,r]=s.useState(!1),[o,c]=s.useState(!1);let d=n;try{d=JSON.stringify(JSON.parse(n),null,2)}catch{}const l=s.useCallback(()=>{var p;(p=navigator.clipboard)==null||p.writeText(d).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)}).catch(()=>{})},[d]);return e.jsxs("div",{className:"sa-tool-call-part",children:[e.jsxs("div",{className:"sa-tool-call-header",onClick:()=>r(!i),children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(F,{name:"zap",size:14})}),e.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",t]}),e.jsx("span",{className:`sa-thinking-arrow ${i?"expanded":""}`,children:e.jsx(F,{name:"chevron-right",size:12})})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-args",children:d}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsxs("button",{className:"sa-action-btn",onClick:l,title:"复制",children:[e.jsx(F,{name:o?"circle-check":"copy",size:14})," ",o?"已复制":"复制"]})})]})]})}function Ce({text:t}){const[a,n]=s.useState(!1),i=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return e.jsxs("button",{className:"sa-action-btn",onClick:i,title:"复制",children:[e.jsx(F,{name:a?"circle-check":"copy",size:14})," ",a?"已复制":"复制"]})}function bt({html:t}){const[a,n]=s.useState(null);return s.useEffect(()=>{let i=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(r=>{i||n(r.default.sanitize(t,{FORCE_BODY:!0,ADD_ATTR:["target"]}))}),()=>{i=!0}},[t]),a===null?null:e.jsx("div",{className:"sa-tool-result-html-scroll",children:e.jsx("div",{className:"sa-tool-result-html sa-text-part",dangerouslySetInnerHTML:{__html:a}})})}function Oe({toolName:t,content:a,artifacts:n,renderMode:i,html:r,artifactPreview:o}){const{openArtifactPreview:c}=X(),d=Ae(n);return e.jsxs("div",{className:"sa-tool-result-part",children:[e.jsxs("div",{className:"sa-tool-result-header",children:[e.jsx("span",{className:"sa-tool-icon",children:e.jsx(F,{name:"circle-check",size:14,color:"#10b981"})}),e.jsx("span",{className:"sa-tool-result-label",children:t||"工具返回"})]}),i==="html"&&r?e.jsxs(e.Fragment,{children:[e.jsx(bt,{html:r}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Ce,{text:r})})]}):a?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"sa-tool-result-content",children:a}),e.jsx("div",{className:"sa-tool-result-actions",children:e.jsx(Ce,{text:a})})]}):e.jsx("pre",{className:"sa-tool-result-content",children:"—"}),d.length>0&&e.jsx("ul",{className:"sa-artifact-file-list",role:"list",children:d.map((l,p)=>e.jsxs("li",{className:"sa-artifact-file-card",onClick:o?()=>c(l):void 0,onKeyDown:o?g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),c(l))}:void 0,tabIndex:o?0:void 0,role:o?"button":void 0,"aria-label":o?`预览 ${l.filename}`:void 0,style:o?{cursor:"pointer"}:void 0,children:[e.jsx("div",{className:"sa-artifact-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:Me(l.type)})}),e.jsxs("div",{className:"sa-artifact-file-info",children:[e.jsx("span",{className:"sa-artifact-file-name",children:l.filename}),l.size!=null&&e.jsx("span",{className:"sa-artifact-file-size",children:Ie(l.size)})]}),o&&e.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${l.filename}`,onClick:g=>{g.stopPropagation(),re(l)},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"})})})]},l.id||`art-${p}`))})]})}function We({content:t,onRetry:a}){return e.jsxs("div",{className:"sa-error-part",children:[e.jsxs("div",{className:"sa-error-content",children:[e.jsx("span",{className:"sa-error-icon",children:e.jsx(F,{name:"triangle-alert",size:14})}),e.jsx("span",{children:t||"发生错误"})]}),a&&e.jsx("button",{className:"sa-error-retry",onClick:a,children:"重试"})]})}function Ye(t){return t==null||Number.isNaN(t)?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function vt({attachment:t}){const a=e.jsxs(e.Fragment,{children:[e.jsx(F,{name:"file-text",size:14,color:"#6366f1"}),e.jsx("span",{className:"sa-attachment-chip-name",children:t.filename}),t.size!=null&&e.jsx("span",{className:"sa-attachment-chip-size",children:Ye(t.size)})]});return t.url?e.jsx("a",{className:"sa-attachment-chip",href:t.url,target:"_blank",rel:"noreferrer",download:t.filename,title:`下载 ${t.filename}`,children:a}):e.jsx("span",{className:"sa-attachment-chip",title:t.filename,children:a})}function yt({interrupt:t,onRespond:a,disabled:n,answeredAction:i}){var d,l;const r=t.options,o=(typeof(r==null?void 0:r[0])=="string"?r[0]:(d=r==null?void 0:r[0])==null?void 0:d.label)||"确认",c=(typeof(r==null?void 0:r[1])=="string"?r[1]:(l=r==null?void 0:r[1])==null?void 0:l.label)||"取消";return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${i==="confirm"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"confirm"}),children:[e.jsx(F,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${i==="cancel"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"cancel"}),children:[e.jsx(F,{name:"x",size:14})," ",c]})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function kt({interrupt:t,onRespond:a,disabled:n,answeredAction:i}){var p,g,f,y;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)||"批准",c=(typeof(r==null?void 0:r[1])=="string"?r[1]:(g=r==null?void 0:r[1])==null?void 0:g.label)||"拒绝",d=(typeof(r==null?void 0:r[2])=="string"?r[2]:(f=r==null?void 0:r[2])==null?void 0:f.label)||"跳过",l=((y=t.metadata)==null?void 0:y.showSkip)!==!1;return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"circle-alert",size:16,color:"#f59e0b"}),e.jsx("span",{children:t.content})]}),e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${i==="approve"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"approve"}),children:[e.jsx(F,{name:"check",size:14})," ",o]}),e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-danger ${i==="reject"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"reject"}),children:[e.jsx(F,{name:"x",size:14})," ",c]}),l&&e.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${i==="skip"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>a({action:"skip"}),children:[e.jsx(F,{name:"chevron-right",size:14})," ",d]})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function jt(t){return typeof t=="string"?{value:t,label:t}:t}function Ct({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=(t.options??[]).map(jt);return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"list",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(o=>{const c=i===o.value;return e.jsxs("button",{className:`sa-interrupt-option ${o.danger?"sa-interrupt-option-danger":""} ${c?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>a({action:"select",value:o.value}),children:[e.jsx(F,{name:c?"circle-check":"circle",size:14}),o.icon&&e.jsx(F,{name:o.icon,size:14}),e.jsx("span",{children:o.label}),o.description&&e.jsx("span",{className:"sa-interrupt-option-desc",children:o.description})]},o.value)})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Nt(t){return typeof t=="string"?{value:t,label:t}:t}function zt({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=(t.options??[]).map(Nt),[o,c]=s.useState(()=>new Set(Array.isArray(i)?i:[])),d=l=>{n||c(p=>{const g=new Set(p);return g.has(l)?g.delete(l):g.add(l),g})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"list-checks",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-options",children:r.map(l=>e.jsxs("button",{className:`sa-interrupt-option ${o.has(l.value)?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>d(l.value),children:[e.jsx(F,{name:o.has(l.value)?"square-check":"square",size:14}),e.jsx("span",{children:l.label})]},l.value))}),!n&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:o.size===0,onClick:()=>a({action:"submit",value:Array.from(o)}),children:[e.jsx(F,{name:"check",size:14})," 确认 (",o.size,")"]})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function St({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const[r,o]=s.useState(i??""),c=t.inputType??"text",d=c==="textarea",l=()=>{n||t.required&&!r.trim()||a({action:"submit",value:r.trim()})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"text-cursor-input",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-input-area",children:d?e.jsx("textarea",{className:"sa-interrupt-textarea",value:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,rows:3,disabled:n}):e.jsx("input",{className:"sa-interrupt-input",type:c,value:r,onChange:p=>o(p.target.value),placeholder:t.placeholder,maxLength:t.maxLength,onKeyDown:p=>p.key==="Enter"&&l(),disabled:n})}),!n&&e.jsx("div",{className:"sa-interrupt-actions",children:e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:t.required?!r.trim():!1,onClick:l,children:[e.jsx(F,{name:"check",size:14})," 提交"]})}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Et({interrupt:t,onRespond:a,disabled:n,initialValue:i}){const r=t.fields??[],[o,c]=s.useState(()=>{const g={};for(const f of r)g[f.name]=(i==null?void 0:i[f.name])??f.defaultValue??"";return g}),d=(g,f)=>{n||c(y=>({...y,[g]:f}))},l=!n&&r.every(g=>!g.required||o[g.name]),p=()=>{l&&a({action:"submit",value:o})};return e.jsxs("div",{className:"sa-interrupt-card",children:[e.jsxs("div",{className:"sa-interrupt-content",children:[e.jsx(F,{name:"file-text",size:16,color:"#6366f1"}),e.jsx("span",{children:t.content})]}),e.jsx("div",{className:"sa-interrupt-form",children:r.map(g=>e.jsxs("div",{className:"sa-interrupt-form-field",children:[e.jsxs("label",{className:"sa-interrupt-form-label",children:[g.label,g.required&&e.jsx("span",{className:"sa-interrupt-form-required",children:"*"})]}),Tt(g,o[g.name],f=>d(g.name,f),n)]},g.name))}),!n&&e.jsxs("div",{className:"sa-interrupt-actions",children:[e.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:!l,onClick:p,children:[e.jsx(F,{name:"check",size:14})," 提交"]}),e.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>a({action:"cancel"}),children:"取消"})]}),n&&e.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Ne(t){return typeof t=="string"?{value:t,label:t}:t}function Tt(t,a,n,i){switch(t.type){case"textarea":return e.jsx("textarea",{className:"sa-interrupt-textarea",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,rows:3,disabled:i});case"select":{const r=(t.options??[]).map(Ne);return e.jsxs("select",{className:"sa-interrupt-select",value:a,onChange:o=>n(o.target.value),disabled:i,children:[e.jsx("option",{value:"",children:"请选择"}),r.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))]})}case"multiSelect":{const r=(t.options??[]).map(Ne),o=Array.isArray(a)?a:[],c=d=>{i||n(o.includes(d)?o.filter(l=>l!==d):[...o,d])};return e.jsx("div",{className:"sa-interrupt-options",children:r.map(d=>e.jsx("button",{type:"button",className:`sa-interrupt-option ${o.includes(d.value)?"sa-interrupt-option-selected":""}`,disabled:i,onClick:()=>c(d.value),children:d.label},d.value))})}case"password":return e.jsx("input",{className:"sa-interrupt-input",type:"password",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,disabled:i});default:return e.jsx("input",{className:"sa-interrupt-input",type:t.type==="number"?"number":t.type==="date"?"date":"text",value:a,onChange:r=>n(r.target.value),placeholder:t.placeholder,disabled:i})}}function Ge({interrupt:t,resolved:a,response:n,onRespond:i}){const r=a,o=n==null?void 0:n.value;switch(t.interruptType){case"confirm":return e.jsx(yt,{interrupt:t,onRespond:i,disabled:r,answeredAction:n==null?void 0:n.action});case"approve":return e.jsx(kt,{interrupt:t,onRespond:i,disabled:r,answeredAction:n==null?void 0:n.action});case"select":return e.jsx(Ct,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"multiSelect":return e.jsx(zt,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"input":return e.jsx(St,{interrupt:t,onRespond:i,disabled:r,initialValue:o});case"form":return e.jsx(Et,{interrupt:t,onRespond:i,disabled:r,initialValue:o});default:return e.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",t.interruptType]})}}const It=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function Ue({message:t,onCopy:a,onRegenerate:n,onFeedback:i}){const{status:r,cancelFeedback:o}=X(),[c,d]=s.useState(null),[l,p]=s.useState(!1),[g,f]=s.useState(!1),y=s.useRef(null),b=s.useCallback(()=>{a(),p(!0),setTimeout(()=>p(!1),2e3)},[a]),S=s.useCallback(()=>{c==="like"?(d(null),o(t.id)):(d("like"),f(!1),i==null||i(t.id,"like"))},[c,t.id,i,o]),h=s.useCallback(()=>{c==="dislike"?(d(null),f(!1),o(t.id)):f(!0)},[c,t.id,o]),z=s.useCallback((v,N)=>{d("dislike"),f(!1),i==null||i(t.id,"dislike",{reason:v,remark:(N==null?void 0:N.trim())||void 0})},[t.id,i]),x=s.useCallback(()=>{f(!1)},[]);return s.useEffect(()=>{if(!g)return;const v=E=>{y.current&&!y.current.contains(E.target)&&f(!1)},N=E=>{E.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",N)}},[g]),r!=="ready"&&r!=="error"?null:e.jsxs("div",{className:"sa-action-bar",children:[e.jsxs("button",{className:"sa-action-btn",onClick:b,title:"复制",children:[e.jsx(F,{name:l?"circle-check":"copy",size:14})," ",l?"已复制":"复制"]}),n&&e.jsxs("button",{className:"sa-action-btn",onClick:n,title:"重新生成",children:[e.jsx(F,{name:"refresh-cw",size:14})," 重新生成"]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sa-action-divider"}),e.jsx("button",{className:`sa-action-btn ${c==="like"?"sa-action-btn-active":""}`,onClick:S,title:"有用","aria-label":"点赞",children:e.jsx(F,{name:"thumbs-up",size:14})}),e.jsx("button",{className:`sa-action-btn ${c==="dislike"?"sa-action-btn-active":""}`,onClick:h,title:"无用","aria-label":"踩","aria-expanded":g,"aria-haspopup":"dialog",children:e.jsx(F,{name:"thumbs-down",size:14})})]}),g&&e.jsx("div",{ref:y,children:e.jsx(Mt,{onSubmit:z,onCancel:x})})]})}function Mt({onSubmit:t,onCancel:a}){const[n,i]=s.useState(void 0),[r,o]=s.useState("");return e.jsxs("div",{className:"sa-dislike-panel",children:[e.jsx("div",{className:"sa-dislike-panel-title",children:"请选择不满意的原因(可选)"}),e.jsx("div",{className:"sa-dislike-reasons",children:It.map(c=>e.jsx("button",{className:`sa-dislike-reason-btn ${n===c.value?"active":""}`,onClick:()=>i(n===c.value?void 0:c.value),children:c.label},c.value))}),e.jsx("textarea",{className:"sa-dislike-remark",placeholder:"补充描述(选填,≤500 字)",maxLength:500,value:r,onChange:c=>o(c.target.value),rows:2}),e.jsxs("div",{className:"sa-dislike-actions",children:[e.jsx("button",{className:"sa-dislike-submit",onClick:()=>t(n,r||void 0),children:"提交"}),e.jsx("button",{className:"sa-dislike-cancel",onClick:a,children:"取消"})]})]})}const At=/^(https?:\/\/|data:|blob:|\/\/|\/|\.\/|\.\.\/)/;function ze({src:t,alt:a}){return t?At.test(t)?e.jsx("img",{src:t,alt:a??"",className:"sa-msg-avatar",draggable:!1}):e.jsx("span",{className:"sa-msg-avatar sa-msg-avatar-text",children:t}):null}function Xe({message:t,isStreaming:a,isLast:n,slots:i,avatar:r,artifactPreview:o,showTimestamp:c}){const{regenerate:d,feedback:l,respondToInterrupt:p}=X(),g=s.useCallback(()=>{var M;const E=t.parts.filter(I=>I.type==="text").map(I=>I.content).join(`
|
|
3
|
+
`);(M=navigator.clipboard)==null||M.writeText(E).catch(()=>{})},[t]),f=t.role==="user",y=i.Message;if(y)return e.jsx(y,{message:t,isStreaming:a,isLast:n,avatar:r,slots:i,onCopy:g,onRegenerate:d,onFeedback:l,showTimestamp:c});const b=i.TextPart??_e,S=i.ThinkingPart??Pe,h=i.ToolCallPart??Be,z=i.ToolResultPart??Oe,x=i.ErrorPart??We,v=i.ActionBar??Ue,N=!f&&t.parts.some(E=>E.type==="text"&&E.content);return e.jsxs("div",{className:`sa-message ${f?"sa-message-user":"sa-message-assistant"}`,children:[!f&&e.jsx(ze,{src:(r==null?void 0:r.assistant)||(a&&n?Y.assistantAvatarGenerating:Y.assistantAvatar),alt:"AI"}),e.jsxs("div",{className:"sa-message-content",children:[c&&e.jsx("span",{className:`sa-message-time ${f?"sa-message-time-right":""}`,children:xt(t.timestamp)}),e.jsxs("div",{className:"sa-message-body",children:[t.parts.map((E,M)=>{switch(E.type){case"text":return e.jsx(b,{content:E.content},M);case"attachment":return e.jsx(vt,{attachment:E.attachment},M);case"thinking":return e.jsx(S,{content:E.content},M);case"tool_call":return e.jsx(h,{toolName:E.toolName,toolCallId:E.toolCallId,args:E.args},M);case"tool_result":return e.jsx(z,{toolName:E.toolName,toolCallId:E.toolCallId,content:E.content,artifacts:E.artifacts,renderMode:E.renderMode,html:E.html,artifactPreview:o},M);case"error":return e.jsx(x,{content:E.content,onRetry:d},M);case"interrupt":return e.jsx(Ge,{interrupt:E.interrupt,resolved:E.resolved??!1,response:E.response,onRespond:I=>p(E.interrupt.interruptId,I)},M);default:return null}}),a&&n&&!f&&!N&&e.jsx("span",{className:"sa-thinking-indicator",children:"思考中…"}),!f&&!a&&N&&e.jsx(v,{message:t,onCopy:g,onRegenerate:n?d:void 0,onFeedback:l})]})]}),f&&(r==null?void 0:r.user)&&e.jsx(ze,{src:r.user,alt:"用户"})]})}function qe({message:t,suggestedPrompts:a,onPromptClick:n,capabilities:i,quickLinks:r,logo:o,openPanel:c}){const d=l=>{if(l.onClick){l.onClick();return}const p=l.action;if(!p){l.prompt&&n(l.prompt);return}c==null||c(p.type==="link"?p:{...p,title:p.title??l.label})};return e.jsxs("div",{className:"flex flex-col gap-8 py-2",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 opacity-0 animate-sa-home-fade-in",children:[e.jsx("img",{src:o||Y.logo,alt:"AI 助手",className:"block max-w-16 shrink-0 animate-sa-logo-float",draggable:!1}),e.jsx("h3",{className:"sa-shimmer-text m-0 mb-1 text-[18px] font-bold leading-[1.3] text-[#333] animate-sa-title-shimmer",children:t||"你好!有什么可以帮你的?"})]}),i&&i.length>0&&e.jsx("div",{className:"flex flex-col items-start gap-4 opacity-0 animate-sa-home-fade-in",style:{animationDelay:"150ms"},children:i.map(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,p)=>e.jsxs("button",{type:"button",className:"sa-chip inline-flex h-7 items-center gap-1 rounded-md px-3 text-[14px] leading-none text-[#333] opacity-0 transition-colors animate-sa-chip-in",style:{animationDelay:`${300+p*130}ms`},onClick:()=>n(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}-${p}`))}),r&&r.length>0&&e.jsxs("div",{className:"opacity-0 animate-sa-home-fade-in",style:{animationDelay:"420ms"},children:[e.jsx("div",{className:"mb-3 text-[14px] leading-none text-[#A0A0A0]",children:"快速查看"}),e.jsx("div",{className:"flex flex-wrap items-center gap-[22px]",children:r.map(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:()=>d(l),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 ce({slots:t,welcomeMessage:a,suggestedPrompts:n,avatar:i,artifactPreview:r,capabilities:o,quickLinks:c,logo:d,showTimestamp:l}){const{messages:p,status:g,sendMessage:f,openPanel:y}=X(),{containerRef:b}=Fe([p]),S=g==="streaming",h=t.WelcomeScreen??qe,z=t.AppendContainer;return p.length===0?e.jsxs("div",{className:"sa-thread",ref:b,children:[e.jsx(h,{message:a,suggestedPrompts:n,onPromptClick:f,capabilities:o,quickLinks:c,logo:d,openPanel:y}),z&&e.jsx(z,{openPanel:y})]}):e.jsx("div",{className:"sa-thread",ref:b,children:p.map((x,v)=>e.jsx(Xe,{message:x,isStreaming:S,isLast:v===p.length-1,slots:t,avatar:i,artifactPreview:r,showTimestamp:l},x.id))})}function Rt({items:t,activeIndex:a,onSelect:n}){const i=s.useRef(null);return s.useEffect(()=>{var o;const r=(o=i.current)==null?void 0:o.children[a];r==null||r.scrollIntoView({block:"nearest"})},[a]),t.length===0?e.jsx("div",{className:"sa-slash-menu",children:e.jsx("div",{className:"sa-slash-menu-empty",children:"没有匹配的技能"})}):e.jsx("div",{className:"sa-slash-menu",ref:i,children:t.map((r,o)=>e.jsxs("div",{className:`sa-slash-menu-item${o===a?" sa-slash-menu-item--active":""}`,onMouseDown:c=>{c.preventDefault(),n(r)},children:[e.jsxs("span",{className:"sa-slash-menu-item-name",children:["/",r.name]}),(r.displayName||r.description)&&e.jsx("span",{className:"sa-slash-menu-item-desc",children:r.displayName||r.description})]},r.code))})}function $t({sdk:t,input:a,onSelect:n}){const[i,r]=s.useState([]),[o,c]=s.useState(!1),[d,l]=s.useState(0),p=s.useRef(!1);s.useEffect(()=>{p.current||(p.current=!0,t.listSkills().then(r).catch(()=>r([])))},[t]);const g=/^\/\S*$/.test(a);s.useEffect(()=>{c(g)},[g]),s.useEffect(()=>{g&&l(0)},[a,g]);const f=a.startsWith("/")?a.slice(1).toLowerCase():"",y=s.useMemo(()=>i.filter(N=>!f||N.code.toLowerCase().includes(f)||N.name.toLowerCase().includes(f)||N.displayName&&N.displayName.toLowerCase().includes(f)),[i,f]),b=s.useRef(o),S=s.useRef(y),h=s.useRef(d),z=s.useRef(n);b.current=o,S.current=y,h.current=d,z.current=n;const x=s.useCallback(N=>{if(!b.current||S.current.length===0)return!1;switch(N.key){case"ArrowDown":return N.preventDefault(),l(E=>(E+1)%S.current.length),!0;case"ArrowUp":return N.preventDefault(),l(E=>(E-1+S.current.length)%S.current.length),!0;case"Enter":case"Tab":return N.preventDefault(),z.current(S.current[h.current]),c(!1),!0;case"Escape":return N.preventDefault(),c(!1),!0;default:return!1}},[]),v=s.useCallback(()=>c(!1),[]);return{isOpen:o,items:y,activeIndex:d,handleKeyDown:x,close:v}}const Lt=10;function Dt({size:t=16}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function de(){const{status:t,sendMessage:a,stop:n,sdk:i,attachmentUploader:r,nosUpload:o}=X(),[c,d]=s.useState(""),[l,p]=s.useState([]),g=s.useRef(null),f=s.useRef(null),y=!!r||!!o,b=t==="streaming"||t==="submitted",S=l.filter(u=>u.attachment),h=l.some(u=>!u.attachment&&u.status==="uploading"),z=!!c.trim()||l.length>0||b,x=!b&&!h&&(c.trim().length>0||S.length>0),v=s.useCallback(u=>{d(`/${u.name} `),setTimeout(()=>{const T=g.current;T&&(T.focus(),T.selectionStart=T.selectionEnd=T.value.length)},0)},[]),N=$t({sdk:i,input:c,onSelect:v}),E=s.useCallback(u=>{const T=Array.from(u.target.files??[]);if(u.target.value="",!y||T.length===0)return;const L=Lt-l.length,_=T.slice(0,Math.max(0,L));if(_.length===0)return;const j=_.map(m=>({key:`${m.name}_${m.size}_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,file:m,status:"uploading"}));p(m=>[...m,...j]);for(const{key:m,file:R}of j)(r||dt.createNosUploader({baseURL:o.baseURL,headers:o.headers,trunkSize:o.trunkSize,onProgress:$=>p(H=>H.map(C=>C.key===m?{...C,percent:$}:C))}))(R).then($=>{p(H=>H.map(C=>C.key===m?{...C,attachment:{...$,filename:$.filename||R.name,size:$.size??R.size,mime:$.mime??R.type}}:C))}).catch($=>{p(H=>H.map(C=>C.key===m?{...C,status:"error",errorMsg:$ instanceof Error?$.message:String($)}:C))})},[r,o,l]),M=s.useCallback(u=>{p(T=>T.filter(L=>L.key!==u))},[]),I=s.useCallback(()=>{if(!x)return;const u=c.trim(),T=S.map(L=>L.attachment);a(u,T.length>0?T:void 0),d(""),p([]),g.current&&(g.current.style.height="auto")},[x,c,S,a]),w=s.useCallback(u=>{N.handleKeyDown(u)||u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),I())},[I,N.handleKeyDown]),A=s.useCallback(u=>{d(u.target.value);const T=u.target;T.style.height="auto",T.style.height=Math.min(T.scrollHeight,90)+"px"},[]),D=s.useCallback(()=>{var u;b||(u=g.current)==null||u.focus()},[b]);return e.jsxs("div",{className:"relative z-[2] shrink-0 px-[15px] pb-2.5",children:[N.isOpen&&e.jsx(Rt,{items:N.items,activeIndex:N.activeIndex,onSelect:v}),e.jsxs("form",{className:`sa-input-form flex min-h-[70px] cursor-text items-start gap-2 rounded-[5px] p-2 ${z?"sa-input-form-active":""}`,onClick:D,onSubmit:u=>{u.preventDefault(),I()},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[l.length>0&&e.jsx("div",{className:"sa-attachment-tray",onClick:u=>u.stopPropagation(),children:l.map(u=>e.jsxs("span",{className:`sa-attachment-tray-chip ${u.status==="error"?"sa-attachment-tray-chip-error":""}`,title:u.status==="error"?`上传失败:${u.errorMsg??""}`:u.file.name,children:[e.jsx(F,{name:"file-text",size:13,color:u.status==="error"?"#ef4444":"#6366f1"}),e.jsx("span",{className:"sa-attachment-tray-chip-name",children:u.file.name}),e.jsx("span",{className:"sa-attachment-tray-chip-size",children:u.attachment?Ye(u.file.size):u.status==="error"?"失败":u.percent!=null?`${Math.min(99,Math.round(u.percent))}%`:"上传中…"}),e.jsx("button",{type:"button",className:"sa-attachment-tray-chip-remove","aria-label":`移除附件 ${u.file.name}`,onClick:()=>M(u.key),children:"✕"})]},u.key))}),e.jsxs("div",{className:"flex items-end gap-2",children:[y&&!b&&e.jsx("button",{type:"button",className:"sa-attach-btn","aria-label":"添加附件",title:"添加附件",onClick:()=>{var u;return(u=f.current)==null?void 0:u.click()},children:e.jsx(Dt,{size:15})}),e.jsx("input",{ref:f,type:"file",multiple:!0,className:"hidden",onChange:E,"aria-label":"选择附件"}),e.jsx("textarea",{ref:g,className:"sa-input-field min-h-[34px] flex-1 resize-none border-none bg-transparent p-0 text-[14px] leading-[1.5] text-[#333] outline-none placeholder:text-[#B8B8B8]",value:c,onChange:A,onKeyDown:w,placeholder:"请输入你想要了解的关键词",rows:1,disabled:b})]})]}),b?e.jsx("button",{type:"button",className:"sa-send-btn sa-send-btn-active","aria-label":"停止生成",title:"停止生成",onClick:n,children:e.jsx("span",{className:"sa-stop-icon"})}):e.jsx("button",{type:"submit",className:`sa-send-btn ${x?"sa-send-btn-active":""}`,"aria-label":"发送",title:"发送",disabled:!x,children:e.jsx("img",{src:Y.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 Ft({artifact:t}){const[a,n]=s.useState(null),[i,r]=s.useState(!0),[o,c]=s.useState(null);return s.useEffect(()=>{let d=!1;r(!0),c(null),n(null);async function l(){try{if(t.type==="pdf"){d||r(!1);return}if(t.type==="html"){const p=await fetch(t.url);if(!p.ok)throw new Error(`HTTP ${p.status}`);const g=await p.text(),f=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;d||(n(f.sanitize(g,{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 g=await p.arrayBuffer(),y=await(await Promise.resolve().then(()=>require("./mammoth.browser-BX8glWVC.cjs")).then(S=>S.mammoth_browser)).convertToHtml({arrayBuffer:g}),b=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;d||(n(b.sanitize(y.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),r(!1));return}d||(r(!1),c(`不支持预览「${t.type}」类型`))}catch(p){d||(r(!1),c(p instanceof Error?p.message:"加载失败"))}}return l(),()=>{d=!0}},[t]),i?e.jsx("div",{className:"sa-drawer-preview-loading",children:"加载中"}):o?e.jsxs("div",{className:"sa-drawer-preview-error",children:[o,e.jsx("button",{className:"sa-drawer-btn-sm",onClick:()=>void re(t),children:"下载查看"})]}):t.type==="pdf"?e.jsx("iframe",{src:t.url,title:t.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):a!==null?e.jsx("div",{className:"sa-drawer-preview-html-scroll",children:e.jsx("div",{className:"sa-drawer-preview-html sa-text-part",dangerouslySetInnerHTML:{__html:a}})}):null}function _t({artifacts:t,initialArtifact:a,onClose:n}){const[i,r]=s.useState(a?{mode:"preview",artifact:a}:{mode:"list"}),[o,c]=s.useState(!1),d=s.useRef(null),[l,p]=s.useState(340),g=s.useRef(null);s.useEffect(()=>{a&&(d.current&&(clearTimeout(d.current),d.current=null,c(!1)),r({mode:"preview",artifact:a}))},[a]);const f=s.useCallback(()=>{c(!0),d.current=setTimeout(()=>{d.current=null,n()},240)},[n]);s.useEffect(()=>()=>{var h;d.current&&clearTimeout(d.current),(h=g.current)==null||h.call(g)},[]);const y=s.useCallback(h=>{r({mode:"preview",artifact:h})},[]),b=s.useCallback(()=>{r({mode:"list"})},[]);s.useEffect(()=>{const h=z=>{z.key==="Escape"&&f()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[f]);const S=s.useCallback(h=>{h.preventDefault();const z=h.clientX,x=l,v=E=>{const M=z-E.clientX;p(Math.max(240,Math.min(window.innerWidth*.7,x+M)))},N=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",N),document.body.style.cursor="",document.body.style.userSelect="",g.current=null};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",v),document.addEventListener("mouseup",N),g.current=N},[l]);return e.jsxs("div",{className:`sa-artifact-drawer ${o?"sa-drawer-closing":""}`,style:{width:l},children:[e.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:S}),e.jsxs("div",{className:"sa-artifact-drawer-header",children:[i.mode==="preview"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"sa-drawer-btn",onClick:b,title:"返回列表","aria-label":"返回列表",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsx("span",{className:"sa-artifact-drawer-title",children:i.artifact.filename})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"sa-artifact-drawer-title",children:"会话产物"})]}),e.jsx("div",{style:{flex:1}}),i.mode==="preview"&&e.jsx("button",{className:"sa-drawer-btn",onClick:()=>void re(i.artifact),title:"下载","aria-label":"下载",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),e.jsx("button",{className:"sa-drawer-btn",onClick:f,title:"关闭","aria-label":"关闭",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"sa-artifact-drawer-body",children:i.mode==="list"?t.length===0?e.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):e.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:t.map((h,z)=>e.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>y(h),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),y(h))},tabIndex:0,role:"button","aria-label":`预览 ${h.filename}`,children:[e.jsx("div",{className:"sa-drawer-file-icon",children:e.jsx("span",{className:"sa-artifact-chip-type",children:Me(h.type)})}),e.jsxs("div",{className:"sa-drawer-file-info",children:[e.jsx("span",{className:"sa-drawer-file-name",children:h.filename}),e.jsx("span",{className:"sa-drawer-file-size",children:Ie(h.size)})]}),e.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${h.filename}`,onClick:x=>{x.stopPropagation(),re(h)},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"})})})]},h.id||`artifact-${z}`))}):e.jsx("div",{className:"sa-drawer-view-enter",children:e.jsx(Ft,{artifact:i.artifact})})})]})}function Ve({page:t,onBack:a,centered:n}){s.useEffect(()=>{const r=o=>{o.key==="Escape"&&a()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[a]);const i=s.isValidElement(t.component)?s.cloneElement(t.component,{close:a}):s.createElement(t.component,{close:a});return e.jsxs("div",{className:`sa-page-overlay ${n?"sa-page-overlay-centered":""}`,children:[e.jsxs("div",{className:"sa-page-overlay-bar",children:[e.jsx("button",{className:"sa-drawer-btn",onClick:a,title:"返回","aria-label":"返回",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),t.title&&e.jsx("span",{className:"sa-page-overlay-title",children:t.title})]}),e.jsx("div",{className:"sa-page-overlay-body",children:i})]})}const Ht="mx-auto w-full max-w-[800px]";function Ke({contentClassName:t,centered:a,composerClassName:n,thread:i,composer:r,artifactPreview:o}){const{activePanel:c,closePanel:d,messagesLoading:l,isArtifactDrawerOpen:p,allArtifacts:g,activePreviewArtifact:f,toggleArtifactDrawer:y}=X();if(c)return e.jsx(Ve,{page:c,onBack:d,centered:a});const b=a?Ht:"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`${t} ${b}`,children:[l?e.jsxs("div",{className:"sa-messages-loading",children:[e.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):i,o&&p&&e.jsx(_t,{artifacts:g,initialArtifact:f,onClose:y})]}),n?e.jsx("div",{className:`${n} ${b}`,children:r}):r]})}function Pt({isOpen:t,onClose:a,title:n,slots:i,welcomeMessage:r,suggestedPrompts:o,avatar:c,artifactPreview:d,capabilities:l,quickLinks:p,logo:g,defaultWidth:f,defaultHeight:y,showTimestamp:b}){const{status:S,sendMessage:h,stop:z,toggleThreadList:x,setThreadListOpen:v,isThreadListOpen:N,toggleArtifactDrawer:E,allArtifacts:M,activePanel:I,closePanel:w,messages:A,messagesLoading:D,conversations:u,activeConversationId:T,switchConversation:L,newConversation:_,deleteConversation:j,renameConversation:m,hasMore:R,loadMoreConversations:k}=X(),{width:$,position:H,hasCustomPosition:C,isMaximized:P,totalWidth:B,windowHeight:Z,startWindowDrag:at,startResize:rt,toggleMaximize:st,reset:pe,setLockedHeight:se}=ut({defaultWidth:f??W.DEFAULT_WIDTH,defaultHeight:y??W.DEFAULT_HEIGHT,sidebarWidth:0}),ue=s.useRef(null),ge=s.useRef(null),ne=!D&&A.length===0,J=!D&&A.length>0,Q=!!I;s.useEffect(()=>{t||(pe(),w())},[t,pe,w]),s.useEffect(()=>{v(P?ue.current??!0:ge.current??!1)},[P,v]),s.useEffect(()=>{J||se(null)},[J,se]);const nt=gt({enabled:t&&J&&!P&&!Q,contentSelector:".sa-panel-content",defaultHeight:y??W.DEFAULT_HEIGHT,onHeightChange:se});if(!t)return null;const fe=i.Header,xe=i.Composer,ee=i.ThreadList,it=()=>{const ae=!N;x(),P?ue.current=ae:ge.current=ae},he=200,me=N&&!P,G="var(--sa-radius, 16px)",we=me?`0px ${G} ${G} 0px`:`${G} ${G} ${G} ${G}`,ot=C?H.x:window.innerWidth-B-20,te=Math.min(he,Math.max(0,ot-1)),lt=C?{width:`${B}px`,height:`${Z}px`,left:`${H.x}px`,top:`${H.y}px`}:{width:`${B}px`,height:`${Z}px`,right:"20px",bottom:"20px"},be={title:n,onClose:a,onToggleThreadList:it,isMaximized:P,onToggleMaximize:st,showHome:J&&!Q,onHome:_,artifactCount:Q||!d?0:M.length,onToggleArtifactDrawer:Q||!d?void 0:E},ve={conversations:u,activeSessionId:T,onSwitch:L,onNew:_,onDelete:j,onRename:m,hasMore:R,onLoadMore:k},ye=e.jsxs("div",{className:`relative flex min-w-0 flex-col bg-white ${P?"flex-1":"h-full shrink-0"}`,style:P?void 0:{width:`${$}px`,borderRadius:we,overflow:"hidden"},children:[ne&&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 ${ne||P?"":"bg-white"} ${P?"cursor-default":"cursor-grab active:cursor-grabbing"}`,onMouseDown:P?void 0:at,children:fe?e.jsx(fe,{...be}):e.jsx(Le,{...be})}),e.jsx(Ke,{contentClassName:`sa-panel-content relative z-[2] ${ne?"sa-home-view":""}`,centered:P,composerClassName:"shrink-0",artifactPreview:d,thread:e.jsx(ce,{slots:i,welcomeMessage:r,suggestedPrompts:o,avatar:c,artifactPreview:d,capabilities:l,quickLinks:p,logo:g,showTimestamp:b}),composer:xe?e.jsx(xe,{status:S,onSend:h,onStop:z}):e.jsx(de,{})})]});return P?e.jsx("div",{className:"fixed inset-0 z-[var(--sa-z-index,9999)] flex animate-sa-fade-in flex-col justify-end bg-black/30",children:e.jsxs("div",{className:"flex h-[calc(100%_-_48px)] w-full animate-sa-slide-up-full flex-row overflow-hidden bg-[#F5F5F5] shadow-[0_-12px_48px_rgba(0,0,0,0.25)]",style:{borderRadius:"var(--sa-radius, 16px) var(--sa-radius, 16px) 0px 0px"},children:[N&&(ee?e.jsx(ee,{...ve}):e.jsx(le,{width:220})),ye]})}):e.jsxs("div",{ref:nt,className:"fixed z-[var(--sa-z-index,9999)] flex animate-sa-window-in flex-row overflow-visible border border-[#DADADA] bg-white shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{...lt,borderRadius:we},children:[e.jsx("div",{className:"sa-resize-handle absolute bottom-0 left-[-3px] top-0 z-20 w-[6px] cursor-col-resize",onMouseDown:ae=>rt(ae)}),me&&(ee?e.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{width:te,transform:`translateX(-${te}px)`,borderRadius:`${G} 0px 0px ${G}`},children:e.jsx(ee,{...ve})}):e.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] shadow-[0_12px_36px_rgba(0,0,0,0.18)]",style:{width:te,transform:`translateX(-${te}px)`,borderRadius:`${G} 0px 0px ${G}`},children:e.jsx(le,{width:he})})),ye]})}const Bt=()=>{};function Ot({conversations:t,activeSessionId:a,onSwitch:n,onNew:i,onDelete:r,onRename:o,isCollapsed:c,onToggleCollapse:d,hasMore:l,onLoadMore:p,conversationsLoading:g}){const[f,y]=s.useState(null),[b,S]=s.useState(null),[h,z]=s.useState(""),[x,v]=s.useState(null),N=s.useRef(null);s.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]);const E=s.useCallback((u,T)=>{T.stopPropagation(),f===u?(r(u),y(null)):(y(u),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>y(null),3e3))},[f,r]),M=s.useCallback((u,T,L)=>{L.stopPropagation(),S(u),z(T??"")},[]),I=s.useCallback(u=>{h.trim()&&o(u,h.trim()),S(null)},[h,o]),w=s.useRef(null),A=s.useCallback(()=>{const u=w.current;!u||!l||!p||u.scrollHeight-u.scrollTop-u.clientHeight<50&&p()},[l,p]),D=s.useMemo(()=>De(t),[t]);return c?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:d,children:e.jsx(F,{name:"panel-left",size:18})}),e.jsx("button",{type:"button",className:"sa-tip relative flex h-7 w-7 items-center justify-center rounded-md text-[#666] transition-colors hover:bg-white","data-tooltip":"新建对话",onClick:()=>{i(),d()},children:e.jsx("img",{src:Y.messageCreate,alt:"",width:18,height:18})})]}):e.jsxs("div",{className:"relative flex w-[220px] shrink-0 flex-col border-r border-[#ECECEC] bg-[#FAFAFA] p-3",children:[e.jsxs("div",{className:"mb-4 flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",className:"sa-new-chat flex h-8 flex-1 items-center justify-center gap-2 rounded-md text-[14px] font-medium transition-colors",onClick:i,children:[e.jsx("img",{src:Y.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:d,children:e.jsx(F,{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:A,children:[g&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!g&&t.length===0&&e.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),D.map(u=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:u.label}),u.items.map(T=>{const L=T.sessionId===a,_=f===T.sessionId;return e.jsx("div",{className:`group relative mb-0.5 flex h-8 w-full cursor-pointer items-center gap-1 rounded-md px-0.5 text-[13px] transition-colors ${L?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{b!==T.sessionId&&n(T.sessionId)},onMouseEnter:j=>{if(b===T.sessionId)return;const m=j.currentTarget.getBoundingClientRect();v({text:T.title||"新会话",x:m.right+8,y:m.top+m.height/2})},onMouseLeave:()=>v(null),children:b===T.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:h,onChange:j=>z(j.target.value),onBlur:()=>I(T.sessionId),onKeyDown:j=>{j.key==="Enter"&&I(T.sessionId),j.key==="Escape"&&S(null)},onClick:j=>j.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Y.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:T.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:j=>M(T.sessionId,T.title,j),title:"重命名",children:e.jsx(F,{name:"pen",size:12})}),e.jsx("button",{type:"button",className:`flex h-5 w-5 items-center justify-center rounded ${_?"bg-[#fee2e2] text-[#ef4444]":"text-[#999] hover:bg-white/70 hover:text-[#ef4444]"}`,onClick:j=>E(T.sessionId,j),title:_?"确认删除":"删除",children:e.jsx(F,{name:_?"x":"trash2",size:12})})]})]})},T.sessionId)})]},u.label)),l&&e.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),x&&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:x.x,top:x.y,transform:"translateY(-50%)"},children:x.text})]})}function Ze({title:t,slots:a,welcomeMessage:n,suggestedPrompts:i,capabilities:r,quickLinks:o,logo:c,sidebarDefaultOpen:d=!0,onClose:l,avatar:p,artifactPreview:g,showTimestamp:f}){const{status:y,sendMessage:b,stop:S,conversations:h,activeConversationId:z,switchConversation:x,newConversation:v,deleteConversation:N,renameConversation:E,toggleArtifactDrawer:M,allArtifacts:I,activePanel:w,closePanel:A,hasMore:D,loadMoreConversations:u,conversationsLoading:T}=X(),[L,_]=s.useState(d),j=s.useCallback(()=>_(H=>!H),[]),m=!!w;s.useEffect(()=>()=>A(),[A]);const R=a.ThreadList,k=a.Composer,$=a.Header;return e.jsxs("div",{className:"sa-fullpage",children:[R?e.jsx("div",{className:`sa-fp-sidebar-wrapper ${L?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:e.jsx(R,{conversations:h,activeSessionId:z,onSwitch:x,onNew:v,onDelete:N,onRename:E,hasMore:D,onLoadMore:u})}):e.jsx(Ot,{conversations:h,activeSessionId:z,onSwitch:x,onNew:v,onDelete:N,onRename:E,isCollapsed:!L,onToggleCollapse:j,hasMore:D,onLoadMore:u,conversationsLoading:T}),e.jsxs("div",{className:"sa-fp-main",children:[$?e.jsx($,{title:t,onClose:l??Bt,onToggleThreadList:j,artifactCount:m||!g?0:I.length,onToggleArtifactDrawer:m||!g?void 0:M}):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:!m&&g&&I.length>0&&e.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:M,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(Ke,{contentClassName:"sa-fp-content-row",artifactPreview:g,thread:e.jsx(ce,{slots:a,welcomeMessage:n,suggestedPrompts:i,capabilities:r,quickLinks:o,logo:c,avatar:p,artifactPreview:g,showTimestamp:f}),composer:k?e.jsx(k,{status:y,onSend:b,onStop:S}):e.jsx(de,{})})]})]})}function Je(t){const{sdk:a,mode:n="floating",slots:i={},hooks:r={},welcomeMessage:o,suggestedPrompts:c,title:d="AI Assistant",initialOpen:l=!1,onOpenChange:p,sidebarDefaultOpen:g,avatar:f,artifactPreview:y,capabilities:b,quickLinks:S,logo:h,triggerLogo:z,theme:x,showTimestamp:v,attachmentUploader:N,nosUpload:E}=t,[M,I]=s.useState(l);s.useEffect(()=>{I(l)},[l]);const w=s.useCallback(()=>{var T,L;const u=!M;I(u),p==null||p(u),u?(T=r.onOpen)==null||T.call(r):(L=r.onClose)==null||L.call(r)},[M,r,p]),A=s.useCallback(()=>{var u;I(!1),p==null||p(!1),(u=r.onClose)==null||u.call(r)},[r,p]),D=i.Trigger??$e;return n==="fullpage"?M?e.jsx(oe,{sdk:a,hooks:r,attachmentUploader:N,nosUpload:E,children:e.jsx(Ze,{title:d,slots:i,welcomeMessage:o,suggestedPrompts:c,capabilities:b,quickLinks:S,logo:h,sidebarDefaultOpen:g,onClose:A,avatar:f,artifactPreview:y,showTimestamp:v})}):null:e.jsxs(oe,{sdk:a,hooks:r,attachmentUploader:N,nosUpload:E,children:[e.jsx(D,{isOpen:M,onClick:w,triggerLogo:z}),e.jsx(Pt,{isOpen:M,onClose:A,title:d,slots:i,welcomeMessage:o,suggestedPrompts:c,avatar:f,artifactPreview:y,capabilities:b,quickLinks:S,logo:h,defaultWidth:x==null?void 0:x.panelWidth,defaultHeight:x==null?void 0:x.panelHeight,showTimestamp:v})]})}const Qe=`
|
|
4
4
|
[data-super-agent-widget] {
|
|
5
5
|
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
6
6
|
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|
|
@@ -18,16 +18,32 @@
|
|
|
18
18
|
text-rendering: optimizeLegibility;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/* 迷你 preflight(scoped):Tailwind preflight 已禁用(避免污染宿主页),
|
|
22
|
+
但 border 工具类只输出 border-width、无 border-style(CSS 初始值 none → 边框不渲染),
|
|
23
|
+
button/ul 也会吃到浏览器原生样式。此处补齐等价复位:
|
|
24
|
+
- 特异性 (0,1,0),低于 scoped utility (0,2,0),靠源顺序让位于后置的 sa-* plain 类
|
|
25
|
+
- 两条注入顺序固定为 widgetStyles + tailwindStyles(mount.ts),utility 恒在其后 */
|
|
21
26
|
[data-super-agent-widget] *,
|
|
22
27
|
[data-super-agent-widget] *::before,
|
|
23
28
|
[data-super-agent-widget] *::after {
|
|
24
29
|
box-sizing: border-box;
|
|
25
30
|
margin: 0;
|
|
26
31
|
padding: 0;
|
|
32
|
+
border-width: 0;
|
|
33
|
+
border-style: solid;
|
|
34
|
+
border-color: var(--sa-border, #e5e7eb);
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
/* :where() 零特异性贡献:plain-CSS 组件类(如 .sa-new-chat 的渐变底)不受影响 */
|
|
38
|
+
[data-super-agent-widget] :where(button) {
|
|
30
39
|
font-family: inherit;
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
background-image: none;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-super-agent-widget] :where(ul, ol) {
|
|
46
|
+
list-style: none;
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
/* ── Trigger / Panel / Header(浮窗框架已改用 Tailwind 实现,见 tailwind.css) ── */
|
|
@@ -978,26 +994,6 @@
|
|
|
978
994
|
padding: 24px 24px;
|
|
979
995
|
}
|
|
980
996
|
|
|
981
|
-
.sa-fp-main .sa-composer {
|
|
982
|
-
margin: 0 auto;
|
|
983
|
-
width: 100%;
|
|
984
|
-
padding: 12px 24px 20px;
|
|
985
|
-
border-top: none;
|
|
986
|
-
background: transparent;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
.sa-fp-main .sa-composer-input {
|
|
990
|
-
background: #f7f7f8;
|
|
991
|
-
border: 1px solid #e4e4e7;
|
|
992
|
-
box-shadow: none;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
.sa-fp-main .sa-composer-input:focus {
|
|
996
|
-
background: #fff;
|
|
997
|
-
border-color: #d4d4d8;
|
|
998
|
-
box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
997
|
/* ── Artifact file cards (in ToolResultPart) ── */
|
|
1002
998
|
.sa-artifact-file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
1003
999
|
.sa-artifact-file-card {
|
|
@@ -1083,7 +1079,8 @@
|
|
|
1083
1079
|
transition: background 0.15s ease, border-color 0.15s ease;
|
|
1084
1080
|
}
|
|
1085
1081
|
.sa-drawer-btn-sm:hover { background: var(--sa-surface); border-color: var(--sa-primary); }
|
|
1086
|
-
.sa-
|
|
1082
|
+
/* flex 列容器:让 .sa-drawer-view-enter(flex:1)与内层滚动/iframe 有真实高度链 */
|
|
1083
|
+
.sa-artifact-drawer-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
|
|
1087
1084
|
.sa-drawer-empty { padding: 48px 24px; text-align: center; color: var(--sa-text-muted); font-size: 14px; }
|
|
1088
1085
|
.sa-drawer-file-list { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
|
|
1089
1086
|
.sa-drawer-file-card {
|
|
@@ -1106,6 +1103,9 @@
|
|
|
1106
1103
|
|
|
1107
1104
|
/* ── Drawer preview ── */
|
|
1108
1105
|
.sa-drawer-preview-iframe { width: 100%; height: 100%; border: none; background: #fff; animation: sa-fade-in 0.3s ease both; }
|
|
1106
|
+
/* html/docx 内联预览:与消息流 ToolResultPart 一致(无 iframe) */
|
|
1107
|
+
.sa-drawer-preview-html-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px; background: #fff; animation: sa-fade-in 0.3s ease both; }
|
|
1108
|
+
.sa-drawer-preview-html { max-width: none; }
|
|
1109
1109
|
.sa-drawer-preview-loading {
|
|
1110
1110
|
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
1111
1111
|
height: 100%; gap: 12px; color: var(--sa-text-muted); font-size: 14px;
|
|
@@ -1122,7 +1122,9 @@
|
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
/* ── Drawer view transition ── */
|
|
1125
|
-
|
|
1125
|
+
/* flex 列 + flex:1 撑满 drawer body,让内层 .sa-drawer-preview-html-scroll 的
|
|
1126
|
+
flex:1/min-height:0 与 pdf iframe 的 height:100% 有真实高度链 */
|
|
1127
|
+
.sa-drawer-view-enter { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: sa-drawer-view-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
|
|
1126
1128
|
|
|
1127
1129
|
/* ── Layout helpers for drawer alongside thread ── */
|
|
1128
1130
|
.sa-panel-content { display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
@@ -1131,6 +1133,24 @@
|
|
|
1131
1133
|
.sa-fp-content-row { display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
1132
1134
|
.sa-fp-content-row .sa-thread { flex: 1; min-width: 0; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
|
|
1133
1135
|
|
|
1136
|
+
/* ── Page overlay(面板级整屏页面:替换内容区 + 输入区,Header 保留) ── */
|
|
1137
|
+
.sa-page-overlay {
|
|
1138
|
+
display: flex; flex-direction: column; flex: 1; min-height: 0;
|
|
1139
|
+
position: relative; z-index: 2; background: #fff; overflow: hidden;
|
|
1140
|
+
animation: sa-page-in 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
1141
|
+
}
|
|
1142
|
+
/* 大窗态与内容区/输入区一致的 800px 居中 */
|
|
1143
|
+
.sa-page-overlay-centered { width: 100%; max-width: 800px; margin: 0 auto; }
|
|
1144
|
+
.sa-page-overlay-bar {
|
|
1145
|
+
display: flex; align-items: center; gap: 8px; flex-shrink: 0;
|
|
1146
|
+
padding: 10px 14px; border-bottom: 1px solid var(--sa-border);
|
|
1147
|
+
background: var(--sa-surface); color: var(--sa-text);
|
|
1148
|
+
font-size: 15px; font-weight: 600;
|
|
1149
|
+
}
|
|
1150
|
+
.sa-page-overlay-back-label { font-size: 13px; font-weight: 400; }
|
|
1151
|
+
.sa-page-overlay-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1152
|
+
/* 滚动归 SDK,业务页不写滚动容器 */
|
|
1153
|
+
.sa-page-overlay-body { flex: 1; min-height: 0; overflow-y: auto; }
|
|
1134
1154
|
/* ── Artifact keyframes ── */
|
|
1135
1155
|
@keyframes sa-slide-in-right {
|
|
1136
1156
|
from { opacity: 0; transform: translateX(100%); }
|
|
@@ -1159,5 +1179,9 @@
|
|
|
1159
1179
|
from { opacity: 0; transform: translateX(12px); }
|
|
1160
1180
|
to { opacity: 1; transform: translateX(0); }
|
|
1161
1181
|
}
|
|
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
|
-
|
|
1182
|
+
@keyframes sa-page-in {
|
|
1183
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
1184
|
+
to { opacity: 1; transform: translateY(0); }
|
|
1185
|
+
}
|
|
1186
|
+
`,Wt='[data-super-agent-widget] .pointer-events-none{pointer-events:none}[data-super-agent-widget] .collapse{visibility:collapse}[data-super-agent-widget] .fixed{position:fixed}[data-super-agent-widget] .absolute{position:absolute}[data-super-agent-widget] .relative{position:relative}[data-super-agent-widget] .inset-0{top:0;right:0;bottom:0;left:0}[data-super-agent-widget] .inset-x-0{left:0;right:0}[data-super-agent-widget] .-bottom-px{bottom:-1px}[data-super-agent-widget] .-left-px{left:-1px}[data-super-agent-widget] .-right-2{right:-.5rem}[data-super-agent-widget] .-top-1\\.5{top:-.375rem}[data-super-agent-widget] .-top-px{top:-1px}[data-super-agent-widget] .bottom-0{bottom:0}[data-super-agent-widget] .left-\\[-3px\\]{left:-3px}[data-super-agent-widget] .top-0{top:0}[data-super-agent-widget] .z-0{z-index:0}[data-super-agent-widget] .z-10{z-index:10}[data-super-agent-widget] .z-20{z-index:20}[data-super-agent-widget] .z-\\[10000\\]{z-index:10000}[data-super-agent-widget] .z-\\[10001\\]{z-index:10001}[data-super-agent-widget] .z-\\[1\\]{z-index:1}[data-super-agent-widget] .z-\\[2\\]{z-index:2}[data-super-agent-widget] .z-\\[5\\]{z-index:5}[data-super-agent-widget] .z-\\[var\\(--sa-z-index\\,9999\\)\\]{z-index:var(--sa-z-index,9999)}[data-super-agent-widget] .m-0{margin:0}[data-super-agent-widget] .mx-auto{margin-left:auto;margin-right:auto}[data-super-agent-widget] .mb-0\\.5{margin-bottom:.125rem}[data-super-agent-widget] .mb-1{margin-bottom:.25rem}[data-super-agent-widget] .mb-3{margin-bottom:.75rem}[data-super-agent-widget] .mb-4{margin-bottom:1rem}[data-super-agent-widget] .mt-3{margin-top:.75rem}[data-super-agent-widget] .block{display:block}[data-super-agent-widget] .inline{display:inline}[data-super-agent-widget] .flex{display:flex}[data-super-agent-widget] .inline-flex{display:inline-flex}[data-super-agent-widget] .table{display:table}[data-super-agent-widget] .hidden{display:none}[data-super-agent-widget] .h-5{height:1.25rem}[data-super-agent-widget] .h-7{height:1.75rem}[data-super-agent-widget] .h-8{height:2rem}[data-super-agent-widget] .h-9{height:2.25rem}[data-super-agent-widget] .h-\\[13px\\]{height:13px}[data-super-agent-widget] .h-\\[18px\\]{height:18px}[data-super-agent-widget] .h-\\[238px\\]{height:238px}[data-super-agent-widget] .h-\\[calc\\(100\\%_-_48px\\)\\]{height:calc(100% - 48px)}[data-super-agent-widget] .h-full{height:100%}[data-super-agent-widget] .min-h-\\[34px\\]{min-height:34px}[data-super-agent-widget] .min-h-\\[70px\\]{min-height:70px}[data-super-agent-widget] .w-12{width:3rem}[data-super-agent-widget] .w-5{width:1.25rem}[data-super-agent-widget] .w-7{width:1.75rem}[data-super-agent-widget] .w-\\[18px\\]{width:18px}[data-super-agent-widget] .w-\\[220px\\]{width:220px}[data-super-agent-widget] .w-\\[6px\\]{width:6px}[data-super-agent-widget] .w-full{width:100%}[data-super-agent-widget] .w-px{width:1px}[data-super-agent-widget] .min-w-0{min-width:0px}[data-super-agent-widget] .min-w-\\[14px\\]{min-width:14px}[data-super-agent-widget] .max-w-16{max-width:4rem}[data-super-agent-widget] .max-w-\\[800px\\]{max-width:800px}[data-super-agent-widget] .max-w-full{max-width:100%}[data-super-agent-widget] .flex-1{flex:1 1 0%}[data-super-agent-widget] .flex-shrink{flex-shrink:1}[data-super-agent-widget] .shrink-0{flex-shrink:0}[data-super-agent-widget] .border-collapse{border-collapse:collapse}[data-super-agent-widget] .scale-50{--tw-scale-x: .5;--tw-scale-y: .5;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}[data-super-agent-widget] .cursor-col-resize{cursor:col-resize}[data-super-agent-widget] .cursor-default{cursor:default}[data-super-agent-widget] .cursor-grab{cursor:grab}[data-super-agent-widget] .cursor-pointer{cursor:pointer}[data-super-agent-widget] .cursor-text{cursor:text}[data-super-agent-widget] .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}[data-super-agent-widget] .resize-none{resize:none}[data-super-agent-widget] .resize{resize:both}[data-super-agent-widget] .flex-row{flex-direction:row}[data-super-agent-widget] .flex-col{flex-direction:column}[data-super-agent-widget] .flex-wrap{flex-wrap:wrap}[data-super-agent-widget] .items-start{align-items:flex-start}[data-super-agent-widget] .items-end{align-items:flex-end}[data-super-agent-widget] .items-center{align-items:center}[data-super-agent-widget] .justify-end{justify-content:flex-end}[data-super-agent-widget] .justify-center{justify-content:center}[data-super-agent-widget] .justify-between{justify-content:space-between}[data-super-agent-widget] .gap-0\\.5{gap:.125rem}[data-super-agent-widget] .gap-1{gap:.25rem}[data-super-agent-widget] .gap-1\\.5{gap:.375rem}[data-super-agent-widget] .gap-2{gap:.5rem}[data-super-agent-widget] .gap-2\\.5{gap:.625rem}[data-super-agent-widget] .gap-3{gap:.75rem}[data-super-agent-widget] .gap-4{gap:1rem}[data-super-agent-widget] .gap-8{gap:2rem}[data-super-agent-widget] .gap-\\[22px\\]{gap:22px}[data-super-agent-widget] .gap-\\[7px\\]{gap:7px}[data-super-agent-widget] .overflow-hidden{overflow:hidden}[data-super-agent-widget] .overflow-visible{overflow:visible}[data-super-agent-widget] .overflow-y-auto{overflow-y:auto}[data-super-agent-widget] .text-ellipsis{text-overflow:ellipsis}[data-super-agent-widget] .whitespace-nowrap{white-space:nowrap}[data-super-agent-widget] .rounded{border-radius:.25rem}[data-super-agent-widget] .rounded-\\[5px\\]{border-radius:5px}[data-super-agent-widget] .rounded-full{border-radius:9999px}[data-super-agent-widget] .rounded-md{border-radius:.375rem}[data-super-agent-widget] .border{border-width:1px}[data-super-agent-widget] .border-r{border-right-width:1px}[data-super-agent-widget] .border-r-0{border-right-width:0px}[data-super-agent-widget] .border-none{border-style:none}[data-super-agent-widget] .border-\\[\\#DADADA\\]{--tw-border-opacity: 1;border-color:rgb(218 218 218 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[\\#E8E8E8\\]{--tw-border-opacity: 1;border-color:rgb(232 232 232 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[\\#ECECEC\\]{--tw-border-opacity: 1;border-color:rgb(236 236 236 / var(--tw-border-opacity, 1))}[data-super-agent-widget] .border-\\[var\\(--sa-primary\\)\\]{border-color:var(--sa-primary)}[data-super-agent-widget] .bg-\\[\\#DCDCDC\\]{--tw-bg-opacity: 1;background-color:rgb(220 220 220 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#E8F1FE\\]{--tw-bg-opacity: 1;background-color:rgb(232 241 254 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#F5F5F5\\]{--tw-bg-opacity: 1;background-color:rgb(245 245 245 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#FAFAFA\\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[\\#fee2e2\\]{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .bg-\\[var\\(--sa-primary\\)\\]{background-color:var(--sa-primary)}[data-super-agent-widget] .bg-black\\/30{background-color:#0000004d}[data-super-agent-widget] .bg-transparent{background-color:transparent}[data-super-agent-widget] .bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}[data-super-agent-widget] .object-contain{-o-object-fit:contain;object-fit:contain}[data-super-agent-widget] .p-0{padding:0}[data-super-agent-widget] .p-2{padding:.5rem}[data-super-agent-widget] .p-3{padding:.75rem}[data-super-agent-widget] .px-0\\.5{padding-left:.125rem;padding-right:.125rem}[data-super-agent-widget] .px-1{padding-left:.25rem;padding-right:.25rem}[data-super-agent-widget] .px-1\\.5{padding-left:.375rem;padding-right:.375rem}[data-super-agent-widget] .px-2\\.5{padding-left:.625rem;padding-right:.625rem}[data-super-agent-widget] .px-3{padding-left:.75rem;padding-right:.75rem}[data-super-agent-widget] .px-\\[15px\\]{padding-left:15px;padding-right:15px}[data-super-agent-widget] .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}[data-super-agent-widget] .py-1{padding-top:.25rem;padding-bottom:.25rem}[data-super-agent-widget] .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}[data-super-agent-widget] .py-2{padding-top:.5rem;padding-bottom:.5rem}[data-super-agent-widget] .py-3{padding-top:.75rem;padding-bottom:.75rem}[data-super-agent-widget] .pb-1{padding-bottom:.25rem}[data-super-agent-widget] .pb-2\\.5{padding-bottom:.625rem}[data-super-agent-widget] .pt-2{padding-top:.5rem}[data-super-agent-widget] .text-left{text-align:left}[data-super-agent-widget] .text-center{text-align:center}[data-super-agent-widget] .text-\\[11px\\]{font-size:11px}[data-super-agent-widget] .text-\\[12px\\]{font-size:12px}[data-super-agent-widget] .text-\\[13px\\]{font-size:13px}[data-super-agent-widget] .text-\\[14px\\]{font-size:14px}[data-super-agent-widget] .text-\\[18px\\]{font-size:18px}[data-super-agent-widget] .text-\\[9px\\]{font-size:9px}[data-super-agent-widget] .font-bold{font-weight:700}[data-super-agent-widget] .font-medium{font-weight:500}[data-super-agent-widget] .font-semibold{font-weight:600}[data-super-agent-widget] .italic{font-style:italic}[data-super-agent-widget] .leading-\\[1\\.3\\]{line-height:1.3}[data-super-agent-widget] .leading-\\[1\\.4\\]{line-height:1.4}[data-super-agent-widget] .leading-\\[1\\.5\\]{line-height:1.5}[data-super-agent-widget] .leading-\\[14px\\]{line-height:14px}[data-super-agent-widget] .leading-none{line-height:1}[data-super-agent-widget] .text-\\[\\#333\\]{--tw-text-opacity: 1;color:rgb(51 51 51 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#666\\]{--tw-text-opacity: 1;color:rgb(102 102 102 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#999\\]{--tw-text-opacity: 1;color:rgb(153 153 153 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#9A9A9A\\]{--tw-text-opacity: 1;color:rgb(154 154 154 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#A0A0A0\\]{--tw-text-opacity: 1;color:rgb(160 160 160 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#B8B8B8\\]{--tw-text-opacity: 1;color:rgb(184 184 184 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#C0C0C0\\]{--tw-text-opacity: 1;color:rgb(192 192 192 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-\\[\\#ef4444\\]{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}[data-super-agent-widget] .underline{text-decoration-line:underline}[data-super-agent-widget] .antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[data-super-agent-widget] .opacity-0{opacity:0}[data-super-agent-widget] .opacity-10{opacity:.1}[data-super-agent-widget] .opacity-100{opacity:1}[data-super-agent-widget] .opacity-60{opacity:.6}[data-super-agent-widget] .opacity-70{opacity:.7}[data-super-agent-widget] .shadow-\\[0_-12px_48px_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 -12px 48px rgba(0,0,0,.25);--tw-shadow-colored: 0 -12px 48px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .shadow-\\[0_12px_36px_rgba\\(0\\,0\\,0\\,0\\.18\\)\\]{--tw-shadow: 0 12px 36px rgba(0,0,0,.18);--tw-shadow-colored: 0 12px 36px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .shadow-\\[0_2px_8px_rgba\\(0\\,0\\,0\\,0\\.12\\)\\]{--tw-shadow: 0 2px 8px rgba(0,0,0,.12);--tw-shadow-colored: 0 2px 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}[data-super-agent-widget] .outline-none{outline:2px solid transparent;outline-offset:2px}[data-super-agent-widget] .outline{outline-style:solid}[data-super-agent-widget] .blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}[data-super-agent-widget] .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}[data-super-agent-widget] .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}[data-super-agent-widget] .duration-200{transition-duration:.2s}[data-super-agent-widget] .ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}[data-super-agent-widget] .ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes sa-window-in{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes sa-slide-up-full{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes sa-home-fade-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}@keyframes sa-chip-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes sa-logo-float{0%,to{transform:translateY(0)}50%{transform:translateY(-3px)}}@keyframes sa-title-shimmer{0%{background-position:100% 0}to{background-position:-100% 0}}@keyframes sa-history-in{0%{opacity:0;transform:translate(-10px)}to{opacity:1;transform:translate(0)}}[data-super-agent-widget] .animate-sa-window-in{animation:sa-window-in .3s cubic-bezier(.16,1,.3,1)}[data-super-agent-widget] .animate-sa-slide-up-full{animation:sa-slide-up-full .3s cubic-bezier(.16,1,.3,1)}[data-super-agent-widget] .animate-sa-fade-in{animation:sa-fade-in .2s ease}[data-super-agent-widget] .animate-sa-home-fade-in{animation:sa-home-fade-in .4s ease forwards}[data-super-agent-widget] .animate-sa-chip-in{animation:sa-chip-in .4s cubic-bezier(.22,1,.36,1) forwards}[data-super-agent-widget] .animate-sa-logo-float{animation:sa-logo-float 3s ease-in-out infinite}[data-super-agent-widget] .animate-sa-title-shimmer{animation:sa-title-shimmer 2.5s ease forwards}[data-super-agent-widget] .animate-sa-history-in{animation:sa-history-in .2s ease}[data-super-agent-widget] .sa-tip{position:relative}[data-super-agent-widget] .sa-tip:before,[data-super-agent-widget] .sa-tip:after{position:absolute;top:100%;left:50%;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:100}[data-super-agent-widget] .sa-tip:before{content:attr(data-tooltip);transform:translate(-50%);margin-top:6px;padding:4px 8px;background:#fff;color:#333;font-size:12px;line-height:1.4;white-space:nowrap;border-radius:4px;box-shadow:0 2px 8px #0000001f;border:1px solid #e8e8e8}[data-super-agent-widget] .sa-tip:after{content:"";transform:translate(-50%);margin-top:2px;border:4px solid transparent;border-bottom-color:#fff;filter:drop-shadow(0 -1px 1px rgba(0,0,0,.06))}[data-super-agent-widget] .sa-tip:hover:before,[data-super-agent-widget] .sa-tip:hover:after{opacity:1}[data-super-agent-widget] .sa-chip{background:linear-gradient(#fff,#fff) padding-box,linear-gradient(#e0e0e0,#e0e0e0) border-box;border:1px solid transparent}[data-super-agent-widget] .sa-chip:hover{background:linear-gradient(#fff,#fff) padding-box,linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7) border-box}[data-super-agent-widget] .sa-chip:hover .sa-chip-text{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-shimmer-text{background:linear-gradient(90deg,#333,#333 35%,#00d4ff 40%,#1881f0,#2b52ee,#d116ea,#ff2e7e 56%,#333 61%,#333);background-size:300% 100%;background-position:100% 0;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-new-chat{background:linear-gradient(258deg,#ff2e7e1a -4%,#d116ea1a 16%,#2b52ee1a 53%,#1881f01a 81%,#00d4ff1a 106%)}[data-super-agent-widget] .sa-new-chat:hover{background:linear-gradient(258deg,#ff2e7e29 -4%,#d116ea29 16%,#2b52ee29 53%,#1881f029 81%,#00d4ff29 106%)}[data-super-agent-widget] .sa-new-chat .sa-new-chat-text{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}[data-super-agent-widget] .sa-home-gradient{background:linear-gradient(239deg,#ff2e7e -3%,#d116ea 17%,#2b52ee 54%,#1881f0 82%,#00d4ff 107%)}[data-super-agent-widget] .sa-home-gradient-fade{background:linear-gradient(180deg,#fff0,#fff)}[data-super-agent-widget] .sa-home-view .sa-thread{background:transparent}[data-super-agent-widget] .sa-resize-handle:hover{background:color-mix(in srgb,var(--sa-primary) 30%,transparent)}[data-super-agent-widget] .sa-input-form{border:1px solid transparent;background-color:#fff;background-image:linear-gradient(#fff,#fff),linear-gradient(110deg,#03b5ff80,#285cff80 47%,#ff28a780);background-origin:border-box;background-clip:padding-box,border-box;transition:background .15s ease}[data-super-agent-widget] .sa-input-form-active,[data-super-agent-widget] .sa-input-form:focus-within{background-image:linear-gradient(#fff,#fff),linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7)}[data-super-agent-widget] .sa-send-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border:none;border-radius:9999px;background:linear-gradient(110deg,#03b5ff80,#285cff80 47%,#ff28a780);cursor:pointer;flex-shrink:0;align-self:flex-end;transition:background .15s ease,opacity .15s ease}[data-super-agent-widget] .sa-send-btn-active,[data-super-agent-widget] .sa-input-form:focus-within .sa-send-btn{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7)}[data-super-agent-widget] .sa-send-btn:hover{opacity:.9}[data-super-agent-widget] .sa-send-btn:active{opacity:.7}[data-super-agent-widget] .sa-send-btn img{display:block;width:14px;height:14px;filter:brightness(0) invert(1)}[data-super-agent-widget] .sa-stop-icon{display:block;width:8px;height:8px;border-radius:2px;background:#fff}[data-super-agent-widget] .sa-attach-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);color:#fff;cursor:pointer;flex-shrink:0;align-self:flex-end;transition:background .15s ease,opacity .15s ease}[data-super-agent-widget] .sa-attach-btn:hover{background:linear-gradient(110deg,#03b5ff,#285cff 47%,#ff28a7);opacity:.9}[data-super-agent-widget] .sa-attach-btn:active{opacity:.7}[data-super-agent-widget] .sa-attachment-tray{display:flex;flex-wrap:wrap;gap:6px;padding:2px 0}[data-super-agent-widget] .sa-attachment-tray-chip{display:inline-flex;align-items:center;gap:4px;max-width:220px;padding:4px 8px;border:1px solid rgba(40,92,255,.25);border-radius:6px;background:#285cff0d;font-size:12px;line-height:1;color:#333}[data-super-agent-widget] .sa-attachment-tray-chip-error{border-color:#ef444459;background:#ef44440f}[data-super-agent-widget] .sa-attachment-tray-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}[data-super-agent-widget] .sa-attachment-tray-chip-size{color:#b8b8b8;flex-shrink:0}[data-super-agent-widget] .sa-attachment-tray-chip-remove{display:flex;align-items:center;justify-content:center;width:14px;height:14px;border:none;border-radius:9999px;background:transparent;color:#b8b8b8;font-size:10px;line-height:1;cursor:pointer;flex-shrink:0;padding:0}[data-super-agent-widget] .sa-attachment-tray-chip-remove:hover{background:#00000014;color:#666}[data-super-agent-widget] .sa-attachment-chip{display:inline-flex;align-items:center;gap:4px;max-width:240px;margin:2px 0;padding:5px 10px;border-radius:8px;background:#ffffff59;font-size:12px;line-height:1;color:inherit}[data-super-agent-widget] .sa-attachment-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}[data-super-agent-widget] .sa-attachment-chip-size{color:#00000073;flex-shrink:0}[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}',et={primaryColor:"#6366f1",backgroundColor:"#ffffff",fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:16,panelWidth:400,panelHeight:648,zIndex:9999};function Yt(t,a){const n=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16),o=1-a;return`#${Math.round(n*o).toString(16).padStart(2,"0")}${Math.round(i*o).toString(16).padStart(2,"0")}${Math.round(r*o).toString(16).padStart(2,"0")}`}function Gt(t,a){const n=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16);return`#${Math.round(n+(255-n)*a).toString(16).padStart(2,"0")}${Math.round(i+(255-i)*a).toString(16).padStart(2,"0")}${Math.round(r+(255-r)*a).toString(16).padStart(2,"0")}`}function tt(t){const a={...et,...t},n=a.primaryColor,i=a.backgroundColor;return[`--sa-primary: ${n}`,`--sa-bg: ${i}`,`--sa-font: ${a.fontFamily}`,`--sa-radius: ${a.borderRadius}px`,`--sa-panel-width: ${a.panelWidth}px`,`--sa-panel-height: ${a.panelHeight}px`,`--sa-z-index: ${a.zIndex}`,`--sa-primary-dark: ${Yt(n,.15)}`,`--sa-primary-light: ${Gt(n,.9)}`,`--sa-surface: ${i}`,"--sa-border: #e5e7eb","--sa-hover: #f4f4f5","--sa-text: #374151","--sa-text-muted: #9ca3af","--sa-text-light: #6b7280"].join("; ")}function Ut(t,a){const n=typeof t=="string"?document.querySelector(t):t;if(!n)throw new Error(`Target element not found: ${t}`);const i=document.createElement("div");i.setAttribute("data-super-agent-widget","");const r=tt(a.theme??{});if(i.setAttribute("style",`${r}; height: 100%;`),n.appendChild(i),!document.getElementById("sa-widget-styles")){const l=document.createElement("style");l.id="sa-widget-styles",l.textContent=`${Qe}
|
|
1187
|
+
${Wt}`,document.head.appendChild(l)}let o=ct.createRoot(i),c=!1;const d=l=>{o&&o.render(s.createElement(Je,{...a,initialOpen:l??c,onOpenChange:p=>{c=p}}))};return d(!1),{open(){c=!0,d(!0)},close(){c=!1,d(!1)},destroy(){o&&(o.unmount(),o=null),i.remove()}}}exports.ASSETS=Y;exports.ActionBar=Ue;exports.ChatProvider=oe;exports.ChatWidget=Je;exports.Composer=de;exports.ErrorPart=We;exports.FullpageLayout=Ze;exports.Header=Le;exports.Icon=F;exports.InterruptCard=Ge;exports.Message=Xe;exports.PageOverlay=Ve;exports.TextPart=_e;exports.ThinkingPart=Pe;exports.Thread=ce;exports.ThreadList=le;exports.ToolCallPart=Be;exports.ToolResultPart=Oe;exports.Trigger=$e;exports.WelcomeScreen=qe;exports.defaultTheme=et;exports.ensureIconFont=He;exports.mount=Ut;exports.themeToCSSVars=tt;exports.useAutoScroll=Fe;exports.useChat=Se;exports.useChatContext=X;exports.useConversations=Te;exports.widgetStyles=Qe;
|