@gientech/modual 1.9.8 → 1.9.9

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.
Files changed (2) hide show
  1. package/chat.js +1 -1
  2. package/package.json +1 -1
package/chat.js CHANGED
@@ -592,7 +592,7 @@ html body {
592
592
  }
593
593
  `};function Mle({config:e,styles:t}){if(!e)return null;const n=JSON.parse(e.configJson),r=Ht(()=>{var o;return{...F8.colors,...(o=t==null?void 0:t.theme)==null?void 0:o.colors}},[t]);return Je("div",{className:"w-[340px] rounded-xl p-4 animate-fade-in bg-white",children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-md font-bold truncate mr-2",style:{color:r.primary},children:n.config_name||"\u52A9\u624B\u914D\u7F6E"}),K("span",{className:"text-xs truncate rounded px-2 py-0.5",style:{backgroundColor:`${r.primary}1A`,color:r.disabled},children:n.model_name})]}),K("div",{className:"border-b my-2",style:{borderColor:r.border}}),Je("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-700 mb-2",style:{color:r.text},children:[Je("div",{children:["\u4E0A\u4E0B\u6587\u6700\u5927\u8F6E\u6570\uFF1A",K("span",{className:"font-semibold",children:n.max_round})]}),Je("div",{children:["\u6700\u5927\u4EE4\u724C\u6570\uFF1A",K("span",{className:"font-semibold",children:n.max_tokens})]}),Je("div",{children:["\u6E29\u5EA6\uFF1A",K("span",{className:"font-semibold",children:n.temperature})]}),Je("div",{children:["\u53EC\u56DE\u6570\uFF1A",K("span",{className:"font-semibold",children:n.top_k})]}),Je("div",{children:["\u591A\u6837\u6027\uFF1A",K("span",{className:"font-semibold",children:n.top_p})]}),Je("div",{children:["\u76F8\u4F3C\u5EA6\u9608\u503C\uFF1A",K("span",{className:"font-semibold",children:n.score_threshold})]})]}),Je("div",{className:"mb-2",children:[K("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5173\u8054\u77E5\u8BC6\u5E93\uFF1A"}),K("div",{className:"flex flex-wrap gap-1",children:n.knowledge_base_name?n.knowledge_base_name.split(";").map((o,i)=>K("span",{className:"px-2 py-0.5 rounded-full text-xs",style:{backgroundColor:`${r.primary}1A`,color:r.primary},children:o},i)):K("span",{className:"text-gray-300",style:{color:r.disabled},children:"\u65E0"})})]}),Je("div",{className:"mb-2",children:[K("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5F00\u542F\u529F\u80FD:"}),Je("div",{className:"flex flex-wrap gap-2 text-xs mt-2",children:[!!n.enabled_faq&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"FAQ"}),!!n.enabled_graph&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u56FE\u8C31"}),!!n.dependOnKb&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u5F3A\u77E5\u8BC6\u4F9D\u8D56"}),!!n.enabled_table_select&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u8868\u683C\u7B5B\u9009"}),!!n.enabled_rerank&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u7CBE\u6392\u6A21\u5F0F"}),!!n.need_trace_source&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u6EAF\u6E90"}),!!n.is_download&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u4E0B\u8F7D\u6EAF\u6E90"})]})]})]})}function Nle(e,t=[],n=60){const[r,o]=ut("");return At(()=>{o("");let i=0;const a=setInterval(()=>{o(s=>i>=e.length?(clearInterval(a),s):(i++,e.slice(0,i)))},n);return()=>clearInterval(a)},[e,...t]),r}function Dle(e){const{assistantList:t,eventsEmit:n,styles:r,selectedId:o,onSelectAssistant:i,productLogo:a}=e,[s,l]=ut(1),[c,u]=ut(!1),[d,f]=ut(""),h=c||d.trim()?6:12,m=et(),g=et(!1),p=et(null),v=et(null),y=et("");At(()=>{o&&m.current!==o&&(n==null||n("conversation:new_assistant_change",{assistantId:o}),m.current=o)},[o,n]);const b=Ht(()=>ga(),[]);At(()=>{var $;if(($=r==null?void 0:r.theme)!=null&&$.colors){const M=document.createElement("style");return M.innerHTML=Ole(r.theme.colors,b),M.id=`g-welcome-styles-${b}`,document.head.appendChild(M),()=>{const N=document.getElementById(M.id);N&&N.remove()}}},[r,b]);const E=Ht(()=>t.find($=>$.id===o),[t,o]),x=Ht(()=>JSON.parse((E==null?void 0:E.configJson)||"{}"),[E]),C=Ht(()=>{if(!d.trim())return t||[];const $=d.toLowerCase().trim();return(t||[]).filter(M=>{var D,T;const N=((D=M.name)==null?void 0:D.toLowerCase())||"";try{const j=((T=JSON.parse(M.configJson||"{}").config_name)==null?void 0:T.toLowerCase())||"";return N.includes($)||j.includes($)}catch{return N.includes($)}})},[t,d]),k=Math.ceil(((C==null?void 0:C.length)||0)/h),S=(C==null?void 0:C.slice((s-1)*h,s*h))||[];At(()=>{if(o&&o!==v.current){if(g.current&&p.current!==null){v.current=o;return}const $=d.trim()?C:t;if($&&$.length>0){const M=$.findIndex(N=>N.id===o);if(M!==-1){const N=Math.floor(M/h)+1;l(N),v.current=o}}}},[o,t,C,h,d]),At(()=>{if(d!==y.current){if(g.current&&p.current!==null){l(p.current),g.current=!1,p.current=null,y.current=d;return}if(v.current===o){y.current=d;return}g.current||(d.trim()&&(v.current=null),l(1)),y.current=d}},[d,o]),At(()=>{k>0&&s>k&&l(k)},[k,s]);const O=x.prologue||"\u60A8\u597D\uFF0C\u6B22\u8FCE\u4F7F\u7528\u5C0F\u9CB8\u667A\u80FD\u95EE\u7B54",A=Nle(O,[o],30);return Je("div",{className:`flex flex-col relative items-center justify-center h-full w-full g-welcome-${b}`,children:[K("img",{src:a||Ale,alt:"logo",className:"mb-4",style:{width:68,height:68}}),K("div",{className:"text-3xl font-bold mb-2 g-welcome-title",children:A}),!o&&K("div",{className:"flex mb-2 g-welcome-subtitle",children:"\u8BF7\u9009\u62E9\u4E00\u4E2A\u667A\u80FD\u52A9\u624B"}),Je("div",{style:{maxWidth:"1200px"},className:`flex mt-8 flex-wrap gap-3
