super-agent-sdk 1.0.19 → 1.0.20
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 +30 -26
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +166 -161
- package/dist/{mammoth.browser-ClkRBm1A.cjs → mammoth.browser-CxQENq5Q.cjs} +1 -1
- package/dist/{mammoth.browser-BmR8YfeV.js → mammoth.browser-xkqZbK20.js} +1 -1
- package/dist/{nosUploader-CgVOa1Lz.cjs → nosUploader-DLX7JsnR.cjs} +5 -5
- package/dist/{nosUploader-CnYDALPr.js → nosUploader-DjJ7u2B1.js} +137 -137
- package/dist/widget.cjs +2 -2
- package/dist/widget.d.ts +3 -4
- package/dist/widget.mjs +5 -4
- package/package.json +1 -1
package/dist/widget.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),wa=require("react-dom/client"),d=require("react/jsx-runtime"),Me=require("./nosUploader-CgVOa1Lz.cjs");function Rr(e){const{sdk:t,sessionId:n,onSessionCreated:r,onRoundStart:i,onStreamStart:s,onStreamEnd:a,onError:o,onMessageSend:l}=e,[u,p]=y.useState([]),[c,h]=y.useState("ready"),[f,m]=y.useState(null),w=y.useRef(new Map),C=y.useRef(new Map),b=y.useRef(n),S=y.useRef(!0),j=y.useRef(u);b.current=n,S.current=u.length===0,j.current=u;const L=y.useCallback((T,E)=>{if(T===b.current)p(I=>{const F=C.current.get(T)??I,q=E(F);return C.current.set(T,q),q});else{const I=C.current.get(T)??[];C.current.set(T,E(I))}},[]),A=y.useCallback((T,E)=>{const I=w.current.get(T);I!=null&&I.stopTimer&&(clearTimeout(I.stopTimer),I.stopTimer=null),w.current.delete(T),C.current.delete(T),T===b.current&&h(E)},[]);y.useEffect(()=>{const T=n?w.current.get(n):void 0;h(T!=null&&T.busy?"streaming":"ready")},[n]);const k=y.useCallback((T,E)=>{var H;const I=b.current;if(I&&((H=w.current.get(I))!=null&&H.busy))return;l==null||l(T);const F={id:`user_${Date.now()}`,role:"user",parts:[...(E??[]).map($=>({type:"attachment",attachment:$})),{type:"text",content:T}],timestamp:Date.now()},q=`assistant_${Date.now()}`,U={id:q,role:"assistant",parts:[],timestamp:Date.now()},P=S.current,B=j.current;p($=>[...$,F,U]),I&&C.current.set(I,[...B,F,U]),h("submitted"),m(null);const x=$=>{let g="",Y="",te=[],ee=!1;C.current.has($)||C.current.set($,[...B,F,U]);const ue={abortController:null,busy:!0,stopTimer:null};w.current.set($,ue);const ae=()=>{const W=[...te];if(g){const se=W.findIndex(le=>le.type==="thinking");se>=0?W[se]={type:"thinking",content:g}:W.unshift({type:"thinking",content:g})}if(Y){const se=W[W.length-1];(se==null?void 0:se.type)==="text"?W[W.length-1]={type:"text",content:Y}:W.push({type:"text",content:Y})}L($,se=>se.map(le=>le.id===q?{...le,parts:W}:le))};ue.abortController=t.chat({sessionId:$,message:T,attachments:E&&E.length>0?E:void 0,stream:!0,onMessage:W=>{switch(ee||(ee=!0,$===b.current&&h("streaming")),W.type){case"session.start":W.roundId&&(i==null||i(W.roundId));break;case"thinking":g+=W.content;break;case"ai":Y+=W.content;break;case"tool_call":Y&&(te.push({type:"text",content:Y}),Y=""),te.push({type:"tool_call",toolName:W.toolName,toolCallId:W.toolCallId,args:W.args??"{}"});break;case"tool_result":Y&&(te.push({type:"text",content:Y}),Y=""),te.push({type:"tool_result",toolName:W.toolName??"",toolCallId:W.toolCallId,content:W.content,artifacts:W.artifacts,renderMode:W.renderMode,html:W.html,markdown:W.markdown});break;case"interrupt":Y&&(te.push({type:"text",content:Y}),Y=""),W.interrupt&&te.push({type:"interrupt",interrupt:W.interrupt,resolved:!1}),ae(),A($,"ready");return;case"stop":W.content&&(Y=W.content),ae();return}ae()},onDone:W=>{if((Y||te.length>0||g)&&ae(),W.artifacts&&W.artifacts.length>0){const le=W.artifacts;L($,Ee=>Ee.map(be=>be.id===q?{...be,artifacts:le}:be))}const se=()=>{A($,"ready"),a==null||a(W.sessionId||$)};if(P){const le=T.slice(0,30),Ee=W.sessionId||$;t.renameConversation(Ee,le).catch(()=>{}).finally(se)}else se()},onError:W=>{te.push({type:"error",content:W.message}),ae(),$===b.current&&(m(W),h("error")),o==null||o(W),A($,"error")}}),s==null||s($)};I?x(I):t.createSession().then($=>{b.current==null&&(b.current=$,r==null||r($)),x($)}).catch($=>{b.current==null&&(m($ instanceof Error?$:new Error(String($))),h("error")),o==null||o($ instanceof Error?$:new Error(String($)))})},[t,r,s,a,o,l,L,A]),N=y.useCallback(()=>{const T=b.current;if(!T)return;const E=w.current.get(T);E!=null&&E.busy&&(E.stopTimer&&clearTimeout(E.stopTimer),E.stopTimer=setTimeout(()=>{var I;E.stopTimer=null,(I=E.abortController)==null||I.abort(),A(T,"ready")},8e3),t.stopGeneration(T).catch(()=>{}))},[t,A]),_=y.useCallback(()=>{var q;const T=b.current;if(T&&((q=w.current.get(T))!=null&&q.busy))return;const E=u.findLastIndex(U=>U.role==="user");if(E<0)return;const I=u[E].parts.filter(U=>U.type==="text").map(U=>U.content).join(""),F=u[E].parts.filter(U=>U.type==="attachment").map(U=>U.attachment);p(U=>U.slice(0,E)),k(I,F.length>0?F:void 0)},[u,k]),O=y.useCallback((T,E)=>{var $;const I=b.current;if(!I||($=w.current.get(I))!=null&&$.busy)return;L(I,g=>g.map(Y=>({...Y,parts:Y.parts.map(te=>te.type==="interrupt"&&te.interrupt.interruptId===T?{...te,resolved:!0,response:E}:te)})));const F={abortController:null,busy:!0,stopTimer:null};w.current.set(I,F);const q=new AbortController;F.abortController=q;let U=0;L(I,g=>g.length>0&&g[g.length-1].role==="assistant"?(U=g[g.length-1].parts.length,g):(U=0,[...g,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),h("streaming");let P="",B="",x=[];const H=()=>{const g=[...x];if(P){const Y=g.findIndex(te=>te.type==="thinking");Y>=0?g[Y]={type:"thinking",content:P}:g.unshift({type:"thinking",content:P})}if(B){const Y=g[g.length-1];(Y==null?void 0:Y.type)==="text"?g[g.length-1]={type:"text",content:B}:g.push({type:"text",content:B})}L(I,Y=>{const te=Y.findLastIndex(ee=>ee.role==="assistant");return te<0?Y:Y.map((ee,ue)=>ue===te?{...ee,parts:[...ee.parts.slice(0,U),...g]}:ee)})};t.respondInterrupt(T,I,E,g=>{let Y=!1;switch(g.type){case"thinking":P+=g.content;break;case"ai":B+=g.content;break;case"tool_call":B&&(x.push({type:"text",content:B}),B=""),x.push({type:"tool_call",toolName:g.toolName,toolCallId:g.toolCallId,args:g.args??"{}"});break;case"tool_result":B&&(x.push({type:"text",content:B}),B=""),x.push({type:"tool_result",toolName:g.toolName??"",toolCallId:g.toolCallId,content:g.content,artifacts:g.artifacts,renderMode:g.renderMode,html:g.html,markdown:g.markdown});break;case"interrupt":B&&(x.push({type:"text",content:B}),B=""),g.interrupt&&x.push({type:"interrupt",interrupt:g.interrupt,resolved:!1}),Y=!0;break;case"stop":g.content&&(B=g.content),a==null||a(I),Y=!0;break;case"done":if(g.artifacts&&g.artifacts.length>0){const te=g.artifacts;L(I,ee=>{const ue=ee.findLastIndex(ae=>ae.role==="assistant");return ue<0?ee:ee.map((ae,W)=>W===ue?{...ae,artifacts:te}:ae)})}a==null||a(I),Y=!0;break}H(),Y&&A(I,"ready")},g=>{x.push({type:"error",content:g.message}),H(),I===b.current&&(m(g),h("error")),o==null||o(g),A(I,"error")},q.signal).catch(g=>{if((g==null?void 0:g.name)==="AbortError"){A(I,"ready");return}I===b.current&&(m(g instanceof Error?g:new Error(String(g))),h("error")),o==null||o(g instanceof Error?g:new Error(String(g))),A(I,"error")})},[t,o,a,L,A]),v=y.useCallback((T,E)=>{b.current=T;const I=E??C.current.get(T)??[];C.current.set(T,I),p(I)},[]),D=y.useCallback(T=>w.current.has(T)?C.current.get(T)??null:null,[]);return y.useEffect(()=>{var E;if(!n||c!=="ready"||(E=w.current.get(n))!=null&&E.busy)return;const T=Me.popPendingChat();T&&T.sessionId===n&&k(T.message)},[n,c]),{messages:u,status:c,error:f,sendMessage:k,stop:N,regenerate:_,setMessages:p,showSession:v,getLiveMessages:D,respondToInterrupt:O}}const Pr="sa_active_conversation",Pt=20;function Mn(e){try{return localStorage.getItem(`${Pr}_${e}`)}catch{return null}}function ya(e,t){try{const n=`${Pr}_${e}`;t?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}function Fr(e){const{sdk:t,onConversationChange:n}=e,r=t.botId,[i,s]=y.useState([]),[a,o]=y.useState(()=>Mn(r)),[l,u]=y.useState(!1),[p,c]=y.useState(!0),h=y.useRef(!0),f=y.useRef(1),m=y.useRef(!1);y.useEffect(()=>()=>{h.current=!1},[]);const w=y.useCallback(N=>{o(N),ya(r,N),N&&(n==null||n(N))},[r,n]),C=y.useCallback(async()=>{if(!m.current){m.current=!0,u(!0);try{f.current=1;const N=await t.listConversations({page:1,size:Pt});if(!h.current)return;s(N.items),c(N.items.length<N.total);const _=Mn(r);_&&!N.items.find(O=>O.sessionId===_)&&w(null)}catch{}finally{m.current=!1,h.current&&u(!1)}}},[t,w]),b=y.useCallback(async()=>{if(!(m.current||!p)){m.current=!0,u(!0);try{const N=f.current+1,_=await t.listConversations({page:N,size:Pt});if(!h.current)return;f.current=N,s(v=>{const D=new Set(v.map(E=>E.sessionId)),T=_.items.filter(E=>!D.has(E.sessionId));return[...v,...T]});const O=f.current*Pt;c(O<_.total)}catch{}finally{m.current=!1,h.current&&u(!1)}}},[t,p]),S=y.useCallback(async(N,_)=>(w(N),(_==null?void 0:_.fetchHistory)===!1?[]:await t.getMessages(N)),[t,w]),j=y.useCallback(async()=>{try{const N=await t.createSession(),_=new Date().toISOString();s(O=>[{sessionId:N,botId:0,title:"新对话",createTime:_,updateTime:_},...O]),w(N)}catch{w(null)}},[t,w]),L=y.useCallback(async N=>{s(_=>_.filter(O=>O.sessionId!==N)),a===N&&w(null);try{await t.deleteConversation(N)}catch{}},[t,a,w]),A=y.useCallback(async(N,_)=>{await t.renameConversation(N,_),s(O=>O.map(v=>v.sessionId===N?{...v,title:_}:v))},[t]),{enabled:k=!0}=e;return y.useEffect(()=>{k&&C()},[k,C]),{conversations:i,activeConversationId:a,loading:l,hasMore:p,loadConversations:C,loadMore:b,switchConversation:S,newConversation:j,deleteConversation:L,renameConversation:A,setActiveConversationId:w}}function _r(e){return!e&&e!==0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Or(e){return e==="pdf"?"PDF":e==="docx"?"DOC":e==="html"?"HTM":e==="md"?"MD":e.slice(0,3).toUpperCase()||"FILE"}function ka(e,t){var i;const n=(e||"").toLowerCase();if(n.includes("html"))return"html";if(n.includes("markdown"))return"md";if(n.includes("pdf"))return"pdf";if(n.includes("wordprocessingml")||n==="application/msword")return"docx";const r=((i=(t||"").split(".").pop())==null?void 0:i.toLowerCase())??"";return r==="htm"||r==="html"?"html":r==="md"||r==="markdown"?"md":r==="pdf"?"pdf":r==="doc"||r==="docx"?"docx":r}function Br(e){if(!e)return[];const t=[];for(const n of e)if(n.type==="file"&&n.data){const r=n.data.name??n.data.filename??"",i=n.data.mime??n.data.mime_type??n.data.mimeType;t.push({id:n.data.id??"",type:n.data.fileType??n.data.type??ka(i,r),filename:r,url:n.data.url??"",mime:i,size:n.data.size,summary:n.data.summary})}return t}async function kt(e){try{const t=await fetch(e.url);if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e.filename,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),4e3)}catch{const t=document.createElement("a");t.href=e.url,t.download=e.filename,t.target="_blank",document.body.appendChild(t),t.click(),t.remove()}}const $r=y.createContext(null);function ze(){const e=y.useContext($r);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e}function Jt({sdk:e,hooks:t,attachmentUploader:n,nosUpload:r,children:i}){const[s,a]=y.useState(!1),[o,l]=y.useState(!1),[u,p]=y.useState(null),[c,h]=y.useState(null),[f,m]=y.useState(!1),[w,C]=y.useState(!1);y.useEffect(()=>{e.getToken().then(()=>{m(!0)}).catch(()=>{m(!0)})},[e]);const b=Fr({sdk:e,onConversationChange:t==null?void 0:t.onConversationChange,enabled:f}),S=Rr({sdk:e,sessionId:b.activeConversationId,onSessionCreated:P=>{b.setActiveConversationId(P)},onStreamStart:t==null?void 0:t.onStreamStart,onStreamEnd:P=>{var B;(B=t==null?void 0:t.onStreamEnd)==null||B.call(t,P),b.loadConversations()},onError:t==null?void 0:t.onError,onMessageSend:t==null?void 0:t.onMessageSend}),j=y.useCallback(P=>{if(P.type==="link"){window.open(P.url,P.target??"_blank","noopener");return}h(P)},[]),L=y.useCallback(()=>h(null),[]),A=y.useRef(0),k=y.useCallback(async P=>{h(null);const B=++A.current;if(S.getLiveMessages(P)){await b.switchConversation(P,{fetchHistory:!1}),S.showSession(P),C(!1);return}C(!0);try{const x=await b.switchConversation(P);if(A.current!==B)return;S.showSession(P,x)}finally{A.current===B&&C(!1)}},[b,S]),N=y.useCallback(async()=>{h(null),S.setMessages([]),await b.newConversation()},[b,S]),_=y.useCallback(async P=>{b.activeConversationId===P&&S.setMessages([]),await b.deleteConversation(P)},[b,S]);y.useEffect(()=>{b.activeConversationId&&S.messages.length===0&&(C(!0),e.getMessages(b.activeConversationId).then(P=>{S.setMessages(P)}).catch(()=>{}).finally(()=>C(!1)))},[]);const O=y.useCallback(()=>{a(P=>!P)},[]),v=y.useCallback(P=>{a(P)},[]),D=y.useCallback(()=>{l(P=>!P),p(P=>null)},[]),T=y.useCallback(P=>{p(P),l(!0)},[]),E=y.useMemo(()=>{const P=new Set,B=[];for(const x of S.messages)if(x.role==="assistant"&&x.artifacts)for(const H of Br(x.artifacts)){const $=H.id||`${H.url}:${H.filename}`;P.has($)||(P.add($),B.push(H))}return B},[S.messages]),I=y.useCallback(async()=>{const P=b.activeConversationId;if(!P)return null;try{const B=await e.getMessages(P);S.setMessages(B);const x=B.findLast(H=>H.role==="assistant");return(x==null?void 0:x.id)??null}catch{return null}},[e,b.activeConversationId,S]),F=y.useCallback((P,B,x)=>{if(/^\d+$/.test(P)){e.feedback(P,B,x).catch(()=>{});return}I().then(H=>{H&&e.feedback(H,B,x).catch(()=>{})})},[e,I]),q=y.useCallback(P=>{if(/^\d+$/.test(P)){e.cancelFeedback(P).catch(()=>{});return}I().then(B=>{B&&e.cancelFeedback(B).catch(()=>{})})},[e,I]),U=y.useMemo(()=>({sdk:e,status:S.status,error:S.error,messages:S.messages,conversations:b.conversations,activeConversationId:b.activeConversationId,isThreadListOpen:s,isArtifactDrawerOpen:o,allArtifacts:E,activePreviewArtifact:u,activePanel:c,hasMore:b.hasMore,conversationsLoading:b.loading,messagesLoading:w,sendMessage:S.sendMessage,attachmentUploader:n??null,nosUpload:r??null,stop:S.stop,regenerate:S.regenerate,switchConversation:k,newConversation:N,deleteConversation:_,renameConversation:b.renameConversation,loadMoreConversations:b.loadMore,toggleThreadList:O,setThreadListOpen:v,toggleArtifactDrawer:D,openArtifactPreview:T,openPanel:j,closePanel:L,feedback:F,cancelFeedback:q,respondToInterrupt:S.respondToInterrupt}),[e,S.status,S.error,S.messages,S.sendMessage,S.stop,S.regenerate,S.respondToInterrupt,n,r,b.conversations,b.activeConversationId,b.renameConversation,b.hasMore,b.loadMore,b.loading,s,o,E,u,c,w,k,N,_,O,v,D,T,j,L,F,q]);return d.jsx($r.Provider,{value:U,children:i})}const ce="https://ehr-web.netease.com/ehr-web/erh-super-agent",pe={recently:`${ce}/recently.svg`,home:`${ce}/home.svg`,mergeWindow:`${ce}/merge_window.svg`,spiltWindow:`${ce}/spilt_window.svg`,close:`${ce}/close.svg`,message:`${ce}/message.svg`,messageCreate:`${ce}/message_create.svg`,customerService:`${ce}/customer_service.svg`,sendSolid:`${ce}/send_solid.svg`,capabilityIcons:[`${ce}/icon1.png`,`${ce}/icon2.png`,`${ce}/icon3.png`],triggerLogo:`${ce}/HRlogo.png`,logo:`${ce}/HRlogo2.png`,assistantAvatarGenerating:`${ce}/profile0.gif`,assistantAvatar:`${ce}/profile1.png`},de={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 va({defaultWidth:e=de.DEFAULT_WIDTH,defaultHeight:t=de.DEFAULT_HEIGHT,sidebarWidth:n=0}={}){const[r,i]=y.useState(e),[s,a]=y.useState({x:0,y:0}),[o,l]=y.useState(!1),[u,p]=y.useState(!1),[c,h]=y.useState(null),[f,m]=y.useState(()=>typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),w=y.useRef(!1),C=y.useRef(0),b=y.useRef(r),S=y.useRef(!1),j=y.useRef({x:0,y:0}),L=y.useRef({x:0,y:0}),A=y.useRef(!1),k=y.useRef(null);y.useEffect(()=>{const I=()=>m({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),y.useEffect(()=>()=>{var I;(I=k.current)==null||I.call(k)},[]);const N=Math.floor(f.height*de.MAX_HEIGHT_RATIO),_=Math.min(c||t,N),O=r+n;y.useEffect(()=>{if(!o){const I=f.width-O-20,F=f.height-_-20;a(q=>q.x===I&&q.y===F?q:{x:I,y:F})}},[o,O,_,f]);const v=y.useCallback(I=>{if(u||I.target.closest("button, input, textarea"))return;S.current=!0,A.current=!1,j.current={x:I.clientX,y:I.clientY},L.current={...s};const F=P=>{if(!S.current)return;const B=P.clientX-j.current.x,x=P.clientY-j.current.y;(Math.abs(B)>3||Math.abs(x)>3)&&(A.current=!0),A.current&&(l(!0),a({x:Math.max(-200,Math.min(L.current.x+B,window.innerWidth-100)),y:Math.max(0,Math.min(L.current.y+x,window.innerHeight-48))}))},q=()=>{S.current=!1,U()},U=()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",q),k.current=null};document.addEventListener("mousemove",F),document.addEventListener("mouseup",q),k.current=U},[u,s]),D=y.useCallback(I=>{I.preventDefault(),I.stopPropagation(),w.current=!0,C.current=I.clientX,b.current=r;const F=s.x+r,q=s.y,U=x=>{if(!w.current)return;const H=x.clientX-C.current;let $=b.current-H;if($>de.MAX_WIDTH){w.current=!1,p(!0),B();return}$=Math.max(de.MIN_WIDTH,$),i($),a({x:F-$,y:q})},P=()=>{w.current=!1,B()},B=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",P),k.current=null};document.addEventListener("mousemove",U),document.addEventListener("mouseup",P),k.current=B},[r,s]),T=y.useCallback(()=>{u&&i(e),p(I=>!I)},[u,e]),E=y.useCallback(()=>{p(!1),i(e),l(!1),h(null)},[e]);return{width:r,position:s,hasCustomPosition:o,isMaximized:u,lockedHeight:c,viewport:f,defaultHeight:t,totalWidth:O,windowHeight:_,startWindowDrag:v,startResize:D,toggleMaximize:T,setIsMaximized:p,setLockedHeight:h,setHasCustomPosition:l,reset:E}}function Ca(e){const{enabled:t,contentSelector:n,defaultHeight:r,onHeightChange:i}=e,s=y.useRef(null);return y.useEffect(()=>{if(!t||!s.current)return;const o=s.current.querySelector(n);if(!o)return;const l=()=>{const c=s.current;if(!c)return;const h=c.querySelector(n);if(!h)return;const f=c.offsetHeight-h.clientHeight,m=h.scrollHeight+f,w=Math.floor(window.innerHeight*de.MAX_HEIGHT_RATIO),C=Math.max(r,Math.min(m,w));i(b=>b===C?b:C)};l();const u=new ResizeObserver(()=>l());Array.from(o.children).forEach(c=>u.observe(c));const p=new MutationObserver(()=>{Array.from(o.children).forEach(c=>u.observe(c)),l()});return p.observe(o,{childList:!0,subtree:!0,characterData:!0}),()=>{u.disconnect(),p.disconnect()}},[t,n,r,i]),s}function Sa(e,t){const n=de.TRIGGER_SIZE;return{x:Math.max(8,Math.min(e,window.innerWidth-n-8)),y:Math.max(8,Math.min(t,window.innerHeight-n-8))}}function Hr({isOpen:e,onClick:t,triggerLogo:n}){const[r,i]=y.useState(null),s=y.useRef(!1),a=y.useRef(!1),o=y.useRef({x:0,y:0}),l=y.useRef({x:0,y:0}),u=y.useRef(null);y.useEffect(()=>()=>{var f;(f=u.current)==null||f.call(u)},[]);const p=y.useCallback(f=>{if(f.button!==0)return;s.current=!0,a.current=!1,o.current={x:f.clientX,y:f.clientY};const m=f.currentTarget.getBoundingClientRect();l.current={x:m.left,y:m.top};const w=b=>{if(!s.current)return;const S=b.clientX-o.current.x,j=b.clientY-o.current.y;(Math.abs(S)>4||Math.abs(j)>4)&&(a.current=!0),a.current&&i(Sa(l.current.x+S,l.current.y+j))},C=()=>{s.current=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C),u.current=null};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C),u.current=C},[]),c=y.useCallback(()=>{if(a.current){a.current=!1;return}t()},[t]),h=r?{left:r.x,top:r.y,width:de.TRIGGER_SIZE,height:de.TRIGGER_SIZE}:{right:de.TRIGGER_RIGHT,bottom:de.TRIGGER_BOTTOM,width:de.TRIGGER_SIZE,height:de.TRIGGER_SIZE};return d.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 ${e?"pointer-events-none scale-50 opacity-0":"opacity-100"}`,style:h,onMouseDown:p,onClick:c,"aria-label":"打开 AI 助手",title:"AI 助手",children:d.jsx("img",{src:n||pe.triggerLogo,alt:"AI 助手",className:"block h-full w-full",draggable:!1})})}function nt({tooltip:e,onClick:t,children:n}){return d.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":e,"aria-label":e,onClick:t,children:n})}function Ur({onClose:e,onToggleThreadList:t,isMaximized:n=!1,onToggleMaximize:r,showHome:i=!1,onHome:s,showClose:a=!0,artifactCount:o=0,onToggleArtifactDrawer:l,panelTitle:u}){return d.jsxs("div",{className:"relative z-20 flex h-9 shrink-0 select-none items-center px-[15px]",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(nt,{tooltip:"历史记录",onClick:t,children:d.jsx("img",{src:pe.recently,alt:"",width:20,height:20})}),i&&s&&d.jsx(nt,{tooltip:u?"返回聊天":"回到首页",onClick:s,children:d.jsx("img",{src:pe.home,alt:"",width:20,height:20})})]}),u&&d.jsx("div",{className:"pointer-events-none absolute inset-x-0 flex justify-center",children:d.jsx("span",{className:"max-w-[50%] truncate text-[15px] font-semibold text-[#18181b]",children:u})}),d.jsxs("div",{className:"ml-auto flex items-center gap-2.5",children:[o>0&&l&&d.jsx(nt,{tooltip:"会话产物",onClick:l,children:d.jsxs("span",{className:"relative flex items-center gap-1",children:[d.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),o>0&&d.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:o>99?"99+":o})]})}),r&&d.jsx(nt,{tooltip:n?"小窗":"大窗",onClick:r,children:d.jsx("img",{src:n?pe.spiltWindow:pe.mergeWindow,alt:"",width:20,height:20})}),a&&d.jsx(nt,{tooltip:"关闭",onClick:e,children:d.jsx("img",{src:pe.close,alt:"",width:20,height:20})})]})]})}const rt=e=>String(e).padStart(2,"0");function ja(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${rt(t.getMonth()+1)}-${rt(t.getDate())} ${rt(t.getHours())}:${rt(t.getMinutes())}:${rt(t.getSeconds())}`}function Vr(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-6*864e5,i=[],s=[],a=[];for(const l of e){const u=new Date(l.updateTime).getTime();u>=n?i.push(l):u>=r?s.push(l):a.push(l)}const o=[];return i.length&&o.push({label:"今天",items:i}),s.length&&o.push({label:"最近 7 天",items:s}),a.length&&o.push({label:"更早",items:a}),o}function Zt({width:e}){const{conversations:t,activeConversationId:n,switchConversation:r,newConversation:i,deleteConversation:s,renameConversation:a,hasMore:o,loadMoreConversations:l,conversationsLoading:u}=ze(),[p,c]=y.useState(null),[h,f]=y.useState(""),[m,w]=y.useState(null),C=y.useRef(null),b=y.useCallback((A,k)=>{c(A),f(k??"")},[]),S=y.useCallback(A=>{h.trim()&&a(A,h.trim()),c(null)},[h,a]),j=y.useCallback(()=>{const A=C.current;!A||!o||A.scrollHeight-A.scrollTop-A.clientHeight<50&&l()},[o,l]),L=y.useMemo(()=>Vr(t),[t]);return d.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:e??200},children:[d.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:i,children:[d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18}),d.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),d.jsxs("div",{className:"px-1 pb-2.5",children:[d.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),d.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),d.jsxs("div",{ref:C,className:"flex-1 overflow-y-auto",onScroll:j,children:[u&&t.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!u&&t.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),L.map(A=>d.jsxs("div",{className:"mb-1",children:[d.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:A.label}),A.items.map(k=>d.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 ${k.sessionId===n?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{p!==k.sessionId&&r(k.sessionId)},onMouseEnter:N=>{if(p===k.sessionId)return;const _=N.currentTarget.getBoundingClientRect();w({text:k.title||"新会话",x:_.right+8,y:_.top+_.height/2})},onMouseLeave:()=>w(null),children:p===k.sessionId?d.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:N=>f(N.target.value),onBlur:()=>S(k.sessionId),onKeyDown:N=>{N.key==="Enter"&&S(k.sessionId),N.key==="Escape"&&c(null)},onClick:N=>N.stopPropagation(),autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("img",{src:pe.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),d.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:k.title||"新会话"}),d.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[d.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:N=>{N.stopPropagation(),b(k.sessionId,k.title)},title:"重命名",children:d.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})}),d.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:N=>{N.stopPropagation(),s(k.sessionId)},title:"删除",children:d.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.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"})})})]})]})},k.sessionId))]},A.label)),u&&t.length>0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:o?"加载更多...":"加载中..."}),!u&&o&&d.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),m&&d.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 qr(e){const t=y.useRef(null),n=y.useRef(!1),r=y.useRef(0),i=y.useCallback(()=>{const a=t.current;if(!a)return;const{scrollTop:o,scrollHeight:l,clientHeight:u}=a,p=l-o-u<40;o<r.current&&!p&&(n.current=!0),p&&(n.current=!1),r.current=o},[]);y.useEffect(()=>{const a=t.current;if(a)return a.addEventListener("scroll",i,{passive:!0}),()=>a.removeEventListener("scroll",i)},[i]),y.useEffect(()=>{if(n.current)return;const a=t.current;a&&requestAnimationFrame(()=>{a.scrollTop=a.scrollHeight})},e);const s=y.useCallback(()=>{n.current=!1;const a=t.current;a&&(a.scrollTop=a.scrollHeight)},[]);return{containerRef:t,scrollToBottom:s}}function Ea(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ia=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,za=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ta={};function Rn(e,t){return(Ta.jsx?za:Ia).test(e)}const Aa=/[ \t\n\f\r]/g;function Na(e){return typeof e=="object"?e.type==="text"?Pn(e.value):!1:Pn(e)}function Pn(e){return e.replace(Aa,"")===""}class dt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}dt.prototype.normal={};dt.prototype.property={};dt.prototype.space=void 0;function Wr(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new dt(n,r,t)}function en(e){return e.toLowerCase()}class xe{constructor(t,n){this.attribute=n,this.property=t}}xe.prototype.attribute="";xe.prototype.booleanish=!1;xe.prototype.boolean=!1;xe.prototype.commaOrSpaceSeparated=!1;xe.prototype.commaSeparated=!1;xe.prototype.defined=!1;xe.prototype.mustUseProperty=!1;xe.prototype.number=!1;xe.prototype.overloadedBoolean=!1;xe.prototype.property="";xe.prototype.spaceSeparated=!1;xe.prototype.space=void 0;let La=0;const X=Ue(),oe=Ue(),tn=Ue(),M=Ue(),re=Ue(),$e=Ue(),ye=Ue();function Ue(){return 2**++La}const nn=Object.freeze(Object.defineProperty({__proto__:null,boolean:X,booleanish:oe,commaOrSpaceSeparated:ye,commaSeparated:$e,number:M,overloadedBoolean:tn,spaceSeparated:re},Symbol.toStringTag,{value:"Module"})),Ft=Object.keys(nn);class fn extends xe{constructor(t,n,r,i){let s=-1;if(super(t,n),Fn(this,"space",i),typeof r=="number")for(;++s<Ft.length;){const a=Ft[s];Fn(this,Ft[s],(r&nn[a])===nn[a])}}}fn.prototype.defined=!0;function Fn(e,t,n){n&&(e[t]=n)}function Ge(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new fn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[en(r)]=r,n[en(s.attribute)]=r}return new dt(t,n,e.space)}const Yr=Ge({properties:{ariaActiveDescendant:null,ariaAtomic:oe,ariaAutoComplete:null,ariaBusy:oe,ariaChecked:oe,ariaColCount:M,ariaColIndex:M,ariaColSpan:M,ariaControls:re,ariaCurrent:null,ariaDescribedBy:re,ariaDetails:null,ariaDisabled:oe,ariaDropEffect:re,ariaErrorMessage:null,ariaExpanded:oe,ariaFlowTo:re,ariaGrabbed:oe,ariaHasPopup:null,ariaHidden:oe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:re,ariaLevel:M,ariaLive:null,ariaModal:oe,ariaMultiLine:oe,ariaMultiSelectable:oe,ariaOrientation:null,ariaOwns:re,ariaPlaceholder:null,ariaPosInSet:M,ariaPressed:oe,ariaReadOnly:oe,ariaRelevant:null,ariaRequired:oe,ariaRoleDescription:re,ariaRowCount:M,ariaRowIndex:M,ariaRowSpan:M,ariaSelected:oe,ariaSetSize:M,ariaSort:null,ariaValueMax:M,ariaValueMin:M,ariaValueNow:M,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Gr(e,t){return t in e?e[t]:t}function Xr(e,t){return Gr(e,t.toLowerCase())}const Da=Ge({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$e,acceptCharset:re,accessKey:re,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:re,autoFocus:X,autoPlay:X,blocking:re,capture:null,charSet:null,checked:X,cite:null,className:re,closedBy:null,colorSpace:null,cols:M,colSpan:M,command:null,commandFor:null,content:null,contentEditable:oe,controls:X,controlsList:re,coords:M|$e,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:tn,draggable:oe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:re,height:M,hidden:tn,high:M,href:null,hrefLang:null,htmlFor:re,httpEquiv:re,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:re,itemRef:re,itemScope:X,itemType:re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:M,manifest:null,max:null,maxLength:M,media:null,method:null,min:null,minLength:M,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:M,pattern:null,ping:re,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:re,required:X,reversed:X,rows:M,rowSpan:M,sandbox:re,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:M,sizes:null,slot:null,span:M,spellCheck:oe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:M,step:null,style:null,tabIndex:M,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:oe,width:M,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:re,axis:null,background:null,bgColor:null,border:M,borderColor:null,bottomMargin:M,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:M,leftMargin:M,link:null,longDesc:null,lowSrc:null,marginHeight:M,marginWidth:M,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:M,rules:null,scheme:null,scrolling:oe,standby:null,summary:null,text:null,topMargin:M,valueType:null,version:null,vAlign:null,vLink:null,vSpace:M,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:$e,part:re,prefix:null,property:null,results:M,security:null,unselectable:null},space:"html",transform:Xr}),Ma=Ge({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ye,accentHeight:M,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:M,amplitude:M,arabicForm:null,ascent:M,attributeName:null,attributeType:null,azimuth:M,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:M,by:null,calcMode:null,capHeight:M,className:re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:M,diffuseConstant:M,direction:null,display:null,dur:null,divisor:M,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:M,enableBackground:null,end:null,event:null,exponent:M,externalResourcesRequired:null,fill:null,fillOpacity:M,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$e,g2:$e,glyphName:$e,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:M,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:M,horizOriginX:M,horizOriginY:M,id:null,ideographic:M,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:M,k:M,k1:M,k2:M,k3:M,k4:M,kernelMatrix:ye,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:M,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:M,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:M,overlineThickness:M,paintOrder:null,panose1:null,path:null,pathLength:M,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:M,pointsAtY:M,pointsAtZ:M,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ye,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ye,rev:ye,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ye,requiredFeatures:ye,requiredFonts:ye,requiredFormats:ye,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:M,specularExponent:M,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:M,strikethroughThickness:M,string:null,stroke:null,strokeDashArray:ye,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:M,strokeOpacity:M,strokeWidth:null,style:null,surfaceScale:M,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ye,tabIndex:M,tableValues:null,target:null,targetX:M,targetY:M,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ye,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:M,underlineThickness:M,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:M,values:null,vAlphabetic:M,vMathematical:M,vectorEffect:null,vHanging:M,vIdeographic:M,version:null,vertAdvY:M,vertOriginX:M,vertOriginY:M,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:M,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gr}),Kr=Ge({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Qr=Ge({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xr}),Jr=Ge({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Ra={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Pa=/[A-Z]/g,_n=/-[a-z]/g,Fa=/^data[-\w.:]+$/i;function _a(e,t){const n=en(t);let r=t,i=xe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Fa.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(_n,Ba);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!_n.test(s)){let a=s.replace(Pa,Oa);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=fn}return new i(r,t)}function Oa(e){return"-"+e.toLowerCase()}function Ba(e){return e.charAt(1).toUpperCase()}const $a=Wr([Yr,Da,Kr,Qr,Jr],"html"),hn=Wr([Yr,Ma,Kr,Qr,Jr],"svg");function Ha(e){return e.join(" ").trim()}var gn={},On=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Ua=/\n/g,Va=/^\s*/,qa=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Wa=/^:\s*/,Ya=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Ga=/^[;\s]*/,Xa=/^\s+|\s+$/g,Ka=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),wa=require("react-dom/client"),d=require("react/jsx-runtime"),Me=require("./nosUploader-DLX7JsnR.cjs");function Rr(e){const{sdk:t,sessionId:n,onSessionCreated:r,onRoundStart:i,onStreamStart:s,onStreamEnd:a,onError:o,onMessageSend:l}=e,[u,p]=y.useState([]),[c,h]=y.useState("ready"),[f,m]=y.useState(null),w=y.useRef(new Map),C=y.useRef(new Map),b=y.useRef(n),S=y.useRef(!0),j=y.useRef(u);b.current=n,S.current=u.length===0,j.current=u;const L=y.useCallback((T,E)=>{if(T===b.current)p(I=>{const F=C.current.get(T)??I,q=E(F);return C.current.set(T,q),q});else{const I=C.current.get(T)??[];C.current.set(T,E(I))}},[]),A=y.useCallback((T,E)=>{const I=w.current.get(T);I!=null&&I.stopTimer&&(clearTimeout(I.stopTimer),I.stopTimer=null),w.current.delete(T),C.current.delete(T),T===b.current&&h(E)},[]);y.useEffect(()=>{const T=n?w.current.get(n):void 0;h(T!=null&&T.busy?"streaming":"ready")},[n]);const k=y.useCallback((T,E)=>{var H;const I=b.current;if(I&&((H=w.current.get(I))!=null&&H.busy))return;l==null||l(T);const F={id:`user_${Date.now()}`,role:"user",parts:[...(E??[]).map($=>({type:"attachment",attachment:$})),{type:"text",content:T}],timestamp:Date.now()},q=`assistant_${Date.now()}`,U={id:q,role:"assistant",parts:[],timestamp:Date.now()},P=S.current,B=j.current;p($=>[...$,F,U]),I&&C.current.set(I,[...B,F,U]),h("submitted"),m(null);const x=$=>{let g="",Y="",te=[],ee=!1;C.current.has($)||C.current.set($,[...B,F,U]);const ue={abortController:null,busy:!0,stopTimer:null};w.current.set($,ue);const ae=()=>{const W=[...te];if(g){const se=W.findIndex(le=>le.type==="thinking");se>=0?W[se]={type:"thinking",content:g}:W.unshift({type:"thinking",content:g})}if(Y){const se=W[W.length-1];(se==null?void 0:se.type)==="text"?W[W.length-1]={type:"text",content:Y}:W.push({type:"text",content:Y})}L($,se=>se.map(le=>le.id===q?{...le,parts:W}:le))};ue.abortController=t.chat({sessionId:$,message:T,attachments:E&&E.length>0?E:void 0,stream:!0,onMessage:W=>{switch(ee||(ee=!0,$===b.current&&h("streaming")),W.type){case"session.start":W.roundId&&(i==null||i(W.roundId));break;case"thinking":g+=W.content;break;case"ai":Y+=W.content;break;case"tool_call":Y&&(te.push({type:"text",content:Y}),Y=""),te.push({type:"tool_call",toolName:W.toolName,toolCallId:W.toolCallId,args:W.args??"{}"});break;case"tool_result":Y&&(te.push({type:"text",content:Y}),Y=""),te.push({type:"tool_result",toolName:W.toolName??"",toolCallId:W.toolCallId,content:W.content,artifacts:W.artifacts,renderMode:W.renderMode,html:W.html,markdown:W.markdown});break;case"interrupt":Y&&(te.push({type:"text",content:Y}),Y=""),W.interrupt&&te.push({type:"interrupt",interrupt:W.interrupt,resolved:!1}),ae(),A($,"ready");return;case"stop":W.content&&(Y=W.content),ae();return}ae()},onDone:W=>{if((Y||te.length>0||g)&&ae(),W.artifacts&&W.artifacts.length>0){const le=W.artifacts;L($,Ee=>Ee.map(be=>be.id===q?{...be,artifacts:le}:be))}const se=()=>{A($,"ready"),a==null||a(W.sessionId||$)};if(P){const le=T.slice(0,30),Ee=W.sessionId||$;t.renameConversation(Ee,le).catch(()=>{}).finally(se)}else se()},onError:W=>{te.push({type:"error",content:W.message}),ae(),$===b.current&&(m(W),h("error")),o==null||o(W),A($,"error")}}),s==null||s($)};I?x(I):t.createSession().then($=>{b.current==null&&(b.current=$,r==null||r($)),x($)}).catch($=>{b.current==null&&(m($ instanceof Error?$:new Error(String($))),h("error")),o==null||o($ instanceof Error?$:new Error(String($)))})},[t,r,s,a,o,l,L,A]),N=y.useCallback(()=>{const T=b.current;if(!T)return;const E=w.current.get(T);E!=null&&E.busy&&(E.stopTimer&&clearTimeout(E.stopTimer),E.stopTimer=setTimeout(()=>{var I;E.stopTimer=null,(I=E.abortController)==null||I.abort(),A(T,"ready")},8e3),t.stopGeneration(T).catch(()=>{}))},[t,A]),_=y.useCallback(()=>{var q;const T=b.current;if(T&&((q=w.current.get(T))!=null&&q.busy))return;const E=u.findLastIndex(U=>U.role==="user");if(E<0)return;const I=u[E].parts.filter(U=>U.type==="text").map(U=>U.content).join(""),F=u[E].parts.filter(U=>U.type==="attachment").map(U=>U.attachment);p(U=>U.slice(0,E)),k(I,F.length>0?F:void 0)},[u,k]),O=y.useCallback((T,E)=>{var $;const I=b.current;if(!I||($=w.current.get(I))!=null&&$.busy)return;L(I,g=>g.map(Y=>({...Y,parts:Y.parts.map(te=>te.type==="interrupt"&&te.interrupt.interruptId===T?{...te,resolved:!0,response:E}:te)})));const F={abortController:null,busy:!0,stopTimer:null};w.current.set(I,F);const q=new AbortController;F.abortController=q;let U=0;L(I,g=>g.length>0&&g[g.length-1].role==="assistant"?(U=g[g.length-1].parts.length,g):(U=0,[...g,{id:`assistant_${Date.now()}`,role:"assistant",parts:[],timestamp:Date.now()}])),h("streaming");let P="",B="",x=[];const H=()=>{const g=[...x];if(P){const Y=g.findIndex(te=>te.type==="thinking");Y>=0?g[Y]={type:"thinking",content:P}:g.unshift({type:"thinking",content:P})}if(B){const Y=g[g.length-1];(Y==null?void 0:Y.type)==="text"?g[g.length-1]={type:"text",content:B}:g.push({type:"text",content:B})}L(I,Y=>{const te=Y.findLastIndex(ee=>ee.role==="assistant");return te<0?Y:Y.map((ee,ue)=>ue===te?{...ee,parts:[...ee.parts.slice(0,U),...g]}:ee)})};t.respondInterrupt(T,I,E,g=>{let Y=!1;switch(g.type){case"thinking":P+=g.content;break;case"ai":B+=g.content;break;case"tool_call":B&&(x.push({type:"text",content:B}),B=""),x.push({type:"tool_call",toolName:g.toolName,toolCallId:g.toolCallId,args:g.args??"{}"});break;case"tool_result":B&&(x.push({type:"text",content:B}),B=""),x.push({type:"tool_result",toolName:g.toolName??"",toolCallId:g.toolCallId,content:g.content,artifacts:g.artifacts,renderMode:g.renderMode,html:g.html,markdown:g.markdown});break;case"interrupt":B&&(x.push({type:"text",content:B}),B=""),g.interrupt&&x.push({type:"interrupt",interrupt:g.interrupt,resolved:!1}),Y=!0;break;case"stop":g.content&&(B=g.content),a==null||a(I),Y=!0;break;case"done":if(g.artifacts&&g.artifacts.length>0){const te=g.artifacts;L(I,ee=>{const ue=ee.findLastIndex(ae=>ae.role==="assistant");return ue<0?ee:ee.map((ae,W)=>W===ue?{...ae,artifacts:te}:ae)})}a==null||a(I),Y=!0;break}H(),Y&&A(I,"ready")},g=>{x.push({type:"error",content:g.message}),H(),I===b.current&&(m(g),h("error")),o==null||o(g),A(I,"error")},q.signal).catch(g=>{if((g==null?void 0:g.name)==="AbortError"){A(I,"ready");return}I===b.current&&(m(g instanceof Error?g:new Error(String(g))),h("error")),o==null||o(g instanceof Error?g:new Error(String(g))),A(I,"error")})},[t,o,a,L,A]),v=y.useCallback((T,E)=>{b.current=T;const I=E??C.current.get(T)??[];C.current.set(T,I),p(I)},[]),D=y.useCallback(T=>w.current.has(T)?C.current.get(T)??null:null,[]);return y.useEffect(()=>{var E;if(!n||c!=="ready"||(E=w.current.get(n))!=null&&E.busy)return;const T=Me.popPendingChat();T&&T.sessionId===n&&k(T.message)},[n,c]),{messages:u,status:c,error:f,sendMessage:k,stop:N,regenerate:_,setMessages:p,showSession:v,getLiveMessages:D,respondToInterrupt:O}}const Pr="sa_active_conversation",Pt=20;function Mn(e){try{return localStorage.getItem(`${Pr}_${e}`)}catch{return null}}function ya(e,t){try{const n=`${Pr}_${e}`;t?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}function Fr(e){const{sdk:t,onConversationChange:n}=e,r=t.botCode,[i,s]=y.useState([]),[a,o]=y.useState(()=>Mn(r)),[l,u]=y.useState(!1),[p,c]=y.useState(!0),h=y.useRef(!0),f=y.useRef(1),m=y.useRef(!1);y.useEffect(()=>()=>{h.current=!1},[]);const w=y.useCallback(N=>{o(N),ya(r,N),N&&(n==null||n(N))},[r,n]),C=y.useCallback(async()=>{if(!m.current){m.current=!0,u(!0);try{f.current=1;const N=await t.listConversations({page:1,size:Pt});if(!h.current)return;s(N.items),c(N.items.length<N.total);const _=Mn(r);_&&!N.items.find(O=>O.sessionId===_)&&w(null)}catch{}finally{m.current=!1,h.current&&u(!1)}}},[t,w]),b=y.useCallback(async()=>{if(!(m.current||!p)){m.current=!0,u(!0);try{const N=f.current+1,_=await t.listConversations({page:N,size:Pt});if(!h.current)return;f.current=N,s(v=>{const D=new Set(v.map(E=>E.sessionId)),T=_.items.filter(E=>!D.has(E.sessionId));return[...v,...T]});const O=f.current*Pt;c(O<_.total)}catch{}finally{m.current=!1,h.current&&u(!1)}}},[t,p]),S=y.useCallback(async(N,_)=>(w(N),(_==null?void 0:_.fetchHistory)===!1?[]:await t.getMessages(N)),[t,w]),j=y.useCallback(async()=>{try{const N=await t.createSession(),_=new Date().toISOString();s(O=>[{sessionId:N,title:"新对话",createTime:_,updateTime:_},...O]),w(N)}catch{w(null)}},[t,w]),L=y.useCallback(async N=>{s(_=>_.filter(O=>O.sessionId!==N)),a===N&&w(null);try{await t.deleteConversation(N)}catch{}},[t,a,w]),A=y.useCallback(async(N,_)=>{await t.renameConversation(N,_),s(O=>O.map(v=>v.sessionId===N?{...v,title:_}:v))},[t]),{enabled:k=!0}=e;return y.useEffect(()=>{k&&C()},[k,C]),{conversations:i,activeConversationId:a,loading:l,hasMore:p,loadConversations:C,loadMore:b,switchConversation:S,newConversation:j,deleteConversation:L,renameConversation:A,setActiveConversationId:w}}function _r(e){return!e&&e!==0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Or(e){return e==="pdf"?"PDF":e==="docx"?"DOC":e==="html"?"HTM":e==="md"?"MD":e.slice(0,3).toUpperCase()||"FILE"}function ka(e,t){var i;const n=(e||"").toLowerCase();if(n.includes("html"))return"html";if(n.includes("markdown"))return"md";if(n.includes("pdf"))return"pdf";if(n.includes("wordprocessingml")||n==="application/msword")return"docx";const r=((i=(t||"").split(".").pop())==null?void 0:i.toLowerCase())??"";return r==="htm"||r==="html"?"html":r==="md"||r==="markdown"?"md":r==="pdf"?"pdf":r==="doc"||r==="docx"?"docx":r}function Br(e){if(!e)return[];const t=[];for(const n of e)if(n.type==="file"&&n.data){const r=n.data.name??n.data.filename??"",i=n.data.mime??n.data.mime_type??n.data.mimeType;t.push({id:n.data.id??"",type:n.data.fileType??n.data.type??ka(i,r),filename:r,url:n.data.url??"",mime:i,size:n.data.size,summary:n.data.summary})}return t}async function kt(e){try{const t=await fetch(e.url);if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e.filename,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),4e3)}catch{const t=document.createElement("a");t.href=e.url,t.download=e.filename,t.target="_blank",document.body.appendChild(t),t.click(),t.remove()}}const $r=y.createContext(null);function ze(){const e=y.useContext($r);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e}function Jt({sdk:e,hooks:t,attachmentUploader:n,nosUpload:r,children:i}){const[s,a]=y.useState(!1),[o,l]=y.useState(!1),[u,p]=y.useState(null),[c,h]=y.useState(null),[f,m]=y.useState(!1),[w,C]=y.useState(!1);y.useEffect(()=>{e.getToken().then(()=>{m(!0)}).catch(()=>{m(!0)})},[e]);const b=Fr({sdk:e,onConversationChange:t==null?void 0:t.onConversationChange,enabled:f}),S=Rr({sdk:e,sessionId:b.activeConversationId,onSessionCreated:P=>{b.setActiveConversationId(P)},onStreamStart:t==null?void 0:t.onStreamStart,onStreamEnd:P=>{var B;(B=t==null?void 0:t.onStreamEnd)==null||B.call(t,P),b.loadConversations()},onError:t==null?void 0:t.onError,onMessageSend:t==null?void 0:t.onMessageSend}),j=y.useCallback(P=>{if(P.type==="link"){window.open(P.url,P.target??"_blank","noopener");return}h(P)},[]),L=y.useCallback(()=>h(null),[]),A=y.useRef(0),k=y.useCallback(async P=>{h(null);const B=++A.current;if(S.getLiveMessages(P)){await b.switchConversation(P,{fetchHistory:!1}),S.showSession(P),C(!1);return}C(!0);try{const x=await b.switchConversation(P);if(A.current!==B)return;S.showSession(P,x)}finally{A.current===B&&C(!1)}},[b,S]),N=y.useCallback(async()=>{h(null),S.setMessages([]),await b.newConversation()},[b,S]),_=y.useCallback(async P=>{b.activeConversationId===P&&S.setMessages([]),await b.deleteConversation(P)},[b,S]);y.useEffect(()=>{b.activeConversationId&&S.messages.length===0&&(C(!0),e.getMessages(b.activeConversationId).then(P=>{S.setMessages(P)}).catch(()=>{}).finally(()=>C(!1)))},[]);const O=y.useCallback(()=>{a(P=>!P)},[]),v=y.useCallback(P=>{a(P)},[]),D=y.useCallback(()=>{l(P=>!P),p(P=>null)},[]),T=y.useCallback(P=>{p(P),l(!0)},[]),E=y.useMemo(()=>{const P=new Set,B=[];for(const x of S.messages)if(x.role==="assistant"&&x.artifacts)for(const H of Br(x.artifacts)){const $=H.id||`${H.url}:${H.filename}`;P.has($)||(P.add($),B.push(H))}return B},[S.messages]),I=y.useCallback(async()=>{const P=b.activeConversationId;if(!P)return null;try{const B=await e.getMessages(P);S.setMessages(B);const x=B.findLast(H=>H.role==="assistant");return(x==null?void 0:x.id)??null}catch{return null}},[e,b.activeConversationId,S]),F=y.useCallback((P,B,x)=>{if(/^\d+$/.test(P)){e.feedback(P,B,x).catch(()=>{});return}I().then(H=>{H&&e.feedback(H,B,x).catch(()=>{})})},[e,I]),q=y.useCallback(P=>{if(/^\d+$/.test(P)){e.cancelFeedback(P).catch(()=>{});return}I().then(B=>{B&&e.cancelFeedback(B).catch(()=>{})})},[e,I]),U=y.useMemo(()=>({sdk:e,status:S.status,error:S.error,messages:S.messages,conversations:b.conversations,activeConversationId:b.activeConversationId,isThreadListOpen:s,isArtifactDrawerOpen:o,allArtifacts:E,activePreviewArtifact:u,activePanel:c,hasMore:b.hasMore,conversationsLoading:b.loading,messagesLoading:w,sendMessage:S.sendMessage,attachmentUploader:n??null,nosUpload:r??null,stop:S.stop,regenerate:S.regenerate,switchConversation:k,newConversation:N,deleteConversation:_,renameConversation:b.renameConversation,loadMoreConversations:b.loadMore,toggleThreadList:O,setThreadListOpen:v,toggleArtifactDrawer:D,openArtifactPreview:T,openPanel:j,closePanel:L,feedback:F,cancelFeedback:q,respondToInterrupt:S.respondToInterrupt}),[e,S.status,S.error,S.messages,S.sendMessage,S.stop,S.regenerate,S.respondToInterrupt,n,r,b.conversations,b.activeConversationId,b.renameConversation,b.hasMore,b.loadMore,b.loading,s,o,E,u,c,w,k,N,_,O,v,D,T,j,L,F,q]);return d.jsx($r.Provider,{value:U,children:i})}const ce="https://ehr-web.netease.com/ehr-web/erh-super-agent",pe={recently:`${ce}/recently.svg`,home:`${ce}/home.svg`,mergeWindow:`${ce}/merge_window.svg`,spiltWindow:`${ce}/spilt_window.svg`,close:`${ce}/close.svg`,message:`${ce}/message.svg`,messageCreate:`${ce}/message_create.svg`,customerService:`${ce}/customer_service.svg`,sendSolid:`${ce}/send_solid.svg`,capabilityIcons:[`${ce}/icon1.png`,`${ce}/icon2.png`,`${ce}/icon3.png`],triggerLogo:`${ce}/HRlogo.png`,logo:`${ce}/HRlogo2.png`,assistantAvatarGenerating:`${ce}/profile0.gif`,assistantAvatar:`${ce}/profile1.png`},de={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 va({defaultWidth:e=de.DEFAULT_WIDTH,defaultHeight:t=de.DEFAULT_HEIGHT,sidebarWidth:n=0}={}){const[r,i]=y.useState(e),[s,a]=y.useState({x:0,y:0}),[o,l]=y.useState(!1),[u,p]=y.useState(!1),[c,h]=y.useState(null),[f,m]=y.useState(()=>typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),w=y.useRef(!1),C=y.useRef(0),b=y.useRef(r),S=y.useRef(!1),j=y.useRef({x:0,y:0}),L=y.useRef({x:0,y:0}),A=y.useRef(!1),k=y.useRef(null);y.useEffect(()=>{const I=()=>m({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),y.useEffect(()=>()=>{var I;(I=k.current)==null||I.call(k)},[]);const N=Math.floor(f.height*de.MAX_HEIGHT_RATIO),_=Math.min(c||t,N),O=r+n;y.useEffect(()=>{if(!o){const I=f.width-O-20,F=f.height-_-20;a(q=>q.x===I&&q.y===F?q:{x:I,y:F})}},[o,O,_,f]);const v=y.useCallback(I=>{if(u||I.target.closest("button, input, textarea"))return;S.current=!0,A.current=!1,j.current={x:I.clientX,y:I.clientY},L.current={...s};const F=P=>{if(!S.current)return;const B=P.clientX-j.current.x,x=P.clientY-j.current.y;(Math.abs(B)>3||Math.abs(x)>3)&&(A.current=!0),A.current&&(l(!0),a({x:Math.max(-200,Math.min(L.current.x+B,window.innerWidth-100)),y:Math.max(0,Math.min(L.current.y+x,window.innerHeight-48))}))},q=()=>{S.current=!1,U()},U=()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",q),k.current=null};document.addEventListener("mousemove",F),document.addEventListener("mouseup",q),k.current=U},[u,s]),D=y.useCallback(I=>{I.preventDefault(),I.stopPropagation(),w.current=!0,C.current=I.clientX,b.current=r;const F=s.x+r,q=s.y,U=x=>{if(!w.current)return;const H=x.clientX-C.current;let $=b.current-H;if($>de.MAX_WIDTH){w.current=!1,p(!0),B();return}$=Math.max(de.MIN_WIDTH,$),i($),a({x:F-$,y:q})},P=()=>{w.current=!1,B()},B=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",P),k.current=null};document.addEventListener("mousemove",U),document.addEventListener("mouseup",P),k.current=B},[r,s]),T=y.useCallback(()=>{u&&i(e),p(I=>!I)},[u,e]),E=y.useCallback(()=>{p(!1),i(e),l(!1),h(null)},[e]);return{width:r,position:s,hasCustomPosition:o,isMaximized:u,lockedHeight:c,viewport:f,defaultHeight:t,totalWidth:O,windowHeight:_,startWindowDrag:v,startResize:D,toggleMaximize:T,setIsMaximized:p,setLockedHeight:h,setHasCustomPosition:l,reset:E}}function Ca(e){const{enabled:t,contentSelector:n,defaultHeight:r,onHeightChange:i}=e,s=y.useRef(null);return y.useEffect(()=>{if(!t||!s.current)return;const o=s.current.querySelector(n);if(!o)return;const l=()=>{const c=s.current;if(!c)return;const h=c.querySelector(n);if(!h)return;const f=c.offsetHeight-h.clientHeight,m=h.scrollHeight+f,w=Math.floor(window.innerHeight*de.MAX_HEIGHT_RATIO),C=Math.max(r,Math.min(m,w));i(b=>b===C?b:C)};l();const u=new ResizeObserver(()=>l());Array.from(o.children).forEach(c=>u.observe(c));const p=new MutationObserver(()=>{Array.from(o.children).forEach(c=>u.observe(c)),l()});return p.observe(o,{childList:!0,subtree:!0,characterData:!0}),()=>{u.disconnect(),p.disconnect()}},[t,n,r,i]),s}function Sa(e,t){const n=de.TRIGGER_SIZE;return{x:Math.max(8,Math.min(e,window.innerWidth-n-8)),y:Math.max(8,Math.min(t,window.innerHeight-n-8))}}function Hr({isOpen:e,onClick:t,triggerLogo:n}){const[r,i]=y.useState(null),s=y.useRef(!1),a=y.useRef(!1),o=y.useRef({x:0,y:0}),l=y.useRef({x:0,y:0}),u=y.useRef(null);y.useEffect(()=>()=>{var f;(f=u.current)==null||f.call(u)},[]);const p=y.useCallback(f=>{if(f.button!==0)return;s.current=!0,a.current=!1,o.current={x:f.clientX,y:f.clientY};const m=f.currentTarget.getBoundingClientRect();l.current={x:m.left,y:m.top};const w=b=>{if(!s.current)return;const S=b.clientX-o.current.x,j=b.clientY-o.current.y;(Math.abs(S)>4||Math.abs(j)>4)&&(a.current=!0),a.current&&i(Sa(l.current.x+S,l.current.y+j))},C=()=>{s.current=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C),u.current=null};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C),u.current=C},[]),c=y.useCallback(()=>{if(a.current){a.current=!1;return}t()},[t]),h=r?{left:r.x,top:r.y,width:de.TRIGGER_SIZE,height:de.TRIGGER_SIZE}:{right:de.TRIGGER_RIGHT,bottom:de.TRIGGER_BOTTOM,width:de.TRIGGER_SIZE,height:de.TRIGGER_SIZE};return d.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 ${e?"pointer-events-none scale-50 opacity-0":"opacity-100"}`,style:h,onMouseDown:p,onClick:c,"aria-label":"打开 AI 助手",title:"AI 助手",children:d.jsx("img",{src:n||pe.triggerLogo,alt:"AI 助手",className:"block h-full w-full",draggable:!1})})}function nt({tooltip:e,onClick:t,children:n}){return d.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":e,"aria-label":e,onClick:t,children:n})}function Ur({onClose:e,onToggleThreadList:t,isMaximized:n=!1,onToggleMaximize:r,showHome:i=!1,onHome:s,showClose:a=!0,artifactCount:o=0,onToggleArtifactDrawer:l,panelTitle:u}){return d.jsxs("div",{className:"relative z-20 flex h-9 shrink-0 select-none items-center px-[15px]",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(nt,{tooltip:"历史记录",onClick:t,children:d.jsx("img",{src:pe.recently,alt:"",width:20,height:20})}),i&&s&&d.jsx(nt,{tooltip:u?"返回聊天":"回到首页",onClick:s,children:d.jsx("img",{src:pe.home,alt:"",width:20,height:20})})]}),u&&d.jsx("div",{className:"pointer-events-none absolute inset-x-0 flex justify-center",children:d.jsx("span",{className:"max-w-[50%] truncate text-[15px] font-semibold text-[#18181b]",children:u})}),d.jsxs("div",{className:"ml-auto flex items-center gap-2.5",children:[o>0&&l&&d.jsx(nt,{tooltip:"会话产物",onClick:l,children:d.jsxs("span",{className:"relative flex items-center gap-1",children:[d.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),o>0&&d.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:o>99?"99+":o})]})}),r&&d.jsx(nt,{tooltip:n?"小窗":"大窗",onClick:r,children:d.jsx("img",{src:n?pe.spiltWindow:pe.mergeWindow,alt:"",width:20,height:20})}),a&&d.jsx(nt,{tooltip:"关闭",onClick:e,children:d.jsx("img",{src:pe.close,alt:"",width:20,height:20})})]})]})}const rt=e=>String(e).padStart(2,"0");function ja(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${rt(t.getMonth()+1)}-${rt(t.getDate())} ${rt(t.getHours())}:${rt(t.getMinutes())}:${rt(t.getSeconds())}`}function Vr(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-6*864e5,i=[],s=[],a=[];for(const l of e){const u=new Date(l.updateTime).getTime();u>=n?i.push(l):u>=r?s.push(l):a.push(l)}const o=[];return i.length&&o.push({label:"今天",items:i}),s.length&&o.push({label:"最近 7 天",items:s}),a.length&&o.push({label:"更早",items:a}),o}function Zt({width:e}){const{conversations:t,activeConversationId:n,switchConversation:r,newConversation:i,deleteConversation:s,renameConversation:a,hasMore:o,loadMoreConversations:l,conversationsLoading:u}=ze(),[p,c]=y.useState(null),[h,f]=y.useState(""),[m,w]=y.useState(null),C=y.useRef(null),b=y.useCallback((A,k)=>{c(A),f(k??"")},[]),S=y.useCallback(A=>{h.trim()&&a(A,h.trim()),c(null)},[h,a]),j=y.useCallback(()=>{const A=C.current;!A||!o||A.scrollHeight-A.scrollTop-A.clientHeight<50&&l()},[o,l]),L=y.useMemo(()=>Vr(t),[t]);return d.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:e??200},children:[d.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:i,children:[d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18}),d.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),d.jsxs("div",{className:"px-1 pb-2.5",children:[d.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),d.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),d.jsxs("div",{ref:C,className:"flex-1 overflow-y-auto",onScroll:j,children:[u&&t.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!u&&t.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),L.map(A=>d.jsxs("div",{className:"mb-1",children:[d.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:A.label}),A.items.map(k=>d.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 ${k.sessionId===n?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{p!==k.sessionId&&r(k.sessionId)},onMouseEnter:N=>{if(p===k.sessionId)return;const _=N.currentTarget.getBoundingClientRect();w({text:k.title||"新会话",x:_.right+8,y:_.top+_.height/2})},onMouseLeave:()=>w(null),children:p===k.sessionId?d.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:N=>f(N.target.value),onBlur:()=>S(k.sessionId),onKeyDown:N=>{N.key==="Enter"&&S(k.sessionId),N.key==="Escape"&&c(null)},onClick:N=>N.stopPropagation(),autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("img",{src:pe.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),d.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:k.title||"新会话"}),d.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[d.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:N=>{N.stopPropagation(),b(k.sessionId,k.title)},title:"重命名",children:d.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})}),d.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:N=>{N.stopPropagation(),s(k.sessionId)},title:"删除",children:d.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.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"})})})]})]})},k.sessionId))]},A.label)),u&&t.length>0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:o?"加载更多...":"加载中..."}),!u&&o&&d.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),m&&d.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 qr(e){const t=y.useRef(null),n=y.useRef(!1),r=y.useRef(0),i=y.useCallback(()=>{const a=t.current;if(!a)return;const{scrollTop:o,scrollHeight:l,clientHeight:u}=a,p=l-o-u<40;o<r.current&&!p&&(n.current=!0),p&&(n.current=!1),r.current=o},[]);y.useEffect(()=>{const a=t.current;if(a)return a.addEventListener("scroll",i,{passive:!0}),()=>a.removeEventListener("scroll",i)},[i]),y.useEffect(()=>{if(n.current)return;const a=t.current;a&&requestAnimationFrame(()=>{a.scrollTop=a.scrollHeight})},e);const s=y.useCallback(()=>{n.current=!1;const a=t.current;a&&(a.scrollTop=a.scrollHeight)},[]);return{containerRef:t,scrollToBottom:s}}function Ea(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ia=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,za=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ta={};function Rn(e,t){return(Ta.jsx?za:Ia).test(e)}const Aa=/[ \t\n\f\r]/g;function Na(e){return typeof e=="object"?e.type==="text"?Pn(e.value):!1:Pn(e)}function Pn(e){return e.replace(Aa,"")===""}class dt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}dt.prototype.normal={};dt.prototype.property={};dt.prototype.space=void 0;function Wr(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new dt(n,r,t)}function en(e){return e.toLowerCase()}class xe{constructor(t,n){this.attribute=n,this.property=t}}xe.prototype.attribute="";xe.prototype.booleanish=!1;xe.prototype.boolean=!1;xe.prototype.commaOrSpaceSeparated=!1;xe.prototype.commaSeparated=!1;xe.prototype.defined=!1;xe.prototype.mustUseProperty=!1;xe.prototype.number=!1;xe.prototype.overloadedBoolean=!1;xe.prototype.property="";xe.prototype.spaceSeparated=!1;xe.prototype.space=void 0;let La=0;const X=Ue(),oe=Ue(),tn=Ue(),M=Ue(),re=Ue(),$e=Ue(),ye=Ue();function Ue(){return 2**++La}const nn=Object.freeze(Object.defineProperty({__proto__:null,boolean:X,booleanish:oe,commaOrSpaceSeparated:ye,commaSeparated:$e,number:M,overloadedBoolean:tn,spaceSeparated:re},Symbol.toStringTag,{value:"Module"})),Ft=Object.keys(nn);class fn extends xe{constructor(t,n,r,i){let s=-1;if(super(t,n),Fn(this,"space",i),typeof r=="number")for(;++s<Ft.length;){const a=Ft[s];Fn(this,Ft[s],(r&nn[a])===nn[a])}}}fn.prototype.defined=!0;function Fn(e,t,n){n&&(e[t]=n)}function Ge(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new fn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[en(r)]=r,n[en(s.attribute)]=r}return new dt(t,n,e.space)}const Yr=Ge({properties:{ariaActiveDescendant:null,ariaAtomic:oe,ariaAutoComplete:null,ariaBusy:oe,ariaChecked:oe,ariaColCount:M,ariaColIndex:M,ariaColSpan:M,ariaControls:re,ariaCurrent:null,ariaDescribedBy:re,ariaDetails:null,ariaDisabled:oe,ariaDropEffect:re,ariaErrorMessage:null,ariaExpanded:oe,ariaFlowTo:re,ariaGrabbed:oe,ariaHasPopup:null,ariaHidden:oe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:re,ariaLevel:M,ariaLive:null,ariaModal:oe,ariaMultiLine:oe,ariaMultiSelectable:oe,ariaOrientation:null,ariaOwns:re,ariaPlaceholder:null,ariaPosInSet:M,ariaPressed:oe,ariaReadOnly:oe,ariaRelevant:null,ariaRequired:oe,ariaRoleDescription:re,ariaRowCount:M,ariaRowIndex:M,ariaRowSpan:M,ariaSelected:oe,ariaSetSize:M,ariaSort:null,ariaValueMax:M,ariaValueMin:M,ariaValueNow:M,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Gr(e,t){return t in e?e[t]:t}function Xr(e,t){return Gr(e,t.toLowerCase())}const Da=Ge({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$e,acceptCharset:re,accessKey:re,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:re,autoFocus:X,autoPlay:X,blocking:re,capture:null,charSet:null,checked:X,cite:null,className:re,closedBy:null,colorSpace:null,cols:M,colSpan:M,command:null,commandFor:null,content:null,contentEditable:oe,controls:X,controlsList:re,coords:M|$e,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:tn,draggable:oe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:re,height:M,hidden:tn,high:M,href:null,hrefLang:null,htmlFor:re,httpEquiv:re,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:re,itemRef:re,itemScope:X,itemType:re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:M,manifest:null,max:null,maxLength:M,media:null,method:null,min:null,minLength:M,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:M,pattern:null,ping:re,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:re,required:X,reversed:X,rows:M,rowSpan:M,sandbox:re,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:M,sizes:null,slot:null,span:M,spellCheck:oe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:M,step:null,style:null,tabIndex:M,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:oe,width:M,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:re,axis:null,background:null,bgColor:null,border:M,borderColor:null,bottomMargin:M,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:M,leftMargin:M,link:null,longDesc:null,lowSrc:null,marginHeight:M,marginWidth:M,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:M,rules:null,scheme:null,scrolling:oe,standby:null,summary:null,text:null,topMargin:M,valueType:null,version:null,vAlign:null,vLink:null,vSpace:M,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:$e,part:re,prefix:null,property:null,results:M,security:null,unselectable:null},space:"html",transform:Xr}),Ma=Ge({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ye,accentHeight:M,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:M,amplitude:M,arabicForm:null,ascent:M,attributeName:null,attributeType:null,azimuth:M,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:M,by:null,calcMode:null,capHeight:M,className:re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:M,diffuseConstant:M,direction:null,display:null,dur:null,divisor:M,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:M,enableBackground:null,end:null,event:null,exponent:M,externalResourcesRequired:null,fill:null,fillOpacity:M,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$e,g2:$e,glyphName:$e,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:M,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:M,horizOriginX:M,horizOriginY:M,id:null,ideographic:M,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:M,k:M,k1:M,k2:M,k3:M,k4:M,kernelMatrix:ye,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:M,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:M,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:M,overlineThickness:M,paintOrder:null,panose1:null,path:null,pathLength:M,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:M,pointsAtY:M,pointsAtZ:M,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ye,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ye,rev:ye,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ye,requiredFeatures:ye,requiredFonts:ye,requiredFormats:ye,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:M,specularExponent:M,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:M,strikethroughThickness:M,string:null,stroke:null,strokeDashArray:ye,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:M,strokeOpacity:M,strokeWidth:null,style:null,surfaceScale:M,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ye,tabIndex:M,tableValues:null,target:null,targetX:M,targetY:M,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ye,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:M,underlineThickness:M,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:M,values:null,vAlphabetic:M,vMathematical:M,vectorEffect:null,vHanging:M,vIdeographic:M,version:null,vertAdvY:M,vertOriginX:M,vertOriginY:M,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:M,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gr}),Kr=Ge({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Qr=Ge({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xr}),Jr=Ge({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Ra={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Pa=/[A-Z]/g,_n=/-[a-z]/g,Fa=/^data[-\w.:]+$/i;function _a(e,t){const n=en(t);let r=t,i=xe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Fa.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(_n,Ba);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!_n.test(s)){let a=s.replace(Pa,Oa);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=fn}return new i(r,t)}function Oa(e){return"-"+e.toLowerCase()}function Ba(e){return e.charAt(1).toUpperCase()}const $a=Wr([Yr,Da,Kr,Qr,Jr],"html"),hn=Wr([Yr,Ma,Kr,Qr,Jr],"svg");function Ha(e){return e.join(" ").trim()}var gn={},On=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Ua=/\n/g,Va=/^\s*/,qa=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Wa=/^:\s*/,Ya=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Ga=/^[;\s]*/,Xa=/^\s+|\s+$/g,Ka=`
|
|
2
2
|
`,Bn="/",$n="*",Be="",Qa="comment",Ja="declaration";function Za(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var w=m.match(Ua);w&&(n+=w.length);var C=m.lastIndexOf(Ka);r=~C?m.length-C:r+m.length}function s(){var m={line:n,column:r};return function(w){return w.position=new a(m),u(),w}}function a(m){this.start=m,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function o(m){var w=new Error(t.source+":"+n+":"+r+": "+m);if(w.reason=m,w.filename=t.source,w.line=n,w.column=r,w.source=e,!t.silent)throw w}function l(m){var w=m.exec(e);if(w){var C=w[0];return i(C),e=e.slice(C.length),w}}function u(){l(Va)}function p(m){var w;for(m=m||[];w=c();)w!==!1&&m.push(w);return m}function c(){var m=s();if(!(Bn!=e.charAt(0)||$n!=e.charAt(1))){for(var w=2;Be!=e.charAt(w)&&($n!=e.charAt(w)||Bn!=e.charAt(w+1));)++w;if(w+=2,Be===e.charAt(w-1))return o("End of comment missing");var C=e.slice(2,w-2);return r+=2,i(C),e=e.slice(w),r+=2,m({type:Qa,comment:C})}}function h(){var m=s(),w=l(qa);if(w){if(c(),!l(Wa))return o("property missing ':'");var C=l(Ya),b=m({type:Ja,property:Hn(w[0].replace(On,Be)),value:C?Hn(C[0].replace(On,Be)):Be});return l(Ga),b}}function f(){var m=[];p(m);for(var w;w=h();)w!==!1&&(m.push(w),p(m));return m}return u(),f()}function Hn(e){return e?e.replace(Xa,Be):Be}var es=Za,ts=Me.commonjsGlobal&&Me.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gn,"__esModule",{value:!0});gn.default=rs;const ns=ts(es);function rs(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,ns.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:a,value:o}=s;i?t(a,o,s):o&&(n=n||{},n[a]=o)}),n}var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.camelCase=void 0;var is=/^--[a-zA-Z0-9_-]+$/,as=/-([a-z])/g,ss=/^[^-]+$/,os=/^-(webkit|moz|ms|o|khtml)-/,ls=/^-(ms)-/,us=function(e){return!e||ss.test(e)||is.test(e)},cs=function(e,t){return t.toUpperCase()},Un=function(e,t){return"".concat(t,"-")},ds=function(e,t){return t===void 0&&(t={}),us(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(ls,Un):e=e.replace(os,Un),e.replace(as,cs))};Et.camelCase=ds;var ps=Me.commonjsGlobal&&Me.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},fs=ps(gn),hs=Et;function rn(e,t){var n={};return!e||typeof e!="string"||(0,fs.default)(e,function(r,i){r&&i&&(n[(0,hs.camelCase)(r,t)]=i)}),n}rn.default=rn;var gs=rn;const ms=Me.getDefaultExportFromCjs(gs),Zr=ei("end"),mn=ei("start");function ei(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function xs(e){const t=mn(e),n=Zr(e);if(t&&n)return{start:t,end:n}}function st(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Vn(e.position):"start"in e||"end"in e?Vn(e):"line"in e||"column"in e?an(e):""}function an(e){return qn(e&&e.line)+":"+qn(e&&e.column)}function Vn(e){return an(e&&e.start)+"-"+an(e&&e.end)}function qn(e){return e&&typeof e=="number"?e:1}class he extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=st(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}he.prototype.file="";he.prototype.name="";he.prototype.reason="";he.prototype.message="";he.prototype.stack="";he.prototype.column=void 0;he.prototype.line=void 0;he.prototype.ancestors=void 0;he.prototype.cause=void 0;he.prototype.fatal=void 0;he.prototype.place=void 0;he.prototype.ruleId=void 0;he.prototype.source=void 0;const xn={}.hasOwnProperty,bs=new Map,ws=/[A-Z]/g,ys=new Set(["table","tbody","thead","tfoot","tr"]),ks=new Set(["td","th"]),ti="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vs(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=As(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Ts(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?hn:$a,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=ni(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function ni(e,t,n){if(t.type==="element")return Cs(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ss(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Es(e,t,n);if(t.type==="mdxjsEsm")return js(e,t);if(t.type==="root")return Is(e,t,n);if(t.type==="text")return zs(e,t)}function Cs(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=hn,e.schema=i),e.ancestors.push(t);const s=ii(e,t.tagName,!1),a=Ns(e,t);let o=wn(e,t);return ys.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Na(l):!0})),ri(e,a,s,t),bn(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Ss(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ut(e,t.position)}function js(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ut(e,t.position)}function Es(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=hn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:ii(e,t.name,!0),a=Ls(e,t),o=wn(e,t);return ri(e,a,s,t),bn(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Is(e,t,n){const r={};return bn(r,wn(e,t)),e.create(t,e.Fragment,r,n)}function zs(e,t){return t.value}function ri(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function bn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ts(e,t,n){return r;function r(i,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function As(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=mn(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Ns(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&xn.call(t.properties,i)){const s=Ds(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&ks.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ls(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else ut(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else ut(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function wn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:bs;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;a=l+"-"+u,i.set(l,u+1)}}const o=ni(e,s,a);o!==void 0&&n.push(o)}return n}function Ds(e,t,n){const r=_a(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ea(n):Ha(n)),r.property==="style"){let i=typeof n=="object"?n:Ms(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Rs(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Ra[r.property]||r.property:r.attribute,n]}}function Ms(e,t){try{return ms(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new he("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=ti+"#cannot-parse-style-attribute",i}}function ii(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Rn(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=Rn(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return xn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);ut(e)}function ut(e,t){const n=new he("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ti+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Rs(e){const t={};let n;for(n in e)xn.call(e,n)&&(t[Ps(n)]=e[n]);return t}function Ps(e){let t=e.replace(ws,Fs);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Fs(e){return"-"+e.toLowerCase()}const _t={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},_s={};function yn(e,t){const n=_s,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return ai(e,r,i)}function ai(e,t,n){if(Os(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Wn(e.children,t,n)}return Array.isArray(e)?Wn(e,t,n):""}function Wn(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=ai(e[i],t,n);return r.join("")}function Os(e){return!!(e&&typeof e=="object")}const Yn=document.createElement("i");function kn(e){const t="&"+e+";";Yn.innerHTML=t;const n=Yn.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ke(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Ce(e,t){return e.length>0?(ke(e,e.length,0,t),e):t}const Gn={}.hasOwnProperty;function si(e){const t={};let n=-1;for(;++n<e.length;)Bs(t,e[n]);return t}function Bs(e,t){let n;for(n in t){const i=(Gn.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Gn.call(i,a)||(i[a]=[]);const o=s[a];$s(i[a],Array.isArray(o)?o:o?[o]:[])}}}function $s(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ke(e,0,0,r)}function oi(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function je(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ge=Re(/[A-Za-z]/),fe=Re(/[\dA-Za-z]/),Hs=Re(/[#-'*+\--9=?A-Z^-~]/);function vt(e){return e!==null&&(e<32||e===127)}const sn=Re(/\d/),Us=Re(/[\dA-Fa-f]/),Vs=Re(/[!-/:-@[-`{-~]/);function V(e){return e!==null&&e<-2}function ie(e){return e!==null&&(e<0||e===32)}function Q(e){return e===-2||e===-1||e===32}const It=Re(new RegExp("\\p{P}|\\p{S}","u")),He=Re(/\s/);function Re(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Xe(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&fe(e.charCodeAt(n+1))&&fe(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Z(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Q(l)?(e.enter(n),o(l)):t(l)}function o(l){return Q(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const qs={tokenize:Ws};function Ws(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Z(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return V(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Ys={tokenize:Gs},Xn={tokenize:Xs};function Gs(e){const t=this,n=[];let r=0,i,s,a;return o;function o(j){if(r<n.length){const L=n[r];return t.containerState=L[1],e.attempt(L[0].continuation,l,u)(j)}return u(j)}function l(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&S();const L=t.events.length;let A=L,k;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){k=t.events[A][1].end;break}b(r);let N=L;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return ke(t.events,A+1,0,t.events.slice(L)),t.events.length=N,u(j)}return o(j)}function u(j){if(r===n.length){if(!i)return h(j);if(i.currentConstruct&&i.currentConstruct.concrete)return m(j);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Xn,p,c)(j)}function p(j){return i&&S(),b(r),h(j)}function c(j){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(j)}function h(j){return t.containerState={},e.attempt(Xn,f,m)(j)}function f(j){return r++,n.push([t.currentConstruct,t.containerState]),h(j)}function m(j){if(j===null){i&&S(),b(0),e.consume(j);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(j)}function w(j){if(j===null){C(e.exit("chunkFlow"),!0),b(0),e.consume(j);return}return V(j)?(e.consume(j),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(j),w)}function C(j,L){const A=t.sliceStream(j);if(L&&A.push(null),j.previous=s,s&&(s.next=j),s=j,i.defineSkip(j.start),i.write(A),t.parser.lazy[j.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const N=t.events.length;let _=N,O,v;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){if(O){v=t.events[_][1].end;break}O=!0}for(b(r),k=N;k<t.events.length;)t.events[k][1].end={...v},k++;ke(t.events,_+1,0,t.events.slice(N)),t.events.length=k}}function b(j){let L=n.length;for(;L-- >j;){const A=n[L];t.containerState=A[1],A[0].exit.call(t,e)}n.length=j}function S(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Xs(e,t,n){return Z(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ye(e){if(e===null||ie(e)||He(e))return 1;if(It(e))return 2}function zt(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const on={name:"attention",resolveAll:Ks,tokenize:Qs};function Ks(e,t){let n=-1,r,i,s,a,o,l,u,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},h={...e[n][1].start};Kn(c,-l),Kn(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ce(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ce(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Ce(u,zt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ce(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,u=Ce(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,ke(e,r-1,n-r+3,u),n=r+u.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Qs(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ye(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const u=e.exit("attentionSequence"),p=Ye(l),c=!p||p===2&&i||n.includes(l),h=!i||i===2&&p||n.includes(r);return u._open=!!(s===42?c:c&&(i||!h)),u._close=!!(s===42?h:h&&(p||!c)),t(l)}}function Kn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Js={name:"autolink",tokenize:Zs};function Zs(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(f){return ge(f)?(e.consume(f),a):f===64?n(f):u(f)}function a(f){return f===43||f===45||f===46||fe(f)?(r=1,o(f)):u(f)}function o(f){return f===58?(e.consume(f),r=0,l):(f===43||f===45||f===46||fe(f))&&r++<32?(e.consume(f),o):(r=0,u(f))}function l(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||vt(f)?n(f):(e.consume(f),l)}function u(f){return f===64?(e.consume(f),p):Hs(f)?(e.consume(f),u):n(f)}function p(f){return fe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,p):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):h(f)}function h(f){if((f===45||fe(f))&&r++<63){const m=f===45?h:c;return e.consume(f),m}return n(f)}}const pt={partial:!0,tokenize:eo};function eo(e,t,n){return r;function r(s){return Q(s)?Z(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||V(s)?t(s):n(s)}}const li={continuation:{tokenize:no},exit:ro,name:"blockQuote",tokenize:to};function to(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Q(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function no(e,t,n){const r=this;return i;function i(a){return Q(a)?Z(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(li,t,n)(a)}}function ro(e){e.exit("blockQuote")}const ui={name:"characterEscape",tokenize:io};function io(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Vs(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const ci={name:"characterReference",tokenize:ao};function ao(e,t,n){const r=this;let i=0,s,a;return o;function o(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),l}function l(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=fe,p(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Us,p):(e.enter("characterReferenceValue"),s=7,a=sn,p(c))}function p(c){if(c===59&&i){const h=e.exit("characterReferenceValue");return a===fe&&!kn(r.sliceSerialize(h))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&i++<s?(e.consume(c),p):n(c)}}const Qn={partial:!0,tokenize:oo},Jn={concrete:!0,name:"codeFenced",tokenize:so};function so(e,t,n){const r=this,i={partial:!0,tokenize:A};let s=0,a=0,o;return l;function l(k){return u(k)}function u(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(k)}function p(k){return k===o?(a++,e.consume(k),p):a<3?n(k):(e.exit("codeFencedFenceSequence"),Q(k)?Z(e,c,"whitespace")(k):c(k))}function c(k){return k===null||V(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Qn,w,L)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||V(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(k)):Q(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Z(e,f,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),h)}function f(k){return k===null||V(k)?c(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||V(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(k)):k===96&&k===o?n(k):(e.consume(k),m)}function w(k){return e.attempt(i,L,C)(k)}function C(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),b}function b(k){return s>0&&Q(k)?Z(e,S,"linePrefix",s+1)(k):S(k)}function S(k){return k===null||V(k)?e.check(Qn,w,L)(k):(e.enter("codeFlowValue"),j(k))}function j(k){return k===null||V(k)?(e.exit("codeFlowValue"),S(k)):(e.consume(k),j)}function L(k){return e.exit("codeFenced"),t(k)}function A(k,N,_){let O=0;return v;function v(F){return k.enter("lineEnding"),k.consume(F),k.exit("lineEnding"),D}function D(F){return k.enter("codeFencedFence"),Q(F)?Z(k,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):T(F)}function T(F){return F===o?(k.enter("codeFencedFenceSequence"),E(F)):_(F)}function E(F){return F===o?(O++,k.consume(F),E):O>=a?(k.exit("codeFencedFenceSequence"),Q(F)?Z(k,I,"whitespace")(F):I(F)):_(F)}function I(F){return F===null||V(F)?(k.exit("codeFencedFence"),N(F)):_(F)}}}function oo(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Ot={name:"codeIndented",tokenize:uo},lo={partial:!0,tokenize:co};function uo(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Z(e,s,"linePrefix",5)(u)}function s(u){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?l(u):V(u)?e.attempt(lo,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||V(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function co(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):V(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Z(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):V(a)?i(a):n(a)}}const po={name:"codeText",previous:ho,resolve:fo,tokenize:go};function fo(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ho(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function go(e,t,n){let r=0,i,s;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),o(c)}function o(c){return c===96?(e.consume(c),r++,o):(e.exit("codeTextSequence"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),l):c===96?(s=e.enter("codeTextSequence"),i=0,p(c)):V(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||V(c)?(e.exit("codeTextData"),l(c)):(e.consume(c),u)}function p(c){return c===96?(e.consume(c),i++,p):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class mo{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&it(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),it(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),it(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);it(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);it(this.left,n.reverse())}}}function it(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function di(e){const t={};let n=-1,r,i,s,a,o,l,u;const p=new mo(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,xo(p,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=p.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(p.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...p.get(i)[1].start},o=p.slice(i,n),o.unshift(r),p.splice(i,n-i+1,o))}}return ke(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!u}function xo(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],u={};let p,c,h=-1,f=n,m=0,w=0;const C=[w];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(p=r.sliceStream(f),f.next||p.push(null),c&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(w=h+1,C.push(w),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):C.pop(),h=C.length;h--;){const b=o.slice(C[h],C[h+1]),S=s.pop();l.push([S,S+b.length-1]),e.splice(S,2,b)}for(l.reverse(),h=-1;++h<l.length;)u[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return u}const bo={resolve:yo,tokenize:ko},wo={partial:!0,tokenize:vo};function yo(e){return di(e),e}function ko(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):V(o)?e.check(wo,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function vo(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Z(e,s,"linePrefix")}function s(a){if(a===null||V(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function pi(e,t,n,r,i,s,a,o,l){const u=l||Number.POSITIVE_INFINITY;let p=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),h):b===null||b===32||b===41||vt(b)?n(b):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(b))}function h(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),f(b))}function f(b){return b===62?(e.exit("chunkString"),e.exit(o),h(b)):b===null||b===60||V(b)?n(b):(e.consume(b),b===92?m:f)}function m(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function w(b){return!p&&(b===null||b===41||ie(b))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(b)):p<u&&b===40?(e.consume(b),p++,w):b===41?(e.consume(b),p--,w):b===null||b===32||b===40||vt(b)?n(b):(e.consume(b),b===92?C:w)}function C(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function fi(e,t,n,r,i,s){const a=this;let o=0,l;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),p}function p(f){return o>999||f===null||f===91||f===93&&!l||f===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):V(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===null||f===91||f===93||V(f)||o++>999?(e.exit("chunkString"),p(f)):(e.consume(f),l||(l=!Q(f)),f===92?h:c)}function h(f){return f===91||f===92||f===93?(e.consume(f),o++,c):c(f)}}function hi(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),l(a)):h===null?n(h):V(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Z(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===a||h===null||V(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?c:p)}function c(h){return h===a||h===92?(e.consume(h),p):p(h)}}function ot(e,t){let n;return r;function r(i){return V(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Q(i)?Z(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Co={name:"definition",tokenize:jo},So={partial:!0,tokenize:Eo};function jo(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),a(f)}function a(f){return fi.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function o(f){return i=je(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),l):n(f)}function l(f){return ie(f)?ot(e,u)(f):u(f)}function u(f){return pi(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function p(f){return e.attempt(So,c,c)(f)}function c(f){return Q(f)?Z(e,h,"whitespace")(f):h(f)}function h(f){return f===null||V(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Eo(e,t,n){return r;function r(o){return ie(o)?ot(e,i)(o):n(o)}function i(o){return hi(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Q(o)?Z(e,a,"whitespace")(o):a(o)}function a(o){return o===null||V(o)?t(o):n(o)}}const Io={name:"hardBreakEscape",tokenize:zo};function zo(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return V(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const To={name:"headingAtx",resolve:Ao,tokenize:No};function Ao(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ke(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function No(e,t,n){let r=0;return i;function i(p){return e.enter("atxHeading"),s(p)}function s(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||ie(p)?(e.exit("atxHeadingSequence"),o(p)):n(p)}function o(p){return p===35?(e.enter("atxHeadingSequence"),l(p)):p===null||V(p)?(e.exit("atxHeading"),t(p)):Q(p)?Z(e,o,"whitespace")(p):(e.enter("atxHeadingText"),u(p))}function l(p){return p===35?(e.consume(p),l):(e.exit("atxHeadingSequence"),o(p))}function u(p){return p===null||p===35||ie(p)?(e.exit("atxHeadingText"),o(p)):(e.consume(p),u)}}const Lo=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Zn=["pre","script","style","textarea"],Do={concrete:!0,name:"htmlFlow",resolveTo:Po,tokenize:Fo},Mo={partial:!0,tokenize:Oo},Ro={partial:!0,tokenize:_o};function Po(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Fo(e,t,n){const r=this;let i,s,a,o,l;return u;function u(g){return p(g)}function p(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),s=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:x):ge(g)?(e.consume(g),a=String.fromCharCode(g),C):n(g)}function h(g){return g===45?(e.consume(g),i=2,f):g===91?(e.consume(g),i=5,o=0,m):ge(g)?(e.consume(g),i=4,r.interrupt?t:x):n(g)}function f(g){return g===45?(e.consume(g),r.interrupt?t:x):n(g)}function m(g){const Y="CDATA[";return g===Y.charCodeAt(o++)?(e.consume(g),o===Y.length?r.interrupt?t:T:m):n(g)}function w(g){return ge(g)?(e.consume(g),a=String.fromCharCode(g),C):n(g)}function C(g){if(g===null||g===47||g===62||ie(g)){const Y=g===47,te=a.toLowerCase();return!Y&&!s&&Zn.includes(te)?(i=1,r.interrupt?t(g):T(g)):Lo.includes(a.toLowerCase())?(i=6,Y?(e.consume(g),b):r.interrupt?t(g):T(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):s?S(g):j(g))}return g===45||fe(g)?(e.consume(g),a+=String.fromCharCode(g),C):n(g)}function b(g){return g===62?(e.consume(g),r.interrupt?t:T):n(g)}function S(g){return Q(g)?(e.consume(g),S):v(g)}function j(g){return g===47?(e.consume(g),v):g===58||g===95||ge(g)?(e.consume(g),L):Q(g)?(e.consume(g),j):v(g)}function L(g){return g===45||g===46||g===58||g===95||fe(g)?(e.consume(g),L):A(g)}function A(g){return g===61?(e.consume(g),k):Q(g)?(e.consume(g),A):j(g)}function k(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,N):Q(g)?(e.consume(g),k):_(g)}function N(g){return g===l?(e.consume(g),l=null,O):g===null||V(g)?n(g):(e.consume(g),N)}function _(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||ie(g)?A(g):(e.consume(g),_)}function O(g){return g===47||g===62||Q(g)?j(g):n(g)}function v(g){return g===62?(e.consume(g),D):n(g)}function D(g){return g===null||V(g)?T(g):Q(g)?(e.consume(g),D):n(g)}function T(g){return g===45&&i===2?(e.consume(g),q):g===60&&i===1?(e.consume(g),U):g===62&&i===4?(e.consume(g),H):g===63&&i===3?(e.consume(g),x):g===93&&i===5?(e.consume(g),B):V(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Mo,$,E)(g)):g===null||V(g)?(e.exit("htmlFlowData"),E(g)):(e.consume(g),T)}function E(g){return e.check(Ro,I,$)(g)}function I(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),F}function F(g){return g===null||V(g)?E(g):(e.enter("htmlFlowData"),T(g))}function q(g){return g===45?(e.consume(g),x):T(g)}function U(g){return g===47?(e.consume(g),a="",P):T(g)}function P(g){if(g===62){const Y=a.toLowerCase();return Zn.includes(Y)?(e.consume(g),H):T(g)}return ge(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),P):T(g)}function B(g){return g===93?(e.consume(g),x):T(g)}function x(g){return g===62?(e.consume(g),H):g===45&&i===2?(e.consume(g),x):T(g)}function H(g){return g===null||V(g)?(e.exit("htmlFlowData"),$(g)):(e.consume(g),H)}function $(g){return e.exit("htmlFlow"),t(g)}}function _o(e,t,n){const r=this;return i;function i(a){return V(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Oo(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(pt,t,n)}}const Bo={name:"htmlText",tokenize:$o};function $o(e,t,n){const r=this;let i,s,a;return o;function o(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),l}function l(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),A):x===63?(e.consume(x),j):ge(x)?(e.consume(x),_):n(x)}function u(x){return x===45?(e.consume(x),p):x===91?(e.consume(x),s=0,m):ge(x)?(e.consume(x),S):n(x)}function p(x){return x===45?(e.consume(x),f):n(x)}function c(x){return x===null?n(x):x===45?(e.consume(x),h):V(x)?(a=c,U(x)):(e.consume(x),c)}function h(x){return x===45?(e.consume(x),f):c(x)}function f(x){return x===62?q(x):x===45?h(x):c(x)}function m(x){const H="CDATA[";return x===H.charCodeAt(s++)?(e.consume(x),s===H.length?w:m):n(x)}function w(x){return x===null?n(x):x===93?(e.consume(x),C):V(x)?(a=w,U(x)):(e.consume(x),w)}function C(x){return x===93?(e.consume(x),b):w(x)}function b(x){return x===62?q(x):x===93?(e.consume(x),b):w(x)}function S(x){return x===null||x===62?q(x):V(x)?(a=S,U(x)):(e.consume(x),S)}function j(x){return x===null?n(x):x===63?(e.consume(x),L):V(x)?(a=j,U(x)):(e.consume(x),j)}function L(x){return x===62?q(x):j(x)}function A(x){return ge(x)?(e.consume(x),k):n(x)}function k(x){return x===45||fe(x)?(e.consume(x),k):N(x)}function N(x){return V(x)?(a=N,U(x)):Q(x)?(e.consume(x),N):q(x)}function _(x){return x===45||fe(x)?(e.consume(x),_):x===47||x===62||ie(x)?O(x):n(x)}function O(x){return x===47?(e.consume(x),q):x===58||x===95||ge(x)?(e.consume(x),v):V(x)?(a=O,U(x)):Q(x)?(e.consume(x),O):q(x)}function v(x){return x===45||x===46||x===58||x===95||fe(x)?(e.consume(x),v):D(x)}function D(x){return x===61?(e.consume(x),T):V(x)?(a=D,U(x)):Q(x)?(e.consume(x),D):O(x)}function T(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,E):V(x)?(a=T,U(x)):Q(x)?(e.consume(x),T):(e.consume(x),I)}function E(x){return x===i?(e.consume(x),i=void 0,F):x===null?n(x):V(x)?(a=E,U(x)):(e.consume(x),E)}function I(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||ie(x)?O(x):(e.consume(x),I)}function F(x){return x===47||x===62||ie(x)?O(x):n(x)}function q(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function U(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return Q(x)?Z(e,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):B(x)}function B(x){return e.enter("htmlTextData"),a(x)}}const vn={name:"labelEnd",resolveAll:qo,resolveTo:Wo,tokenize:Yo},Ho={tokenize:Go},Uo={tokenize:Xo},Vo={tokenize:Ko};function qo(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&ke(e,0,e.length,n),e}function Wo(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",u,t]],o=Ce(o,e.slice(s+1,s+r+3)),o=Ce(o,[["enter",p,t]]),o=Ce(o,zt(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Ce(o,[["exit",p,t],e[a-2],e[a-1],["exit",u,t]]),o=Ce(o,e.slice(a+1)),o=Ce(o,[["exit",l,t]]),ke(e,s,e.length,o),e}function Yo(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(h){return s?s._inactive?c(h):(a=r.parser.defined.includes(je(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(Ho,p,a?p:c)(h):h===91?e.attempt(Uo,p,a?u:c)(h):a?p(h):c(h)}function u(h){return e.attempt(Vo,p,c)(h)}function p(h){return t(h)}function c(h){return s._balanced=!0,n(h)}}function Go(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return ie(c)?ot(e,s)(c):s(c)}function s(c){return c===41?p(c):pi(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return ie(c)?ot(e,l)(c):p(c)}function o(c){return n(c)}function l(c){return c===34||c===39||c===40?hi(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):p(c)}function u(c){return ie(c)?ot(e,p)(c):p(c)}function p(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function Xo(e,t,n){const r=this;return i;function i(o){return fi.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(je(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Ko(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Qo={name:"labelStartImage",resolveAll:vn.resolveAll,tokenize:Jo};function Jo(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Zo={name:"labelStartLink",resolveAll:vn.resolveAll,tokenize:el};function el(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Bt={name:"lineEnding",tokenize:tl};function tl(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Z(e,t,"linePrefix")}}const wt={name:"thematicBreak",tokenize:nl};function nl(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||V(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Q(u)?Z(e,o,"whitespace")(u):o(u))}}const me={continuation:{tokenize:sl},exit:ll,name:"list",tokenize:al},rl={partial:!0,tokenize:ul},il={partial:!0,tokenize:ol};function al(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:sn(f)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(wt,n,u)(f):u(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(f)}return n(f)}function l(f){return sn(f)&&++a<10?(e.consume(f),l):(!r.interrupt||a<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(pt,r.interrupt?n:p,e.attempt(rl,h,c))}function p(f){return r.containerState.initialBlankLine=!0,s++,h(f)}function c(f){return Q(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),h):n(f)}function h(f){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function sl(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(pt,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Z(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Q(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(il,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(me,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function ol(e,t,n){const r=this;return Z(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function ll(e){e.exit(this.containerState.type)}function ul(e,t,n){const r=this;return Z(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Q(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const er={name:"setextUnderline",resolveTo:cl,tokenize:dl};function cl(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function dl(e,t,n){const r=this;let i;return s;function s(u){let p=r.events.length,c;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){c=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Q(u)?Z(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||V(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const pl={tokenize:fl};function fl(e){const t=this,n=e.attempt(pt,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bo,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const hl={resolveAll:mi()},gl=gi("string"),ml=gi("text");function gi(e){return{resolveAll:mi(e==="text"?xl:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(p){return u(p)?s(p):o(p)}function o(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),l}function l(p){return u(p)?(n.exit("data"),s(p)):(n.consume(p),l)}function u(p){if(p===null)return!0;const c=i[p];let h=-1;if(c)for(;++h<c.length;){const f=c[h];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function mi(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function xl(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)l=!0,o++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const u={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const bl={42:me,43:me,45:me,48:me,49:me,50:me,51:me,52:me,53:me,54:me,55:me,56:me,57:me,62:li},wl={91:Co},yl={[-2]:Ot,[-1]:Ot,32:Ot},kl={35:To,42:wt,45:[er,wt],60:Do,61:er,95:wt,96:Jn,126:Jn},vl={38:ci,92:ui},Cl={[-5]:Bt,[-4]:Bt,[-3]:Bt,33:Qo,38:ci,42:on,60:[Js,Bo],91:Zo,92:[Io,ui],93:vn,95:on,96:po},Sl={null:[on,hl]},jl={null:[42,95]},El={null:[]},Il=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jl,contentInitial:wl,disable:El,document:bl,flow:kl,flowInitial:yl,insideSpan:Sl,string:vl,text:Cl},Symbol.toStringTag,{value:"Module"}));function zl(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:N(A),check:N(k),consume:S,enter:j,exit:L,interrupt:N(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:f,write:c};let p=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function c(D){return a=Ce(a,D),C(),a[a.length-1]!==null?[]:(_(t,0),u.events=zt(s,u.events,u),u.events)}function h(D,T){return Al(f(D),T)}function f(D){return Tl(a,D)}function m(){const{_bufferIndex:D,_index:T,line:E,column:I,offset:F}=r;return{_bufferIndex:D,_index:T,line:E,column:I,offset:F}}function w(D){i[D.line]=D.column,v()}function C(){let D;for(;r._index<a.length;){const T=a[r._index];if(typeof T=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<T.length;)b(T.charCodeAt(r._bufferIndex));else b(T)}}function b(D){p=p(D)}function S(D){V(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,v()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=D}function j(D,T){const E=T||{};return E.type=D,E.start=m(),u.events.push(["enter",E,u]),o.push(E),E}function L(D){const T=o.pop();return T.end=m(),u.events.push(["exit",T,u]),T}function A(D,T){_(D,T.from)}function k(D,T){T.restore()}function N(D,T){return E;function E(I,F,q){let U,P,B,x;return Array.isArray(I)?$(I):"tokenize"in I?$([I]):H(I);function H(ee){return ue;function ue(ae){const W=ae!==null&&ee[ae],se=ae!==null&&ee.null,le=[...Array.isArray(W)?W:W?[W]:[],...Array.isArray(se)?se:se?[se]:[]];return $(le)(ae)}}function $(ee){return U=ee,P=0,ee.length===0?q:g(ee[P])}function g(ee){return ue;function ue(ae){return x=O(),B=ee,ee.partial||(u.currentConstruct=ee),ee.name&&u.parser.constructs.disable.null.includes(ee.name)?te():ee.tokenize.call(T?Object.assign(Object.create(u),T):u,l,Y,te)(ae)}}function Y(ee){return D(B,x),F}function te(ee){return x.restore(),++P<U.length?g(U[P]):q}}}function _(D,T){D.resolveAll&&!s.includes(D)&&s.push(D),D.resolve&&ke(u.events,T,u.events.length-T,D.resolve(u.events.slice(T),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function O(){const D=m(),T=u.previous,E=u.currentConstruct,I=u.events.length,F=Array.from(o);return{from:I,restore:q};function q(){r=D,u.previous=T,u.currentConstruct=E,u.events.length=I,o=F,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Tl(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Al(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
3
3
|
`;break}case-3:{a=`\r
|
|
4
4
|
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Nl(e){const r={constructs:si([Il,...(e||{}).extensions||[]]),content:i(qs),defined:[],document:i(Ys),flow:i(pl),lazy:{},string:i(gl),text:i(ml)};return r;function i(s){return a;function a(o){return zl(r,s,o)}}}function Ll(e){for(;!di(e););return e}const tr=/[\0\t\n\r]/g;function Dl(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let u,p,c,h,f;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),c=0,t="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){if(tr.lastIndex=c,u=tr.exec(s),h=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(h),!u){t=s.slice(c);break}if(f===10&&c===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<h&&(l.push(s.slice(c,h)),e+=h-c),f){case 0:{l.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,l.push(-2);e++<p;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Ml=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Rl(e){return e.replace(Ml,Pl)}function Pl(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return oi(n.slice(s?2:1),s?16:10)}return kn(n)||e}const xi={}.hasOwnProperty;function Fl(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),_l(n)(Ll(Nl(n).document().write(Dl()(e,t,!0))))}function _l(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Je),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(Ke),blockQuote:s(se),characterEscape:O,characterReference:O,codeFenced:s(le),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(le,a),codeText:s(Ee,a),codeTextData:O,data:O,codeFlowValue:O,definition:s(be),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Lt),hardBreakEscape:s(Qe),hardBreakTrailing:s(Qe),htmlFlow:s(Pe,a),htmlFlowData:O,htmlText:s(Pe,a),htmlTextData:O,image:s(Dt),label:a,link:s(Je),listItem:s(ve),listItemValue:h,listOrdered:s(Ze,c),listUnordered:s(Ze),paragraph:s(ht),reference:g,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Ke),strong:s(Mt),thematicBreak:s(Rt)},exit:{atxHeading:l(),atxHeadingSequence:A,autolink:l(),autolinkEmail:W,autolinkProtocol:ae,blockQuote:l(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:ee,characterReference:ue,codeFenced:l(C),codeFencedFence:w,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:v,codeIndented:l(b),codeText:l(F),codeTextData:v,data:v,definition:l(),definitionDestinationString:L,definitionLabelString:S,definitionTitleString:j,emphasis:l(),hardBreakEscape:l(T),hardBreakTrailing:l(T),htmlFlow:l(E),htmlFlowData:v,htmlText:l(I),htmlTextData:v,image:l(U),label:B,labelText:P,lineEnding:D,link:l(q),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Y,resourceDestinationString:x,resourceTitleString:H,resource:$,setextHeading:l(_),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};bi(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(z){let R={type:"root",children:[]};const G={stack:[R],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:p,data:n},K=[];let ne=-1;for(;++ne<z.length;)if(z[ne][1].type==="listOrdered"||z[ne][1].type==="listUnordered")if(z[ne][0]==="enter")K.push(ne);else{const Se=K.pop();ne=i(z,Se,ne)}for(ne=-1;++ne<z.length;){const Se=t[z[ne][0]];xi.call(Se,z[ne][1].type)&&Se[z[ne][1].type].call(Object.assign({sliceSerialize:z[ne][2].sliceSerialize},G),z[ne][1])}if(G.tokenStack.length>0){const Se=G.tokenStack[G.tokenStack.length-1];(Se[1]||nr).call(G,void 0,Se[0])}for(R.position={start:De(z.length>0?z[0][1].start:{line:1,column:1,offset:0}),end:De(z.length>0?z[z.length-2][1].end:{line:1,column:1,offset:0})},ne=-1;++ne<t.transforms.length;)R=t.transforms[ne](R)||R;return R}function i(z,R,G){let K=R-1,ne=-1,Se=!1,Fe,Ae,et,tt;for(;++K<=G;){const we=z[K];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?ne++:ne--,tt=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(Fe&&!tt&&!ne&&!et&&(et=K),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!ne&&we[0]==="enter"&&we[1].type==="listItemPrefix"||ne===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(Fe){let qe=K;for(Ae=void 0;qe--;){const Ne=z[qe];if(Ne[1].type==="lineEnding"||Ne[1].type==="lineEndingBlank"){if(Ne[0]==="exit")continue;Ae&&(z[Ae][1].type="lineEndingBlank",Se=!0),Ne[1].type="lineEnding",Ae=qe}else if(!(Ne[1].type==="linePrefix"||Ne[1].type==="blockQuotePrefix"||Ne[1].type==="blockQuotePrefixWhitespace"||Ne[1].type==="blockQuoteMarker"||Ne[1].type==="listItemIndent"))break}et&&(!Ae||et<Ae)&&(Fe._spread=!0),Fe.end=Object.assign({},Ae?z[Ae][1].start:we[1].end),z.splice(Ae||K,0,["exit",Fe,we[2]]),K++,G++}if(we[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};Fe=qe,z.splice(K,0,["enter",qe,we[2]]),K++,G++,et=void 0,tt=!0}}}return z[R][1]._spread=Se,G}function s(z,R){return G;function G(K){o.call(this,z(K),K),R&&R.call(this,K)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(z,R,G){this.stack[this.stack.length-1].children.push(z),this.stack.push(z),this.tokenStack.push([R,G||void 0]),z.position={start:De(R.start),end:void 0}}function l(z){return R;function R(G){z&&z.call(this,G),u.call(this,G)}}function u(z,R){const G=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==z.type&&(R?R.call(this,z,K[0]):(K[1]||nr).call(this,z,K[0]));else throw new Error("Cannot close `"+z.type+"` ("+st({start:z.start,end:z.end})+"): it’s not open");G.position.end=De(z.end)}function p(){return yn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function h(z){if(this.data.expectingFirstListItemValue){const R=this.stack[this.stack.length-2];R.start=Number.parseInt(this.sliceSerialize(z),10),this.data.expectingFirstListItemValue=void 0}}function f(){const z=this.resume(),R=this.stack[this.stack.length-1];R.lang=z}function m(){const z=this.resume(),R=this.stack[this.stack.length-1];R.meta=z}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const z=this.resume(),R=this.stack[this.stack.length-1];R.value=z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const z=this.resume(),R=this.stack[this.stack.length-1];R.value=z.replace(/(\r?\n|\r)$/g,"")}function S(z){const R=this.resume(),G=this.stack[this.stack.length-1];G.label=R,G.identifier=je(this.sliceSerialize(z)).toLowerCase()}function j(){const z=this.resume(),R=this.stack[this.stack.length-1];R.title=z}function L(){const z=this.resume(),R=this.stack[this.stack.length-1];R.url=z}function A(z){const R=this.stack[this.stack.length-1];if(!R.depth){const G=this.sliceSerialize(z).length;R.depth=G}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(z){const R=this.stack[this.stack.length-1];R.depth=this.sliceSerialize(z).codePointAt(0)===61?1:2}function _(){this.data.setextHeadingSlurpLineEnding=void 0}function O(z){const G=this.stack[this.stack.length-1].children;let K=G[G.length-1];(!K||K.type!=="text")&&(K=Ve(),K.position={start:De(z.start),end:void 0},G.push(K)),this.stack.push(K)}function v(z){const R=this.stack.pop();R.value+=this.sliceSerialize(z),R.position.end=De(z.end)}function D(z){const R=this.stack[this.stack.length-1];if(this.data.atHardBreak){const G=R.children[R.children.length-1];G.position.end=De(z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(R.type)&&(O.call(this,z),v.call(this,z))}function T(){this.data.atHardBreak=!0}function E(){const z=this.resume(),R=this.stack[this.stack.length-1];R.value=z}function I(){const z=this.resume(),R=this.stack[this.stack.length-1];R.value=z}function F(){const z=this.resume(),R=this.stack[this.stack.length-1];R.value=z}function q(){const z=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=R,delete z.url,delete z.title}else delete z.identifier,delete z.label;this.data.referenceType=void 0}function U(){const z=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=R,delete z.url,delete z.title}else delete z.identifier,delete z.label;this.data.referenceType=void 0}function P(z){const R=this.sliceSerialize(z),G=this.stack[this.stack.length-2];G.label=Rl(R),G.identifier=je(R).toLowerCase()}function B(){const z=this.stack[this.stack.length-1],R=this.resume(),G=this.stack[this.stack.length-1];if(this.data.inReference=!0,G.type==="link"){const K=z.children;G.children=K}else G.alt=R}function x(){const z=this.resume(),R=this.stack[this.stack.length-1];R.url=z}function H(){const z=this.resume(),R=this.stack[this.stack.length-1];R.title=z}function $(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function Y(z){const R=this.resume(),G=this.stack[this.stack.length-1];G.label=R,G.identifier=je(this.sliceSerialize(z)).toLowerCase(),this.data.referenceType="full"}function te(z){this.data.characterReferenceType=z.type}function ee(z){const R=this.sliceSerialize(z),G=this.data.characterReferenceType;let K;G?(K=oi(R,G==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=kn(R);const ne=this.stack[this.stack.length-1];ne.value+=K}function ue(z){const R=this.stack.pop();R.position.end=De(z.end)}function ae(z){v.call(this,z);const R=this.stack[this.stack.length-1];R.url=this.sliceSerialize(z)}function W(z){v.call(this,z);const R=this.stack[this.stack.length-1];R.url="mailto:"+this.sliceSerialize(z)}function se(){return{type:"blockquote",children:[]}}function le(){return{type:"code",lang:null,meta:null,value:""}}function Ee(){return{type:"inlineCode",value:""}}function be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Lt(){return{type:"emphasis",children:[]}}function Ke(){return{type:"heading",depth:0,children:[]}}function Qe(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Dt(){return{type:"image",title:null,url:"",alt:null}}function Je(){return{type:"link",title:null,url:"",children:[]}}function Ze(z){return{type:"list",ordered:z.type==="listOrdered",start:null,spread:z._spread,children:[]}}function ve(z){return{type:"listItem",spread:z._spread,checked:null,children:[]}}function ht(){return{type:"paragraph",children:[]}}function Mt(){return{type:"strong",children:[]}}function Ve(){return{type:"text",value:""}}function Rt(){return{type:"thematicBreak"}}}function De(e){return{line:e.line,column:e.column,offset:e.offset}}function bi(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?bi(e,r):Ol(e,r)}}function Ol(e,t){let n;for(n in t)if(xi.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function nr(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+st({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+st({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+st({start:t.start,end:t.end})+") is still open")}function Bl(e){const t=this;t.parser=n;function n(r){return Fl(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $l(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Hl(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
`,...s.current()});return/^[\t ]/.test(u)&&(u=ct(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}Ri.peek=od;function Ri(e){return e.value||""}function od(){return"<"}Pi.peek=ld;function Pi(e,t,n,r){const i=Tn(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(o=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),o()),u+=l.move(")"),a(),u}function ld(){return"!"}Fi.peek=ud;function Fi(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const u=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=p,s(),i==="full"||!u||u!==c?l+=o.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function ud(){return"!"}_i.peek=cd;function _i(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function cd(){return"`"}function Oi(e,t){const n=yn(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Bi.peek=dd;function Bi(e,t,n,r){const i=Tn(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(Oi(e,n)){const p=n.stack;n.stack=[],o=n.enter("autolink");let c=a.move("<");return c+=a.move(n.containerPhrasing(e,{before:c,after:">",...a.current()})),c+=a.move(">"),o(),n.stack=p,c}o=n.enter("link"),l=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),u+=a.move(")"),o(),u}function dd(e,t,n){return Oi(e,n)?"<":"["}$i.peek=pd;function $i(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=p,s(),i==="full"||!u||u!==c?l+=o.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function pd(){return"["}function An(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function fd(e){const t=An(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function hd(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Hi(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function gd(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?hd(n):An(n);const o=e.ordered?a==="."?")":".":fd(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Hi(n)===a&&p){let c=-1;for(;++c<e.children.length;){const h=e.children[c];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function md(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function xd(e,t,n,r){const i=md(n);let s=n.bulletCurrent||An(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),p);return l(),u;function p(c,h,f){return h?(f?"":" ".repeat(a))+c:(f?s:s+" ".repeat(a-s.length))+c}}function bd(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const wd=At(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function yd(e,t,n,r){return(e.children.some(function(a){return wd(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function kd(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ui.peek=vd;function Ui(e,t,n,r){const i=kd(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=l.charCodeAt(0),p=jt(r.before.charCodeAt(r.before.length-1),u,i);p.inside&&(l=ct(u)+l.slice(1));const c=l.charCodeAt(l.length-1),h=jt(r.after.charCodeAt(0),c,i);h.inside&&(l=l.slice(0,-1)+ct(c));const f=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:p.outside},o+l+f}function vd(e,t,n){return n.options.strong||"*"}function Cd(e,t,n,r){return n.safe(e.value,r)}function Sd(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function jd(e,t,n){const r=(Hi(n)+(n.options.ruleSpaces?" ":"")).repeat(Sd(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Vi={blockquote:Gc,break:Er,code:ed,definition:nd,emphasis:Mi,hardBreak:Er,heading:sd,html:Ri,image:Pi,imageReference:Fi,inlineCode:_i,link:Bi,linkReference:$i,list:gd,listItem:xd,paragraph:bd,root:yd,strong:Ui,text:Cd,thematicBreak:jd};function Ed(){return{enter:{table:Id,tableData:Ir,tableHeader:Ir,tableRow:Td},exit:{codeText:Ad,table:zd,tableData:Qt,tableHeader:Qt,tableRow:Qt}}}function Id(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function zd(e){this.exit(e),this.data.inTable=void 0}function Td(e){this.enter({type:"tableRow",children:[]},e)}function Qt(e){this.exit(e)}function Ir(e){this.enter({type:"tableCell",children:[]},e)}function Ad(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Nd));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Nd(e,t){return t==="|"?t:e}function Ld(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
28
28
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:a,tableCell:l,tableRow:o}};function a(f,m,w,C){return u(p(f,w,C),f.align)}function o(f,m,w,C){const b=c(f,w,C),S=u([b]);return S.slice(0,S.indexOf(`
|
|
29
29
|
`))}function l(f,m,w,C){const b=w.enter("tableCell"),S=w.enter("phrasing"),j=w.containerPhrasing(f,{...C,before:s,after:s});return S(),b(),j}function u(f,m){return Wc(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function p(f,m,w){const C=f.children;let b=-1;const S=[],j=m.enter("table");for(;++b<C.length;)S[b]=c(C[b],m,w);return j(),S}function c(f,m,w){const C=f.children;let b=-1;const S=[],j=m.enter("tableRow");for(;++b<C.length;)S[b]=l(C[b],f,m,w);return j(),S}function h(f,m,w){let C=Vi.inlineCode(f,m,w);return w.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function Dd(){return{exit:{taskListCheckValueChecked:zr,taskListCheckValueUnchecked:zr,paragraph:Rd}}}function Md(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Pd}}}function zr(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Rd(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Pd(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=Vi.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(p){return p+a}}function Fd(){return[gc(),Pc(),Bc(),Ed(),Dd()]}function _d(e){return{extensions:[mc(),Fc(e),$c(),Ld(e),Md()]}}const Od={tokenize:qd,partial:!0},qi={tokenize:Wd,partial:!0},Wi={tokenize:Yd,partial:!0},Yi={tokenize:Gd,partial:!0},Bd={tokenize:Xd,partial:!0},Gi={name:"wwwAutolink",tokenize:Ud,previous:Ki},Xi={name:"protocolAutolink",tokenize:Vd,previous:Qi},Le={name:"emailAutolink",tokenize:Hd,previous:Ji},Te={};function $d(){return{text:Te}}let _e=48;for(;_e<123;)Te[_e]=Le,_e++,_e===58?_e=65:_e===91&&(_e=97);Te[43]=Le;Te[45]=Le;Te[46]=Le;Te[95]=Le;Te[72]=[Le,Xi];Te[104]=[Le,Xi];Te[87]=[Le,Gi];Te[119]=[Le,Gi];function Hd(e,t,n){const r=this;let i,s;return a;function a(c){return!pn(c)||!Ji.call(r,r.previous)||Nn(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(c))}function o(c){return pn(c)?(e.consume(c),o):c===64?(e.consume(c),l):n(c)}function l(c){return c===46?e.check(Bd,p,u)(c):c===45||c===95||fe(c)?(s=!0,e.consume(c),l):p(c)}function u(c){return e.consume(c),i=!0,l}function p(c){return s&&i&&ge(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function Ud(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Ki.call(r,r.previous)||Nn(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Od,e.attempt(qi,e.attempt(Wi,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Vd(e,t,n){const r=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&Qi.call(r,r.previous)&&!Nn(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),o):n(c)}function o(c){if(ge(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),o;if(c===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(c),l}return n(c)}function l(c){return c===47?(e.consume(c),s?u:(s=!0,l)):n(c)}function u(c){return c===null||vt(c)||ie(c)||He(c)||It(c)?n(c):e.attempt(qi,e.attempt(Wi,p),n)(c)}function p(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function qd(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function Wd(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Yi,l,o)(u):u===null||ie(u)||He(u)||u!==45&&It(u)?l(u):(s=!0,e.consume(u),a)}function o(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function l(u){return i||r||!s?n(u):t(u)}}function Yd(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Yi,t,s)(a):a===null||ie(a)||He(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function Gd(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||ie(o)||He(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||ie(o)||He(o)?t(o):r(o)}function s(o){return ge(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):ge(o)?(e.consume(o),a):n(o)}}function Xd(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return fe(s)?n(s):t(s)}}function Ki(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ie(e)}function Qi(e){return!ge(e)}function Ji(e){return!(e===47||pn(e))}function pn(e){return e===43||e===45||e===46||e===95||fe(e)}function Nn(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Kd={tokenize:ip,partial:!0};function Qd(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:tp,continuation:{tokenize:np},exit:rp}},text:{91:{name:"gfmFootnoteCall",tokenize:ep},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Jd,resolveTo:Zd}}}}function Jd(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const u=je(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Zd(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function ep(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),l}function l(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!a||c===null||c===91||ie(c))return n(c);if(c===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(je(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return ie(c)||(a=!0),s++,e.consume(c),c===92?p:u}function p(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function tp(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(m)}function p(m){if(a>999||m===93&&!o||m===null||m===91||ie(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=je(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return ie(m)||(o=!0),a++,e.consume(m),m===92?c:p}function c(m){return m===91||m===92||m===93?(e.consume(m),a++,p):p(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Z(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function np(e,t,n){return e.check(pt,t,e.attempt(Kd,t,n))}function rp(e){e.exit("gfmFootnoteDefinition")}function ip(e,t,n){const r=this;return Z(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function ap(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let u=l;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[l][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[l][1].end)},c={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},h=[["enter",p,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",c,o]],f=o.parser.constructs.insideSpan.null;f&&ke(h,h.length,0,zt(f,a.slice(u+1,l),o)),ke(h,h.length,0,[["exit",c,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",p,o]]),ke(a,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const u=this.previous,p=this.events;let c=0;return h;function h(m){return u===126&&p[p.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const w=Ye(u);if(m===126)return c>1?l(m):(a.consume(m),c++,f);if(c<2&&!n)return l(m);const C=a.exit("strikethroughSequenceTemporary"),b=Ye(m);return C._open=!b||b===2&&!!w,C._close=!w||w===2&&!!b,o(m)}}}class sp{constructor(){this.map=[]}add(t,n,r){op(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function op(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function lp(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function up(){return{flow:{null:{name:"table",tokenize:cp,resolveAll:dp}}}}function cp(e,t,n){const r=this;let i=0,s=0,a;return o;function o(v){let D=r.events.length-1;for(;D>-1;){const I=r.events[D][1].type;if(I==="lineEnding"||I==="linePrefix")D--;else break}const T=D>-1?r.events[D][1].type:null,E=T==="tableHead"||T==="tableRow"?k:l;return E===k&&r.parser.lazy[r.now().line]?n(v):E(v)}function l(v){return e.enter("tableHead"),e.enter("tableRow"),u(v)}function u(v){return v===124||(a=!0,s+=1),p(v)}function p(v){return v===null?n(v):V(v)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),f):n(v):Q(v)?Z(e,p,"whitespace")(v):(s+=1,a&&(a=!1,i+=1),v===124?(e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),a=!0,p):(e.enter("data"),c(v)))}function c(v){return v===null||v===124||ie(v)?(e.exit("data"),p(v)):(e.consume(v),v===92?h:c)}function h(v){return v===92||v===124?(e.consume(v),c):c(v)}function f(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter("tableDelimiterRow"),a=!1,Q(v)?Z(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):m(v))}function m(v){return v===45||v===58?C(v):v===124?(a=!0,e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),w):A(v)}function w(v){return Q(v)?Z(e,C,"whitespace")(v):C(v)}function C(v){return v===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(v),e.exit("tableDelimiterMarker"),b):v===45?(s+=1,b(v)):v===null||V(v)?L(v):A(v)}function b(v){return v===45?(e.enter("tableDelimiterFiller"),S(v)):A(v)}function S(v){return v===45?(e.consume(v),S):v===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(v),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(v))}function j(v){return Q(v)?Z(e,L,"whitespace")(v):L(v)}function L(v){return v===124?m(v):v===null||V(v)?!a||i!==s?A(v):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(v)):A(v)}function A(v){return n(v)}function k(v){return e.enter("tableRow"),N(v)}function N(v){return v===124?(e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),N):v===null||V(v)?(e.exit("tableRow"),t(v)):Q(v)?Z(e,N,"whitespace")(v):(e.enter("data"),_(v))}function _(v){return v===null||v===124||ie(v)?(e.exit("data"),N(v)):(e.consume(v),v===92?O:_)}function O(v){return v===92||v===124?(e.consume(v),_):_(v)}}function dp(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,u,p,c;const h=new sp;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(Tr(h,t,l,u,p),p=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,c=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,p={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",p,t]])),i=m.type==="tableDelimiterRow"?2:p?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],c=bt(h,t,s,i,void 0,c),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],c=bt(h,t,s,i,void 0,c)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],c=bt(h,t,s,i,n,c)):a[1]!==0&&(c=bt(h,t,a,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&Tr(h,t,l,u,p),h.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=lp(t.events,n))}return e}function bt(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},We(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=We(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=We(t.events,n[2]),p=We(t.events,n[3]),c={type:o,start:Object.assign({},u),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const h=t.events[n[2]],f=t.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,w=n[3]-n[2]-1;e.add(m,w,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},We(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Tr(e,t,n,r,i){const s=[],a=We(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function We(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const pp={name:"tasklistCheck",tokenize:hp};function fp(){return{text:{91:pp}}}function hp(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ie(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return V(l)?t(l):Q(l)?e.check({tokenize:gp},t,n)(l):n(l)}}function gp(e,t,n){return Z(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function mp(e){return si([$d(),Qd(),ap(e),up(),fp()])}const xp={};function Zi(e){const t=this,n=e||xp,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mp(n)),s.push(Fd()),a.push(_d(n))}function ea({content:e}){return d.jsx("div",{className:"sa-text-part",children:d.jsx(Ti,{remarkPlugins:[Zi],children:e})})}const bp="https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";let Ar=!1;function ta(e=bp){if(Ar||typeof document>"u")return;Ar=!0;const t=e.split("?")[0].split("/").pop();if(t&&document.querySelector(`script[src*="${t}"]`))return;const n=document.createElement("script");n.src=e,document.head.appendChild(n)}ta();function J({name:e,size:t=16,color:n="currentColor",className:r,style:i}){return d.jsx("svg",{className:r,style:{width:t,height:t,fill:n,verticalAlign:"middle",...i},"aria-hidden":"true",children:d.jsx("use",{href:`#icon-${e}`})})}function na({content:e}){const[t,n]=y.useState(!1);return d.jsxs("div",{className:"sa-thinking-part",onClick:()=>n(!t),children:[d.jsxs("div",{className:"sa-thinking-header",children:[d.jsx("span",{className:"sa-thinking-icon",children:d.jsx(J,{name:"brain",size:14})}),d.jsx("span",{className:"sa-thinking-label",children:"思考过程"}),d.jsx("span",{className:`sa-thinking-arrow ${t?"expanded":""}`,children:d.jsx(J,{name:"chevron-right",size:12})})]}),t&&d.jsx("div",{className:"sa-thinking-content",children:e})]})}function ra({toolName:e,toolCallId:t,args:n}){const[r,i]=y.useState(!1),[s,a]=y.useState(!1);let o=n;try{o=JSON.stringify(JSON.parse(n),null,2)}catch{}const l=y.useCallback(()=>{var u;(u=navigator.clipboard)==null||u.writeText(o).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})},[o]);return d.jsxs("div",{className:"sa-tool-call-part",children:[d.jsxs("div",{className:"sa-tool-call-header",onClick:()=>i(!r),children:[d.jsx("span",{className:"sa-tool-icon",children:d.jsx(J,{name:"zap",size:14})}),d.jsxs("span",{className:"sa-tool-name",children:["调用工具: ",e]}),d.jsx("span",{className:`sa-thinking-arrow ${r?"expanded":""}`,children:d.jsx(J,{name:"chevron-right",size:12})})]}),r&&d.jsxs(d.Fragment,{children:[d.jsx("pre",{className:"sa-tool-args",children:o}),d.jsx("div",{className:"sa-tool-result-actions",children:d.jsxs("button",{className:"sa-action-btn",onClick:l,title:"复制",children:[d.jsx(J,{name:s?"circle-check":"copy",size:14})," ",s?"已复制":"复制"]})})]})]})}function Nr({text:e}){const[t,n]=y.useState(!1),r=()=>{var i;(i=navigator.clipboard)==null||i.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return d.jsxs("button",{className:"sa-action-btn",onClick:r,title:"复制",children:[d.jsx(J,{name:t?"circle-check":"copy",size:14})," ",t?"已复制":"复制"]})}function wp({html:e}){const[t,n]=y.useState(null);return y.useEffect(()=>{let r=!1;return Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs")).then(i=>{r||n(i.default.sanitize(e,{FORCE_BODY:!0,ADD_ATTR:["target"]}))}),()=>{r=!0}},[e]),t===null?null:d.jsx("div",{className:"sa-tool-result-html-scroll",children:d.jsx("div",{className:"sa-tool-result-html sa-text-part",dangerouslySetInnerHTML:{__html:t}})})}function ia({toolName:e,content:t,renderMode:n,html:r}){let i=t;if(i)try{i=JSON.stringify(JSON.parse(i),null,2)}catch{}return d.jsxs("div",{className:"sa-tool-result-part",children:[d.jsxs("div",{className:"sa-tool-result-header",children:[d.jsx("span",{className:"sa-tool-icon",children:d.jsx(J,{name:"circle-check",size:14,color:"#10b981"})}),d.jsx("span",{className:"sa-tool-result-label",children:e||"工具返回"})]}),n==="html"&&r?d.jsxs(d.Fragment,{children:[d.jsx(wp,{html:r}),d.jsx("div",{className:"sa-tool-result-actions",children:d.jsx(Nr,{text:r})})]}):i?d.jsxs(d.Fragment,{children:[d.jsx("pre",{className:"sa-tool-result-content",children:i}),d.jsx("div",{className:"sa-tool-result-actions",children:d.jsx(Nr,{text:i})})]}):d.jsx("pre",{className:"sa-tool-result-content",children:"—"})]})}function aa({content:e,onRetry:t}){return d.jsxs("div",{className:"sa-error-part",children:[d.jsxs("div",{className:"sa-error-content",children:[d.jsx("span",{className:"sa-error-icon",children:d.jsx(J,{name:"triangle-alert",size:14})}),d.jsx("span",{children:e||"发生错误"})]}),t&&d.jsx("button",{className:"sa-error-retry",onClick:t,children:"重试"})]})}function sa(e){return e==null||Number.isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yp({attachment:e}){const t=d.jsxs(d.Fragment,{children:[d.jsx(J,{name:"file-text",size:14,color:"#6366f1"}),d.jsx("span",{className:"sa-attachment-chip-name",children:e.filename}),e.size!=null&&d.jsx("span",{className:"sa-attachment-chip-size",children:sa(e.size)})]});return e.url?d.jsx("a",{className:"sa-attachment-chip",href:e.url,target:"_blank",rel:"noreferrer",download:e.filename,title:`下载 ${e.filename}`,children:t}):d.jsx("span",{className:"sa-attachment-chip",title:e.filename,children:t})}function kp({interrupt:e,onRespond:t,disabled:n,answeredAction:r}){var o,l;const i=e.options,s=(typeof(i==null?void 0:i[0])=="string"?i[0]:(o=i==null?void 0:i[0])==null?void 0:o.label)||"确认",a=(typeof(i==null?void 0:i[1])=="string"?i[1]:(l=i==null?void 0:i[1])==null?void 0:l.label)||"取消";return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"circle-alert",size:16,color:"#f59e0b"}),d.jsx("span",{children:e.content})]}),d.jsxs("div",{className:"sa-interrupt-actions",children:[d.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${r==="confirm"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>t({action:"confirm"}),children:[d.jsx(J,{name:"check",size:14})," ",s]}),d.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${r==="cancel"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>t({action:"cancel"}),children:[d.jsx(J,{name:"x",size:14})," ",a]})]}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function vp({interrupt:e,onRespond:t,disabled:n,answeredAction:r}){var u,p,c,h;const i=e.options,s=(typeof(i==null?void 0:i[0])=="string"?i[0]:(u=i==null?void 0:i[0])==null?void 0:u.label)||"批准",a=(typeof(i==null?void 0:i[1])=="string"?i[1]:(p=i==null?void 0:i[1])==null?void 0:p.label)||"拒绝",o=(typeof(i==null?void 0:i[2])=="string"?i[2]:(c=i==null?void 0:i[2])==null?void 0:c.label)||"跳过",l=((h=e.metadata)==null?void 0:h.showSkip)!==!1;return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"circle-alert",size:16,color:"#f59e0b"}),d.jsx("span",{children:e.content})]}),d.jsxs("div",{className:"sa-interrupt-actions",children:[d.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-primary ${r==="approve"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>t({action:"approve"}),children:[d.jsx(J,{name:"check",size:14})," ",s]}),d.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-danger ${r==="reject"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>t({action:"reject"}),children:[d.jsx(J,{name:"x",size:14})," ",a]}),l&&d.jsxs("button",{className:`sa-interrupt-btn sa-interrupt-btn-secondary ${r==="skip"?"sa-interrupt-btn-answered":""}`,disabled:n,onClick:()=>t({action:"skip"}),children:[d.jsx(J,{name:"chevron-right",size:14})," ",o]})]}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Cp(e){return typeof e=="string"?{value:e,label:e}:e}function Sp({interrupt:e,onRespond:t,disabled:n,initialValue:r}){const i=(e.options??[]).map(Cp);return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"list",size:16,color:"#6366f1"}),d.jsx("span",{children:e.content})]}),d.jsx("div",{className:"sa-interrupt-options",children:i.map(s=>{const a=r===s.value;return d.jsxs("button",{className:`sa-interrupt-option ${s.danger?"sa-interrupt-option-danger":""} ${a?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>t({action:"select",value:s.value}),children:[d.jsx(J,{name:a?"circle-check":"circle",size:14}),s.icon&&d.jsx(J,{name:s.icon,size:14}),d.jsx("span",{children:s.label}),s.description&&d.jsx("span",{className:"sa-interrupt-option-desc",children:s.description})]},s.value)})}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function jp(e){return typeof e=="string"?{value:e,label:e}:e}function Ep({interrupt:e,onRespond:t,disabled:n,initialValue:r}){const i=(e.options??[]).map(jp),[s,a]=y.useState(()=>new Set(Array.isArray(r)?r:[])),o=l=>{n||a(u=>{const p=new Set(u);return p.has(l)?p.delete(l):p.add(l),p})};return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"list-checks",size:16,color:"#6366f1"}),d.jsx("span",{children:e.content})]}),d.jsx("div",{className:"sa-interrupt-options",children:i.map(l=>d.jsxs("button",{className:`sa-interrupt-option ${s.has(l.value)?"sa-interrupt-option-selected":""}`,disabled:n,onClick:()=>o(l.value),children:[d.jsx(J,{name:s.has(l.value)?"square-check":"square",size:14}),d.jsx("span",{children:l.label})]},l.value))}),!n&&d.jsx("div",{className:"sa-interrupt-actions",children:d.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:s.size===0,onClick:()=>t({action:"submit",value:Array.from(s)}),children:[d.jsx(J,{name:"check",size:14})," 确认 (",s.size,")"]})}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Ip({interrupt:e,onRespond:t,disabled:n,initialValue:r}){const[i,s]=y.useState(r??""),a=e.inputType??"text",o=a==="textarea",l=()=>{n||e.required&&!i.trim()||t({action:"submit",value:i.trim()})};return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"text-cursor-input",size:16,color:"#6366f1"}),d.jsx("span",{children:e.content})]}),d.jsx("div",{className:"sa-interrupt-input-area",children:o?d.jsx("textarea",{className:"sa-interrupt-textarea",value:i,onChange:u=>s(u.target.value),placeholder:e.placeholder,maxLength:e.maxLength,rows:3,disabled:n}):d.jsx("input",{className:"sa-interrupt-input",type:a,value:i,onChange:u=>s(u.target.value),placeholder:e.placeholder,maxLength:e.maxLength,onKeyDown:u=>u.key==="Enter"&&l(),disabled:n})}),!n&&d.jsx("div",{className:"sa-interrupt-actions",children:d.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:e.required?!i.trim():!1,onClick:l,children:[d.jsx(J,{name:"check",size:14})," 提交"]})}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function zp({interrupt:e,onRespond:t,disabled:n,initialValue:r}){const i=e.fields??[],[s,a]=y.useState(()=>{const p={};for(const c of i)p[c.name]=(r==null?void 0:r[c.name])??c.defaultValue??"";return p}),o=(p,c)=>{n||a(h=>({...h,[p]:c}))},l=!n&&i.every(p=>!p.required||s[p.name]),u=()=>{l&&t({action:"submit",value:s})};return d.jsxs("div",{className:"sa-interrupt-card",children:[d.jsxs("div",{className:"sa-interrupt-content",children:[d.jsx(J,{name:"file-text",size:16,color:"#6366f1"}),d.jsx("span",{children:e.content})]}),d.jsx("div",{className:"sa-interrupt-form",children:i.map(p=>d.jsxs("div",{className:"sa-interrupt-form-field",children:[d.jsxs("label",{className:"sa-interrupt-form-label",children:[p.label,p.required&&d.jsx("span",{className:"sa-interrupt-form-required",children:"*"})]}),Tp(p,s[p.name],c=>o(p.name,c),n)]},p.name))}),!n&&d.jsxs("div",{className:"sa-interrupt-actions",children:[d.jsxs("button",{className:"sa-interrupt-btn sa-interrupt-btn-primary",disabled:!l,onClick:u,children:[d.jsx(J,{name:"check",size:14})," 提交"]}),d.jsx("button",{className:"sa-interrupt-btn sa-interrupt-btn-secondary",onClick:()=>t({action:"cancel"}),children:"取消"})]}),n&&d.jsx("div",{className:"sa-interrupt-submitted",children:"已提交"})]})}function Lr(e){return typeof e=="string"?{value:e,label:e}:e}function Tp(e,t,n,r){switch(e.type){case"textarea":return d.jsx("textarea",{className:"sa-interrupt-textarea",value:t,onChange:i=>n(i.target.value),placeholder:e.placeholder,rows:3,disabled:r});case"select":{const i=(e.options??[]).map(Lr);return d.jsxs("select",{className:"sa-interrupt-select",value:t,onChange:s=>n(s.target.value),disabled:r,children:[d.jsx("option",{value:"",children:"请选择"}),i.map(s=>d.jsx("option",{value:s.value,children:s.label},s.value))]})}case"multiSelect":{const i=(e.options??[]).map(Lr),s=Array.isArray(t)?t:[],a=o=>{r||n(s.includes(o)?s.filter(l=>l!==o):[...s,o])};return d.jsx("div",{className:"sa-interrupt-options",children:i.map(o=>d.jsx("button",{type:"button",className:`sa-interrupt-option ${s.includes(o.value)?"sa-interrupt-option-selected":""}`,disabled:r,onClick:()=>a(o.value),children:o.label},o.value))})}case"password":return d.jsx("input",{className:"sa-interrupt-input",type:"password",value:t,onChange:i=>n(i.target.value),placeholder:e.placeholder,disabled:r});default:return d.jsx("input",{className:"sa-interrupt-input",type:e.type==="number"?"number":e.type==="date"?"date":"text",value:t,onChange:i=>n(i.target.value),placeholder:e.placeholder,disabled:r})}}function oa({interrupt:e,resolved:t,response:n,onRespond:r}){const i=t,s=n==null?void 0:n.value;switch(e.interruptType){case"confirm":return d.jsx(kp,{interrupt:e,onRespond:r,disabled:i,answeredAction:n==null?void 0:n.action});case"approve":return d.jsx(vp,{interrupt:e,onRespond:r,disabled:i,answeredAction:n==null?void 0:n.action});case"select":return d.jsx(Sp,{interrupt:e,onRespond:r,disabled:i,initialValue:s});case"multiSelect":return d.jsx(Ep,{interrupt:e,onRespond:r,disabled:i,initialValue:s});case"input":return d.jsx(Ip,{interrupt:e,onRespond:r,disabled:i,initialValue:s});case"form":return d.jsx(zp,{interrupt:e,onRespond:r,disabled:i,initialValue:s});default:return d.jsxs("div",{className:"sa-interrupt-unknown",children:["未知的交互类型: ",e.interruptType]})}}function Ap({files:e,artifactPreview:t}){const{openArtifactPreview:n}=ze();return e.length===0?null:d.jsx("ul",{className:"sa-artifact-file-list",role:"list",children:e.map((r,i)=>d.jsxs("li",{className:"sa-artifact-file-card",onClick:t?()=>n(r):void 0,onKeyDown:t?s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),n(r))}:void 0,tabIndex:t?0:void 0,role:t?"button":void 0,"aria-label":t?`预览 ${r.filename}`:void 0,style:t?{cursor:"pointer"}:void 0,children:[d.jsx("div",{className:"sa-artifact-file-icon",children:d.jsx("span",{className:"sa-artifact-chip-type",children:Or(r.type)})}),d.jsxs("div",{className:"sa-artifact-file-info",children:[d.jsx("span",{className:"sa-artifact-file-name",children:r.filename}),r.size!=null&&d.jsx("span",{className:"sa-artifact-file-size",children:_r(r.size)})]}),t&&d.jsx("button",{className:"sa-artifact-file-download",title:"下载","aria-label":`下载 ${r.filename}`,onClick:s=>{s.stopPropagation(),kt(r)},children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},r.id||`art-${i}`))})}const Np=[{value:1,label:"事实错误"},{value:2,label:"逻辑问题"},{value:3,label:"不相关"},{value:4,label:"信息过时"},{value:5,label:"冗长啰嗦"},{value:6,label:"难以理解"}];function la({message:e,onCopy:t,onRegenerate:n,onFeedback:r}){const{status:i,cancelFeedback:s}=ze(),[a,o]=y.useState(null),[l,u]=y.useState(!1),[p,c]=y.useState(!1),h=y.useRef(null),f=y.useCallback(()=>{t(),u(!0),setTimeout(()=>u(!1),2e3)},[t]),m=y.useCallback(()=>{a==="like"?(o(null),s(e.id)):(o("like"),c(!1),r==null||r(e.id,"like"))},[a,e.id,r,s]),w=y.useCallback(()=>{a==="dislike"?(o(null),c(!1),s(e.id)):c(!0)},[a,e.id,s]),C=y.useCallback((S,j)=>{o("dislike"),c(!1),r==null||r(e.id,"dislike",{reason:S,remark:(j==null?void 0:j.trim())||void 0})},[e.id,r]),b=y.useCallback(()=>{c(!1)},[]);return y.useEffect(()=>{if(!p)return;const S=L=>{h.current&&!h.current.contains(L.target)&&c(!1)},j=L=>{L.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",j)}},[p]),i!=="ready"&&i!=="error"?null:d.jsxs("div",{className:"sa-action-bar",children:[d.jsxs("button",{className:"sa-action-btn",onClick:f,title:"复制",children:[d.jsx(J,{name:l?"circle-check":"copy",size:14})," ",l?"已复制":"复制"]}),n&&d.jsxs("button",{className:"sa-action-btn",onClick:n,title:"重新生成",children:[d.jsx(J,{name:"refresh-cw",size:14})," 重新生成"]}),r&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"sa-action-divider"}),d.jsx("button",{className:`sa-action-btn ${a==="like"?"sa-action-btn-active":""}`,onClick:m,title:"有用","aria-label":"点赞",children:d.jsx(J,{name:"thumbs-up",size:14})}),d.jsx("button",{className:`sa-action-btn ${a==="dislike"?"sa-action-btn-active":""}`,onClick:w,title:"无用","aria-label":"踩","aria-expanded":p,"aria-haspopup":"dialog",children:d.jsx(J,{name:"thumbs-down",size:14})})]}),p&&d.jsx("div",{ref:h,children:d.jsx(Lp,{onSubmit:C,onCancel:b})})]})}function Lp({onSubmit:e,onCancel:t}){const[n,r]=y.useState(void 0),[i,s]=y.useState("");return d.jsxs("div",{className:"sa-dislike-panel",children:[d.jsx("div",{className:"sa-dislike-panel-title",children:"请选择不满意的原因(可选)"}),d.jsx("div",{className:"sa-dislike-reasons",children:Np.map(a=>d.jsx("button",{className:`sa-dislike-reason-btn ${n===a.value?"active":""}`,onClick:()=>r(n===a.value?void 0:a.value),children:a.label},a.value))}),d.jsx("textarea",{className:"sa-dislike-remark",placeholder:"补充描述(选填,≤500 字)",maxLength:500,value:i,onChange:a=>s(a.target.value),rows:2}),d.jsxs("div",{className:"sa-dislike-actions",children:[d.jsx("button",{className:"sa-dislike-submit",onClick:()=>e(n,i||void 0),children:"提交"}),d.jsx("button",{className:"sa-dislike-cancel",onClick:t,children:"取消"})]})]})}const Dp=/^(https?:\/\/|data:|blob:|\/\/|\/|\.\/|\.\.\/)/;function Dr({src:e,alt:t}){return e?Dp.test(e)?d.jsx("img",{src:e,alt:t??"",className:"sa-msg-avatar",draggable:!1}):d.jsx("span",{className:"sa-msg-avatar sa-msg-avatar-text",children:e}):null}function ua({message:e,isStreaming:t,isLast:n,slots:r,avatar:i,artifactPreview:s,showTimestamp:a}){const{regenerate:o,feedback:l,respondToInterrupt:u}=ze(),p=y.useCallback(()=>{var A;const L=e.parts.filter(k=>k.type==="text").map(k=>k.content).join(`
|
|
30
|
-
`);(A=navigator.clipboard)==null||A.writeText(L).catch(()=>{})},[e]),c=e.role==="user",h=r.Message;if(h)return d.jsx(h,{message:e,isStreaming:t,isLast:n,avatar:i,slots:r,onCopy:p,onRegenerate:o,onFeedback:l,showTimestamp:a});const f=r.TextPart??ea,m=r.ThinkingPart??na,w=r.ToolCallPart??ra,C=r.ToolResultPart??ia,b=r.ErrorPart??aa,S=r.ActionBar??la,j=!c&&e.parts.some(L=>L.type==="text"&&L.content);return d.jsxs("div",{className:`sa-message ${c?"sa-message-user":"sa-message-assistant"}`,children:[!c&&d.jsx(Dr,{src:(i==null?void 0:i.assistant)||(t&&n?pe.assistantAvatarGenerating:pe.assistantAvatar),alt:"AI"}),d.jsxs("div",{className:"sa-message-content",children:[a&&d.jsx("span",{className:`sa-message-time ${c?"sa-message-time-right":""}`,children:ja(e.timestamp)}),d.jsxs("div",{className:"sa-message-body",children:[e.parts.map((L,A)=>{switch(L.type){case"text":return d.jsx(f,{content:L.content},A);case"attachment":return d.jsx(yp,{attachment:L.attachment},A);case"thinking":return d.jsx(m,{content:L.content},A);case"tool_call":return d.jsx(w,{toolName:L.toolName,toolCallId:L.toolCallId,args:L.args},A);case"tool_result":return d.jsx(C,{toolName:L.toolName,toolCallId:L.toolCallId,content:L.content,artifacts:L.artifacts,renderMode:L.renderMode,html:L.html,artifactPreview:s},A);case"error":return d.jsx(b,{content:L.content,onRetry:o},A);case"interrupt":return d.jsx(oa,{interrupt:L.interrupt,resolved:L.resolved??!1,response:L.response,onRespond:k=>u(L.interrupt.interruptId,k)},A);default:return null}}),t&&n&&!c&&!j&&d.jsx("span",{className:"sa-thinking-indicator",children:"思考中…"}),!c&&e.artifacts&&e.artifacts.length>0&&d.jsx(Ap,{files:Br(e.artifacts),artifactPreview:s}),!c&&!t&&j&&d.jsx(S,{message:e,onCopy:p,onRegenerate:n?o:void 0,onFeedback:l})]})]}),c&&(i==null?void 0:i.user)&&d.jsx(Dr,{src:i.user,alt:"用户"})]})}function ca({message:e,suggestedPrompts:t,onPromptClick:n,capabilities:r,quickLinks:i,logo:s,openPanel:a}){const o=l=>{if(l.onClick){l.onClick();return}const u=l.action;if(!u){l.prompt&&n(l.prompt);return}a==null||a(u.type==="link"?u:{...u,title:u.title??l.label})};return d.jsxs("div",{className:"flex flex-col gap-8 py-2",children:[d.jsxs("div",{className:"flex flex-col items-center gap-1 opacity-0 animate-sa-home-fade-in",children:[d.jsx("img",{src:s||pe.logo,alt:"AI 助手",className:"block max-w-16 shrink-0 animate-sa-logo-float",draggable:!1}),d.jsx("h3",{className:"sa-shimmer-text m-0 mb-1 text-[18px] font-bold leading-[1.3] text-[#333] animate-sa-title-shimmer",children:e||"你好!有什么可以帮你的?"})]}),r&&r.length>0&&d.jsx("div",{className:"flex flex-col items-start gap-4 opacity-0 animate-sa-home-fade-in",style:{animationDelay:"150ms"},children:r.map(l=>d.jsxs("div",{className:"inline-flex w-full max-w-full min-w-0 items-center gap-[7px]",children:[l.icon&&d.jsx("img",{src:l.icon,alt:"",className:"h-[18px] w-[18px] shrink-0 object-contain",draggable:!1}),d.jsx("span",{className:"shrink-0 text-[14px] leading-[1.4] text-[#333]",children:l.label}),l.desc&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"h-[13px] w-px shrink-0 bg-[#DCDCDC]"}),d.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[14px] leading-[1.4] text-[#9A9A9A]",children:l.desc})]})]},l.label))}),t&&t.length>0&&d.jsx("div",{className:"flex flex-col items-start gap-3",children:t.map((l,u)=>d.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+u*130}ms`},onClick:()=>n(l),children:[d.jsx("span",{className:"sa-chip-text overflow-hidden text-ellipsis whitespace-nowrap",children:l}),d.jsx("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",className:"shrink-0 text-[#9A9A9A]","aria-hidden":"true",children:d.jsx("path",{d:"M5 3L9 7L5 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${l}-${u}`))}),i&&i.length>0&&d.jsxs("div",{className:"opacity-0 animate-sa-home-fade-in",style:{animationDelay:"420ms"},children:[d.jsx("div",{className:"mb-3 text-[14px] leading-none text-[#A0A0A0]",children:"快速查看"}),d.jsx("div",{className:"flex flex-wrap items-center gap-[22px]",children:i.map(l=>d.jsxs("button",{type:"button",className:"inline-flex items-center gap-[7px] rounded-md px-1 py-1 transition-colors hover:bg-[#F5F5F5]",onClick:()=>o(l),children:[l.icon&&d.jsx("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center opacity-70",children:d.jsx("img",{src:l.icon,alt:"",width:18,height:18,draggable:!1})}),d.jsx("span",{className:"text-[14px] leading-none text-[#333] transition-colors hover:text-[#1881F0]",children:l.label})]},l.label))})]})]})}function Ln({slots:e,welcomeMessage:t,suggestedPrompts:n,avatar:r,artifactPreview:i,capabilities:s,quickLinks:a,logo:o,showTimestamp:l}){const{messages:u,status:p,sendMessage:c,openPanel:h}=ze(),{containerRef:f}=qr([u]),m=p==="streaming",w=e.WelcomeScreen??ca,C=e.AppendContainer;return u.length===0?d.jsxs("div",{className:"sa-thread",ref:f,children:[d.jsx(w,{message:t,suggestedPrompts:n,onPromptClick:c,capabilities:s,quickLinks:a,logo:o,openPanel:h}),C&&d.jsx(C,{openPanel:h})]}):d.jsx("div",{className:"sa-thread",ref:f,children:u.map((b,S)=>d.jsx(ua,{message:b,isStreaming:m,isLast:S===u.length-1,slots:e,avatar:r,artifactPreview:i,showTimestamp:l},b.id))})}function da({size:e=12}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M12 2.5l1.8 5.2a3 3 0 0 0 1.9 1.9l5.2 1.8-5.2 1.8a3 3 0 0 0-1.9 1.9L12 20.3l-1.8-5.2a3 3 0 0 0-1.9-1.9L3.1 11.4l5.2-1.8a3 3 0 0 0 1.9-1.9z"})})}function Mp({items:e,activeIndex:t,onSelect:n}){const r=y.useRef(null);return y.useEffect(()=>{var s;const i=(s=r.current)==null?void 0:s.children[t];i==null||i.scrollIntoView({block:"nearest"})},[t]),d.jsxs("div",{className:"sa-slash-menu",children:[d.jsxs("div",{className:"sa-slash-menu-header",children:["技能 (",e.length,")"]}),d.jsx("div",{className:"sa-slash-menu-body",ref:r,children:e.length===0?d.jsx("div",{className:"sa-slash-menu-empty",children:"没有匹配的技能"}):e.map((i,s)=>{const a=i.displayName||i.name,o=i.owner==="member"&&i.memberName?i.memberName:null,l=!i.selectable;return d.jsxs("div",{className:"sa-slash-menu-item"+(s===t?" sa-slash-menu-item--active":"")+(l?" sa-slash-menu-item--disabled":""),"aria-disabled":l||void 0,title:l?i.disabledReason??void 0:void 0,onMouseDown:u=>{u.preventDefault(),!l&&n(i)},children:[d.jsx("span",{className:"sa-slash-menu-item-icon",children:d.jsx(da,{size:13})}),d.jsx("span",{className:"sa-slash-menu-item-name",children:a}),o&&d.jsx("span",{className:"sa-slash-menu-item-owner",children:o}),l&&i.disabledReason?d.jsx("span",{className:"sa-slash-menu-item-desc",children:i.disabledReason}):i.description&&d.jsx("span",{className:"sa-slash-menu-item-desc",children:i.description})]},i.code)})})]})}function Rp({sdk:e,input:t,onSelect:n}){const[r,i]=y.useState([]),[s,a]=y.useState(!1),[o,l]=y.useState(0),u=y.useRef(!1);y.useEffect(()=>{u.current||(u.current=!0,e.listSkills().then(i).catch(()=>i([])))},[e]);const p=/^\/\S*$/.test(t);y.useEffect(()=>{a(p)},[p]);const c=t.startsWith("/")?t.slice(1).toLowerCase():"",h=y.useMemo(()=>r.filter(A=>!c||A.code.toLowerCase().includes(c)||A.name.toLowerCase().includes(c)||A.displayName&&A.displayName.toLowerCase().includes(c)),[r,c]),f=y.useMemo(()=>h.reduce((A,k,N)=>k.selectable?[...A,N]:A,[]),[h]);y.useEffect(()=>{p&&l(f[0]??0)},[t,p,f]);const m=y.useRef(s),w=y.useRef(h),C=y.useRef(f),b=y.useRef(o),S=y.useRef(n);m.current=s,w.current=h,C.current=f,b.current=o,S.current=n;const j=y.useCallback(A=>{if(!m.current)return!1;const k=C.current;if(k.length===0)return!1;const N=_=>{const O=k.indexOf(b.current),v=O===-1?k[0]:k[(O+_+k.length)%k.length];l(v)};switch(A.key){case"ArrowDown":return A.preventDefault(),N(1),!0;case"ArrowUp":return A.preventDefault(),N(-1),!0;case"Enter":case"Tab":{const _=w.current[b.current];return!_||!_.selectable?!1:(A.preventDefault(),S.current(_),a(!1),!0)}case"Escape":return A.preventDefault(),a(!1),!0;default:return!1}},[]),L=y.useCallback(()=>a(!1),[]);return{isOpen:s,items:h,activeIndex:o,handleKeyDown:j,close:L}}const Pp=10,Fp=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent);function _p({size:e=16}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.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 Op({size:e=12}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})}function Bp({skill:e,onRemove:t}){const n=e.displayName||e.name,r=e.owner==="member"&&e.memberName?`${n}(成员 ${e.memberName} 的技能)`:n;return d.jsxs("span",{className:"sa-skill-chip",title:r,children:[d.jsxs("button",{type:"button",className:"sa-skill-chip-icon","aria-label":`移除技能 ${n}`,onClick:i=>{i.stopPropagation(),t()},children:[d.jsx("span",{className:"sa-skill-chip-icon-skill",children:d.jsx(da,{})}),d.jsx("span",{className:"sa-skill-chip-icon-remove",children:d.jsx(Op,{})})]}),d.jsx("span",{className:"sa-skill-chip-label",children:n})]})}function Dn(){const{status:e,sendMessage:t,stop:n,sdk:r,attachmentUploader:i,nosUpload:s}=ze(),[a,o]=y.useState(""),[l,u]=y.useState(null),[p,c]=y.useState([]),h=y.useRef(null),f=y.useRef(null),m=!!i||!!s,w=e==="streaming"||e==="submitted",C=p.filter(E=>E.attachment),b=p.some(E=>!E.attachment&&E.status==="uploading"),S=!!a.trim()||!!l||p.length>0||w,j=!w&&!b&&(a.trim().length>0||!!l||C.length>0),L=y.useCallback(E=>{u(E),o(""),setTimeout(()=>{var I;return(I=h.current)==null?void 0:I.focus()},0)},[]),A=y.useCallback(()=>{var E;u(null),(E=h.current)==null||E.focus()},[]),k=Rp({sdk:r,input:a,onSelect:L}),N=y.useCallback(E=>{const I=Array.from(E.target.files??[]);if(E.target.value="",!m||I.length===0)return;const F=Pp-p.length,q=I.slice(0,Math.max(0,F));if(q.length===0)return;const U=q.map(P=>({key:`${P.name}_${P.size}_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,file:P,status:"uploading"}));c(P=>[...P,...U]);for(const{key:P,file:B}of U)(i||Me.createNosUploader({baseURL:s.baseURL,headers:s.headers,trunkSize:s.trunkSize,onProgress:H=>c($=>$.map(g=>g.key===P?{...g,percent:H}:g))}))(B).then(H=>{c($=>$.map(g=>g.key===P?{...g,attachment:{...H,filename:H.filename||B.name,size:H.size??B.size,mime:H.mime??B.type}}:g))}).catch(H=>{c($=>$.map(g=>g.key===P?{...g,status:"error",errorMsg:H instanceof Error?H.message:String(H)}:g))})},[i,s,p]),_=y.useCallback(E=>{c(I=>I.filter(F=>F.key!==E))},[]),O=y.useCallback(()=>{if(!j)return;const E=a.trim(),I=C.map(q=>q.attachment),F=l?`/${l.code}${E?` ${E}`:""}`:E;t(F,I.length>0?I:void 0),o(""),u(null),c([]),h.current&&(h.current.style.height="auto")},[j,a,l,C,t]),v=y.useCallback(E=>{if(!k.handleKeyDown(E)){if(E.key==="Backspace"&&l&&a.length===0){E.preventDefault(),u(null);return}E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),O())}},[O,k.handleKeyDown,l,a]),D=y.useCallback(E=>{o(E.target.value);const I=E.target;I.style.height="auto",I.style.height=Math.min(I.scrollHeight,90)+"px"},[]),T=y.useCallback(()=>{var E;w||(E=h.current)==null||E.focus()},[w]);return d.jsxs("div",{className:"relative z-[2] shrink-0 px-[15px] pb-2.5",children:[k.isOpen&&d.jsx(Mp,{items:k.items,activeIndex:k.activeIndex,onSelect:L}),p.length>0&&d.jsx("div",{className:"sa-attachment-tray mb-1.5",onClick:E=>E.stopPropagation(),children:p.map(E=>d.jsxs("span",{className:`sa-attachment-tray-chip ${E.status==="error"?"sa-attachment-tray-chip-error":""}`,title:E.status==="error"?`上传失败:${E.errorMsg??""}`:E.file.name,children:[d.jsx(J,{name:"file-text",size:13,color:E.status==="error"?"#ef4444":"#6366f1"}),d.jsx("span",{className:"sa-attachment-tray-chip-name",children:E.file.name}),d.jsx("span",{className:"sa-attachment-tray-chip-size",children:E.attachment?sa(E.file.size):E.status==="error"?"失败":E.percent!=null?`${Math.min(99,Math.round(E.percent))}%`:"上传中…"}),d.jsx("button",{type:"button",className:"sa-attachment-tray-chip-remove","aria-label":`移除附件 ${E.file.name}`,onClick:()=>_(E.key),children:"✕"})]},E.key))}),d.jsxs("form",{className:`sa-input-form relative flex min-h-[70px] cursor-text flex-col gap-1 rounded-[5px] p-2 ${S?"sa-input-form-active":""} ${w?"sa-input-form-streaming":""}`,onClick:T,onSubmit:E=>{E.preventDefault(),O()},children:[d.jsxs("div",{className:"flex items-start gap-1.5",children:[l&&d.jsx(Bp,{skill:l,onRemove:A}),d.jsx("textarea",{ref:h,className:"sa-input-field min-h-[34px] min-w-0 flex-1 resize-none border-none bg-transparent p-0 text-[14px] leading-[1.5] text-[#333] outline-none placeholder:text-[#B8B8B8]",value:a,onChange:D,onKeyDown:v,placeholder:w?"回答生成中,请稍候…":l?"补充你的需求…":"发消息或创建任务... /使用技能",rows:1,disabled:w})]}),d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m&&!w&&d.jsx("button",{type:"button",className:"sa-attach-btn mr-auto","aria-label":"添加附件",title:"添加附件",onClick:()=>{var E;return(E=f.current)==null?void 0:E.click()},children:d.jsx(_p,{size:15})}),d.jsx("input",{ref:f,type:"file",multiple:!0,className:"hidden",onChange:N,"aria-label":"选择附件"}),!w&&d.jsxs("span",{className:"sa-send-hint","aria-hidden":"true",children:[d.jsx("kbd",{className:"sa-send-kbd",children:Fp?"⌘":"Ctrl"}),d.jsx("span",{children:"+"}),d.jsx("kbd",{className:"sa-send-kbd",children:"Enter"}),d.jsx("span",{children:"发送"})]}),w?d.jsx("button",{type:"button",className:"sa-send-btn sa-send-btn-active","aria-label":"停止生成",title:"停止生成",onClick:n,children:d.jsx("span",{className:"sa-stop-icon"})}):d.jsx("button",{type:"submit",className:`sa-send-btn ${j?"sa-send-btn-active":""}`,"aria-label":"发送",title:"发送",disabled:!j,children:d.jsx("img",{src:pe.sendSolid,alt:"发送",width:14,height:14,draggable:!1})})]})]}),d.jsx("div",{className:"mt-3 text-center text-[11px] leading-none text-[#B8B8B8]",children:"所有内容均由AI生成仅供参考"})]})}function $p({artifact:e}){const[t,n]=y.useState(null),[r,i]=y.useState(null),[s,a]=y.useState(!0),[o,l]=y.useState(null);return y.useEffect(()=>{let u=!1;a(!0),l(null),n(null),i(null);async function p(){try{if(e.type==="pdf"){u||a(!1);return}if(e.type==="md"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.text();u||(i(h),a(!1));return}if(e.type==="html"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.text(),f=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;u||(n(f.sanitize(h,{FORCE_BODY:!0,ADD_ATTR:["target"]})),a(!1));return}if(e.type==="docx"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.arrayBuffer(),m=await(await Promise.resolve().then(()=>require("./mammoth.browser-ClkRBm1A.cjs")).then(C=>C.mammoth_browser)).convertToHtml({arrayBuffer:h}),w=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;u||(n(w.sanitize(m.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),a(!1));return}u||(a(!1),l(`不支持预览「${e.type}」类型`))}catch(c){u||(a(!1),l(c instanceof Error?c.message:"加载失败"))}}return p(),()=>{u=!0}},[e]),s?d.jsx("div",{className:"sa-drawer-preview-loading",children:"加载中"}):o?d.jsxs("div",{className:"sa-drawer-preview-error",children:[o,d.jsx("button",{className:"sa-drawer-btn-sm",onClick:()=>void kt(e),children:"下载查看"})]}):e.type==="pdf"?d.jsx("iframe",{src:e.url,title:e.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):r!==null?d.jsx("div",{className:"sa-drawer-preview-html-scroll",children:d.jsx("div",{className:"sa-drawer-preview-html sa-text-part",children:d.jsx(Ti,{remarkPlugins:[Zi],children:r})})}):t!==null?d.jsx("div",{className:"sa-drawer-preview-html-scroll",children:d.jsx("div",{className:"sa-drawer-preview-html sa-text-part",dangerouslySetInnerHTML:{__html:t}})}):null}function Hp({artifacts:e,initialArtifact:t,onClose:n}){const[r,i]=y.useState(t?{mode:"preview",artifact:t}:{mode:"list"}),[s,a]=y.useState(!1),o=y.useRef(null),[l,u]=y.useState(340),p=y.useRef(null);y.useEffect(()=>{t&&(o.current&&(clearTimeout(o.current),o.current=null,a(!1)),i({mode:"preview",artifact:t}))},[t]);const c=y.useCallback(()=>{a(!0),o.current=setTimeout(()=>{o.current=null,n()},240)},[n]);y.useEffect(()=>()=>{var w;o.current&&clearTimeout(o.current),(w=p.current)==null||w.call(p)},[]);const h=y.useCallback(w=>{i({mode:"preview",artifact:w})},[]),f=y.useCallback(()=>{i({mode:"list"})},[]);y.useEffect(()=>{const w=C=>{C.key==="Escape"&&c()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[c]);const m=y.useCallback(w=>{w.preventDefault();const C=w.clientX,b=l,S=L=>{const A=C-L.clientX;u(Math.max(240,Math.min(window.innerWidth*.7,b+A)))},j=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect="",p.current=null};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",S),document.addEventListener("mouseup",j),p.current=j},[l]);return d.jsxs("div",{className:`sa-artifact-drawer ${s?"sa-drawer-closing":""}`,style:{width:l},children:[d.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:m}),d.jsxs("div",{className:"sa-artifact-drawer-header",children:[r.mode==="preview"?d.jsxs(d.Fragment,{children:[d.jsx("button",{className:"sa-drawer-btn",onClick:f,title:"返回列表","aria-label":"返回列表",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M15 18l-6-6 6-6"})})}),d.jsx("span",{className:"sa-artifact-drawer-title",children:r.artifact.filename})]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),d.jsx("span",{className:"sa-artifact-drawer-title",children:"会话产物"})]}),d.jsx("div",{style:{flex:1}}),r.mode==="preview"&&d.jsx("button",{className:"sa-drawer-btn",onClick:()=>void kt(r.artifact),title:"下载","aria-label":"下载",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),d.jsx("button",{className:"sa-drawer-btn",onClick:c,title:"关闭","aria-label":"关闭",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),d.jsx("div",{className:"sa-artifact-drawer-body",children:r.mode==="list"?e.length===0?d.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):d.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:e.map((w,C)=>d.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>h(w),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),h(w))},tabIndex:0,role:"button","aria-label":`预览 ${w.filename}`,children:[d.jsx("div",{className:"sa-drawer-file-icon",children:d.jsx("span",{className:"sa-artifact-chip-type",children:Or(w.type)})}),d.jsxs("div",{className:"sa-drawer-file-info",children:[d.jsx("span",{className:"sa-drawer-file-name",children:w.filename}),d.jsx("span",{className:"sa-drawer-file-size",children:_r(w.size)})]}),d.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${w.filename}`,onClick:b=>{b.stopPropagation(),kt(w)},children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},w.id||`artifact-${C}`))}):d.jsx("div",{className:"sa-drawer-view-enter",children:d.jsx($p,{artifact:r.artifact})})})]})}function pa({page:e,onBack:t,centered:n}){y.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t]);const r=y.isValidElement(e.component)?y.cloneElement(e.component,{close:t}):y.createElement(e.component,{close:t});return d.jsx("div",{className:`sa-page-overlay ${n?"sa-page-overlay-centered":""}`,children:d.jsx("div",{className:"sa-page-overlay-body",children:r})})}const Up="mx-auto w-full max-w-[800px]";function fa({contentClassName:e,centered:t,composerClassName:n,thread:r,composer:i,artifactPreview:s}){const{activePanel:a,closePanel:o,messagesLoading:l,isArtifactDrawerOpen:u,allArtifacts:p,activePreviewArtifact:c,toggleArtifactDrawer:h}=ze();if(a)return d.jsx(pa,{page:a,onBack:o,centered:t});const f=t?Up:"";return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`${e} ${f}`,children:[l?d.jsxs("div",{className:"sa-messages-loading",children:[d.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):r,s&&u&&d.jsx(Hp,{artifacts:p,initialArtifact:c,onClose:h})]}),n?d.jsx("div",{className:`${n} ${f}`,children:i}):i]})}function Vp({isOpen:e,onClose:t,title:n,slots:r,welcomeMessage:i,suggestedPrompts:s,avatar:a,artifactPreview:o,capabilities:l,quickLinks:u,logo:p,defaultWidth:c,defaultHeight:h,showTimestamp:f}){const{status:m,sendMessage:w,stop:C,toggleThreadList:b,setThreadListOpen:S,isThreadListOpen:j,toggleArtifactDrawer:L,allArtifacts:A,activePanel:k,closePanel:N,messages:_,messagesLoading:O,conversations:v,activeConversationId:D,switchConversation:T,newConversation:E,deleteConversation:I,renameConversation:F,hasMore:q,loadMoreConversations:U}=ze(),{width:P,position:B,hasCustomPosition:x,isMaximized:H,totalWidth:$,windowHeight:g,startWindowDrag:Y,startResize:te,toggleMaximize:ee,reset:ue,setLockedHeight:ae}=va({defaultWidth:c??de.DEFAULT_WIDTH,defaultHeight:h??de.DEFAULT_HEIGHT,sidebarWidth:0}),W=y.useRef(null),se=y.useRef(null),le=!O&&_.length===0,Ee=!O&&_.length>0,be=!!k;y.useEffect(()=>{e||(ue(),N())},[e,ue,N]),y.useEffect(()=>{S(H?W.current??!0:se.current??!1)},[H,S]),y.useEffect(()=>{Ee||ae(null)},[Ee,ae]);const Lt=Ca({enabled:e&&Ee&&!H&&!be,contentSelector:".sa-panel-content",defaultHeight:h??de.DEFAULT_HEIGHT,onHeightChange:ae});if(!e)return null;const Ke=r.Header,Qe=r.Composer,Pe=r.ThreadList,Dt=()=>{const K=!j;b(),H?W.current=K:se.current=K},Je=200,Ze=j&&!H,ve="var(--sa-radius, 16px)",ht=Ze?`0px ${ve} ${ve} 0px`:`${ve} ${ve} ${ve} ${ve}`,Mt=x?B.x:window.innerWidth-$-20,Ve=Math.min(Je,Math.max(0,Mt-1)),Rt=x?{width:`${$}px`,height:`${g}px`,left:`${B.x}px`,top:`${B.y}px`}:{width:`${$}px`,height:`${g}px`,right:"20px",bottom:"20px"},z={title:n,onClose:t,onToggleThreadList:Dt,isMaximized:H,onToggleMaximize:ee,showHome:Ee||be,onHome:be?N:E,panelTitle:be?k==null?void 0:k.title:void 0,artifactCount:be||!o?0:A.length,onToggleArtifactDrawer:be||!o?void 0:L},R={conversations:v,activeSessionId:D,onSwitch:T,onNew:E,onDelete:I,onRename:F,hasMore:q,onLoadMore:U},G=d.jsxs("div",{className:`relative flex min-w-0 flex-col bg-white ${H?"flex-1":"h-full shrink-0"}`,style:H?void 0:{width:`${P}px`,borderRadius:ht,overflow:"hidden"},children:[le&&!be&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sa-home-gradient pointer-events-none absolute inset-x-0 top-0 z-0 h-[238px] opacity-10"}),d.jsx("div",{className:"sa-home-gradient-fade pointer-events-none absolute inset-x-0 top-0 z-[1] h-[238px]"})]}),d.jsx("div",{className:`relative z-20 ${le||H?"":"bg-white"} ${H?"cursor-default":"cursor-grab active:cursor-grabbing"}`,onMouseDown:H?void 0:Y,children:Ke?d.jsx(Ke,{...z}):d.jsx(Ur,{...z})}),d.jsx(fa,{contentClassName:`sa-panel-content relative z-[2] ${le?"sa-home-view":""}`,centered:H,composerClassName:"shrink-0",artifactPreview:o,thread:d.jsx(Ln,{slots:r,welcomeMessage:i,suggestedPrompts:s,avatar:a,artifactPreview:o,capabilities:l,quickLinks:u,logo:p,showTimestamp:f}),composer:Qe?d.jsx(Qe,{status:m,onSend:w,onStop:C}):d.jsx(Dn,{})})]});return H?d.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:d.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:[j&&(Pe?d.jsx(Pe,{...R}):d.jsx(Zt,{width:220})),G]})}):d.jsxs("div",{ref:Lt,className:"fixed z-[var(--sa-z-index,9999)] flex animate-sa-window-in flex-row overflow-visible border border-[#DADADA] bg-white ",style:{...Rt,borderRadius:ht},children:[d.jsx("div",{className:"sa-resize-handle absolute bottom-0 left-[-3px] top-0 z-20 w-[6px] cursor-col-resize",onMouseDown:K=>te(K)}),Ze&&(Pe?d.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] ",style:{width:Ve,transform:`translateX(-${Ve}px)`,borderRadius:`${ve} 0px 0px ${ve}`},children:d.jsx(Pe,{...R})}):d.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] ",style:{width:Ve,transform:`translateX(-${Ve}px)`,borderRadius:`${ve} 0px 0px ${ve}`},children:d.jsx(Zt,{width:Je})})),G]})}const Mr=()=>{};function qp({conversations:e,activeSessionId:t,onSwitch:n,onNew:r,onDelete:i,onRename:s,isCollapsed:a,onToggleCollapse:o,hasMore:l,onLoadMore:u,conversationsLoading:p}){const[c,h]=y.useState(null),[f,m]=y.useState(null),[w,C]=y.useState(""),[b,S]=y.useState(null),j=y.useRef(null);y.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const L=y.useCallback((v,D)=>{D.stopPropagation(),c===v?(i(v),h(null)):(h(v),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>h(null),3e3))},[c,i]),A=y.useCallback((v,D,T)=>{T.stopPropagation(),m(v),C(D??"")},[]),k=y.useCallback(v=>{w.trim()&&s(v,w.trim()),m(null)},[w,s]),N=y.useRef(null),_=y.useCallback(()=>{const v=N.current;!v||!l||!u||v.scrollHeight-v.scrollTop-v.clientHeight<50&&u()},[l,u]),O=y.useMemo(()=>Vr(e),[e]);return a?d.jsxs("div",{className:"flex w-12 shrink-0 flex-col items-center gap-1 border-r border-[#ECECEC] bg-[#FAFAFA] py-3",children:[d.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:o,children:d.jsx(J,{name:"panel-left",size:18})}),d.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:()=>{r(),o()},children:d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18})})]}):d.jsxs("div",{className:"relative flex w-[220px] shrink-0 flex-col border-r border-[#ECECEC] bg-[#FAFAFA] p-3",children:[d.jsxs("div",{className:"mb-4 flex shrink-0 items-center gap-1.5",children:[d.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:r,children:[d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18}),d.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),d.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:o,children:d.jsx(J,{name:"panel-left-close",size:16})})]}),d.jsxs("div",{className:"px-1 pb-2.5",children:[d.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),d.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),d.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto",onScroll:_,children:[p&&e.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!p&&e.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),O.map(v=>d.jsxs("div",{className:"mb-1",children:[d.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:v.label}),v.items.map(D=>{const T=D.sessionId===t,E=c===D.sessionId;return d.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 ${T?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{f!==D.sessionId&&n(D.sessionId)},onMouseEnter:I=>{if(f===D.sessionId)return;const F=I.currentTarget.getBoundingClientRect();S({text:D.title||"新会话",x:F.right+8,y:F.top+F.height/2})},onMouseLeave:()=>S(null),children:f===D.sessionId?d.jsx("input",{className:"w-full rounded border border-[var(--sa-primary)] bg-white px-1.5 py-0.5 text-[12px] outline-none",value:w,onChange:I=>C(I.target.value),onBlur:()=>k(D.sessionId),onKeyDown:I=>{I.key==="Enter"&&k(D.sessionId),I.key==="Escape"&&m(null)},onClick:I=>I.stopPropagation(),autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("img",{src:pe.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),d.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:D.title||"新会话"}),d.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[d.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:I=>A(D.sessionId,D.title,I),title:"重命名",children:d.jsx(J,{name:"pen",size:12})}),d.jsx("button",{type:"button",className:`flex h-5 w-5 items-center justify-center rounded ${E?"bg-[#fee2e2] text-[#ef4444]":"text-[#999] hover:bg-white/70 hover:text-[#ef4444]"}`,onClick:I=>L(D.sessionId,I),title:E?"确认删除":"删除",children:d.jsx(J,{name:E?"x":"trash2",size:12})})]})]})},D.sessionId)})]},v.label)),l&&d.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),b&&d.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:b.x,top:b.y,transform:"translateY(-50%)"},children:b.text})]})}function ha({title:e,slots:t,welcomeMessage:n,suggestedPrompts:r,capabilities:i,quickLinks:s,logo:a,sidebarDefaultOpen:o=!0,onClose:l,avatar:u,artifactPreview:p,showTimestamp:c}){const{status:h,sendMessage:f,stop:m,conversations:w,activeConversationId:C,switchConversation:b,newConversation:S,deleteConversation:j,renameConversation:L,toggleArtifactDrawer:A,allArtifacts:k,activePanel:N,closePanel:_,hasMore:O,loadMoreConversations:v,conversationsLoading:D}=ze(),[T,E]=y.useState(o),I=y.useCallback(()=>E(B=>!B),[]),F=!!N;y.useEffect(()=>()=>_(),[_]);const q=t.ThreadList,U=t.Composer,P=t.Header;return d.jsxs("div",{className:"sa-fullpage",children:[q?d.jsx("div",{className:`sa-fp-sidebar-wrapper ${T?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:d.jsx(q,{conversations:w,activeSessionId:C,onSwitch:b,onNew:S,onDelete:j,onRename:L,hasMore:O,onLoadMore:v})}):d.jsx(qp,{conversations:w,activeSessionId:C,onSwitch:b,onNew:S,onDelete:j,onRename:L,isCollapsed:!T,onToggleCollapse:I,hasMore:O,onLoadMore:v,conversationsLoading:D}),d.jsxs("div",{className:"sa-fp-main",children:[P?d.jsx(P,{title:F?(N==null?void 0:N.title)??e:e,panelTitle:F?N==null?void 0:N.title:void 0,onClose:l??Mr,onToggleThreadList:I,showHome:F,onHome:F?_:Mr,artifactCount:F||!p?0:k.length,onToggleArtifactDrawer:F||!p?void 0:A}):d.jsxs("div",{className:"sa-fp-header",children:[d.jsx("div",{className:"sa-fp-header-title",children:F?(N==null?void 0:N.title)??e:e}),d.jsxs("div",{className:"sa-fp-header-actions",children:[F&&d.jsx("button",{className:"sa-fp-header-btn",onClick:_,title:"返回聊天","aria-label":"返回聊天",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),d.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]})}),!F&&p&&k.length>0&&d.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:A,title:"会话产物",children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),d.jsx("span",{children:"产物"})]})]})]}),d.jsx(fa,{contentClassName:"sa-fp-content-row",artifactPreview:p,thread:d.jsx(Ln,{slots:t,welcomeMessage:n,suggestedPrompts:r,capabilities:i,quickLinks:s,logo:a,avatar:u,artifactPreview:p,showTimestamp:c}),composer:U?d.jsx(U,{status:h,onSend:f,onStop:m}):d.jsx(Dn,{})})]})]})}function ga(e){const{sdk:t,mode:n="floating",slots:r={},hooks:i={},welcomeMessage:s,suggestedPrompts:a,title:o="AI Assistant",initialOpen:l=!1,onOpenChange:u,sidebarDefaultOpen:p,avatar:c,artifactPreview:h,capabilities:f,quickLinks:m,logo:w,triggerLogo:C,theme:b,showTimestamp:S,attachmentUploader:j,nosUpload:L}=e,[A,k]=y.useState(l);y.useEffect(()=>{k(l)},[l]);const N=y.useCallback(()=>{var D,T;const v=!A;k(v),u==null||u(v),v?(D=i.onOpen)==null||D.call(i):(T=i.onClose)==null||T.call(i)},[A,i,u]),_=y.useCallback(()=>{var v;k(!1),u==null||u(!1),(v=i.onClose)==null||v.call(i)},[i,u]),O=r.Trigger??Hr;return n==="fullpage"?A?d.jsx(Jt,{sdk:t,hooks:i,attachmentUploader:j,nosUpload:L,children:d.jsx(ha,{title:o,slots:r,welcomeMessage:s,suggestedPrompts:a,capabilities:f,quickLinks:m,logo:w,sidebarDefaultOpen:p,onClose:_,avatar:c,artifactPreview:h,showTimestamp:S})}):null:d.jsxs(Jt,{sdk:t,hooks:i,attachmentUploader:j,nosUpload:L,children:[d.jsx(O,{isOpen:A,onClick:N,triggerLogo:C}),d.jsx(Vp,{isOpen:A,onClose:_,title:o,slots:r,welcomeMessage:s,suggestedPrompts:a,avatar:c,artifactPreview:h,capabilities:f,quickLinks:m,logo:w,defaultWidth:b==null?void 0:b.panelWidth,defaultHeight:b==null?void 0:b.panelHeight,showTimestamp:S})]})}const ma=`
|
|
30
|
+
`);(A=navigator.clipboard)==null||A.writeText(L).catch(()=>{})},[e]),c=e.role==="user",h=r.Message;if(h)return d.jsx(h,{message:e,isStreaming:t,isLast:n,avatar:i,slots:r,onCopy:p,onRegenerate:o,onFeedback:l,showTimestamp:a});const f=r.TextPart??ea,m=r.ThinkingPart??na,w=r.ToolCallPart??ra,C=r.ToolResultPart??ia,b=r.ErrorPart??aa,S=r.ActionBar??la,j=!c&&e.parts.some(L=>L.type==="text"&&L.content);return d.jsxs("div",{className:`sa-message ${c?"sa-message-user":"sa-message-assistant"}`,children:[!c&&d.jsx(Dr,{src:(i==null?void 0:i.assistant)||(t&&n?pe.assistantAvatarGenerating:pe.assistantAvatar),alt:"AI"}),d.jsxs("div",{className:"sa-message-content",children:[a&&d.jsx("span",{className:`sa-message-time ${c?"sa-message-time-right":""}`,children:ja(e.timestamp)}),d.jsxs("div",{className:"sa-message-body",children:[e.parts.map((L,A)=>{switch(L.type){case"text":return d.jsx(f,{content:L.content},A);case"attachment":return d.jsx(yp,{attachment:L.attachment},A);case"thinking":return d.jsx(m,{content:L.content},A);case"tool_call":return d.jsx(w,{toolName:L.toolName,toolCallId:L.toolCallId,args:L.args},A);case"tool_result":return d.jsx(C,{toolName:L.toolName,toolCallId:L.toolCallId,content:L.content,artifacts:L.artifacts,renderMode:L.renderMode,html:L.html,artifactPreview:s},A);case"error":return d.jsx(b,{content:L.content,onRetry:o},A);case"interrupt":return d.jsx(oa,{interrupt:L.interrupt,resolved:L.resolved??!1,response:L.response,onRespond:k=>u(L.interrupt.interruptId,k)},A);default:return null}}),t&&n&&!c&&!j&&d.jsx("span",{className:"sa-thinking-indicator",children:"思考中…"}),!c&&e.artifacts&&e.artifacts.length>0&&d.jsx(Ap,{files:Br(e.artifacts),artifactPreview:s}),!c&&!t&&j&&d.jsx(S,{message:e,onCopy:p,onRegenerate:n?o:void 0,onFeedback:l})]})]}),c&&(i==null?void 0:i.user)&&d.jsx(Dr,{src:i.user,alt:"用户"})]})}function ca({message:e,suggestedPrompts:t,onPromptClick:n,capabilities:r,quickLinks:i,logo:s,openPanel:a}){const o=l=>{if(l.onClick){l.onClick();return}const u=l.action;if(!u){l.prompt&&n(l.prompt);return}a==null||a(u.type==="link"?u:{...u,title:u.title??l.label})};return d.jsxs("div",{className:"flex flex-col gap-8 py-2",children:[d.jsxs("div",{className:"flex flex-col items-center gap-1 opacity-0 animate-sa-home-fade-in",children:[d.jsx("img",{src:s||pe.logo,alt:"AI 助手",className:"block max-w-16 shrink-0 animate-sa-logo-float",draggable:!1}),d.jsx("h3",{className:"sa-shimmer-text m-0 mb-1 text-[18px] font-bold leading-[1.3] text-[#333] animate-sa-title-shimmer",children:e||"你好!有什么可以帮你的?"})]}),r&&r.length>0&&d.jsx("div",{className:"flex flex-col items-start gap-4 opacity-0 animate-sa-home-fade-in",style:{animationDelay:"150ms"},children:r.map(l=>d.jsxs("div",{className:"inline-flex w-full max-w-full min-w-0 items-center gap-[7px]",children:[l.icon&&d.jsx("img",{src:l.icon,alt:"",className:"h-[18px] w-[18px] shrink-0 object-contain",draggable:!1}),d.jsx("span",{className:"shrink-0 text-[14px] leading-[1.4] text-[#333]",children:l.label}),l.desc&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"h-[13px] w-px shrink-0 bg-[#DCDCDC]"}),d.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[14px] leading-[1.4] text-[#9A9A9A]",children:l.desc})]})]},l.label))}),t&&t.length>0&&d.jsx("div",{className:"flex flex-col items-start gap-3",children:t.map((l,u)=>d.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+u*130}ms`},onClick:()=>n(l),children:[d.jsx("span",{className:"sa-chip-text overflow-hidden text-ellipsis whitespace-nowrap",children:l}),d.jsx("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",className:"shrink-0 text-[#9A9A9A]","aria-hidden":"true",children:d.jsx("path",{d:"M5 3L9 7L5 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${l}-${u}`))}),i&&i.length>0&&d.jsxs("div",{className:"opacity-0 animate-sa-home-fade-in",style:{animationDelay:"420ms"},children:[d.jsx("div",{className:"mb-3 text-[14px] leading-none text-[#A0A0A0]",children:"快速查看"}),d.jsx("div",{className:"flex flex-wrap items-center gap-[22px]",children:i.map(l=>d.jsxs("button",{type:"button",className:"inline-flex items-center gap-[7px] rounded-md px-1 py-1 transition-colors hover:bg-[#F5F5F5]",onClick:()=>o(l),children:[l.icon&&d.jsx("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center opacity-70",children:d.jsx("img",{src:l.icon,alt:"",width:18,height:18,draggable:!1})}),d.jsx("span",{className:"text-[14px] leading-none text-[#333] transition-colors hover:text-[#1881F0]",children:l.label})]},l.label))})]})]})}function Ln({slots:e,welcomeMessage:t,suggestedPrompts:n,avatar:r,artifactPreview:i,capabilities:s,quickLinks:a,logo:o,showTimestamp:l}){const{messages:u,status:p,sendMessage:c,openPanel:h}=ze(),{containerRef:f}=qr([u]),m=p==="streaming",w=e.WelcomeScreen??ca,C=e.AppendContainer;return u.length===0?d.jsxs("div",{className:"sa-thread",ref:f,children:[d.jsx(w,{message:t,suggestedPrompts:n,onPromptClick:c,capabilities:s,quickLinks:a,logo:o,openPanel:h}),C&&d.jsx(C,{openPanel:h})]}):d.jsx("div",{className:"sa-thread",ref:f,children:u.map((b,S)=>d.jsx(ua,{message:b,isStreaming:m,isLast:S===u.length-1,slots:e,avatar:r,artifactPreview:i,showTimestamp:l},b.id))})}function da({size:e=12}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M12 2.5l1.8 5.2a3 3 0 0 0 1.9 1.9l5.2 1.8-5.2 1.8a3 3 0 0 0-1.9 1.9L12 20.3l-1.8-5.2a3 3 0 0 0-1.9-1.9L3.1 11.4l5.2-1.8a3 3 0 0 0 1.9-1.9z"})})}function Mp({items:e,activeIndex:t,onSelect:n}){const r=y.useRef(null);return y.useEffect(()=>{var s;const i=(s=r.current)==null?void 0:s.children[t];i==null||i.scrollIntoView({block:"nearest"})},[t]),d.jsxs("div",{className:"sa-slash-menu",children:[d.jsxs("div",{className:"sa-slash-menu-header",children:["技能 (",e.length,")"]}),d.jsx("div",{className:"sa-slash-menu-body",ref:r,children:e.length===0?d.jsx("div",{className:"sa-slash-menu-empty",children:"没有匹配的技能"}):e.map((i,s)=>{const a=i.displayName||i.name,o=i.owner==="member"&&i.memberName?i.memberName:null,l=!i.selectable;return d.jsxs("div",{className:"sa-slash-menu-item"+(s===t?" sa-slash-menu-item--active":"")+(l?" sa-slash-menu-item--disabled":""),"aria-disabled":l||void 0,title:l?i.disabledReason??void 0:void 0,onMouseDown:u=>{u.preventDefault(),!l&&n(i)},children:[d.jsx("span",{className:"sa-slash-menu-item-icon",children:d.jsx(da,{size:13})}),d.jsx("span",{className:"sa-slash-menu-item-name",children:a}),o&&d.jsx("span",{className:"sa-slash-menu-item-owner",children:o}),l&&i.disabledReason?d.jsx("span",{className:"sa-slash-menu-item-desc",children:i.disabledReason}):i.description&&d.jsx("span",{className:"sa-slash-menu-item-desc",children:i.description})]},i.code)})})]})}function Rp({sdk:e,input:t,onSelect:n}){const[r,i]=y.useState([]),[s,a]=y.useState(!1),[o,l]=y.useState(0),u=y.useRef(!1);y.useEffect(()=>{u.current||(u.current=!0,e.listSkills().then(i).catch(()=>i([])))},[e]);const p=/^\/\S*$/.test(t);y.useEffect(()=>{a(p)},[p]);const c=t.startsWith("/")?t.slice(1).toLowerCase():"",h=y.useMemo(()=>r.filter(A=>!c||A.code.toLowerCase().includes(c)||A.name.toLowerCase().includes(c)||A.displayName&&A.displayName.toLowerCase().includes(c)),[r,c]),f=y.useMemo(()=>h.reduce((A,k,N)=>k.selectable?[...A,N]:A,[]),[h]);y.useEffect(()=>{p&&l(f[0]??0)},[t,p,f]);const m=y.useRef(s),w=y.useRef(h),C=y.useRef(f),b=y.useRef(o),S=y.useRef(n);m.current=s,w.current=h,C.current=f,b.current=o,S.current=n;const j=y.useCallback(A=>{if(!m.current)return!1;const k=C.current;if(k.length===0)return!1;const N=_=>{const O=k.indexOf(b.current),v=O===-1?k[0]:k[(O+_+k.length)%k.length];l(v)};switch(A.key){case"ArrowDown":return A.preventDefault(),N(1),!0;case"ArrowUp":return A.preventDefault(),N(-1),!0;case"Enter":case"Tab":{const _=w.current[b.current];return!_||!_.selectable?!1:(A.preventDefault(),S.current(_),a(!1),!0)}case"Escape":return A.preventDefault(),a(!1),!0;default:return!1}},[]),L=y.useCallback(()=>a(!1),[]);return{isOpen:s,items:h,activeIndex:o,handleKeyDown:j,close:L}}const Pp=10,Fp=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent);function _p({size:e=16}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.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 Op({size:e=12}){return d.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})}function Bp({skill:e,onRemove:t}){const n=e.displayName||e.name,r=e.owner==="member"&&e.memberName?`${n}(成员 ${e.memberName} 的技能)`:n;return d.jsxs("span",{className:"sa-skill-chip",title:r,children:[d.jsxs("button",{type:"button",className:"sa-skill-chip-icon","aria-label":`移除技能 ${n}`,onClick:i=>{i.stopPropagation(),t()},children:[d.jsx("span",{className:"sa-skill-chip-icon-skill",children:d.jsx(da,{})}),d.jsx("span",{className:"sa-skill-chip-icon-remove",children:d.jsx(Op,{})})]}),d.jsx("span",{className:"sa-skill-chip-label",children:n})]})}function Dn(){const{status:e,sendMessage:t,stop:n,sdk:r,attachmentUploader:i,nosUpload:s}=ze(),[a,o]=y.useState(""),[l,u]=y.useState(null),[p,c]=y.useState([]),h=y.useRef(null),f=y.useRef(null),m=!!i||!!s,w=e==="streaming"||e==="submitted",C=p.filter(E=>E.attachment),b=p.some(E=>!E.attachment&&E.status==="uploading"),S=!!a.trim()||!!l||p.length>0||w,j=!w&&!b&&(a.trim().length>0||!!l||C.length>0),L=y.useCallback(E=>{u(E),o(""),setTimeout(()=>{var I;return(I=h.current)==null?void 0:I.focus()},0)},[]),A=y.useCallback(()=>{var E;u(null),(E=h.current)==null||E.focus()},[]),k=Rp({sdk:r,input:a,onSelect:L}),N=y.useCallback(E=>{const I=Array.from(E.target.files??[]);if(E.target.value="",!m||I.length===0)return;const F=Pp-p.length,q=I.slice(0,Math.max(0,F));if(q.length===0)return;const U=q.map(P=>({key:`${P.name}_${P.size}_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,file:P,status:"uploading"}));c(P=>[...P,...U]);for(const{key:P,file:B}of U)(i||Me.createNosUploader({baseURL:s.baseURL,headers:s.headers,trunkSize:s.trunkSize,onProgress:H=>c($=>$.map(g=>g.key===P?{...g,percent:H}:g))}))(B).then(H=>{c($=>$.map(g=>g.key===P?{...g,attachment:{...H,filename:H.filename||B.name,size:H.size??B.size,mime:H.mime??B.type}}:g))}).catch(H=>{c($=>$.map(g=>g.key===P?{...g,status:"error",errorMsg:H instanceof Error?H.message:String(H)}:g))})},[i,s,p]),_=y.useCallback(E=>{c(I=>I.filter(F=>F.key!==E))},[]),O=y.useCallback(()=>{if(!j)return;const E=a.trim(),I=C.map(q=>q.attachment),F=l?`/${l.code}${E?` ${E}`:""}`:E;t(F,I.length>0?I:void 0),o(""),u(null),c([]),h.current&&(h.current.style.height="auto")},[j,a,l,C,t]),v=y.useCallback(E=>{if(!k.handleKeyDown(E)){if(E.key==="Backspace"&&l&&a.length===0){E.preventDefault(),u(null);return}E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),O())}},[O,k.handleKeyDown,l,a]),D=y.useCallback(E=>{o(E.target.value);const I=E.target;I.style.height="auto",I.style.height=Math.min(I.scrollHeight,90)+"px"},[]),T=y.useCallback(()=>{var E;w||(E=h.current)==null||E.focus()},[w]);return d.jsxs("div",{className:"relative z-[2] shrink-0 px-[15px] pb-2.5",children:[k.isOpen&&d.jsx(Mp,{items:k.items,activeIndex:k.activeIndex,onSelect:L}),p.length>0&&d.jsx("div",{className:"sa-attachment-tray mb-1.5",onClick:E=>E.stopPropagation(),children:p.map(E=>d.jsxs("span",{className:`sa-attachment-tray-chip ${E.status==="error"?"sa-attachment-tray-chip-error":""}`,title:E.status==="error"?`上传失败:${E.errorMsg??""}`:E.file.name,children:[d.jsx(J,{name:"file-text",size:13,color:E.status==="error"?"#ef4444":"#6366f1"}),d.jsx("span",{className:"sa-attachment-tray-chip-name",children:E.file.name}),d.jsx("span",{className:"sa-attachment-tray-chip-size",children:E.attachment?sa(E.file.size):E.status==="error"?"失败":E.percent!=null?`${Math.min(99,Math.round(E.percent))}%`:"上传中…"}),d.jsx("button",{type:"button",className:"sa-attachment-tray-chip-remove","aria-label":`移除附件 ${E.file.name}`,onClick:()=>_(E.key),children:"✕"})]},E.key))}),d.jsxs("form",{className:`sa-input-form relative flex min-h-[70px] cursor-text flex-col gap-1 rounded-[5px] p-2 ${S?"sa-input-form-active":""} ${w?"sa-input-form-streaming":""}`,onClick:T,onSubmit:E=>{E.preventDefault(),O()},children:[d.jsxs("div",{className:"flex items-start gap-1.5",children:[l&&d.jsx(Bp,{skill:l,onRemove:A}),d.jsx("textarea",{ref:h,className:"sa-input-field min-h-[34px] min-w-0 flex-1 resize-none border-none bg-transparent p-0 text-[14px] leading-[1.5] text-[#333] outline-none placeholder:text-[#B8B8B8]",value:a,onChange:D,onKeyDown:v,placeholder:w?"回答生成中,请稍候…":l?"补充你的需求…":"发消息或创建任务... /使用技能",rows:1,disabled:w})]}),d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m&&!w&&d.jsx("button",{type:"button",className:"sa-attach-btn mr-auto","aria-label":"添加附件",title:"添加附件",onClick:()=>{var E;return(E=f.current)==null?void 0:E.click()},children:d.jsx(_p,{size:15})}),d.jsx("input",{ref:f,type:"file",multiple:!0,className:"hidden",onChange:N,"aria-label":"选择附件"}),!w&&d.jsxs("span",{className:"sa-send-hint","aria-hidden":"true",children:[d.jsx("kbd",{className:"sa-send-kbd",children:Fp?"⌘":"Ctrl"}),d.jsx("span",{children:"+"}),d.jsx("kbd",{className:"sa-send-kbd",children:"Enter"}),d.jsx("span",{children:"发送"})]}),w?d.jsx("button",{type:"button",className:"sa-send-btn sa-send-btn-active","aria-label":"停止生成",title:"停止生成",onClick:n,children:d.jsx("span",{className:"sa-stop-icon"})}):d.jsx("button",{type:"submit",className:`sa-send-btn ${j?"sa-send-btn-active":""}`,"aria-label":"发送",title:"发送",disabled:!j,children:d.jsx("img",{src:pe.sendSolid,alt:"发送",width:14,height:14,draggable:!1})})]})]}),d.jsx("div",{className:"mt-3 text-center text-[11px] leading-none text-[#B8B8B8]",children:"所有内容均由AI生成仅供参考"})]})}function $p({artifact:e}){const[t,n]=y.useState(null),[r,i]=y.useState(null),[s,a]=y.useState(!0),[o,l]=y.useState(null);return y.useEffect(()=>{let u=!1;a(!0),l(null),n(null),i(null);async function p(){try{if(e.type==="pdf"){u||a(!1);return}if(e.type==="md"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.text();u||(i(h),a(!1));return}if(e.type==="html"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.text(),f=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;u||(n(f.sanitize(h,{FORCE_BODY:!0,ADD_ATTR:["target"]})),a(!1));return}if(e.type==="docx"){const c=await fetch(e.url);if(!c.ok)throw new Error(`HTTP ${c.status}`);const h=await c.arrayBuffer(),m=await(await Promise.resolve().then(()=>require("./mammoth.browser-CxQENq5Q.cjs")).then(C=>C.mammoth_browser)).convertToHtml({arrayBuffer:h}),w=(await Promise.resolve().then(()=>require("./purify.es-Dsdnkgrg.cjs"))).default;u||(n(w.sanitize(m.value,{FORCE_BODY:!0,ADD_ATTR:["target"]})),a(!1));return}u||(a(!1),l(`不支持预览「${e.type}」类型`))}catch(c){u||(a(!1),l(c instanceof Error?c.message:"加载失败"))}}return p(),()=>{u=!0}},[e]),s?d.jsx("div",{className:"sa-drawer-preview-loading",children:"加载中"}):o?d.jsxs("div",{className:"sa-drawer-preview-error",children:[o,d.jsx("button",{className:"sa-drawer-btn-sm",onClick:()=>void kt(e),children:"下载查看"})]}):e.type==="pdf"?d.jsx("iframe",{src:e.url,title:e.filename,className:"sa-drawer-preview-iframe",sandbox:"allow-scripts"}):r!==null?d.jsx("div",{className:"sa-drawer-preview-html-scroll",children:d.jsx("div",{className:"sa-drawer-preview-html sa-text-part",children:d.jsx(Ti,{remarkPlugins:[Zi],children:r})})}):t!==null?d.jsx("div",{className:"sa-drawer-preview-html-scroll",children:d.jsx("div",{className:"sa-drawer-preview-html sa-text-part",dangerouslySetInnerHTML:{__html:t}})}):null}function Hp({artifacts:e,initialArtifact:t,onClose:n}){const[r,i]=y.useState(t?{mode:"preview",artifact:t}:{mode:"list"}),[s,a]=y.useState(!1),o=y.useRef(null),[l,u]=y.useState(340),p=y.useRef(null);y.useEffect(()=>{t&&(o.current&&(clearTimeout(o.current),o.current=null,a(!1)),i({mode:"preview",artifact:t}))},[t]);const c=y.useCallback(()=>{a(!0),o.current=setTimeout(()=>{o.current=null,n()},240)},[n]);y.useEffect(()=>()=>{var w;o.current&&clearTimeout(o.current),(w=p.current)==null||w.call(p)},[]);const h=y.useCallback(w=>{i({mode:"preview",artifact:w})},[]),f=y.useCallback(()=>{i({mode:"list"})},[]);y.useEffect(()=>{const w=C=>{C.key==="Escape"&&c()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[c]);const m=y.useCallback(w=>{w.preventDefault();const C=w.clientX,b=l,S=L=>{const A=C-L.clientX;u(Math.max(240,Math.min(window.innerWidth*.7,b+A)))},j=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect="",p.current=null};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",S),document.addEventListener("mouseup",j),p.current=j},[l]);return d.jsxs("div",{className:`sa-artifact-drawer ${s?"sa-drawer-closing":""}`,style:{width:l},children:[d.jsx("div",{className:"sa-drawer-resize-handle",onMouseDown:m}),d.jsxs("div",{className:"sa-artifact-drawer-header",children:[r.mode==="preview"?d.jsxs(d.Fragment,{children:[d.jsx("button",{className:"sa-drawer-btn",onClick:f,title:"返回列表","aria-label":"返回列表",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M15 18l-6-6 6-6"})})}),d.jsx("span",{className:"sa-artifact-drawer-title",children:r.artifact.filename})]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),d.jsx("span",{className:"sa-artifact-drawer-title",children:"会话产物"})]}),d.jsx("div",{style:{flex:1}}),r.mode==="preview"&&d.jsx("button",{className:"sa-drawer-btn",onClick:()=>void kt(r.artifact),title:"下载","aria-label":"下载",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),d.jsx("button",{className:"sa-drawer-btn",onClick:c,title:"关闭","aria-label":"关闭",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),d.jsx("div",{className:"sa-artifact-drawer-body",children:r.mode==="list"?e.length===0?d.jsx("div",{className:"sa-drawer-empty",children:"暂无产物"}):d.jsx("ul",{className:"sa-drawer-file-list",role:"list",children:e.map((w,C)=>d.jsxs("li",{className:"sa-drawer-file-card",onClick:()=>h(w),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),h(w))},tabIndex:0,role:"button","aria-label":`预览 ${w.filename}`,children:[d.jsx("div",{className:"sa-drawer-file-icon",children:d.jsx("span",{className:"sa-artifact-chip-type",children:Or(w.type)})}),d.jsxs("div",{className:"sa-drawer-file-info",children:[d.jsx("span",{className:"sa-drawer-file-name",children:w.filename}),d.jsx("span",{className:"sa-drawer-file-size",children:_r(w.size)})]}),d.jsx("button",{className:"sa-drawer-btn",title:"下载","aria-label":`下载 ${w.filename}`,onClick:b=>{b.stopPropagation(),kt(w)},children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},w.id||`artifact-${C}`))}):d.jsx("div",{className:"sa-drawer-view-enter",children:d.jsx($p,{artifact:r.artifact})})})]})}function pa({page:e,onBack:t,centered:n}){y.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t]);const r=y.isValidElement(e.component)?y.cloneElement(e.component,{close:t}):y.createElement(e.component,{close:t});return d.jsx("div",{className:`sa-page-overlay ${n?"sa-page-overlay-centered":""}`,children:d.jsx("div",{className:"sa-page-overlay-body",children:r})})}const Up="mx-auto w-full max-w-[800px]";function fa({contentClassName:e,centered:t,composerClassName:n,thread:r,composer:i,artifactPreview:s}){const{activePanel:a,closePanel:o,messagesLoading:l,isArtifactDrawerOpen:u,allArtifacts:p,activePreviewArtifact:c,toggleArtifactDrawer:h}=ze();if(a)return d.jsx(pa,{page:a,onBack:o,centered:t});const f=t?Up:"";return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`${e} ${f}`,children:[l?d.jsxs("div",{className:"sa-messages-loading",children:[d.jsx("span",{className:"sa-loading-spinner"}),"加载对话..."]}):r,s&&u&&d.jsx(Hp,{artifacts:p,initialArtifact:c,onClose:h})]}),n?d.jsx("div",{className:`${n} ${f}`,children:i}):i]})}function Vp({isOpen:e,onClose:t,title:n,slots:r,welcomeMessage:i,suggestedPrompts:s,avatar:a,artifactPreview:o,capabilities:l,quickLinks:u,logo:p,defaultWidth:c,defaultHeight:h,showTimestamp:f}){const{status:m,sendMessage:w,stop:C,toggleThreadList:b,setThreadListOpen:S,isThreadListOpen:j,toggleArtifactDrawer:L,allArtifacts:A,activePanel:k,closePanel:N,messages:_,messagesLoading:O,conversations:v,activeConversationId:D,switchConversation:T,newConversation:E,deleteConversation:I,renameConversation:F,hasMore:q,loadMoreConversations:U}=ze(),{width:P,position:B,hasCustomPosition:x,isMaximized:H,totalWidth:$,windowHeight:g,startWindowDrag:Y,startResize:te,toggleMaximize:ee,reset:ue,setLockedHeight:ae}=va({defaultWidth:c??de.DEFAULT_WIDTH,defaultHeight:h??de.DEFAULT_HEIGHT,sidebarWidth:0}),W=y.useRef(null),se=y.useRef(null),le=!O&&_.length===0,Ee=!O&&_.length>0,be=!!k;y.useEffect(()=>{e||(ue(),N())},[e,ue,N]),y.useEffect(()=>{S(H?W.current??!0:se.current??!1)},[H,S]),y.useEffect(()=>{Ee||ae(null)},[Ee,ae]);const Lt=Ca({enabled:e&&Ee&&!H&&!be,contentSelector:".sa-panel-content",defaultHeight:h??de.DEFAULT_HEIGHT,onHeightChange:ae});if(!e)return null;const Ke=r.Header,Qe=r.Composer,Pe=r.ThreadList,Dt=()=>{const K=!j;b(),H?W.current=K:se.current=K},Je=200,Ze=j&&!H,ve="var(--sa-radius, 16px)",ht=Ze?`0px ${ve} ${ve} 0px`:`${ve} ${ve} ${ve} ${ve}`,Mt=x?B.x:window.innerWidth-$-20,Ve=Math.min(Je,Math.max(0,Mt-1)),Rt=x?{width:`${$}px`,height:`${g}px`,left:`${B.x}px`,top:`${B.y}px`}:{width:`${$}px`,height:`${g}px`,right:"20px",bottom:"20px"},z={title:n,onClose:t,onToggleThreadList:Dt,isMaximized:H,onToggleMaximize:ee,showHome:Ee||be,onHome:be?N:E,panelTitle:be?k==null?void 0:k.title:void 0,artifactCount:be||!o?0:A.length,onToggleArtifactDrawer:be||!o?void 0:L},R={conversations:v,activeSessionId:D,onSwitch:T,onNew:E,onDelete:I,onRename:F,hasMore:q,onLoadMore:U},G=d.jsxs("div",{className:`relative flex min-w-0 flex-col bg-white ${H?"flex-1":"h-full shrink-0"}`,style:H?void 0:{width:`${P}px`,borderRadius:ht,overflow:"hidden"},children:[le&&!be&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sa-home-gradient pointer-events-none absolute inset-x-0 top-0 z-0 h-[238px] opacity-10"}),d.jsx("div",{className:"sa-home-gradient-fade pointer-events-none absolute inset-x-0 top-0 z-[1] h-[238px]"})]}),d.jsx("div",{className:`relative z-20 ${le||H?"":"bg-white"} ${H?"cursor-default":"cursor-grab active:cursor-grabbing"}`,onMouseDown:H?void 0:Y,children:Ke?d.jsx(Ke,{...z}):d.jsx(Ur,{...z})}),d.jsx(fa,{contentClassName:`sa-panel-content relative z-[2] ${le?"sa-home-view":""}`,centered:H,composerClassName:"shrink-0",artifactPreview:o,thread:d.jsx(Ln,{slots:r,welcomeMessage:i,suggestedPrompts:s,avatar:a,artifactPreview:o,capabilities:l,quickLinks:u,logo:p,showTimestamp:f}),composer:Qe?d.jsx(Qe,{status:m,onSend:w,onStop:C}):d.jsx(Dn,{})})]});return H?d.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:d.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:[j&&(Pe?d.jsx(Pe,{...R}):d.jsx(Zt,{width:220})),G]})}):d.jsxs("div",{ref:Lt,className:"fixed z-[var(--sa-z-index,9999)] flex animate-sa-window-in flex-row overflow-visible border border-[#DADADA] bg-white ",style:{...Rt,borderRadius:ht},children:[d.jsx("div",{className:"sa-resize-handle absolute bottom-0 left-[-3px] top-0 z-20 w-[6px] cursor-col-resize",onMouseDown:K=>te(K)}),Ze&&(Pe?d.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] ",style:{width:Ve,transform:`translateX(-${Ve}px)`,borderRadius:`${ve} 0px 0px ${ve}`},children:d.jsx(Pe,{...R})}):d.jsx("div",{className:"absolute -top-px -bottom-px -left-px z-10 overflow-hidden border border-r-0 border-[#DADADA] bg-[#FAFAFA] ",style:{width:Ve,transform:`translateX(-${Ve}px)`,borderRadius:`${ve} 0px 0px ${ve}`},children:d.jsx(Zt,{width:Je})})),G]})}const Mr=()=>{};function qp({conversations:e,activeSessionId:t,onSwitch:n,onNew:r,onDelete:i,onRename:s,isCollapsed:a,onToggleCollapse:o,hasMore:l,onLoadMore:u,conversationsLoading:p}){const[c,h]=y.useState(null),[f,m]=y.useState(null),[w,C]=y.useState(""),[b,S]=y.useState(null),j=y.useRef(null);y.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const L=y.useCallback((v,D)=>{D.stopPropagation(),c===v?(i(v),h(null)):(h(v),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>h(null),3e3))},[c,i]),A=y.useCallback((v,D,T)=>{T.stopPropagation(),m(v),C(D??"")},[]),k=y.useCallback(v=>{w.trim()&&s(v,w.trim()),m(null)},[w,s]),N=y.useRef(null),_=y.useCallback(()=>{const v=N.current;!v||!l||!u||v.scrollHeight-v.scrollTop-v.clientHeight<50&&u()},[l,u]),O=y.useMemo(()=>Vr(e),[e]);return a?d.jsxs("div",{className:"flex w-12 shrink-0 flex-col items-center gap-1 border-r border-[#ECECEC] bg-[#FAFAFA] py-3",children:[d.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:o,children:d.jsx(J,{name:"panel-left",size:18})}),d.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:()=>{r(),o()},children:d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18})})]}):d.jsxs("div",{className:"relative flex w-[220px] shrink-0 flex-col border-r border-[#ECECEC] bg-[#FAFAFA] p-3",children:[d.jsxs("div",{className:"mb-4 flex shrink-0 items-center gap-1.5",children:[d.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:r,children:[d.jsx("img",{src:pe.messageCreate,alt:"",width:18,height:18}),d.jsx("span",{className:"sa-new-chat-text whitespace-nowrap",children:"新建对话"})]}),d.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:o,children:d.jsx(J,{name:"panel-left-close",size:16})})]}),d.jsxs("div",{className:"px-1 pb-2.5",children:[d.jsx("div",{className:"mb-1 text-[14px] font-semibold text-[#333]",children:"历史对话"}),d.jsx("div",{className:"text-[11px] text-[#999]",children:"展示最近的会话记录"})]}),d.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto",onScroll:_,children:[p&&e.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"加载中..."}),!p&&e.length===0&&d.jsx("div",{className:"px-0.5 py-2 text-[12px] text-[#999]",children:"暂无记录"}),O.map(v=>d.jsxs("div",{className:"mb-1",children:[d.jsx("div",{className:"px-1 pb-1 pt-2 text-[11px] text-[#A0A0A0]",children:v.label}),v.items.map(D=>{const T=D.sessionId===t,E=c===D.sessionId;return d.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 ${T?"bg-[#E8F1FE]":"hover:bg-[#E8F1FE]"}`,onClick:()=>{f!==D.sessionId&&n(D.sessionId)},onMouseEnter:I=>{if(f===D.sessionId)return;const F=I.currentTarget.getBoundingClientRect();S({text:D.title||"新会话",x:F.right+8,y:F.top+F.height/2})},onMouseLeave:()=>S(null),children:f===D.sessionId?d.jsx("input",{className:"w-full rounded border border-[var(--sa-primary)] bg-white px-1.5 py-0.5 text-[12px] outline-none",value:w,onChange:I=>C(I.target.value),onBlur:()=>k(D.sessionId),onKeyDown:I=>{I.key==="Enter"&&k(D.sessionId),I.key==="Escape"&&m(null)},onClick:I=>I.stopPropagation(),autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("img",{src:pe.message,alt:"",width:16,height:16,className:"shrink-0 opacity-60"}),d.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-[#333]",children:D.title||"新会话"}),d.jsxs("span",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[d.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:I=>A(D.sessionId,D.title,I),title:"重命名",children:d.jsx(J,{name:"pen",size:12})}),d.jsx("button",{type:"button",className:`flex h-5 w-5 items-center justify-center rounded ${E?"bg-[#fee2e2] text-[#ef4444]":"text-[#999] hover:bg-white/70 hover:text-[#ef4444]"}`,onClick:I=>L(D.sessionId,I),title:E?"确认删除":"删除",children:d.jsx(J,{name:E?"x":"trash2",size:12})})]})]})},D.sessionId)})]},v.label)),l&&d.jsx("div",{className:"px-0.5 py-2 text-center text-[11px] text-[#C0C0C0]",children:"向下滚动加载更多"})]}),b&&d.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:b.x,top:b.y,transform:"translateY(-50%)"},children:b.text})]})}function ha({title:e,slots:t,welcomeMessage:n,suggestedPrompts:r,capabilities:i,quickLinks:s,logo:a,sidebarDefaultOpen:o=!0,onClose:l,avatar:u,artifactPreview:p,showTimestamp:c}){const{status:h,sendMessage:f,stop:m,conversations:w,activeConversationId:C,switchConversation:b,newConversation:S,deleteConversation:j,renameConversation:L,toggleArtifactDrawer:A,allArtifacts:k,activePanel:N,closePanel:_,hasMore:O,loadMoreConversations:v,conversationsLoading:D}=ze(),[T,E]=y.useState(o),I=y.useCallback(()=>E(B=>!B),[]),F=!!N;y.useEffect(()=>()=>_(),[_]);const q=t.ThreadList,U=t.Composer,P=t.Header;return d.jsxs("div",{className:"sa-fullpage",children:[q?d.jsx("div",{className:`sa-fp-sidebar-wrapper ${T?"":"sa-fp-sidebar-wrapper-collapsed"}`,children:d.jsx(q,{conversations:w,activeSessionId:C,onSwitch:b,onNew:S,onDelete:j,onRename:L,hasMore:O,onLoadMore:v})}):d.jsx(qp,{conversations:w,activeSessionId:C,onSwitch:b,onNew:S,onDelete:j,onRename:L,isCollapsed:!T,onToggleCollapse:I,hasMore:O,onLoadMore:v,conversationsLoading:D}),d.jsxs("div",{className:"sa-fp-main",children:[P?d.jsx(P,{title:F?(N==null?void 0:N.title)??e:e,panelTitle:F?N==null?void 0:N.title:void 0,onClose:l??Mr,onToggleThreadList:I,showHome:F,onHome:F?_:Mr,artifactCount:F||!p?0:k.length,onToggleArtifactDrawer:F||!p?void 0:A}):d.jsxs("div",{className:"sa-fp-header",children:[d.jsx("div",{className:"sa-fp-header-title",children:F?(N==null?void 0:N.title)??e:e}),d.jsxs("div",{className:"sa-fp-header-actions",children:[F&&d.jsx("button",{className:"sa-fp-header-btn",onClick:_,title:"返回聊天","aria-label":"返回聊天",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),d.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]})}),!F&&p&&k.length>0&&d.jsxs("button",{className:"sa-fp-header-btn sa-header-btn-artifact",onClick:A,title:"会话产物",children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("polyline",{points:"14 2 14 8 20 8"})]}),d.jsx("span",{children:"产物"})]})]})]}),d.jsx(fa,{contentClassName:"sa-fp-content-row",artifactPreview:p,thread:d.jsx(Ln,{slots:t,welcomeMessage:n,suggestedPrompts:r,capabilities:i,quickLinks:s,logo:a,avatar:u,artifactPreview:p,showTimestamp:c}),composer:U?d.jsx(U,{status:h,onSend:f,onStop:m}):d.jsx(Dn,{})})]})]})}function ga(e){const{sdk:t,mode:n="floating",slots:r={},hooks:i={},welcomeMessage:s,suggestedPrompts:a,title:o="AI Assistant",initialOpen:l=!1,onOpenChange:u,sidebarDefaultOpen:p,avatar:c,artifactPreview:h,capabilities:f,quickLinks:m,logo:w,triggerLogo:C,theme:b,showTimestamp:S,attachmentUploader:j,nosUpload:L}=e,[A,k]=y.useState(l);y.useEffect(()=>{k(l)},[l]);const N=y.useCallback(()=>{var D,T;const v=!A;k(v),u==null||u(v),v?(D=i.onOpen)==null||D.call(i):(T=i.onClose)==null||T.call(i)},[A,i,u]),_=y.useCallback(()=>{var v;k(!1),u==null||u(!1),(v=i.onClose)==null||v.call(i)},[i,u]),O=r.Trigger??Hr;return n==="fullpage"?A?d.jsx(Jt,{sdk:t,hooks:i,attachmentUploader:j,nosUpload:L,children:d.jsx(ha,{title:o,slots:r,welcomeMessage:s,suggestedPrompts:a,capabilities:f,quickLinks:m,logo:w,sidebarDefaultOpen:p,onClose:_,avatar:c,artifactPreview:h,showTimestamp:S})}):null:d.jsxs(Jt,{sdk:t,hooks:i,attachmentUploader:j,nosUpload:L,children:[d.jsx(O,{isOpen:A,onClick:N,triggerLogo:C}),d.jsx(Vp,{isOpen:A,onClose:_,title:o,slots:r,welcomeMessage:s,suggestedPrompts:a,avatar:c,artifactPreview:h,capabilities:f,quickLinks:m,logo:w,defaultWidth:b==null?void 0:b.panelWidth,defaultHeight:b==null?void 0:b.panelHeight,showTimestamp:S})]})}const ma=`
|
|
31
31
|
[data-super-agent-widget] {
|
|
32
32
|
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
33
33
|
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|