import{M as e,d as s,r as a,G as t,b as l,K as n,X as i,s as u,aA as o,c as r,w as c,k as d,P as _,o as p,l as m,m as v,q as f,t as h,S as g,D as y,x as b,F as w,y as $,v as k,z as C,aB as x,j,N as I,n as A,av as q,e as M,a8 as D,a0 as z,_ as S}from"./index-C9upDdnN.js";import{w as V,A as B}from"./aiRequest.br0QglYY.js";function N(s){return e.get({url:"/assistant/messages",data:s})}const T=e=>e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),F=e=>e.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,(e,s,a)=>{const t=(e=>T(e))(a);return`${s}`}),G=e=>{let s=T(e);return s=F(s),s=s.replace(/`([^`]+)`/g,"$1"),s=s.replace(/\*\*([^*]+)\*\*/g,"$1"),s=s.replace(/(^|[^\*])\*([^\*\n]+)\*(?!\*)/g,"$1$2"),s},K=e=>{const s=String(e||"").replace(/\r\n?/g,"\n").trim();if(!s)return"";const a=s.split("\n"),t=[],l=[],n=[],i=[],u=[];let o="",r=!1;const c=()=>{l.length&&(t.push(`

${l.map(e=>G(e)).join("
")}

`),l.length=0)},d=()=>{o&&(t.push(``),o="")},_=()=>{i.length&&(t.push(`
${i.map(e=>G(e)).join("
")}
`),i.length=0)},p=()=>{n.length&&(t.push(`
${T(n.join("\n"))}
`),n.length=0)},m=e=>{const s=e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim());return s.filter((e,a)=>a/^\|.*\|$/.test(e)&&m(e).length>=2,f=()=>{if(u.length){if(u.length>=2&&(e=u[1],v(e)&&m(e).every(e=>/^:?-{3,}:?$/.test(e)))){const e=m(u[0]),s=u.slice(2).map(m).filter(e=>e.length>0),a=`${e.map(e=>`${G(e)}`).join("")}`,l=s.length?`${s.map(e=>`${e.map(e=>`${G(e)}`).join("")}`).join("")}`:"";t.push(`${a}${l}
`)}else t.push(`

${u.map(e=>G(e)).join("
")}

`);var e;u.length=0}};for(const h of a){const e=h.trim();if(/^```/.test(e)){c(),d(),_(),f(),r&&p(),r=!r;continue}if(r){n.push(h);continue}if(!e){c(),d(),_(),f();continue}const s=e.match(/^(#{1,6})\s+(.*)$/);if(s){c(),d(),_(),f();const e=Math.min(6,s[1].length);t.push(`${G(s[2])}`);continue}const a=e.match(/^>\s?(.*)$/);if(a){c(),d(),f(),i.push(a[1]);continue}if(_(),/^(-{3,}|\*{3,}|_{3,})$/.test(e)){c(),d(),f(),t.push("
");continue}const m=e.match(/^[-*+]\s+(.*)$/);if(m){c(),f(),"ul"!==o&&(d(),o="ul",t.push("