594
594
  max-w-[1200px] px-8 w-full mx-auto justify-center mb-4`,children:[c?K("div",{className:"flex items-center gap-2 px-5 w-full",style:{flexBasis:"100%"},children:K(Wu,{className:"g-welcome-search-input w-full",placeholder:"\u641C\u7D22\u52A9\u624B\u540D\u79F0",prefix:K(c3,{size:16}),suffix:K("button",{type:"button",onClick:()=>{u(!1),f("")},style:{background:"transparent",border:"none",cursor:"pointer"},children:K(vp,{size:14})}),value:d,onChange:$=>f($.target.value),autoFocus:!0})}):K("button",{type:"button",className:"g-welcome-search-btn",onClick:()=>u(!0),children:K(c3,{size:16})}),S&&S.length>0?K(E0,{children:S.map($=>{const M=o===$.id;let N=$.icon;try{const D=JSON.parse($.configJson||"{}");N=N||D.icon||D.avatar||D.logo}catch{}return N=N||$le,K(IT,{content:()=>K(Mle,{config:t.find(D=>D.id===$.id),styles:r}),trigger:"hover",placement:"bottom",children:Je("button",{type:"button",className:`g-welcome-btn px-3 cursor-pointer rounded-full border font-medium min-w-[160px] text-sm transition-all flex items-center gap-2 ${M?"active":""}`,onClick:()=>{i==null||i($.id);const D=c||d.trim(),I=(D?t:d.trim()?C:t).findIndex(j=>j.id===$.id);if(I!==-1){const R=Math.floor(I/(D?12:h))+1;l(R),v.current=$.id,D&&(p.current=R,g.current=!0,setTimeout(()=>{f(""),u(!1)},100))}},title:$.name,children:[K("span",{className:"icon-badge",children:K("img",{src:N,alt:"icon",style:{width:16,height:16,borderRadius:4}})}),K("span",{className:"truncate max-w-[180px]",children:$.name})]})},$.id)})}):K("div",{className:"g-welcome-subtitle",children:"\u6682\u65E0\u53EF\u7528\u52A9\u624B"})]}),k>1&&Je("div",{className:"flex items-center gap-2",children:[K("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l($=>Math.max(1,$-1)),disabled:s===1,children:K(Dz,{size:16})}),K("div",{className:"flex items-center gap-1",children:(()=>{const $=[];if(k<=7)for(let N=1;N<=k;N++)$.push(N);else if($.push(1),s<=4){for(let N=2;N<=5;N++)$.push(N);$.push("..."),$.push(k)}else if(s>=k-3){$.push("...");for(let N=k-4;N<=k;N++)$.push(N)}else{$.push("...");for(let N=s-1;N<=s+1;N++)$.push(N);$.push("..."),$.push(k)}return $.map((N,D)=>{if(N==="...")return K("span",{className:"g-welcome-pagination-text px-1",children:"..."},`ellipsis-${D}`);const T=N;return K("button",{type:"button",className:`g-welcome-pagination-btn ${s===T?"active":""}`,onClick:()=>l(T),children:T},T)})})()}),K("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l($=>Math.min(k,$+1)),disabled:s===k,children:K(TT,{size:16})})]})]})}async function Tle(e,t){const n=e.getReader();let r;for(;!(r=await n.read()).done;)t(r.value)}function Ple(e){let t,n,r,o=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=Fle(t,a);const s=t.length;let l=0;for(;n<s;){o&&(t[n]===10&&(l=++n),o=!1);let c=-1;for(;n<s&&c===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-l);break;case 13:o=!0;case 10:c=n;break}if(c===-1)break;e(t.subarray(l,c),r),l=n,r=-1}l===s?t=void 0:l!==0&&(t=t.subarray(l),n-=l)}}function Ile(e,t,n){let r=Mk();const o=new TextDecoder;return function(a,s){if(a.length===0)n==null||n(r),r=Mk();else if(s>0){const l=o.decode(a.subarray(0,s)),c=s+(a[s+1]===32?2:1),u=o.decode(a.subarray(c));switch(l){case"data":r.data=r.data?r.data+`
