var je=Object.defineProperty;var Ze=(e,t,n)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>Ze(e,typeof t!="symbol"?t+"":t,n);import{M as qe,l as Ke,a as Ye,b as Je,c as Qe,_ as X,d as S,m as ue,g as et,h as tt}from"./vendor-common.js?v=1775123024591";import{R as a,r as x}from"./vendor-react.js?v=1775123024591";import{d as nt,C as Te,F as ot,K as Ce,a as fe,u as st,i as rt,b as at,c as it,f as ct,g as lt,m as we,e as V,_ as se,T as K,R as dt,h as mt,j as ut,k as pt,l as ft,n as gt,o as ht,p as Ct,q as $t,D as yt,r as xt,s as kt,t as Et,v as It,B as Rt,w as bt,S as St}from"./vendor-antd.js?v=1775123024591";const H={escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeTest:/[&<>"']/,notSpaceStart:/^\S*/,endingNewline:/\n$/,escapeReplace:/[&<>"']/g,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,completeFencedCode:/^ {0,3}(`{3,}|~{3,})([\s\S]*?)\n {0,3}\1[ \n\t]*$/},vt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ie=e=>vt[e];function Re(e,t){if(t){if(H.escapeTest.test(e))return e.replace(H.escapeReplace,Ie)}else if(H.escapeTestNoEncode.test(e))return e.replace(H.escapeReplaceNoEncode,Ie);return e}class Tt{constructor(t={}){U(this,"options");U(this,"markdownInstance");const{markedConfig:n={}}=t;this.options=t,this.markdownInstance=new qe,this.configureLinkRenderer(),this.configureParagraphRenderer(),this.configureCodeRenderer(),this.markdownInstance.use(n)}configureLinkRenderer(){if(!this.options.openLinksInNewTab)return;const t={link({href:n,title:o,tokens:s}){const r=this.parser.parseInline(s),c=o?` title="${o}"`:"";return`<a href="${n}"${c} target="_blank" rel="noopener noreferrer">${r}</a>`}};this.markdownInstance.use({renderer:t})}configureParagraphRenderer(){const{paragraphTag:t}=this.options;if(!t)return;const n={paragraph({tokens:o}){return`<${t}>${this.parser.parseInline(o)}</${t}>
`}};this.markdownInstance.use({renderer:n})}configureCodeRenderer(){const t={code({text:n,raw:o,lang:s,escaped:r,codeBlockStyle:c}){var d;const i=(d=(s||"").match(H.notSpaceStart))==null?void 0:d[0],l=`${n.replace(H.endingNewline,"")}
`,m=c==="indented"||H.completeFencedCode.test(o)?"done":"loading",p=r?l:Re(l,!0),f=i?` class="language-${Re(i)}"`:"";return`<pre><code data-block="true" data-state="${m}"${f}>${p}</code></pre>
`}};this.markdownInstance.use({renderer:t})}parse(t){return this.markdownInstance.parse(t)}}const wt=a.memo(e=>{const{text:t,animationConfig:n}=e,{fadeDuration:o=200,easing:s="ease-in-out"}=n||{},[r,c]=x.useState([]),i=x.useRef("");x.useEffect(()=>{if(t===i.current)return;if(!(i.current&&t.indexOf(i.current)===0)){c([t]),i.current=t;return}const u=t.slice(i.current.length);u&&(c(m=>[...m,u]),i.current=t)},[t]);const l=x.useMemo(()=>({animation:`x-markdown-fade-in ${o}ms ${s} forwards`}),[o,s]);return a.createElement(a.Fragment,null,r.map((u,m)=>a.createElement("span",{style:l,key:`animation-text-${m}`},u)))}),oe=class oe{constructor(t){U(this,"options");this.options=t}detectUnclosedTags(t){var c;const n=new Set,o=[],s=/<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s[^>]*)?>/g;let r=s.exec(t);for(;r!==null;){const[i,l]=r,u=i.startsWith("</"),m=i.endsWith("/>");if((c=this.options.components)!=null&&c[l.toLowerCase()])if(u){const p=o.lastIndexOf(l.toLowerCase());p!==-1&&o.splice(p,1)}else m||o.push(l.toLowerCase());r=s.exec(t)}return o.forEach(i=>{n.add(i)}),n}configureDOMPurify(){const t=Object.keys(this.options.components||{}),n=this.options.dompurifyConfig||{},o=Array.isArray(n.ADD_TAGS)?n.ADD_TAGS:[],s=Array.isArray(n.ADD_ATTR)?n.ADD_ATTR:[];return{...n,ADD_TAGS:Array.from(new Set([...t,...o])),ADD_ATTR:Array.from(new Set(["target","rel",...s]))}}createReplaceElement(t,n){const{enableAnimation:o,animationConfig:s}=this.options.streaming||{};return r=>{var $,h,k;const c=`x-markdown-component-${n.current++}`,i=r.type==="text"&&r.data&&oe.NON_WHITESPACE_REGEX.test(r.data),l=($=r.parent)==null?void 0:$.name,u=l&&((h=this.options.components)==null?void 0:h[l]);if(o&&i&&!u)return a.createElement(wt,{text:r.data,key:c,animationConfig:s});if(!("name"in r))return;const{name:p,attribs:f,children:d}=r,g=(k=this.options.components)==null?void 0:k[p];if(g){const E=t!=null&&t.has(p)?"loading":"done",y={domNode:r,streamStatus:E,key:c,...f,...f.disabled!==void 0&&{disabled:!0},...f.checked!==void 0&&{checked:!0}},b=[y.className,y.classname,y.class].filter(Boolean).join(" ").trim();if(y.className=b||"",p==="code"){const{"data-block":O="false","data-state":P="done"}=f||{};y.block=O==="true",y.streamStatus=P==="loading"?"loading":"done"}return d&&(y.children=this.processChildren(d,t,n)),a.createElement(g,y)}}}processChildren(t,n,o){return Ke.domToReact(t,{replace:this.createReplaceElement(n,o)})}processHtml(t){const n=this.detectUnclosedTags(t),o={current:0},s=this.configureDOMPurify(),r=Ye.sanitize(t,s);return Je(r,{replace:this.createReplaceElement(n,o)})}render(t){return this.processHtml(t)}};U(oe,"NON_WHITESPACE_REGEX",/[^\r\n\s]+/);let ge=oe,I=function(e){return e.Text="text",e.Link="link",e.Image="image",e.Html="html",e.Emphasis="emphasis",e.List="list",e.Table="table",e}({});const Mt=/^(`{3,}|~{3,})/,W={image:[/^!\[[^\]\r\n]{0,1000}$/,/^!\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],link:[/^\[[^\]\r\n]{0,1000}$/,/^\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],html:[/^<\/$/,/^<\/?[a-zA-Z][a-zA-Z0-9-]{0,100}[^>\r\n]{0,1000}$/],commonEmphasis:[/^(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/],list:[/^[-+*]\s{0,3}$/,/^[-+*]\s{1,3}(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/]},Nt=e=>{if(e.includes(`

`))return!1;const t=e.split(`
`);if(t.length<=1)return!0;const[n,o]=t,s=n.trim();if(!/^\|.*\|$/.test(s))return!1;const c=o.trim().split("|").map(l=>l.trim()).filter(Boolean),i=/^:?-+:?$/;return c.every((l,u)=>u===c.length-1&&l===":"||i.test(l))},Me={[I.Link]:{tokenType:I.Link,isStartOfToken:e=>e.startsWith("["),isStreamingValid:e=>W.link.some(t=>t.test(e))},[I.Image]:{tokenType:I.Image,isStartOfToken:e=>e.startsWith("!"),isStreamingValid:e=>W.image.some(t=>t.test(e))},[I.Html]:{tokenType:I.Html,isStartOfToken:e=>e.startsWith("<"),isStreamingValid:e=>W.html.some(t=>t.test(e))},[I.Emphasis]:{tokenType:I.Emphasis,isStartOfToken:e=>e.startsWith("*")||e.startsWith("_"),isStreamingValid:e=>W.commonEmphasis.some(t=>t.test(e))},[I.List]:{tokenType:I.List,isStartOfToken:e=>/^[-+*]/.test(e),isStreamingValid:e=>W.list.some(t=>t.test(e))},[I.Table]:{tokenType:I.Table,isStartOfToken:e=>e.startsWith("|"),isStreamingValid:Nt}},Pt=(e,t)=>{const n=Me[t];if(!n)return;const{token:o,pending:s}=e;if(o===I.Text&&n.isStartOfToken(s)){e.token=t;return}o===t&&!n.isStreamingValid(s)&&he(e)},be=Object.values(Me).map(e=>({tokenType:e.tokenType,recognize:t=>Pt(t,e.tokenType)})),pe=()=>({pending:"",token:I.Text,processedLength:0,completeMarkdown:""}),he=e=>{e.pending&&(e.completeMarkdown+=e.pending,e.pending=""),e.token=I.Text},At=e=>{const t=e.split(`
`);let n=!1,o="",s=0;for(const r of t){const i=(r.endsWith("\r")?r.slice(0,-1):r).match(Mt);if(i){const l=i[1],u=l[0],m=l.length;n?u===o&&m>=s&&(n=!1,o="",s=0):(n=!0,o=u,s=m)}}return n},Lt=e=>{let t="";for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);o>=55296&&o<=56319?n+1<e.length&&e.charCodeAt(n+1)>=56320&&e.charCodeAt(n+1)<=57343&&(t+=e[n]+e[n+1],n++):(o<56320||o>57343)&&(t+=e[n])}return t},Dt=e=>{try{return encodeURIComponent(e)}catch(t){return t instanceof URIError?encodeURIComponent(Lt(e)):""}},zt=(e,t)=>{const{streaming:n,components:o={}}=t||{},{hasNextChunk:s=!1,incompleteMarkdownComponentMap:r}=n||{},[c,i]=x.useState(""),l=x.useRef(pe()),u=x.useCallback(p=>{const{token:f,pending:d}=p;if(f===I.Text||f===I.Image&&d==="!")return;if(f===I.Table&&d.split(`
`).length>2)return d;const $=(r||{})[f]||`incomplete-${f}`,h=Dt(d);return o!=null&&o[$]?`<${$} data-raw="${h}" />`:void 0},[r,o]),m=x.useCallback(p=>{if(!p){i(""),l.current=pe();return}const f=l.current.completeMarkdown+l.current.pending;p.startsWith(f)||(l.current=pe());const d=l.current,g=p.slice(d.processedLength);if(!g)return;d.processedLength+=g.length;const $=At(p);for(const k of g){if(d.pending+=k,$){he(d);continue}if(d.token===I.Text)for(const E of be)E.recognize(d);else{const E=be.find(y=>y.tokenType===d.token);E==null||E.recognize(d)}d.token===I.Text&&he(d)}const h=u(d);i(d.completeMarkdown+(h||""))},[u]);return x.useEffect(()=>{if(typeof e!="string"){console.error(`X-Markdown: input must be string, not ${typeof e}.`),i("");return}s?m(e):i(e)},[e,s,m]),c},yn=a.memo(e=>{const{streaming:t,config:n,components:o,paragraphTag:s,content:r,children:c,rootClassName:i,className:l,style:u,openLinksInNewTab:m,dompurifyConfig:p}=e,f=Qe("x-markdown",i,l),d=zt(r||c||"",{streaming:t,components:o}),g=x.useMemo(()=>new Tt({markedConfig:n,paragraphTag:s,openLinksInNewTab:m}),[n,s,m]),$=x.useMemo(()=>new ge({components:o,dompurifyConfig:p,streaming:t}),[o,p,t]),h=x.useMemo(()=>d?g.parse(d):"",[d,g]);return d?a.createElement("div",{className:f,style:u},$.render(h)):null});function Xt(e,t){return x.useImperativeHandle(e,()=>{const n=t(),{nativeElement:o}=n;return new Proxy(o,{get(s,r){return n[r]?n[r]:Reflect.get(s,r)}})})}const Ne=a.createContext({}),Ot={classNames:{},styles:{},className:"",style:{},shortcutKeys:{}},Pe=e=>{const t=a.useContext(Ne);return a.useMemo(()=>({...Ot,...t[e]}),[t[e]])},Ae=x.createContext(void 0),D={locale:"en",Conversations:{create:"New chat"},Sender:{stopLoading:"Stop loading",speechRecording:"Speech recording"},Actions:{feedbackLike:"Like",feedbackDislike:"Dislike",audio:"Play audio",audioRunning:"Audio playing",audioError:"Playback error",audioLoading:"Loading audio"},Bubble:{editableOk:"OK",editableCancel:"Cancel"},Mermaid:{zoomIn:"Zoom in",zoomOut:"Zoom out",zoomReset:"Reset",download:"Download",code:"Code",image:"Image"}},re=(e,t)=>{const n=x.useContext(Ae),o=x.useMemo(()=>{var i;const r=t||(D==null?void 0:D[e])||((i=nt)==null?void 0:i[e]),c=(n==null?void 0:n[e])??{};return{...typeof r=="function"?r():r,...c||{}}},[e,t,n]),s=x.useMemo(()=>{const r=n==null?void 0:n.locale;return n!=null&&n.exist&&!r?D.locale:r},[n]);return[o,s]},Ht="internalMark",Ft=e=>{const{locale:t={},children:n,_ANT_MARK__:o}=e,s=x.useMemo(()=>({...t,exist:!0}),[t]);return x.createElement(Ae.Provider,{value:s},n)};function z(){const{getPrefixCls:e,direction:t,csp:n,iconPrefixCls:o,theme:s}=a.useContext(Te.ConfigContext);return{theme:s,getPrefixCls:e,direction:t,csp:n,iconPrefixCls:o}}const xn=e=>{const{actions:t,attachments:n,bubble:o,conversations:s,prompts:r,sender:c,suggestion:i,thoughtChain:l,welcome:u,fileCard:m,think:p,theme:f,locale:d,children:g,mermaid:$,codeHighlighter:h,...k}=e,E=a.useMemo(()=>({actions:t,attachments:n,bubble:o,conversations:s,prompts:r,sender:c,suggestion:i,thoughtChain:l,fileCard:m,think:p,mermaid:$,codeHighlighter:h,welcome:u}),[t,n,o,s,r,c,i,l,u,$,p,m,h]);let y=g;return d&&(y=a.createElement(Ft,{locale:d,_ANT_MARK__:Ht},y)),a.createElement(Ne.Provider,{value:E},a.createElement(Te,X({},k,{theme:f,locale:d}),y))},j=1e3,Z=4,ne=140,Se=ne/2,ee=250,ve=500,te=.8;function _t({className:e}){const[t]=re("Sender",D.Sender);return a.createElement("svg",{color:"currentColor",viewBox:`0 0 ${j} ${j}`,xmlns:"http://www.w3.org/2000/svg",className:e},a.createElement("title",null,t.speechRecording),Array.from({length:Z}).map((n,o)=>{const s=(j-ne*Z)/(Z-1),r=o*(s+ne),c=j/2-ee/2,i=j/2-ve/2;return a.createElement("rect",{fill:"currentColor",rx:Se,ry:Se,height:ee,width:ne,x:r,y:c,key:o},a.createElement("animate",{attributeName:"height",values:`${ee}; ${ve}; ${ee}`,keyTimes:"0; 0.5; 1",dur:`${te}s`,begin:`${te/Z*o}s`,repeatCount:"indefinite"}),a.createElement("animate",{attributeName:"y",values:`${c}; ${i}; ${c}`,keyTimes:"0; 0.5; 1",dur:`${te}s`,begin:`${te/Z*o}s`,repeatCount:"indefinite"}))}))}const Bt=e=>({animationDuration:e,animationFillMode:"both"}),Gt=e=>({animationDuration:e,animationFillMode:"both"}),Le=(e,t,n,o,s=!1)=>{const r=s?"&":"";return{[`
      ${r}${e}-enter,
      ${r}${e}-appear
    `]:{...Bt(o),animationPlayState:"paused"},[`${r}${e}-leave`]:{...Gt(o),animationPlayState:"paused"},[`
      ${r}${e}-enter${e}-enter-active,
      ${r}${e}-appear${e}-appear-active
    `]:{animationName:t,animationPlayState:"running"},[`${r}${e}-leave${e}-leave-active`]:{animationName:n,animationPlayState:"running",pointerEvents:"none"}}},Ut=new Ce("antXFadeInLeft",{"0%":{maskPosition:"100% 0"},"100%":{maskPosition:"0% 0%"}}),Vt=new Ce("antXFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),De=new Ce("antFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),Wt=(e,t=!1)=>{const{antCls:n}=e,o=`${n}-x-fade-left`,s=t?"&":"";return[{[e.componentCls]:{...Le(o,Ut,De,"1s",t),[`${s}${o}-enter,${s}${o}-appear`]:{transitionProperty:"mask-position",animationTimingFunction:"linear",maskImage:`linear-gradient(90deg, ${e.colorTextBase} 33%, ${new ot(e.colorTextBase).setA(0)} 66%)`,maskSize:"300% 100%",maskPosition:"100% 0%"},[`${s}${o}-leave`]:{animationTimingFunction:"linear"}}}]},jt=(e,t=!1)=>{const{antCls:n}=e,o=`${n}-x-fade`,s=t?"&":"";return[{[e.componentCls]:{...Le(o,Vt,De,"1.2s",t),[`${s}${o}-enter,${s}${o}-appear`]:{opacity:0},[`${s}${o}-leave`]:{animationTimingFunction:"linear"}}}]},Zt="2.1.2",qt=it(fe.defaultAlgorithm),Kt={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},ze=(e,t,n)=>{const o=n.getDerivativeToken(e),{override:s,...r}=t;let c={...o,override:s};return c=ct(c),r&&Object.entries(r).forEach(([i,l])=>{const{theme:u,...m}=l;let p=m;u&&(p=ze({...c,...m},{override:m},u)),c[i]=p}),c};function Yt(){const{token:e,hashed:t,theme:n,override:o,cssVar:s}=a.useContext(fe._internalContext),r={prefix:(s==null?void 0:s.prefix)||"ant",key:(s==null?void 0:s.key)||"css-var-root"},c=n||qt,[i,l,u]=st(c,[fe.defaultSeed,e],{salt:`${Zt}-${t||""}`,override:o,getComputedToken:ze,cssVar:{...r,unitless:at,ignore:rt,preserve:Kt}});return[c,u,t?l:"",i,r]}const{genStyleHooks:Xe}=lt({usePrefix:()=>{const{getPrefixCls:e,iconPrefixCls:t}=z();return{iconPrefixCls:t,rootPrefixCls:e()}},useToken:()=>{const[e,t,n,o,s]=Yt();return{theme:e,realToken:t,hashId:n,token:o,cssVar:s}},useCSP:()=>{const{csp:e}=z();return e??{}},layer:{name:"antdx",dependencies:["antd"]}}),Jt=e=>{const{componentCls:t}=e,n=`${t}-audio`;return{[n]:{[`&${n}-rtl`]:{direction:"rtl"},[`${n}-recording-icon`]:{width:e.fontSize,height:e.fontSize}}}},Qt=e=>{const{componentCls:t}=e,n=`${t}-copy`;return{[t]:{[`&${n}-rtl`]:{direction:"rtl"},[`${n}-copy`]:{fontSize:"inherit",[`&:not(${t}-copy-success)`]:{color:"inherit!important"}}}}},en=e=>{const{componentCls:t}=e,n=`${t}-feedback`;return{[t]:{[`&${n}-rtl`]:{direction:"rtl"}}}},tn=e=>{const{componentCls:t,antCls:n,calc:o}=e;return{[t]:{[`&${t}-rtl`]:{direction:"rtl"},[`${n}-pagination-item-link`]:{width:e.controlHeightSM},[`${t}-variant-outlined`]:{paddingInline:V(o(e.paddingXXS).add(1).equal()),paddingBlock:e.paddingXXS,borderRadius:e.borderRadius,border:`${V(e.lineWidth)} ${e.lineType}, ${e.colorBorderSecondary}`},[`${t}-variant-filled`]:{paddingInline:V(o(e.paddingXXS).add(1).equal()),paddingBlock:e.paddingXXS,borderRadius:e.borderRadius,backgroundColor:e.colorBorderSecondary,[`${t}-item`]:{paddingInline:V(o(e.paddingXXS).add(1).equal()),paddingBlock:e.paddingXXS,"&:hover":{color:e.colorTextSecondary,background:"transparent"}}},[`${t}-list-danger`]:{color:e.colorError},[`&${t}-item,${t}-item`]:{cursor:"pointer",fontSize:e.fontSize,paddingInline:V(o(e.paddingXXS).add(1).equal()),paddingBlock:e.paddingXXS,borderRadius:e.borderRadiusSM,height:e.controlHeightSM,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:e.lineHeight,transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,[`${t}-icon`]:{display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.fontSize},"&:hover":{background:e.colorBgTextHover}},[`&${t}-list,${t}-list`]:{display:"inline-flex",flexDirection:"row",alignItems:"center",color:e.colorText,gap:e.paddingXS}}}},nn=()=>({}),Y=Xe("Actions",e=>{const t=we(e,{});return[tn(t),Qt(t),en(t),Jt(t),Wt(t),jt(t)]},nn);let L=function(e){return e.LOADING="loading",e.ERROR="error",e.RUNNING="running",e.DEFAULT="default",e}({});const Oe=e=>{const{status:t="default",defaultIcon:n,runningIcon:o,label:s,className:r,classNames:c={},styles:i={},style:l,prefixCls:u,rootClassName:m,...p}=e,f=se(p,{attr:!0,aria:!0,data:!0}),{direction:d,getPrefixCls:g}=z(),$=g("actions",u),[h,k]=Y($),E=`${$}-button-item`,y=S(E,h,k,m,r,c.root,$,`${$}-item`,{[`${E}-rtl`]:d==="rtl",[`${c[t]}`]:c[t]}),b={[L.LOADING]:a.createElement(mt,null),[L.ERROR]:a.createElement(dt,null),[L.RUNNING]:o,[L.DEFAULT]:n},O=t&&b[t]?b[t]:n;return a.createElement(K,{title:s},a.createElement("div",X({},f,{className:y,style:{...l,...i.root,...i==null?void 0:i[t]}}),O))},on=e=>{const{status:t=L.DEFAULT,className:n,style:o,prefixCls:s,rootClassName:r,classNames:c={},styles:i={},...l}=e,{direction:u,getPrefixCls:m}=z(),p=m("actions",s),[f,d]=Y(p),g=`${p}-audio`,$=S(p,g,f,d,r,n,c.root,{[`${g}-rtl`]:u==="rtl",[`${g}-${t}`]:t}),[h]=re("Actions",D.Actions),k={[L.LOADING]:h.audioLoading,[L.ERROR]:h.audioError,[L.RUNNING]:h.audioRunning,[L.DEFAULT]:h.audio};return a.createElement(Oe,X({label:t?k[t]:"",style:o,styles:i,classNames:{...c,root:$},status:t,defaultIcon:a.createElement(ut,null),runningIcon:a.createElement(_t,{className:`${g}-recording-icon`})},l))},{Text:sn}=pt,rn=e=>{const{text:t="",icon:n,className:o,style:s,prefixCls:r,rootClassName:c,classNames:i={},styles:l={},...u}=e,m=se(u,{attr:!0,aria:!0,data:!0}),{direction:p,getPrefixCls:f}=z(),d=f("actions",r),[g,$]=Y(d),h=`${d}-copy`,k=S(d,`${d}-item`,g,$,c,o,i.root,{[`${h}-rtl`]:p==="rtl"});return a.createElement(sn,X({},m,{className:k,style:{...s,...l.root},prefixCls:h,copyable:{text:t,icon:n}}))};var w=function(e){return e.like="like",e.dislike="dislike",e.default="default",e}(w||{});const an=e=>{const{value:t="default",onChange:n,className:o,style:s,classNames:r={},styles:c={},prefixCls:i,rootClassName:l,...u}=e,m=se(u,{attr:!0,aria:!0,data:!0}),[p]=re("Actions",D.Actions),{direction:f,getPrefixCls:d}=z(),g=d("actions",i),[$,h]=Y(g),k=`${g}-feedback`,E=S(g,k,$,h,l,r.root,`${g}-list`,o,{[`${k}-rtl`]:f==="rtl"}),y=()=>n==null?void 0:n(t===w.dislike?w.default:w.dislike);return a.createElement("div",X({},m,{className:E,style:{...s,...c.root}}),[w.default,w.like].includes(t)&&a.createElement(K,{key:`like_${t}`,title:p.feedbackLike},a.createElement("span",{onClick:()=>n==null?void 0:n(t===w.like?w.default:w.like),style:{...c.like,...t==="like"?c.liked:{}},className:S(`${k}-item`,`${g}-item`,`${k}-item-like`,r.like,{[`${r.liked}`]:r.liked&&t==="like",[`${k}-item-like-active`]:t==="like"})},t===w.like?a.createElement(ft,null):a.createElement(gt,null))),[w.default,w.dislike].includes(t)&&a.createElement(K,{key:`dislike_${t}`,title:p.feedbackDislike},a.createElement("span",{onClick:y,style:{...c.dislike,...t==="dislike"?c.disliked:{}},className:S(`${k}-item`,`${g}-item`,`${k}-item-dislike`,r.dislike,{[`${r.disliked}`]:r.disliked&&t==="dislike",[`${k}-item-dislike-active`]:t==="dislike"})},t===w.dislike?a.createElement(ht,null):a.createElement(Ct,null))))},$e=a.createContext(null),q=(e,t)=>{const n=e[0];for(const o of t){if(!o)return null;if(o.key===n){if(e.length===1)return o;if(o.subItems)return q(e.slice(1),o==null?void 0:o.subItems)}}return null},cn=e=>{const{onClick:t,item:n,dropdownProps:o={}}=e,{prefixCls:s,classNames:r={},styles:c={}}=a.useContext($e)||{},{subItems:i=[],triggerSubMenuAction:l="hover"}=n,u=(n==null?void 0:n.icon)??a.createElement($t,null),m={items:i,onClick:({key:p,keyPath:f,domEvent:d})=>{var g,$,h;if((g=q(f,i))!=null&&g.onItemClick){(h=($=q(f,i))==null?void 0:$.onItemClick)==null||h.call($,q(f,i));return}t==null||t({key:p,keyPath:[...f,(n==null?void 0:n.key)||""],domEvent:d,item:q(f,i)})}};return a.createElement(yt,X({menu:m,trigger:[l]},o,{className:S(`${s}-dropdown`,r.itemDropdown,o==null?void 0:o.className),styles:{root:c.itemDropdown,...o==null?void 0:o.styles}}),a.createElement("div",{className:S(`${s}-item`,`${s}-sub-item`,r==null?void 0:r.item),style:c==null?void 0:c.item},a.createElement("div",{className:`${s}-icon`},u)))},ln=e=>{const{item:t,onClick:n,dropdownProps:o={}}=e,{prefixCls:s,classNames:r={},styles:c={}}=a.useContext($e)||{},i=a.useId(),l=(t==null?void 0:t.key)||i;return t?t.actionRender?typeof t.actionRender=="function"?t.actionRender(t):t.actionRender:t.subItems?a.createElement(cn,{key:l,item:t,onClick:n,dropdownProps:o}):a.createElement("div",{className:S(`${s}-item`,r.item,{[`${s}-list-danger`]:t==null?void 0:t.danger}),style:c.item,onClick:u=>{if(t!=null&&t.onItemClick){t.onItemClick(t);return}n==null||n({key:l,item:t,keyPath:[l],domEvent:u})},key:l},a.createElement(K,{title:t.label},a.createElement("div",{className:`${s}-icon`},t==null?void 0:t.icon))):null},dn=a.forwardRef((e,t)=>{const{items:n=[],onClick:o,dropdownProps:s={},fadeIn:r,fadeInLeft:c,variant:i="borderless",prefixCls:l,classNames:u={},rootClassName:m="",className:p="",styles:f={},style:d={},...g}=e,$=se(g,{attr:!0,aria:!0,data:!0}),{getPrefixCls:h,direction:k}=z(),E=h("actions",l),y=Pe("actions"),[b,O]=Y(E),P=h(),ae=r||c?`${P}-x-fade${c?"-left":""}`:"",ie=S(E,y.className,y.classNames.root,m,p,u.root,O,b,{[`${E}-rtl`]:k==="rtl"}),A={...y.style,...f.root,...d},J=a.useRef(null);return Xt(t,()=>({nativeElement:J.current})),a.createElement(xt,{motionName:ae},({className:ce},N)=>a.createElement("div",X({ref:kt(J,N)},$,{className:ie,style:A}),a.createElement($e.Provider,{value:{prefixCls:E,classNames:{item:S(y.classNames.item,u.item),itemDropdown:S(y.classNames.itemDropdown,u.itemDropdown)},styles:{item:{...y.styles.item,...f.item},itemDropdown:{...y.styles.itemDropdown,...f.itemDropdown}}}},a.createElement("div",{className:S(`${E}-list`,`${E}-variant-${i}`,ce)},n.map((Q,le)=>a.createElement(ln,{item:Q,onClick:o,dropdownProps:s,key:Q.key||le}))))))}),B=dn;B.Feedback=an;B.Copy=rn;B.Item=Oe;B.Audio=on;const mn=e=>{const{componentCls:t}=e;return{[t]:{[`${t}-header`]:{display:"flex",alignItems:"center",justifyContent:"space-between",background:e.colorBgTitle,color:e.colorTextTitle,padding:e.paddingSM,borderStartStartRadius:e.borderRadius,borderStartEndRadius:e.borderRadius},[`${t}-graph`]:{display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${e.colorBgTitle}`,borderTop:"none",padding:e.paddingSM,background:e.colorBgContainer,overflow:"auto",borderEndEndRadius:e.borderRadius,borderEndStartRadius:e.borderRadius,height:"400px"},[`${t}-graph-hidden`]:{display:"none"},[`${t}-graph svg`]:{maxWidth:"100%",maxHeight:"100%",height:"auto",width:"auto"},[`${t}-code`]:{borderEndEndRadius:e.borderRadius,borderEndStartRadius:e.borderRadius,borderBottom:`1px solid ${e.colorBgTitle}`,borderInlineStart:`1px solid ${e.colorBgTitle}`,borderInlineEnd:`1px solid ${e.colorBgTitle}`,background:e.colorBgContainer,paddingInline:e.paddingSM,paddingBlock:e.paddingSM,overflow:"auto",height:"400px","pre,code":{whiteSpace:"pre",fontSize:e.fontSize,fontFamily:e.fontFamilyCode,lineHeight:2,borderRadius:0,border:"none"},"code[class*='language-'],pre[class*='language-']":{background:"none"}},[`&${t}-rtl`]:{direction:"rtl"}}}},un=e=>({colorBgTitle:e.colorFillContent,colorBorderCode:e.colorBorderSecondary,colorBorderGraph:e.colorBorderSecondary,colorTextTitle:e.colorText}),pn=Xe("Mermaid",e=>{const t=we(e,{});return[mn(t)]},un);var M=function(e){return e.Code="code",e.Image="image",e}(M||{});let fn=0;const kn=a.memo(e=>{var xe,ke;const{prefixCls:t,className:n,style:o,classNames:s={},styles:r={},header:c,children:i,highlightProps:l,onRenderTypeChange:u}=e,[m,p]=x.useState(M.Image),[f,d]=x.useState(1),[g,$]=x.useState({x:0,y:0}),[h,k]=x.useState(!1),[E,y]=x.useState({x:0,y:0}),b=x.useRef(null),O=`mermaid-${fn++}-${(i==null?void 0:i.length)||0}`;x.useEffect(()=>{ue.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default",fontFamily:"monospace"})},[]);const[P]=re("Mermaid",D.Mermaid),{getPrefixCls:ae,direction:ie}=z(),A=ae("mermaid",t),[J,ce]=pn(A),N=Pe("mermaid"),Q=S(A,N.className,(xe=N.classNames)==null?void 0:xe.root,n,s.root,J,ce,{[`${A}-rtl`]:ie==="rtl"}),le=et(async()=>{if(!(!i||!b.current||m===M.Code))try{if(!await ue.parse(i,{suppressErrors:!0}))throw new Error("Invalid Mermaid syntax");const T=i.replace(/[`\s]+$/g,""),{svg:R}=await ue.render(O,T,b.current);b.current.innerHTML=R}catch{}},100);x.useEffect(()=>{m===M.Code&&b.current?b.current.innerHTML="":le()},[i,m]),x.useEffect(()=>{const C=b.current;if(!C||m!==M.Image)return;let T=0;const R=v=>{v.preventDefault(),v.stopPropagation();const F=Date.now();if(F-T<16)return;T=F;const G=v.deltaY>0?-.1:.1;d(_=>Math.max(.5,Math.min(3,_+G)))};return C.addEventListener("wheel",R,{passive:!1}),()=>{C.removeEventListener("wheel",R)}},[m]),x.useEffect(()=>{if(b.current&&m===M.Image){const C=b.current.querySelector("svg");C&&(C.style.transform=`scale(${f}) translate(${g.x}px, ${g.y}px)`,C.style.transformOrigin="center",C.style.transition=h?"none":"transform 0.1s ease-out",C.style.cursor=h?"grabbing":"grab")}},[f,g,m,h]);const He=C=>{m===M.Image&&(C.preventDefault(),k(!0),y({x:C.clientX,y:C.clientY}))},Fe=C=>{if(!h||m!==M.Image)return;C.preventDefault();const T=C.clientX-E.x,R=C.clientY-E.y;$(v=>({x:v.x+T/f,y:v.y+R/f})),y({x:C.clientX,y:C.clientY})},ye=()=>{k(!1)},_e=()=>{d(1),$({x:0,y:0})};if(!i)return null;const Be=async()=>{var Ee;const C=(Ee=b.current)==null?void 0:Ee.querySelector("svg");if(!C)return;const T=new XMLSerializer().serializeToString(C),R=document.createElement("canvas"),v=R.getContext("2d");if(!v)return;const{width:F,height:G}=C.getBoundingClientRect(),_=window.devicePixelRatio||1;R.width=F*_,R.height=G*_,R.style.width=`${F}px`,R.style.height=`${G}px`,v.scale(_,_);const de=new Image;de.onload=()=>{v.drawImage(de,0,0,F,G);const me=document.createElement("a");me.download=`${Date.now()}.png`,me.href=R.toDataURL("image/png",1),me.click()},de.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(T)}`},Ge=()=>{d(C=>Math.min(C+.2,3))},Ue=()=>{d(C=>Math.max(C-.2,.5))},Ve=()=>{var T,R;if(c===null)return null;if(c)return c;const C=m===M.Image?[{key:"zoomIn",icon:a.createElement(Et,null),label:P.zoomIn,onItemClick:Ge},{key:"zoomOut",icon:a.createElement(It,null),label:P.zoomOut,onItemClick:Ue},{key:"zoomReset",actionRender:()=>a.createElement(K,{title:P.zoomReset},a.createElement(Rt,{type:"text",size:"small",onClick:_e},P.zoomReset))},{key:"download",icon:a.createElement(bt,null),label:P.download,onItemClick:Be}]:[{key:"copy",actionRender:()=>a.createElement(B.Copy,{text:i})}];return a.createElement("div",{className:S(`${A}-header`,(T=N.classNames)==null?void 0:T.header,s==null?void 0:s.header),style:{...(R=N.styles)==null?void 0:R.header,...r.header}},a.createElement(St,{options:[{label:P.image,value:M.Image},{label:P.code,value:M.Code}],value:m,onChange:v=>{p(v),u==null||u(v)}}),a.createElement(B,{items:C}))},We=()=>{var C,T,R,v;return a.createElement(a.Fragment,null,a.createElement("div",{className:S(`${A}-graph`,(C=N.classNames)==null?void 0:C.graph,m===M.Code&&`${A}-graph-hidden`,s==null?void 0:s.graph),style:{...(T=N.styles)==null?void 0:T.graph,...r.graph},ref:b,onMouseDown:He,onMouseMove:Fe,onMouseUp:ye,onMouseLeave:ye}),m===M.Code?a.createElement("div",{className:S(`${A}-code`,(R=N.classNames)==null?void 0:R.code,s==null?void 0:s.code),style:{...(v=N.styles)==null?void 0:v.code,...r.code}},a.createElement(tt,X({customStyle:{padding:0,background:"transparent"},language:"mermaid",wrapLines:!0},l),i.replace(/\n$/,""))):null)};return a.createElement("div",{className:Q,style:{...o,...N.style,...(ke=N.styles)==null?void 0:ke.root,...r.root}},Ve(),We())}),En={locale:"zh-cn",Conversations:{create:"新对话"},Sender:{stopLoading:"停止请求",speechRecording:"正在录音"},Actions:{feedbackLike:"喜欢",feedbackDislike:"不喜欢",audio:"播放语音",audioRunning:"语音播放中",audioError:"播放出错了",audioLoading:"正在加载语音"},Bubble:{editableOk:"确认",editableCancel:"取消"},Mermaid:{zoomIn:"放大",zoomOut:"缩小",zoomReset:"重置",download:"下载",code:"代码",image:"图片"}};export{kn as M,xn as X,yn as a,En as l};
