2025-06-02 18:11:04 +08:00
|
|
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-1Hy45NwC.js","assets/markdown-vendor-DmIvJdn7.js","assets/ui-vendor-CeCm8EER.js","assets/react-vendor-DEwriMA6.js","assets/katex-B1t2RQs_.css"])))=>i.map(i=>d[i]);
|
2025-07-13 00:57:41 +08:00
|
|
|
import{j as r,E as Hr,I as Xr,F as jr,G as Tr,H as $r,J as Or,V as en,L as Fr,K as Dr,M as on,N as rn,Q as Wr,U as nn,W as an,X as tn}from"./ui-vendor-CeCm8EER.js";import{c as ee,P as wo,Q as Rr,V as ln,I as So,B as he,u as vo,z as ue,C as cn,J as sn,a as dn,b as un,K as gn,W as J,Y,Z,_ as X,o as xe,$ as Br,a0 as fn,a1 as bn,a2 as Ao,a3 as pn,a4 as hn,g as mn,a5 as kn,a6 as yn,E as wn,a7 as Sn}from"./feature-graph-NODQb6qW.js";import{r as u,R as se}from"./react-vendor-DEwriMA6.js";import{m as Mo}from"./mermaid-vendor-D0f_SE0h.js";import{h as Co,M as vn,r as xn,a as zn,b as An}from"./markdown-vendor-DmIvJdn7.js";const Ho=nn,jo=tn,To=an,ko=u.forwardRef(({className:e,children:o,...n},a)=>r.jsxs(Hr,{ref:a,className:ee("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-10 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[o,r.jsx(Xr,{asChild:!0,children:r.jsx(wo,{className:"h-4 w-4 opacity-50"})})]}));ko.displayName=Hr.displayName;const _r=u.forwardRef(({className:e,...o},n)=>r.jsx(jr,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...o,children:r.jsx(Rr,{className:"h-4 w-4"})}));_r.displayName=jr.displayName;const Nr=u.forwardRef(({className:e,...o},n)=>r.jsx(Tr,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...o,children:r.jsx(wo,{className:"h-4 w-4"})}));Nr.displayName=Tr.displayName;const yo=u.forwardRef(({className:e,children:o,position:n="popper",...a},t)=>r.jsx($r,{children:r.jsxs(Or,{ref:t,className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...a,children:[r.jsx(_r,{}),r.jsx(en,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:o}),r.jsx(Nr,{})]})}));yo.displayName=Or.displayName;const Mn=u.forwardRef(({className:e,...o},n)=>r.jsx(Fr,{ref:n,className:ee("py-1.5 pr-2 pl-8 text-sm font-semibold",e),...o}));Mn.displayName=Fr.displayName;const $=u.forwardRef(({className:e,children:o,...n},a)=>r.jsxs(Dr,{ref:a,className:ee("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(on,{children:r.jsx(ln,{className:"h-4 w-4"})})}),r.jsx(rn,{children:o})]}));$.displayName=Dr.displayName;const Cn=u.forwardRef(({className:e,...o},n)=>r.jsx(Wr,{ref:n,className:ee("bg-muted -mx-1 my-1 h-px",e),...o}));Cn.displayName=Wr.displayName;function Pr(e,o){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&o.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,a=Object.getOwnPropertySymbols(e);t<a.length;t++)o.indexOf(a[t])<0&&Object.prototype.propertyIsEnumerable.call(e,a[t])&&(n[a[t]]=e[a[t]]);return n}var me;(function(e){e.event="event",e.props="prop"})(me||(me={}));function te(){}function Hn(e){var o,n=void 0;return function(){for(var a=[],t=arguments.length;t--;)a[t]=arguments[t];return o&&a.length===o.length&&a.every(function(l,c){return l===o[c]})||(o=a,n=e.apply(void 0,a)),n}}function ke(e){return!!(e||"").match(/\d/)}function ge(e){return e==null}function jn(e){return typeof e
|
2025-06-02 18:11:04 +08:00
|
|
|
Decimal separator can't be same as thousand separator.
|
|
|
|
thousandSeparator: `+n+` (thousandSeparator = {true} is same as thousandSeparator = ",")
|
|
|
|
decimalSeparator: `+a+` (default value for decimalSeparator is .)
|
|
|
|
`);return t.startsWith("-")&&l&&(console.error(`
|
|
|
|
Prefix can't start with '-' when allowNegative is true.
|
|
|
|
prefix: `+t+`
|
|
|
|
allowNegative: `+l+`
|
|
|
|
`),l=!1),Object.assign(Object.assign({},e),{allowNegative:l})}function Yn(e){e=Jn(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var o=e.suffix,n=e.allowNegative,a=e.allowLeadingZeros,t=e.onKeyDown;t===void 0&&(t=te);var l=e.onBlur;l===void 0&&(l=te);var c=e.thousandSeparator,S=e.decimalScale,A=e.fixedDecimalScale,p=e.prefix;p===void 0&&(p="");var M=e.defaultValue,b=e.value,h=e.valueIsNumericString,z=e.onValueChange,g=Pr(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),d=we(e),f=d.decimalSeparator,w=d.allowedDecimalSeparators,F=function(x){return Wo(x,e)},v=function(x,k){return Qn(x,k,e)},j=ge(b)?M:b,m=h??Kn(j,p,o);ge(b)?ge(M)||(m=m||typeof M=="number"):m=m||typeof b=="number";var H=function(x){return Er(x)?x:(typeof x=="number"&&(x=Vr(x)),m&&typeof S=="number"?Fo(x,S,!!A):x)},V=Ur(H(b),H(M),!!m,F,v,z),T=V[0],B=T.numAsString,I=T.formattedValue,L=V[1],U=function(x){var k=x.target,O=x.key,E=k.selectionStart,_=k.selectionEnd,W=k.value;if(W===void 0&&(W=""),(O==="Backspace"||O==="Delete")&&_<p.length){x.preventDefault();return}if(E!==_){t(x);return}O==="Backspace"&&W[0]==="-"&&E===p.length+1&&n&&ce(k,1),S&&A&&(O==="Backspace"&&W[E-1]===f?(ce(k,E-1),x.preventDefault()):O==="Delete"&&W[E]===f&&x.preventDefault()),w!=null&&w.includes(O)&&W[E]===f&&ce(k,E+1);var q=c===!0?",":c;O==="Backspace"&&W[E-1]===q&&ce(k,E-1),O==="Delete"&&W[E]===q&&ce(k,E+1),t(x)},Q=function(x){var k=B;if(k.match(/\d/g)||(k=""),a||(k=Dn(k)),A&&S&&(k=Fo(k,S,A)),k!==B){var O=Wo(k,e);L({formattedValue:O,value:k,floatValue:parseFloat(k)},{event:x,source:me.event})}l(x)},D=function(x){return x===f?!0:ke(x)},G=function(x){var k=x.currentValue,O=x.lastValue,E=x.formattedValue,_=x.currentValueIndex,W=x.formattedValueIndex,q=k[_],re=E[W],fe=Ir(O,k),le=fe.to,ie=function(be){return v(be).indexOf(".")+p.length};return b===0&&A&&S&&k[le.start]===f&&ie(k)<_&&ie(E)>W?!1:_>=le.start&&_<le.end&&w&&w.includes(q)&&re===f?!0:q===re};return Object.assign(Object.assign({},g),{value:I,valueIsNumericString:!1,isValidInputCharacter:D,isCharacterSame:G,onValueChange:L,format:F,removeFormatting:v,getCaretBoundary:function(x){return Gn(x,e)},onKeyDown:U,onBlur:Q})}function Zn(e){var o=Yn(e);return se.createElement(Vn,Object.assign({},o))}const de=u.forwardRef(({stepper:e,thousandSeparator:o,placeholder:n,defaultValue:a,min:t=-1/0,max:l=1/0,onValueChange:c,fixedDecimalScale:S=!1,decimalScale:A=0,className:p=void 0,suffix:M,prefix:b,value:h,...z},g)=>{const[d,f]=u.useState(h??a),w=u.useCallback(()=>{f(m=>m===void 0?e??1:Math.min(m+(e??1),l))},[e,l]),F=u.useCallback(()=>{f(m=>m===void 0?-(e??1):Math.max(m-(e??1),t))},[e,t]);u.useEffect(()=>{h!==void 0&&f(h)},[h]);const v=m=>{const H=m.floatValue===void 0?void 0:m.floatValue;f(H),c&&c(H)},j=()=>{d!==void 0&&(d<t?(f(t),g.current.value=String(t)):d>l&&(f(l),g.current.value=String(l)))};return r.jsxs("div",{className:"relative flex",children:[r.jsx(Zn,{value:d,onValueChange:v,thousandSeparator:o,decimalScale:A,fixedDecimalScale:S,allowNegative:t<0,valueIsNumericString:!0,onBlur:j,max:l,min:t,suffix:M,prefix:b,customInput:m=>r.jsx(So,{...m,className:ee("w-full",p)}),placeholder:n,className:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",getInputRef:g,...z}),r.jsxs("div",{className:"absolute top-0 right-0 bottom-0 flex flex-col",children:[r.jsx(he,{"aria-label":"Increase value",className:"border-input h-1/2 rounded-l-none rounded-br-none border-b border-l px-2 focus-visible:relative",variant:"outline",onClick:w,disabled:d===l,children:r.jsx(Rr,{size:15})}),r.jsx(he,{"aria-label":"Decrease value",className:"border-input h-1/2 rounded-l-none rounded-tr-none border-b border-l px-2 focus-visible:relative",variant:"outline",onClick:F,disabled:d===t,children:r.jsx(wo,{size:15})})]})]})});de.displayName="NumberInput";function Xn(){const{t
|
|
|
|
`)||o.length<40},Qa=(e,o)=>!o||e!=="json"?!1:o.length>5e3,Kr=u.memo(({className:e,children:o,node:n,renderAsDiagram:a=!1,...t})=>{const{theme:l}=Br(),[c,S]=u.useState(!1),A=e==null?void 0:e.match(/language-(\w+)/),p=A?A[1]:void 0,M=Ka(n),b=u.useRef(null),h=u.useRef(null),z=String(o||"").replace(/\n$/,""),g=Qa(p,z);return u.useEffect(()=>{if(a&&!c&&p==="mermaid"&&b.current){const d=b.current;h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{if(d&&!c)try{Mo.initialize({startOnLoad:!1,theme:l==="dark"?"dark":"default",securityLevel:"loose"}),d.innerHTML='<div class="flex justify-center items-center p-4"><svg class="animate-spin h-5 w-5 text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg></div>';const f=String(o).replace(/\n$/,"").trim();if(!(f.length>10&&(f.startsWith("graph")||f.startsWith("sequenceDiagram")||f.startsWith("classDiagram")||f.startsWith("stateDiagram")||f.startsWith("gantt")||f.startsWith("pie")||f.startsWith("flowchart")||f.startsWith("erDiagram")))){console.log("Mermaid content might be incomplete, skipping render attempt:",f);return}const F=f.split(`
|
|
|
|
`).map(j=>{const m=j.trim();if(m.startsWith("subgraph")){const H=m.split(" ");if(H.length>1)return`subgraph "${H.slice(1).join(" ").replace(/["']/g,"")}"`}return m}).filter(j=>!j.trim().startsWith("linkStyle")).join(`
|
|
|
|
`),v=`mermaid-${Date.now()}`;Mo.render(v,F).then(({svg:j,bindFunctions:m})=>{if(b.current===d&&!c){if(d.innerHTML=j,S(!0),m)try{m(d)}catch(H){console.error("Mermaid bindFunctions error:",H),d.innerHTML+='<p class="text-orange-500 text-xs">Diagram interactions might be limited.</p>'}}else b.current!==d&&console.log("Mermaid container changed before rendering completed.")}).catch(j=>{if(console.error("Mermaid rendering promise error (debounced):",j),console.error("Failed content (debounced):",F),b.current===d){const m=j instanceof Error?j.message:String(j),H=document.createElement("pre");H.className="text-red-500 text-xs whitespace-pre-wrap break-words",H.textContent=`Mermaid diagram error: ${m}
|
|
|
|
|
|
|
|
Content:
|
|
|
|
${F}`,d.innerHTML="",d.appendChild(H)}})}catch(f){if(console.error("Mermaid synchronous error (debounced):",f),console.error("Failed content (debounced):",String(o)),b.current===d){const w=f instanceof Error?f.message:String(f),F=document.createElement("pre");F.className="text-red-500 text-xs whitespace-pre-wrap break-words",F.textContent=`Mermaid diagram setup error: ${w}`,d.innerHTML="",d.appendChild(F)}}},300)}return()=>{h.current&&clearTimeout(h.current)}},[a,c,p,o,l]),g?r.jsx("pre",{className:"whitespace-pre-wrap break-words bg-muted p-4 rounded-md overflow-x-auto text-sm font-mono",children:z}):p==="mermaid"&&!a?r.jsx(Co,{style:l==="dark"?ye.oneDark:ye.oneLight,PreTag:"div",language:"text",...t,children:z}):p==="mermaid"?r.jsx("div",{className:"mermaid-diagram-container my-4 overflow-x-auto",ref:b}):M?r.jsx("code",{className:ee(e,"mx-1 rounded-sm bg-muted px-1 py-0.5 font-mono text-sm"),...t,children:o}):r.jsx(Co,{style:l==="dark"?ye.oneDark:ye.oneLight,PreTag:"div",language:p,...t,children:z})});Kr.displayName="CodeHighlight";const Cr=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).substring(2,9)}`;function $a(){const{t:e}=vo(),[o,n]=u.useState(()=>{try{return(ue.getState().retrievalHistory||[]).map((j,m)=>{try{const H=j;return{...j,id:H.id||`hist-${Date.now()}-${m}`,mermaidRendered:H.mermaidRendered??!0}}catch(H){return console.error("Error processing message:",H),{role:"system",content:"Error loading message",id:`error-${Date.now()}-${m}`,isError:!0,mermaidRendered:!0}}})}catch(v){return console.error("Error loading history:",v),[]}}),[a,t]=u.useState(""),[l,c]=u.useState(!1),[S,A]=u.useState(""),p=u.useRef(!0),M=u.useRef(!1),b=u.useRef(!1),h=u.useRef(!1),z=u.useRef(null),g=u.useRef(null),d=u.useCallback(()=>{b.current=!0,requestAnimationFrame(()=>{z.current&&z.current.scrollIntoView({behavior:"auto"})})},[]),f=u.useCallback(async v=>{if(v.preventDefault(),!a.trim()||l)return;const j=["naive","local","global","hybrid","mix","bypass"],m=a.match(/^\/(\w+)\s+(.+)/);let H,V=a;if(/^\/\S+/.test(a)&&!m){A(e("retrievePanel.retrieval.queryModePrefixInvalid"));return}if(m){const D=m[1],G=m[2];if(!j.includes(D)){A(e("retrievePanel.retrieval.queryModeError",{modes:"naive, local, global, hybrid, mix, bypass"}));return}H=D,V=G}A("");const T={id:Cr(),content:a,role:"user"},B={id:Cr(),content:"",role:"assistant",mermaidRendered:!1},I=[...o];n([...I,T,B]),p.current=!0,h.current=!0,setTimeout(()=>{d()},0),t(""),c(!0);const L=(D,G)=>{B.content+=D;const x=/```mermaid\s+([\s\S]+?)```/g;let k=!1,O;for(;(O=x.exec(B.content))!==null;)if(O[1]&&O[1].trim().length>10){k=!0;break}B.mermaidRendered=k,n(E=>{const _=[...E],W=_[_.length-1];return W.role==="assistant"&&(W.content=B.content,W.isError=G,W.mermaidRendered=B.mermaidRendered),_}),p.current&&setTimeout(()=>{d()},30)},U=ue.getState(),Q={...U.querySettings,query:V,conversation_history:I.filter(D=>D.isError!==!0).slice(-(U.querySettings.history_turns||0)*2).map(D=>({role:D.role,content:D.content})),...H?{mode:H}:{}};try{if(U.querySettings.stream){let D="";await pn(Q,L,G=>{D+=G}),D&&(B.content&&(D=B.content+`
|
|
|
|
`+D),L(D,!0))}else{const D=await hn(Q);L(D.response)}}catch(D){L(`${e("retrievePanel.retrieval.error")}
|
|
|
|
${mn(D)}`,!0)}finally{c(!1),h.current=!1,ue.getState().setRetrievalHistory([...I,T,B])}},[a,l,o,n,e,d]);u.useEffect(()=>{const v=g.current;if(!v)return;const j=H=>{Math.abs(H.deltaY)>10&&!M.current&&(p.current=!1)},m=kn(()=>{if(b.current){b.current=!1;return}const H=g.current;H&&(H.scrollHeight-H.scrollTop-H.clientHeight<20?p.current=!0:!M.current&&!h.current&&(p.current=!1))},30);return v.addEventListener("wheel",j),v.addEventListener("scroll",m),()=>{v.removeEventListener("wheel",j),v.removeEventListener("scroll",m)}},[]),u.useEffect(()=>{const v=document.querySelector("form");if(!v)return;const j=()=>{M.current=!0,setTimeout(()=>{M.current=!1},500)};return v.addEventListener("mousedown",j),()=>{v.removeEventListener("mousedown",j)}},[]);const w=yn(o,150);u.useEffect(()=>{p.current&&d()},[w,d]);const F=u.useCallback(()=>{n([]),ue.getState().setRetrievalHistory([])},[n]);return r.jsxs("div",{className:"flex size-full gap-2 px-2 pb-12 overflow-hidden",children:[r.jsxs("div",{className:"flex grow flex-col gap-4",children:[r.jsx("div",{className:"relative grow",children:r.jsx("div",{ref:g,className:"bg-primary-foreground/60 absolute inset-0 flex flex-col overflow-auto rounded-lg border p-2",onClick:()=>{p.current&&(p.current=!1)},children:r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[o.length===0?r.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center text-lg",children:e("retrievePanel.retrieval.startPrompt")}):o.map(v=>r.jsx("div",{className:`flex ${v.role==="user"?"justify-end":"justify-start"}`,children:r.jsx(Ua,{message:v})},v.id)),r.jsx("div",{ref:z,className:"pb-1"})]})})}),r.jsxs("form",{onSubmit:f,className:"flex shrink-0 items-center gap-2",children:[r.jsxs(he,{type:"button",variant:"outline",onClick:F,disabled:l,size:"sm",children:[r.jsx(wn,{}),e("retrievePanel.retrieval.clear")]}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx("label",{htmlFor:"query-input",className:"sr-only",children:e("retrievePanel.retrieval.placeholder")}),r.jsx(So,{id:"query-input",className:"w-full",value:a,onChange:v=>{t(v.target.value),S&&A("")},placeholder:e("retrievePanel.retrieval.placeholder"),disabled:l}),S&&r.jsx("div",{className:"absolute left-0 top-full mt-1 text-xs text-red-500",children:S})]}),r.jsxs(he,{type:"submit",variant:"default",disabled:l,size:"sm",children:[r.jsx(Sn,{}),e("retrievePanel.retrieval.send")]})]})]}),r.jsx(Xn,{})]})}export{$a as R,Ho as S,ko as a,To as b,yo as c,$ as d};
|