595
- `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":const d=parseInt(u,10);isNaN(d)||t(r.retry=d);break}}}}function Fle(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Mk(){return{data:"",event:"",id:"",retry:void 0}}var Ble=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n};const I6="text/event-stream",Rle=1e3,Nk="last-event-id";function Lle(e,t){var{signal:n,headers:r,onopen:o,onmessage:i,onclose:a,onerror:s,openWhenHidden:l,fetch:c}=t,u=Ble(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,f)=>{const h=Object.assign({},r);h.accept||(h.accept=I6);let m;function g(){m.abort(),document.hidden||x()}l||document.addEventListener("visibilitychange",g);let p=Rle,v=0;function y(){document.removeEventListener("visibilitychange",g),window.clearTimeout(v),m.abort()}n==null||n.addEventListener("abort",()=>{y(),d()});const b=c??window.fetch,E=o??jle;async function x(){var C;m=new AbortController;try{const k=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:m.signal}));await E(k),await Tle(k.body,Ple(Ile(S=>{S?h[Nk]=S:delete h[Nk]},S=>{p=S},i))),a==null||a(),y(),d()}catch(k){if(!m.signal.aborted)try{const S=(C=s==null?void 0:s(k))!==null&&C!==void 0?C:p;window.clearTimeout(v),v=window.setTimeout(x,S)}catch(S){y(),f(S)}}}x()})}function jle(e){const t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(I6)))throw new Error(`Expected content-type to be ${I6}, Actual: ${t}`)}class am extends Error{}let To=null,aa=null;const _le=({baseUrl:e,token:t,CSRFToken:n,setChatData:r,activeSessionId:o,setAppStatus:i,setConversationList:a})=>{const s=p=>{if(!p)return!1;if(typeof p=="string"){const v=p.trim();return v!==""&&v!=="[]"&&v!=="null"}return!0},l=({content:p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:C,databaseReference:k,llmType:S,resultType:O,queryId:A,tokens:$})=>{r(M=>{var z;if(!M[0])return M;const N=M[0],D=N.messages||[],T=D.length-1;if(T<0)return M;const I=D[T];if(I.istype!=="ai")return M;let j=D.slice();if(b!=null&&b.length){const B=D.length-2;if(B>=0&&((z=D[B])==null?void 0:z.istype)==="user"){const F={...D[B],filePaths:b};j[B]=F}}const R=C!==void 0&&s(C)?C:I.graphReference;v===2&&C!==void 0&&console.log("[AichatUseController] reset_chat status=2 \u65F6\u7684 graphReference:",{graphReference:C,isValid:s(C),lastMessageGraphReference:I.graphReference,finalGraphReference:R});const H={...I,content:(I.content||"")+p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:R,databaseReference:k??I.databaseReference,resultType:O,llmType:S,tokens:$,queryId:A||I.queryId||ga(32)};return H.clientSideId=H.clientSideId||H.queryId+"-ai",j[T]=H,[{...N,isNew:!1,messages:j},...M.slice(1)]})},c=p=>{if(p instanceof am)throw i(v=>({...v,display:"error",sender:"ready"})),To&&(To.abort(),To=null),aa=null,p};return{updateUserFilesMessage:({currentFiles:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-2;if(E<0||b[E].istype!=="user")return v;const C=b.slice();return C[E]={...b[E],currentFiles:p},[{...y,messages:C},...v.slice(1)]})},api_startChat_re:(p,v)=>{To&&To.abort(),To=new AbortController,aa=p.sessionId;const y=`${e}/qa/ai/question_re`;console.log("data",p);const b={...p};Lle(y,{method:"post",signal:To.signal,headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:t||"","X-CSRF-TOKEN-IN":n||""},openWhenHidden:!0,body:JSON.stringify(b),onopen:async E=>{if(E.status===500)throw new am("Internal Server Error");if(!E.ok)throw new am(`HTTP error: ${E.status}`)},onmessage:E=>{const x=JSON.parse(E.data);if(aa!==x.sessionId){console.log("[AichatUseController] \u6D41\u5F0F\u8BF7\u6C42\u7684 sessionId \u5DF2\u4E0D\u5339\u914D\uFF0C\u5FFD\u7565\u6570\u636E",{currentStreamSessionId:aa,receivedSessionId:x.sessionId,activeSessionId:o});return}if(o!==x.sessionId)return;const{reply:C,resultType:k,respTime:S,reference:O,webReference:A,graphReference:$,filePaths:M,status:N,docs:D,llmType:T,databaseReference:I}=x,j=M?JSON.parse(M):[];N===2&&C&&C.content&&(C.content.includes("\u6A21\u578B\u6682\u65E0\u6CD5\u8FD4\u56DE")||C.content.includes("\u5931\u8D25")||C.content.includes("\u9519\u8BEF")||C.content.includes("\u8BF7\u7A0D\u540E\u518D\u8BD5"))&&i(H=>({...H,display:"ready",sender:"ready"}));const R=s($)?$:void 0;if(N===2&&console.log("[AichatUseController] status=2 \u65F6\u7684 graphReference:",{graphReference:$,type:typeof $,isValid:s($),finalGraphReference:R}),N===2){if(l({content:C.content||"",status:2,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens}),i(H=>({...H,display:"ready",sender:"ready"})),v){const H=S||Date.now();console.log("[AichatUseController] \u6D88\u606F\u53D1\u9001\u6210\u529F\uFF0CgmtModified:",H),v(H)}}else l({content:C.content||"",status:N,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens})},onerror:c,onclose:()=>{aa===p.sessionId&&(aa=null)}})},addEmptyMessage:({queryId:p,content:v,filePaths:y,currentFiles:b})=>{r(E=>{const x=new Date().toISOString(),C=p||ga(32),k={istype:"user",content:v,time:x,queryId:C,clientSideId:C+"-user",filePaths:y||"",currentFiles:b||[]},S={istype:"ai",content:"",time:new Date(Date.now()+1).toISOString(),streaming:!0,status:0,queryId:C,clientSideId:C+"-ai"},O=E.find(A=>A.id===o);return O?O.messages.push(k,S):console.warn("addEmptyMessage called without an active session."),[...E]})},setLastEmptyMessage:({now:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-1;if(E<0)return v;const x=b[E];if(x.istype!=="ai")return v;const C=b.slice();return C[E]={...x,istype:"ai",content:"",time:p,streaming:!0,status:0},[{...y,messages:C},...v.slice(1)]})},stopStream:()=>{To&&(To.abort(),To=null),aa=null,i(p=>({...p,display:"ready",sender:"ready"}))},cancelStreamBySessionId:p=>To&&aa===p?(console.log("[AichatUseController] \u5207\u6362\u4F1A\u8BDD\uFF0C\u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u5F0F\u8BF7\u6C42",p),To.abort(),To=null,aa=null,i(v=>({...v,display:"ready",sender:"ready"})),!0):!1}},zle="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACRSURBVHgB7ZJBCsQgDEWTmQvMncT7dOuqmY3iai6kMN31UmIjdNFFKuk+DwKahP9ABDAMQyTnvHCtT/ZjjIs0e0nN1hr03kkjGTu8+0PEjzR/S81a6+6cQz6S9x5KKdsknLi+IQRSC07JfybRhE8FM4k2fICgIKVE/MYrF427NlwtuEpOgSr8MUNy9x0Nw7jnAFsnZ7Uu5CkqAAAAAElFTkSuQmCC",{TextArea:Dk}=Wu,{useForm:Hle}=La,LR={\u56DE\u7B54\u4E0D\u4F73:"ansPoor",\u683C\u5F0F\u95EE\u9898:"formatError",\u7406\u89E3\u95EE\u9898\u6709\u8BEF:"harmfulInfo",\u5176\u4ED6:"othres"},Vle=({open:e,setOpen:t,feedBackList:n,handleConfirm:r})=>{const o={header:{padding:"20px 24px",borderBottom:"1px solid #F0F0F0",margin:0},body:{padding:"16px 24px 20px 24px",borderBottom:"1px solid #F0F0F0"},mask:{},footer:{padding:"16px 24px",margin:0},content:{padding:0,borderRadius:"4px",width:"563px"}},[i]=Hle(),[a,s]=ut({}),l=async()=>{try{const u=await i.validateFields();t(!1);const d={...u};Object.entries(a||{}).forEach(f=>{const[h,m]=f;m&&(d[LR[h]]=m)}),r(d)}catch(u){console.log(u);return}};At(()=>{e||(i.resetFields(),s(null))},[e]);const c=Ht(()=>{var u;return(u=JSON.parse(localStorage.getItem("gitech_ril:rag_ai")||"{}"))==null?void 0:u.userInfo},[]);return K(mp,{modal:{styles:o},children:Je(yp,{open:e,onCancel:()=>t(!1),title:K("div",{className:"text-[16px] text-[#2A2A2A] font-bold leading-[1]",children:"\u611F\u8C22\u60A8\u7684\u53CD\u9988\uFF01\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u4E0D\u65AD\u4F18\u5316\u4E0E\u63D0\u5347\u3002"}),footer:Je("div",{children:[K(ko,{className:"mr-[16px] w-[76px]",onClick:()=>{t(!1)},children:"\u53D6\u6D88"}),K(ko,{type:"primary",className:"w-[76px] border-none",onClick:l,children:"\u786E\u8BA4"})]}),children:[K(Wle,{feedBackList:n,treeSelectResult:a,setTreeSelectResult:s}),Je(La,{form:i,layout:"vertical",children:[K(La.Item,{name:"supplementExplain",label:"\u8865\u5145\u63CF\u8FF0",children:K(Dk,{})})," ",K(La.Item,{name:"idealAnswer",label:"\u60A8\u89C9\u5F97\u66F4\u597D\u7684\u56DE\u7B54\u662F\u4EC0\u4E48\uFF1F",children:K(Dk,{})}),c&&Je(E0,{children:[K(La.Item,{name:"userPhone",label:"\u8054\u7CFB\u7535\u8BDD",initialValue:c==null?void 0:c.phone,children:K(Wu,{disabled:!0})}),K(La.Item,{name:"deptName",label:"\u90E8\u95E8",initialValue:c==null?void 0:c.deptName,children:K(Wu,{disabled:!0})})]})]})]})})},Wle=({feedBackList:e,treeSelectResult:t,setTreeSelectResult:n})=>{const[r,o]=ut(!1),[i,a]=ut([]),[s,l]=ut([]),[c,u]=ut([]),[d,f]=ut(null),h=Ht(()=>(l([]),d!=null&&d.items?[{title:"\u5168\u9009",key:"\u5168\u9009",children:d.items.map(g=>({title:g,key:g}))}]:[]),[d]),m=g=>{u(p=>Array.isArray(p)&&Array.isArray(s)?Object.entries(t).reduce((y,b)=>{const[E,x]=b,k=(x?x.split(";"):[]).filter(S=>S!==g);return n(S=>({...S||{},[E]:k.join(";")})),[...y,...k]},[]):p)};return At(()=>{if(a(["\u5168\u9009"]),!t||!(d!=null&&d.que_name))return;const g=t[d.que_name]||"",p=g?g.split(";"):[];l(p)},[h,r]),At(()=>{t===null&&(u([]),f(null),l([]))},[t]),At(()=>{console.log("treeSelectResult",t),console.log("selectedValue",c),console.log("feedBackList",e),console.log("pKey",LR),console.log("selectedParent",d)},[t,c]),Je("div",{className:"relative mb-[24px] z-20",children:[Je("div",{className:"absolute w-full z-10",children:[Je("div",{className:"h-[32px] box-border flex items-center justify-between border-[1px] border-solid border-[#D9D9D9] rounded-[4px] cursor-pointer",onClick:()=>o(!r),children:[K("div",{className:"ml-[16px]",children:"\u95EE\u9898\u7C7B\u578B"}),K("img",{src:zle,width:24,height:24,className:"mr-[16px]"})]}),Je("div",{style:{display:r?"":"none"},className:"h-[288px] rounded-[4px] shadow-md mt-[4px] bg-white",children:[Je("div",{className:"h-[248px] flex",style:{borderBottom:"1px solid #F0F0F0"},children:[K("div",{className:"w-[203px] px-[8px] py-[8px]",style:{borderRight:"1px solid #F0F0F0"},children:e.map((g,p)=>{var v;return Je("div",{className:"rounded-[4px] h-[32px] cursor-pointer flex items-center",style:{backgroundColor:(d==null?void 0:d.que_name)===g.que_name?"#E6F4FF":""},children:[K("div",{className:"h-full w-full leading-[32px]",onClick:()=>{f(g)},children:Je("div",{className:"ml-[8px] text-[14px] text-[#2A2A2A]",children:[g.que_name,"(",t&&t[g.que_name]?t[g.que_name].split(";").length:0,"/",(v=g==null?void 0:g.items)==null?void 0:v.length,")"]})}),K(TT,{className:"mr-[8px] w-3 h-3 text-[rgba(0,0,0,0.45)]"})]},p)})}),K("div",{className:"selfTree h-full flex-1 mt-[8px] ml-[16px]",children:K(kz,{checkable:!0,defaultSelectedKeys:["0-1"],treeData:h,blockNode:!0,checkedKeys:s,expandedKeys:i,onCheck:g=>{Array.isArray(g)&&n(p=>({...p||{},[(d==null?void 0:d.que_name)||""]:(g||[]).filter(v=>v!=="\u5168\u9009").join(";")})),l(g)}})})]}),Je("div",{className:"flex justify-end h-[40px] items-center",children:[K(ko,{size:"small",className:"mr-[8px]",onClick:()=>o(!1),children:"\u53D6\u6D88"}),K(ko,{size:"small",type:"primary",className:"border-none mr-[16px]",onClick:()=>{u(g=>Array.isArray(g)&&Array.isArray(s)?Object.values(t).reduce((v,y)=>[...v,...y?y.split(";"):[]],[]):g),o(!1)},children:"\u786E\u8BA4"})]})]})]}),K("div",{className:"h-[32px]"}),!!(c!=null&&c.length)&&Je("div",{children:[Je("div",{className:"mt-[5px] text-[12px] text-[#555555]",children:["\u5DF2\u9009\u62E9 ",c.length," \u4E2A"]}),(c||[]).map(g=>{let p="";return Object.entries(t||{}).forEach(v=>{const[y,b]=v;b.indexOf(g)>-1&&(p=y)}),Je(Az,{closable:!0,className:"mt-[5px]",onClose:()=>m(g),children:[p,"\uFF08",g,"\uFF09"]},g)})]})]})},Tk=e=>e?Array.isArray(e)?e.map(r=>"/minio/"+r.split("/").slice(3).join("/")):"/minio/"+e.split("/").slice(3).join("/"):"",Pk="http://10.15.12.13:9000/",Ule=e=>{if(typeof e=="string"){const t=e.split(".");return t.length?t[t.length-1]:""}else return""},Gle=e=>{var x,C,k,S,O,A,$,M;const{file_type:t,file_name:n,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,onlyDownloadTypes:l,references:c,eventsEmit:u,styles:d,isUploadFile:f,type:h,collectionItems:m,pdfPages:g=0,fileManagerData:p}=e;if(h==="collection"&&Array.isArray(m)){const T=`calc(90% - ${.5}px)`,I=m.slice(0,4),j=m.length>4,R="\u6253\u5F00\u5408\u96C6",H=()=>{if(p&&t==="pdf"&&!e.pdfPages){const V=((p==null?void 0:p.uploadedFiles)||[]).find(z=>{var B;return((z==null?void 0:z.name)||((B=z==null?void 0:z.file)==null?void 0:B.name))===n});if(!(V!=null&&V.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{...e,pdfPages:(V==null?void 0:V.pdfPages)||0})}else u==null||u("reference_file:click",e)};return Je("div",{className:"user-file relative group flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all bg-white shadow",style:{width:94,height:94,minWidth:94,minHeight:94,borderColor:(C=(x=d==null?void 0:d.theme)==null?void 0:x.colors)==null?void 0:C.border},onClick:H,children:[K("div",{className:"grid grid-cols-2 items-center justify-center grid-rows-2 gap-1 w-full h-full",style:{width:"100%",height:"100%",gap:1},children:I.map((V,z)=>{var P,L,_,W;if(j&&z===3)return K("div",{className:"flex items-center justify-center bg-gray-100 rounded",style:{width:T,height:T},children:K("span",{className:"text-xl text-gray-300 font-bold scale-75",children:"..."})},"ellipsis");if(V.file_type==="image"||V.file_type==="jpg"||V.file_type==="jpeg"||V.file_type==="png"||V.file_type==="gif"||V.file_type==="bmp"||V.file_type==="webp")return K("div",{className:"relative flex items-center justify-center bg-white rounded-lg border overflow-hidden",style:{width:T,height:T,borderColor:(L=(P=d==null?void 0:d.theme)==null?void 0:P.colors)==null?void 0:L.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:K("img",{src:String(V.url||V.file_path||""),alt:V.file_name||"",className:"object-contain max-w-full max-h-full"})})},V.file_name||z);const F=F6(String(V.file_type||""),d);return K("div",{className:"user-file flex flex-col items-center justify-center rounded-lg border bg-gray-50 p-1 text-sm",title:V.file_name,style:{width:T,height:T,borderColor:(W=(_=d==null?void 0:d.theme)==null?void 0:_.colors)==null?void 0:W.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:F})},V.file_name||z)})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg pointer-events-none",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{size:20,className:"mb-1 text-white"}),K("span",{className:"text-white text-center",style:{fontSize:12},children:R})]})})]})}const v=()=>{if(console.log(o,"parse_url",r,"url"),p&&t==="pdf"&&!g){const N=((p==null?void 0:p.uploadedFiles)||[]).find(D=>{var T;return((D==null?void 0:D.name)||((T=D==null?void 0:D.file)==null?void 0:T.name))===(n||"").replace(/\s+/g,"")});if(!(N!=null&&N.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:N.pdfPages||0})}else u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:g})},y=Ht(()=>(n||"").split(".").pop()||"",[n]),b=F6(y,d),E=async()=>{if(r){const N=Tk(r.indexOf("http")>-1?r:`${Pk}/${r}`);if(y.toLowerCase()==="json"){try{const I=await fetch(N);if(!I.ok)throw new Error("\u4E0B\u8F7D\u5931\u8D25");const j=await I.blob(),R=document.createElement("a");R.href=URL.createObjectURL(j),R.download=n||"",document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(R.href),1e3)}catch{alert("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}return}const T=document.createElement("a");T.href=N,T.download=n||"",document.body.appendChild(T),T.click(),document.body.removeChild(T)}};return l&&l.includes(y.toLowerCase())?Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:E,style:{borderColor:(S=(k=d==null?void 0:d.theme)==null?void 0:k.colors)==null?void 0:S.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u4E0B\u8F7D\u6587\u4EF6"})]})})]},n):y==="image"||y==="jpg"||y==="jpeg"||y==="png"||y==="gif"||y==="bmp"||y==="webp"?Je("div",{className:"relative group w-24 h-24 cursor-pointer flex items-center justify-center",onClick:()=>v(),children:[r?K("img",{src:String(Tk(r&&r.indexOf("http")>-1?r:`${Pk}/${r}`)||""),alt:n||"",className:"w-full h-full object-cover rounded-md border",style:{borderColor:(A=(O=d==null?void 0:d.theme)==null?void 0:O.colors)==null?void 0:A.border}}):K("div",{className:"w-full h-full flex items-center justify-center",children:K("span",{className:"animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 w-8 h-8 inline-block"})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-md",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(Lz,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",children:"\u67E5\u770B\u56FE\u7247"})]})})]},n):Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:v,style:{borderColor:(M=($=d==null?void 0:d.theme)==null?void 0:$.colors)==null?void 0:M.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u6253\u5F00\u6587\u4EF6"})]})})]},n)},qle=e=>e?e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`:"",Yle=({fileName:e,fileSize:t,icon:n,statusText:r,statusColor:o="text-gray-400",statusIcon:i,onRemove:a,themeColors:s={},cardId:l,showRemove:c=!0,disabledRemove:u=!1,onRemoveWithAnim:d,extra:f,style:h})=>Je("div",{id:l,className:"group gap-x-2.5 items-center file-display-card relative flex w-[210px] bg-white border border-gray-200 rounded-md shadow-sm px-2 py-1 transition-all hover:shadow-md hover:border-blue-300",style:h,children:[K("div",{className:"pt-1",children:n}),Je("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[Je("div",{className:"flex items-center justify-between gap-1",children:[K("span",{className:"text-[12px] font-medium truncate max-w-[120px]",title:e,children:e}),K("span",{className:"ml-1 text-[11px] text-gray-400",children:qle(t)})]}),Je("div",{className:`text-[10px] mt-0.5 flex items-center gap-3 ${o}`,children:[i,K("span",{children:r})]})]}),f,c&&!u&&K("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 text-xs p-0.5 rounded-full bg-white shadow-sm z-10",onClick:()=>{d&&l?d(l):a&&a()},title:"\u79FB\u9664",style:{lineHeight:0,color:s.error||"#FF0000"},children:K(vp,{className:"w-3.5 h-3.5"})})]});function F6(e,t){var r;const n=((r=t==null?void 0:t.theme)==null?void 0:r.icons)||{};switch(e.toLowerCase()){case"docx":case"doc":return n.docx?K("img",{src:n.docx,alt:"docx",style:{width:20,height:20}}):K(Ko,{type:"rag/word",size:18});case"image":case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return n.image?K("img",{src:n.image,alt:"image",style:{width:20,height:20}}):K(Ko,{type:"rag/pic",size:18});case"pptx":case"ppt":return n.pptx?K("img",{src:n.pptx,alt:"pptx",style:{width:20,height:20}}):K(Ko,{type:"rag/ppt",size:18});case"sheets":case"excel":case"xls":case"csv":case"xlsx":case"xlsm":case"xlsb":case"xltx":case"xltm":case"xlt":case"xlam":return n.sheets?K("img",{src:n.sheets,alt:"sheets",style:{width:20,height:20}}):K(Ko,{type:"rag/excel",size:18});case"pdf":return n.pdf?K("img",{src:n.pdf,alt:"pdf",style:{width:20,height:20}}):K(Ko,{type:"rag/pdf",size:18});case"txt":return n.txt?K("img",{src:n.txt,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/txt",size:18});case"md":return n.md?K("img",{src:n.md,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/document",size:18});case"json":return n.json?K("img",{src:n.json,alt:"json",style:{width:20,height:20}}):K(Ko,{type:"rag/json",size:18});case"html":case"htm":return n.html?K("img",{src:n.html,alt:"html",style:{width:20,height:20}}):K(Ko,{type:"rag/url",size:18});case"xml":default:return K(Ko,{type:"rag/file",size:18})}}const Xle=[{file:{name:"\u4EA7\u54C1\u9700\u6C42\u6587\u6863.pdf",size:1024*1024*2.5,type:"application/pdf"},type:"pdf",status:"uploaded",url:"https://example.com/file1.pdf"},{file:{name:"\u6570\u636E\u5206\u6790\u62A5\u544A.xlsx",size:1024*1024*1.2,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},type:"excel",status:"uploaded",url:"https://example.com/file3.xlsx"},{file:{name:"\u7CFB\u7EDF\u67B6\u6784\u56FE.png",size:1024*512,type:"image/png"},type:"image",status:"uploaded",url:"https://example.com/file2.png"}];function Kle({open:e,onCancel:t,files:n=Xle,currentFiles:r=[],onUpload:o,onRemoveFile:i,styles:a,eventsEmit:s}){const l={pending:"\u5F85\u4E0A\u4F20",uploading:"\u4E0A\u4F20\u4E2D",uploaded:"\u5DF2\u4E0A\u4F20",analyzing:"\u89E3\u6790\u4E2D",analyze_failed:"\u89E3\u6790\u5931\u8D25",error:"\u5931\u8D25"},[c,u]=ut([]),d=(g,p)=>{s&&s("uploaded_file:removeFromTemp",{file:g,idx:p})},f=a&&a.theme&&a.theme.colors?a.theme.colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080",shadow:"#000000",appBackground:"#fff"},h=n.map((g,p)=>Je("div",{className:"relative flex flex-col gap-2.5 items-center justify-center",children:[K("div",{className:"absolute right-1 top-1 z-10",children:K(jT,{title:"\u786E\u8BA4\u4ECE\u4E34\u65F6\u5BF9\u8BDD\u77E5\u8BC6\u5E93\u79FB\u9664\u8BE5\u6587\u4EF6\uFF1F",onConfirm:()=>d(g,p),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",children:K("button",{className:"bg-white cursor-pointer rounded-full p-0.5",style:{lineHeight:0,color:f&&f.text?f.text:"#FF0000",transition:"background 0.2s, color 0.2s"},onMouseOver:v=>{v.currentTarget.style.color=f&&f.error?f.error:"#FF0000"},onMouseOut:v=>{v.currentTarget.style.color=f.text},title:"\u79FB\u9664",children:K(vp,{className:"w-3 h-3"})})})}),K(Gle,{file_type:Ule(g.file.name||g.name),file_name:g.name||g.file.name,url:g.url,retrieve_tags:[],styles:a,isUploadFile:!0,eventsEmit:s,parse_url:g.convertedFilePath,pdfPages:g.pdfPages||0})]},g.file.name+p)),m=r.map((g,p)=>{const v=g.file.name.split(".").pop()||"",y=F6(v,a);return K(Yle,{cardId:`pending-file-card-${p}`,fileName:g.file.name,fileSize:g.file.size,icon:y,statusText:l[g.status||"pending"],statusColor:"text-gray-400",showRemove:!0,onRemove:()=>i&&i(g,p,"pending"),themeColors:f,style:{boxShadow:"none",height:55,background:"#f8fafc"}},g.file.name+p)});return c.length>0?(f&&f.error&&f.error,f&&f.error&&f.error+"",f&&f.error&&f.error):(f&&f.disabledText&&f.disabledText,f&&f.disabledBackground&&f.disabledBackground,f&&f.disabledText&&f.disabledText),Je(yp,{open:e,onCancel:t,footer:null,title:"\u5BF9\u8BDD\u4E34\u65F6\u6587\u4EF6\u77E5\u8BC6\u5E93",closable:!1,width:800,styles:{body:{padding:"0",maxHeight:"70vh",overflow:"auto"}},children:[Je("div",{className:"file-manager-modal space-y-6 px-4 py-4",children:[Je("div",{className:"",children:[K("div",{className:"flex items-center mb-2 justify-between",children:Je("div",{className:"flex items-center",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5DF2\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[n.length," \u4E2A"]})]})}),K("div",{className:"w-full relative min-h-[200px] max-h-[260px] p-2 overflow-y-auto",style:{overflowX:"hidden"},children:K("div",{className:"flex flex-wrap gap-1",children:h.length>0?h:K("div",{className:"flex items-center w-full h-full py-10 justify-center text-gray-400 text-sm",children:"\u6682\u65E0\u5DF2\u4E0A\u4F20\u6587\u4EF6"})})})]}),Je("div",{children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5F85\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[r.length," \u4E2A"]})]}),Je("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[m,K(B8.Dragger,{multiple:!0,showUploadList:!1,beforeUpload:(g,p)=>(g===p[0]&&(o==null||o(p)),!1),className:"!bg-gray-50 !border-dashed !border-gray-300 hover:!border-blue-400 cursor-pointer min-w-[160px] max-w-[220px] flex flex-row items-center justify-center border-2 rounded-lg transition-all",style:{height:45,boxShadow:"none",padding:0},children:Je("div",{className:"flex flex-row items-center pb-8 justify-center",children:[K(PT,{size:20,className:"text-blue-400 mr-2"}),K("div",{className:"text-xs text-gray-500",children:"\u4E0A\u4F20\u6587\u4EF6"})]})})]})]}),K("div",{className:"flex justify-end gap-2",children:K(ko,{type:"primary",onClick:t,children:"\u786E\u8BA4"})})]}),K("style",{children:`
595
+ `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":const d=parseInt(u,10);isNaN(d)||t(r.retry=d);break}}}}function Fle(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Mk(){return{data:"",event:"",id:"",retry:void 0}}var Ble=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n};const I6="text/event-stream",Rle=1e3,Nk="last-event-id";function Lle(e,t){var{signal:n,headers:r,onopen:o,onmessage:i,onclose:a,onerror:s,openWhenHidden:l,fetch:c}=t,u=Ble(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,f)=>{const h=Object.assign({},r);h.accept||(h.accept=I6);let m;function g(){m.abort(),document.hidden||x()}l||document.addEventListener("visibilitychange",g);let p=Rle,v=0;function y(){document.removeEventListener("visibilitychange",g),window.clearTimeout(v),m.abort()}n==null||n.addEventListener("abort",()=>{y(),d()});const b=c??window.fetch,E=o??jle;async function x(){var C;m=new AbortController;try{const k=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:m.signal}));await E(k),await Tle(k.body,Ple(Ile(S=>{S?h[Nk]=S:delete h[Nk]},S=>{p=S},i))),a==null||a(),y(),d()}catch(k){if(!m.signal.aborted)try{const S=(C=s==null?void 0:s(k))!==null&&C!==void 0?C:p;window.clearTimeout(v),v=window.setTimeout(x,S)}catch(S){y(),f(S)}}}x()})}function jle(e){const t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(I6)))throw new Error(`Expected content-type to be ${I6}, Actual: ${t}`)}class am extends Error{}let To=null,aa=null;const _le=({baseUrl:e,token:t,CSRFToken:n,setChatData:r,activeSessionId:o,setAppStatus:i,setConversationList:a})=>{const s=p=>{if(!p)return!1;if(typeof p=="string"){const v=p.trim();return v!==""&&v!=="[]"&&v!=="null"}return!0},l=({content:p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:C,databaseReference:k,llmType:S,resultType:O,queryId:A,tokens:$})=>{r(M=>{var z;if(!M[0])return M;const N=M[0],D=N.messages||[],T=D.length-1;if(T<0)return M;const I=D[T];if(I.istype!=="ai")return M;let j=D.slice();if(b!=null&&b.length){const B=D.length-2;if(B>=0&&((z=D[B])==null?void 0:z.istype)==="user"){const F={...D[B],filePaths:b};j[B]=F}}const R=C!==void 0&&s(C)?C:I.graphReference;v===2&&C!==void 0&&console.log("[AichatUseController] reset_chat status=2 \u65F6\u7684 graphReference:",{graphReference:C,isValid:s(C),lastMessageGraphReference:I.graphReference,finalGraphReference:R});const H={...I,content:(I.content||"")+p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:R,databaseReference:k??I.databaseReference,resultType:O,llmType:S,tokens:$,queryId:A||I.queryId||ga(32)};return H.clientSideId=H.clientSideId||H.queryId+"-ai",j[T]=H,[{...N,isNew:!1,messages:j},...M.slice(1)]})},c=p=>{if(p instanceof am)throw i(v=>({...v,display:"error",sender:"ready"})),To&&(To.abort(),To=null),aa=null,p};return{updateUserFilesMessage:({currentFiles:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-2;if(E<0||b[E].istype!=="user")return v;const C=b.slice();return C[E]={...b[E],currentFiles:p},[{...y,messages:C},...v.slice(1)]})},api_startChat_re:(p,v)=>{To&&To.abort(),To=new AbortController,aa=p.sessionId;const y=`${e}/qa/ai/question_re`;console.log("data",p);const b={...p};Lle(y,{method:"post",signal:To.signal,headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:t||"","X-CSRF-TOKEN-IN":n||""},openWhenHidden:!0,body:JSON.stringify(b),onopen:async E=>{if(E.status===500)throw new am("Internal Server Error");if(!E.ok)throw new am(`HTTP error: ${E.status}`)},onmessage:E=>{const x=JSON.parse(E.data);if(aa!==x.sessionId){console.log("[AichatUseController] \u6D41\u5F0F\u8BF7\u6C42\u7684 sessionId \u5DF2\u4E0D\u5339\u914D\uFF0C\u5FFD\u7565\u6570\u636E",{currentStreamSessionId:aa,receivedSessionId:x.sessionId,activeSessionId:o});return}if(o!==x.sessionId)return;const{reply:C,resultType:k,respTime:S,reference:O,webReference:A,graphReference:$,filePaths:M,status:N,docs:D,llmType:T,databaseReference:I}=x,j=M?JSON.parse(M):[];N===2&&C&&C.content&&(C.content.includes("\u6A21\u578B\u6682\u65E0\u6CD5\u8FD4\u56DE")||C.content.includes("\u5931\u8D25")||C.content.includes("\u9519\u8BEF")||C.content.includes("\u8BF7\u7A0D\u540E\u518D\u8BD5"))&&i(H=>({...H,display:"ready",sender:"ready"}));const R=s($)?$:void 0;if(N===2&&console.log("[AichatUseController] status=2 \u65F6\u7684 graphReference:",{graphReference:$,type:typeof $,isValid:s($),finalGraphReference:R}),N===2){if(l({content:C.content||"",status:2,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens}),i(H=>({...H,display:"ready",sender:"ready"})),v){const H=S||Date.now();console.log("[AichatUseController] \u6D88\u606F\u53D1\u9001\u6210\u529F\uFF0CgmtModified:",H),v(H)}}else l({content:C.content||"",status:N,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens})},onerror:c,onclose:()=>{aa===p.sessionId&&(aa=null)}})},addEmptyMessage:({queryId:p,content:v,filePaths:y,currentFiles:b})=>{r(E=>{const x=new Date().toISOString(),C=p||ga(32),k={istype:"user",content:v,time:x,queryId:C,clientSideId:C+"-user",filePaths:y||"",currentFiles:b||[]},S={istype:"ai",content:"",time:new Date(Date.now()+1).toISOString(),streaming:!0,status:0,queryId:C,clientSideId:C+"-ai"},O=E.find(A=>A.id===o);return O?O.messages.push(k,S):console.warn("addEmptyMessage called without an active session."),[...E]})},setLastEmptyMessage:({now:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-1;if(E<0)return v;const x=b[E];if(x.istype!=="ai")return v;const C=b.slice();return C[E]={...x,istype:"ai",content:"",time:p,streaming:!0,status:0},[{...y,messages:C},...v.slice(1)]})},stopStream:()=>{To&&(To.abort(),To=null),aa=null,i(p=>({...p,display:"ready",sender:"ready"}))},cancelStreamBySessionId:p=>To&&aa===p?(console.log("[AichatUseController] \u5207\u6362\u4F1A\u8BDD\uFF0C\u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u5F0F\u8BF7\u6C42",p),To.abort(),To=null,aa=null,i(v=>({...v,display:"ready",sender:"ready"})),!0):!1}},zle="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACRSURBVHgB7ZJBCsQgDEWTmQvMncT7dOuqmY3iai6kMN31UmIjdNFFKuk+DwKahP9ABDAMQyTnvHCtT/ZjjIs0e0nN1hr03kkjGTu8+0PEjzR/S81a6+6cQz6S9x5KKdsknLi+IQRSC07JfybRhE8FM4k2fICgIKVE/MYrF427NlwtuEpOgSr8MUNy9x0Nw7jnAFsnZ7Uu5CkqAAAAAElFTkSuQmCC",{TextArea:Dk}=Wu,{useForm:Hle}=La,LR={\u56DE\u7B54\u4E0D\u4F73:"ansPoor",\u683C\u5F0F\u95EE\u9898:"formatError",\u7406\u89E3\u95EE\u9898\u6709\u8BEF:"harmfulInfo",\u5176\u4ED6:"othres"},Vle=({open:e,setOpen:t,feedBackList:n,handleConfirm:r})=>{const o={header:{padding:"20px 24px",borderBottom:"1px solid #F0F0F0",margin:0},body:{padding:"16px 24px 20px 24px",borderBottom:"1px solid #F0F0F0"},mask:{},footer:{padding:"16px 24px",margin:0},content:{padding:0,borderRadius:"4px",width:"563px"}},[i]=Hle(),[a,s]=ut({}),l=async()=>{try{const u=await i.validateFields();t(!1);const d={...u};Object.entries(a||{}).forEach(f=>{const[h,m]=f;m&&(d[LR[h]]=m)}),r(d)}catch(u){console.log(u);return}};At(()=>{e||(i.resetFields(),s(null))},[e]);const c=Ht(()=>{var u;return(u=JSON.parse(localStorage.getItem("gitech_ril:rag_ai")||"{}"))==null?void 0:u.userInfo},[e]);return K(mp,{modal:{styles:o},children:Je(yp,{open:e,onCancel:()=>t(!1),title:K("div",{className:"text-[16px] text-[#2A2A2A] font-bold leading-[1]",children:"\u611F\u8C22\u60A8\u7684\u53CD\u9988\uFF01\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u4E0D\u65AD\u4F18\u5316\u4E0E\u63D0\u5347\u3002"}),destroyOnHidden:!0,footer:Je("div",{children:[K(ko,{className:"mr-[16px] w-[76px]",onClick:()=>{t(!1)},children:"\u53D6\u6D88"}),K(ko,{type:"primary",className:"w-[76px] border-none",onClick:l,children:"\u786E\u8BA4"})]}),children:[K(Wle,{feedBackList:n,treeSelectResult:a,setTreeSelectResult:s}),Je(La,{form:i,layout:"vertical",children:[K(La.Item,{name:"supplementExplain",label:"\u8865\u5145\u63CF\u8FF0",children:K(Dk,{})})," ",K(La.Item,{name:"idealAnswer",label:"\u60A8\u89C9\u5F97\u66F4\u597D\u7684\u56DE\u7B54\u662F\u4EC0\u4E48\uFF1F",children:K(Dk,{})}),c&&Je(E0,{children:[K(La.Item,{name:"userPhone",label:"\u8054\u7CFB\u7535\u8BDD",initialValue:c==null?void 0:c.phone,children:K(Wu,{disabled:!0})}),K(La.Item,{name:"deptName",label:"\u90E8\u95E8",initialValue:c==null?void 0:c.deptName,children:K(Wu,{disabled:!0})})]})]})]})})},Wle=({feedBackList:e,treeSelectResult:t,setTreeSelectResult:n})=>{const[r,o]=ut(!1),[i,a]=ut([]),[s,l]=ut([]),[c,u]=ut([]),[d,f]=ut(null),h=Ht(()=>(l([]),d!=null&&d.items?[{title:"\u5168\u9009",key:"\u5168\u9009",children:d.items.map(g=>({title:g,key:g}))}]:[]),[d]),m=g=>{u(p=>Array.isArray(p)&&Array.isArray(s)?Object.entries(t).reduce((y,b)=>{const[E,x]=b,k=(x?x.split(";"):[]).filter(S=>S!==g);return n(S=>({...S||{},[E]:k.join(";")})),[...y,...k]},[]):p)};return At(()=>{if(a(["\u5168\u9009"]),!t||!(d!=null&&d.que_name))return;const g=t[d.que_name]||"",p=g?g.split(";"):[];l(p)},[h,r]),At(()=>{t===null&&(u([]),f(null),l([]))},[t]),At(()=>{console.log("treeSelectResult",t),console.log("selectedValue",c),console.log("feedBackList",e),console.log("pKey",LR),console.log("selectedParent",d)},[t,c]),Je("div",{className:"relative mb-[24px] z-20",children:[Je("div",{className:"absolute w-full z-10",children:[Je("div",{className:"h-[32px] box-border flex items-center justify-between border-[1px] border-solid border-[#D9D9D9] rounded-[4px] cursor-pointer",onClick:()=>o(!r),children:[K("div",{className:"ml-[16px]",children:"\u95EE\u9898\u7C7B\u578B"}),K("img",{src:zle,width:24,height:24,className:"mr-[16px]"})]}),Je("div",{style:{display:r?"":"none"},className:"h-[288px] rounded-[4px] shadow-md mt-[4px] bg-white",children:[Je("div",{className:"h-[248px] flex",style:{borderBottom:"1px solid #F0F0F0"},children:[K("div",{className:"w-[203px] px-[8px] py-[8px]",style:{borderRight:"1px solid #F0F0F0"},children:e.map((g,p)=>{var v;return Je("div",{className:"rounded-[4px] h-[32px] cursor-pointer flex items-center",style:{backgroundColor:(d==null?void 0:d.que_name)===g.que_name?"#E6F4FF":""},children:[K("div",{className:"h-full w-full leading-[32px]",onClick:()=>{f(g)},children:Je("div",{className:"ml-[8px] text-[14px] text-[#2A2A2A]",children:[g.que_name,"(",t&&t[g.que_name]?t[g.que_name].split(";").length:0,"/",(v=g==null?void 0:g.items)==null?void 0:v.length,")"]})}),K(TT,{className:"mr-[8px] w-3 h-3 text-[rgba(0,0,0,0.45)]"})]},p)})}),K("div",{className:"selfTree h-full flex-1 mt-[8px] ml-[16px]",children:K(kz,{checkable:!0,defaultSelectedKeys:["0-1"],treeData:h,blockNode:!0,checkedKeys:s,expandedKeys:i,onCheck:g=>{Array.isArray(g)&&n(p=>({...p||{},[(d==null?void 0:d.que_name)||""]:(g||[]).filter(v=>v!=="\u5168\u9009").join(";")})),l(g)}})})]}),Je("div",{className:"flex justify-end h-[40px] items-center",children:[K(ko,{size:"small",className:"mr-[8px]",onClick:()=>o(!1),children:"\u53D6\u6D88"}),K(ko,{size:"small",type:"primary",className:"border-none mr-[16px]",onClick:()=>{u(g=>Array.isArray(g)&&Array.isArray(s)?Object.values(t).reduce((v,y)=>[...v,...y?y.split(";"):[]],[]):g),o(!1)},children:"\u786E\u8BA4"})]})]})]}),K("div",{className:"h-[32px]"}),!!(c!=null&&c.length)&&Je("div",{children:[Je("div",{className:"mt-[5px] text-[12px] text-[#555555]",children:["\u5DF2\u9009\u62E9 ",c.length," \u4E2A"]}),(c||[]).map(g=>{let p="";return Object.entries(t||{}).forEach(v=>{const[y,b]=v;b.indexOf(g)>-1&&(p=y)}),Je(Az,{closable:!0,className:"mt-[5px]",onClose:()=>m(g),children:[p,"\uFF08",g,"\uFF09"]},g)})]})]})},Tk=e=>e?Array.isArray(e)?e.map(r=>"/minio/"+r.split("/").slice(3).join("/")):"/minio/"+e.split("/").slice(3).join("/"):"",Pk="http://10.15.12.13:9000/",Ule=e=>{if(typeof e=="string"){const t=e.split(".");return t.length?t[t.length-1]:""}else return""},Gle=e=>{var x,C,k,S,O,A,$,M;const{file_type:t,file_name:n,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,onlyDownloadTypes:l,references:c,eventsEmit:u,styles:d,isUploadFile:f,type:h,collectionItems:m,pdfPages:g=0,fileManagerData:p}=e;if(h==="collection"&&Array.isArray(m)){const T=`calc(90% - ${.5}px)`,I=m.slice(0,4),j=m.length>4,R="\u6253\u5F00\u5408\u96C6",H=()=>{if(p&&t==="pdf"&&!e.pdfPages){const V=((p==null?void 0:p.uploadedFiles)||[]).find(z=>{var B;return((z==null?void 0:z.name)||((B=z==null?void 0:z.file)==null?void 0:B.name))===n});if(!(V!=null&&V.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{...e,pdfPages:(V==null?void 0:V.pdfPages)||0})}else u==null||u("reference_file:click",e)};return Je("div",{className:"user-file relative group flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all bg-white shadow",style:{width:94,height:94,minWidth:94,minHeight:94,borderColor:(C=(x=d==null?void 0:d.theme)==null?void 0:x.colors)==null?void 0:C.border},onClick:H,children:[K("div",{className:"grid grid-cols-2 items-center justify-center grid-rows-2 gap-1 w-full h-full",style:{width:"100%",height:"100%",gap:1},children:I.map((V,z)=>{var P,L,_,W;if(j&&z===3)return K("div",{className:"flex items-center justify-center bg-gray-100 rounded",style:{width:T,height:T},children:K("span",{className:"text-xl text-gray-300 font-bold scale-75",children:"..."})},"ellipsis");if(V.file_type==="image"||V.file_type==="jpg"||V.file_type==="jpeg"||V.file_type==="png"||V.file_type==="gif"||V.file_type==="bmp"||V.file_type==="webp")return K("div",{className:"relative flex items-center justify-center bg-white rounded-lg border overflow-hidden",style:{width:T,height:T,borderColor:(L=(P=d==null?void 0:d.theme)==null?void 0:P.colors)==null?void 0:L.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:K("img",{src:String(V.url||V.file_path||""),alt:V.file_name||"",className:"object-contain max-w-full max-h-full"})})},V.file_name||z);const F=F6(String(V.file_type||""),d);return K("div",{className:"user-file flex flex-col items-center justify-center rounded-lg border bg-gray-50 p-1 text-sm",title:V.file_name,style:{width:T,height:T,borderColor:(W=(_=d==null?void 0:d.theme)==null?void 0:_.colors)==null?void 0:W.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:F})},V.file_name||z)})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg pointer-events-none",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{size:20,className:"mb-1 text-white"}),K("span",{className:"text-white text-center",style:{fontSize:12},children:R})]})})]})}const v=()=>{if(console.log(o,"parse_url",r,"url"),p&&t==="pdf"&&!g){const N=((p==null?void 0:p.uploadedFiles)||[]).find(D=>{var T;return((D==null?void 0:D.name)||((T=D==null?void 0:D.file)==null?void 0:T.name))===(n||"").replace(/\s+/g,"")});if(!(N!=null&&N.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:N.pdfPages||0})}else u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:g})},y=Ht(()=>(n||"").split(".").pop()||"",[n]),b=F6(y,d),E=async()=>{if(r){const N=Tk(r.indexOf("http")>-1?r:`${Pk}/${r}`);if(y.toLowerCase()==="json"){try{const I=await fetch(N);if(!I.ok)throw new Error("\u4E0B\u8F7D\u5931\u8D25");const j=await I.blob(),R=document.createElement("a");R.href=URL.createObjectURL(j),R.download=n||"",document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(R.href),1e3)}catch{alert("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}return}const T=document.createElement("a");T.href=N,T.download=n||"",document.body.appendChild(T),T.click(),document.body.removeChild(T)}};return l&&l.includes(y.toLowerCase())?Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:E,style:{borderColor:(S=(k=d==null?void 0:d.theme)==null?void 0:k.colors)==null?void 0:S.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u4E0B\u8F7D\u6587\u4EF6"})]})})]},n):y==="image"||y==="jpg"||y==="jpeg"||y==="png"||y==="gif"||y==="bmp"||y==="webp"?Je("div",{className:"relative group w-24 h-24 cursor-pointer flex items-center justify-center",onClick:()=>v(),children:[r?K("img",{src:String(Tk(r&&r.indexOf("http")>-1?r:`${Pk}/${r}`)||""),alt:n||"",className:"w-full h-full object-cover rounded-md border",style:{borderColor:(A=(O=d==null?void 0:d.theme)==null?void 0:O.colors)==null?void 0:A.border}}):K("div",{className:"w-full h-full flex items-center justify-center",children:K("span",{className:"animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 w-8 h-8 inline-block"})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-md",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(Lz,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",children:"\u67E5\u770B\u56FE\u7247"})]})})]},n):Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:v,style:{borderColor:(M=($=d==null?void 0:d.theme)==null?void 0:$.colors)==null?void 0:M.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u6253\u5F00\u6587\u4EF6"})]})})]},n)},qle=e=>e?e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`:"",Yle=({fileName:e,fileSize:t,icon:n,statusText:r,statusColor:o="text-gray-400",statusIcon:i,onRemove:a,themeColors:s={},cardId:l,showRemove:c=!0,disabledRemove:u=!1,onRemoveWithAnim:d,extra:f,style:h})=>Je("div",{id:l,className:"group gap-x-2.5 items-center file-display-card relative flex w-[210px] bg-white border border-gray-200 rounded-md shadow-sm px-2 py-1 transition-all hover:shadow-md hover:border-blue-300",style:h,children:[K("div",{className:"pt-1",children:n}),Je("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[Je("div",{className:"flex items-center justify-between gap-1",children:[K("span",{className:"text-[12px] font-medium truncate max-w-[120px]",title:e,children:e}),K("span",{className:"ml-1 text-[11px] text-gray-400",children:qle(t)})]}),Je("div",{className:`text-[10px] mt-0.5 flex items-center gap-3 ${o}`,children:[i,K("span",{children:r})]})]}),f,c&&!u&&K("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 text-xs p-0.5 rounded-full bg-white shadow-sm z-10",onClick:()=>{d&&l?d(l):a&&a()},title:"\u79FB\u9664",style:{lineHeight:0,color:s.error||"#FF0000"},children:K(vp,{className:"w-3.5 h-3.5"})})]});function F6(e,t){var r;const n=((r=t==null?void 0:t.theme)==null?void 0:r.icons)||{};switch(e.toLowerCase()){case"docx":case"doc":return n.docx?K("img",{src:n.docx,alt:"docx",style:{width:20,height:20}}):K(Ko,{type:"rag/word",size:18});case"image":case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return n.image?K("img",{src:n.image,alt:"image",style:{width:20,height:20}}):K(Ko,{type:"rag/pic",size:18});case"pptx":case"ppt":return n.pptx?K("img",{src:n.pptx,alt:"pptx",style:{width:20,height:20}}):K(Ko,{type:"rag/ppt",size:18});case"sheets":case"excel":case"xls":case"csv":case"xlsx":case"xlsm":case"xlsb":case"xltx":case"xltm":case"xlt":case"xlam":return n.sheets?K("img",{src:n.sheets,alt:"sheets",style:{width:20,height:20}}):K(Ko,{type:"rag/excel",size:18});case"pdf":return n.pdf?K("img",{src:n.pdf,alt:"pdf",style:{width:20,height:20}}):K(Ko,{type:"rag/pdf",size:18});case"txt":return n.txt?K("img",{src:n.txt,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/txt",size:18});case"md":return n.md?K("img",{src:n.md,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/document",size:18});case"json":return n.json?K("img",{src:n.json,alt:"json",style:{width:20,height:20}}):K(Ko,{type:"rag/json",size:18});case"html":case"htm":return n.html?K("img",{src:n.html,alt:"html",style:{width:20,height:20}}):K(Ko,{type:"rag/url",size:18});case"xml":default:return K(Ko,{type:"rag/file",size:18})}}const Xle=[{file:{name:"\u4EA7\u54C1\u9700\u6C42\u6587\u6863.pdf",size:1024*1024*2.5,type:"application/pdf"},type:"pdf",status:"uploaded",url:"https://example.com/file1.pdf"},{file:{name:"\u6570\u636E\u5206\u6790\u62A5\u544A.xlsx",size:1024*1024*1.2,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},type:"excel",status:"uploaded",url:"https://example.com/file3.xlsx"},{file:{name:"\u7CFB\u7EDF\u67B6\u6784\u56FE.png",size:1024*512,type:"image/png"},type:"image",status:"uploaded",url:"https://example.com/file2.png"}];function Kle({open:e,onCancel:t,files:n=Xle,currentFiles:r=[],onUpload:o,onRemoveFile:i,styles:a,eventsEmit:s}){const l={pending:"\u5F85\u4E0A\u4F20",uploading:"\u4E0A\u4F20\u4E2D",uploaded:"\u5DF2\u4E0A\u4F20",analyzing:"\u89E3\u6790\u4E2D",analyze_failed:"\u89E3\u6790\u5931\u8D25",error:"\u5931\u8D25"},[c,u]=ut([]),d=(g,p)=>{s&&s("uploaded_file:removeFromTemp",{file:g,idx:p})},f=a&&a.theme&&a.theme.colors?a.theme.colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080",shadow:"#000000",appBackground:"#fff"},h=n.map((g,p)=>Je("div",{className:"relative flex flex-col gap-2.5 items-center justify-center",children:[K("div",{className:"absolute right-1 top-1 z-10",children:K(jT,{title:"\u786E\u8BA4\u4ECE\u4E34\u65F6\u5BF9\u8BDD\u77E5\u8BC6\u5E93\u79FB\u9664\u8BE5\u6587\u4EF6\uFF1F",onConfirm:()=>d(g,p),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",children:K("button",{className:"bg-white cursor-pointer rounded-full p-0.5",style:{lineHeight:0,color:f&&f.text?f.text:"#FF0000",transition:"background 0.2s, color 0.2s"},onMouseOver:v=>{v.currentTarget.style.color=f&&f.error?f.error:"#FF0000"},onMouseOut:v=>{v.currentTarget.style.color=f.text},title:"\u79FB\u9664",children:K(vp,{className:"w-3 h-3"})})})}),K(Gle,{file_type:Ule(g.file.name||g.name),file_name:g.name||g.file.name,url:g.url,retrieve_tags:[],styles:a,isUploadFile:!0,eventsEmit:s,parse_url:g.convertedFilePath,pdfPages:g.pdfPages||0})]},g.file.name+p)),m=r.map((g,p)=>{const v=g.file.name.split(".").pop()||"",y=F6(v,a);return K(Yle,{cardId:`pending-file-card-${p}`,fileName:g.file.name,fileSize:g.file.size,icon:y,statusText:l[g.status||"pending"],statusColor:"text-gray-400",showRemove:!0,onRemove:()=>i&&i(g,p,"pending"),themeColors:f,style:{boxShadow:"none",height:55,background:"#f8fafc"}},g.file.name+p)});return c.length>0?(f&&f.error&&f.error,f&&f.error&&f.error+"",f&&f.error&&f.error):(f&&f.disabledText&&f.disabledText,f&&f.disabledBackground&&f.disabledBackground,f&&f.disabledText&&f.disabledText),Je(yp,{open:e,onCancel:t,footer:null,title:"\u5BF9\u8BDD\u4E34\u65F6\u6587\u4EF6\u77E5\u8BC6\u5E93",closable:!1,width:800,styles:{body:{padding:"0",maxHeight:"70vh",overflow:"auto"}},children:[Je("div",{className:"file-manager-modal space-y-6 px-4 py-4",children:[Je("div",{className:"",children:[K("div",{className:"flex items-center mb-2 justify-between",children:Je("div",{className:"flex items-center",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5DF2\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[n.length," \u4E2A"]})]})}),K("div",{className:"w-full relative min-h-[200px] max-h-[260px] p-2 overflow-y-auto",style:{overflowX:"hidden"},children:K("div",{className:"flex flex-wrap gap-1",children:h.length>0?h:K("div",{className:"flex items-center w-full h-full py-10 justify-center text-gray-400 text-sm",children:"\u6682\u65E0\u5DF2\u4E0A\u4F20\u6587\u4EF6"})})})]}),Je("div",{children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5F85\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[r.length," \u4E2A"]})]}),Je("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[m,K(B8.Dragger,{multiple:!0,showUploadList:!1,beforeUpload:(g,p)=>(g===p[0]&&(o==null||o(p)),!1),className:"!bg-gray-50 !border-dashed !border-gray-300 hover:!border-blue-400 cursor-pointer min-w-[160px] max-w-[220px] flex flex-row items-center justify-center border-2 rounded-lg transition-all",style:{height:45,boxShadow:"none",padding:0},children:Je("div",{className:"flex flex-row items-center pb-8 justify-center",children:[K(PT,{size:20,className:"text-blue-400 mr-2"}),K("div",{className:"text-xs text-gray-500",children:"\u4E0A\u4F20\u6587\u4EF6"})]})})]})]}),K("div",{className:"flex justify-end gap-2",children:K(ko,{type:"primary",onClick:t,children:"\u786E\u8BA4"})})]}),K("style",{children:`
596
596
  .file-manager-modal .ant-upload-wrapper,
597
597
  .file-manager-modal .ant-upload-drag,
598
598
  .file-manager-modal .ant-upload-drag-container {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "style": "assets/style.css",
5
5
  "private": false,
6
- "version": "1.9.8",
6
+ "version": "1.9.9",
7
7
  "author": "hanfeng_Zhang",
8
8
  "type": "module",
9
9
  "main": "index.js",