1import{cg as Pe,d0 as Ue,cJ as d,c6 as v,c$ as l,f as _e,cQ as He,cX as y,c1 as Y,cd as T,c3 as o,c4 as lt,c5 as te,d4 as Xe,cF as it,cC as kt,dc as re,cx as ee,de as oe,cy as wt,cO as k,cw as Me,cc as xe,dh as ue,df as rt,da as ut,cv as Ct,bR as tt,bP as _t,cH as At,cb as It,d3 as St}from"./vendor-vue-C3df0gLH.js";import{X as Tt}from"./XAgentInput-CjgpMwaR.js";import{b as Ft,f as $t,d as Dt,a as Et,c as Mt,s as Pt,e as Nt,u as jt,X as Lt}from"./chat-DuWtLHIG.js";import{a as Rt,U as Ut,_ as Vt}from"./UserProfileDropdown-w_fHVL96.js";import{H as Ge,_ as Qe,E as zt}from"./index-ByVTmJon.js";import{aH as st,ay as qt,az as Bt,aA as Ht,aI as Jt,aB as ot,aC as Ot}from"./vendor-BAp2x3JD.js";/* empty css *//* empty css */import{i as ct}from"./iosDialog-3t7wGQfZ.js";import{y as Ke,n as pe,s as Wt}from"./vendor-vuetify-Cd8aE-6N.js";import{i as nt}from"./iosButton-BqygnPia.js";import{t as Kt,d as Xt,a as Gt,h as Qt,g as Yt}from"./notification-OMCvXGeN.js";import"./vendor-charts-BofaT7g3.js";import"./file-CU8GT6kg.js";import"./xagentMarkdown-DFQtG115.js";import"./useMembershipStatus-CINdA73W.js";import"./DateUtils-CZ2rt_kb.js";import"./membershipPlans-DBoM_yKq.js";import"./vendor-vxe-D9xzQ_Nx.js";/* empty css */const Zt=["aria-label"],es=["onClick"],ts=Pe({__name:"WelcomeQuickPromptsPanel",emits:["apply"],setup(W,{emit:P}){const X=P,{t:u}=Ue(),G=Y(()=>[u("xAgentInput.quickPrompts.salesOverviewYesterday"),u("xAgentInput.quickPrompts.topVideosYesterday"),u("xAgentInput.quickPrompts.replicateTikTokLink"),u("xAgentInput.quickPrompts.salesOverviewUsLastWeek"),u("xAgentInput.quickPrompts.topVideosJapanDayBeforeYesterday"),u("xAgentInput.quickPrompts.extractSellingPoints"),u("xAgentInput.quickPrompts.analyzeViralVideo"),u("xAgentInput.quickPrompts.rewriteForSales"),u("xAgentInput.quickPrompts.generateScript")]);return(b,B)=>(d(),v("div",{class:"flex flex-wrap justify-center gap-2 py-5",role:"list","aria-label":l(u)("xAgent.moreDirections")},[(d(!0),v(_e,null,He(G.value,M=>(d(),v("button",{key:M,type:"button",class:"inline-flex min-w-0 cursor-pointer items-center rounded-full border border-slate-200 bg-white/80 px-4 py-2 text-left text-[13px] text-[#2D3348] shadow-sm transition-[background-color,border-color,box-shadow,color] duration-200 hover:border-[#6A5CFF]/25 hover:bg-white hover:shadow-[0_6px_18px_rgba(13,19,33,0.08)] hover:text-[#0D1321] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25",onClick:_=>X("apply",M)},y(M),9,es))),128))],8,Zt))}}),ss={class:"flex items-center gap-1"},os=Pe({__name:"HeaderRightActions",setup(W){return(P,X)=>(d(),v("div",ss,[T(Rt),T(Ut,{position:"header",class:"ml-1"})]))}}),ns={class:"border-b border-gray-200/80 bg-white/85 supports-[backdrop-filter]:bg-white/75"},as={class:"flex h-[52px] w-full items-center justify-between gap-4 px-4 md:px-6"},ls={class:"flex min-w-0 items-center gap-2"},is=["title"],rs={class:"truncate"},us=["title"],cs=Pe({__name:"XAgentHeader",props:{selectedChatId:{},currentViewTitle:{}},emits:["go-home","rename-current-chat"],setup(W,{emit:P}){const X=P,{t:u}=Ue(),G=Xe(),b=()=>{X("go-home"),G.push("/xagent")};return(B,M)=>(d(),v("header",ns,[o("div",as,[o("div",ls,[W.selectedChatId?(d(),v("button",{key:1,type:"button",class:"min-w-0 truncate text-left text-[15px] font-semibold text-[#0D1321] transition-colors hover:text-[#2D3348] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25 md:text-base",title:W.currentViewTitle,onClick:b},[o("h1",rs,y(W.currentViewTitle),1)],8,is)):(d(),lt(Vt,{key:0,class:"hidden md:block"})),W.selectedChatId?(d(),v("button",{key:2,type:"button",class:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-gray-400 transition-colors hover:bg-[#EDF9FF] hover:text-[#6A5CFF] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25",title:l(u)("xAgent.renameTitle"),onClick:M[0]||(M[0]=_=>X("rename-current-chat"))},[...M[1]||(M[1]=[o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},[o("path",{d:"M12 20H21",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{d:"M16.5 3.5C17.3284 2.67157 18.6716 2.67157 19.5 3.5C20.3284 4.32843 20.3284 5.67157 19.5 6.5L7 19L3 20L4 16L16.5 3.5Z",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,us)):te("",!0)]),T(os)])]))}}),ds={class:"relative flex h-full flex-col"},fs=["title"],ps=["src"],vs={class:"truncate text-[15px] font-semibold leading-5 text-[#0D1321]"},hs=["aria-label"],gs=["src"],ms=["title"],xs={class:"flex-1 min-h-0 overflow-y-auto px-2 pb-3"},bs={class:"mb-1"},ys={class:"flex h-7 w-7 items-center justify-center rounded-lg text-[#2D3348]"},ks={class:"mb-1.5 px-3 text-[12px] font-normal tracking-[0.02em] text-gray-400"},ws={key:0,class:"px-3 py-4 text-sm text-gray-400"},Cs={key:1,class:"px-3 py-4 text-sm text-gray-400"},_s={key:2,class:"space-y-0.5 px-1"},As=["onClick"],Is=["placeholder","disabled","onKeydown","onBlur"],Ss=["title","disabled","onClick"],Ts=["title","disabled"],Fs={key:1,class:"flex items-center justify-between gap-2"},$s={class:"relative min-w-0 flex-1"},Ds=["title"],Es=["title","aria-label","disabled"],Ms={class:"min-w-[132px] rounded-xl border border-gray-200 bg-white p-1 shadow-lg"},Ps=["disabled","onClick"],Ns=["disabled","onClick"],js={class:"px-3 pb-4 pt-1"},Ls=["disabled"],Rs={key:0},Us={key:1},Vs={key:1,class:"text-center text-[11px] text-gray-400"},zs={key:1,class:"flex flex-1 min-h-0 flex-col px-2 py-6"},qs=["aria-label"],Bs=["aria-label"],Hs={class:"space-y-4"},Js={class:"flex items-start gap-3 rounded-2xl border border-red-100 bg-red-50 px-4 py-3"},Os={class:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-100 text-red-600"},Ws={class:"min-w-0"},Ks={class:"text-sm font-medium text-[#0D1321]"},Xs=["title"],Gs={class:"flex justify-end gap-3 border-t border-gray-200 pt-4"}
1,Qs=["disabled"],Ys=["disabled"],Zs={key:0,class:"h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},eo="/video-post",to=20,at="xagent_sidebar_width",so=72,oo=248,no=192,ao=460,lo=Pe({__name:"AgentAside",props:{selectedChatId:{default:""}},emits:["select","new-draft","titles-change","title-updated","chat-deleted"],setup(W,{expose:P,emit:X}){const{t:u}=Ue(),{showMessage:G}=Ge(),b=Xe(),B="/daren360-favicon.png",M=Y(()=>{const r=u("logo.name").trim();return`${/ai$/i.test(r)?r.replace(/ai$/i," AI"):`${r} AI`} Agent`}),_=W,$=X,F=k(!1),I=k(oo),U=k(!1),h=k(!1),V=k(1),Q=k(0),J=k(!1),f=k([]),H=k(""),g=k(""),A=k(!1),D=k(""),R=k(!1),ne=k(""),ae=k(null);let le=null;const Ae=Y(()=>F.value?so:I.value),Ne=Y(()=>{const r=`${Ae.value}px`;return{width:r,minWidth:r,maxWidth:r,flexBasis:r}}),Ie=Y(()=>V.value<Q.value),ce=Y(()=>f.value.map(r=>({chatId:r.chatId,title:n(r.title),displayTitle:i(n(r.title),30)}))),Se=Y(()=>{const r=f.value.find(c=>c.chatId===ne.value);return n(r==null?void 0:r.title)}),ie=()=>{F.value=!F.value},be=()=>{b.push(eo)},ye=r=>Math.min(ao,Math.max(no,r)),je=r=>{try{localStorage.setItem(at,String(r))}catch{}},Te=r=>{I.value=ye(r),je(I.value)},ve=r=>r.replace(/\s+/g," ").trim(),n=r=>ve(r||"")||u("xAgent.untitledChat"),i=(r,c=48)=>{const x=ve(r);return x?x.length>c?`${x.slice(0,c)}...`:x:u("xAgent.noContent")},a=r=>{if(F.value)return;r.preventDefault(),r.stopPropagation();const c=r.clientX,x=I.value;J.value=!0,document.body.style.userSelect="none",document.body.style.cursor="col-resize";const S=ge=>{Te(x+(ge.clientX-c))},K=()=>{J.value=!1,document.body.style.userSelect="",document.body.style.cursor="",document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",K),document.removeEventListener("pointercancel",K),le=null};le=K,document.addEventListener("pointermove",S),document.addEventListener("pointerup",K),document.addEventListener("pointercancel",K)},N=(r,c=!1)=>{if(!c){f.value=[...r];return}const x=[...f.value],S=new Map(x.map((K,ge)=>[K.chatId,ge]));for(const K of r){const ge=S.get(K.chatId);if(ge==null){S.set(K.chatId,x.length),x.push(K);continue}x[ge]=K}f.value=x},O=()=>{!f.value.length||!_.selectedChatId||f.value.some(c=>c.chatId===_.selectedChatId)},Z=async(r=1,c=!1)=>{if(!(U.value||h.value)){c?h.value=!0:U.value=!0;try{const x=await Ft({pageNumber:r,pageSize:to});N(x.list||[],c),V.value=x.pageNumber||r,Q.value=x.totalPages||0,c||O()}catch(x){console.error("å è½½ä¼è¯å表失败:",x),G("å è½½ä¼è¯å表失败ï¼è¯·ç¨åéè¯","error")}finally{U.value=!1,h.value=!1}}},z=async()=>{Ie.value&&await Z(V.value+1,!0)},Fe=()=>{$("new-draft")},Je=r=>{r!==_.selectedChatId&&$("select",r)},Ve=async r=>{var x,S;const c=f.value.find(K=>K.chatId===r);!c||A.value||D.value===r||(H.value=r,g.value=n(c.title),await Me(),(x=ae.value)==null||x.focus(),(S=ae.value)==null||S.select())},he=()=>{A.value||(H.value="",g.value="")},Le=async r=>{const c=ve(g.value);if(!c){G(u("xAgent.renameTitleRequired"),"warning");return}const x=f.value.find(S=>S.chatId===r);if(!x){he();return}if(n(x.title)===c){he();return}A.value=!0;try{await $t({chatId:r,title:c}),x.title=c,$("title-updated",{chatId:r,title:c}),G(u("xAgent.renameTitleSuccess"),"success"),he()}catch(S){console.error("æ´æ°ä¼è¯æ é¢å¤±è´¥:",S),G(u("xAgent.renameTitleFailed"),"error")}finally{A.value=!1}},Oe=(r,c)=>{if(r.key==="Enter"){r.preventDefault(),Le(c);return}r.key==="Escape"&&(r.preventDefault(),he())},ze=r=>{A.value||D.value||(ne.value=r,R.value=!0)},$e=()=>{D.value||(R.value=!1,ne.value="")},Re=()=>{R.value=!1,ne.value=""},qe=async()=>{const r=ne.value;if(!(!r||A.value||D.value)){D.value=r,H.value===r&&he();try{await Dt({chatId:r}),$("chat-deleted",{chatId:r}),await ke(),G(u("xAgent.deleteChatSuccess"),"success"),Re()}catch(c){console.error("å é¤ä¼è¯å¤±è´¥:",c),G(u("xAgent.deleteChatFailed"),"error")}finally{D.value=""}}},ke=async()=>{V.value=1,Q.value=0,f.value=[],await Z(1,!1)};return it(()=>{try{const r=Number(localStorage.getItem(at));Number.isFinite(r)&&r>0&&(I.value=ye(r))}catch{}Z(1,!1)}),kt(()=>{le&&le()}),re(f,r=>{$("titles-change",r.map(c=>({chatId:c.chatId,title:n(c.title)})))},{deep:!0,immediate:!0}),P({reload:ke,startEditTitle:Ve}),(r,c)=>(d(),v(_e,null,[o("aside",{class:"xagent-sidebar border-r border-gray-200/70 bg-[#F7F8FA]",style:wt(Ne.value)},[o("div",ds,[o("div",{class:ee(["relative flex items-center justify-between px-4 pt-2.5",F.value?"justify-center px-2":""])}
1,[F.value?te("",!0):(d(),v("button",{key:0,type:"button",onClick:be,class:"flex min-w-0 flex-1 items-center gap-2 rounded-2xl p-1 transition-colors hover:bg-black/[0.03]",title:M.value},[o("img",{src:l(B),alt:"Logo",class:"h-6 w-6 object-contain opacity-90"},null,8,ps),o("span",vs,y(M.value),1)],8,fs)),F.value?(d(),v("button",{key:1,type:"button",onClick:ie,class:"group relative mx-auto flex h-10 w-10 items-center justify-center rounded-2xl transition-colors hover:bg-black/[0.03]","aria-label":l(u)("sidebar.expandSidebar")},[o("img",{src:l(B),alt:"Logo",class:"h-7 w-7 object-contain opacity-95 transition-opacity group-hover:opacity-0"},null,8,gs),c[6]||(c[6]=o("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"21",height:"21",class:"absolute opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":"true"},[o("path",{d:"M810.666667 85.333333H213.333333C140.8 85.333333 85.333333 140.8 85.333333 213.333333v597.333334c0 72.533333 55.466667 128 128 128h597.333334c72.533333 0 128-55.466667 128-128V213.333333c0-72.533333-55.466667-128-128-128zM170.666667 810.666667V213.333333c0-25.6 17.066667-42.666667 42.666666-42.666666h128v682.666666H213.333333c-25.6 0-42.666667-17.066667-42.666666-42.666666z m682.666666 0c0 25.6-17.066667 42.666667-42.666666 42.666666h-384V170.666667h384c25.6 0 42.666667 17.066667 42.666666 42.666666v597.333334z",fill:"currentColor"})],-1)),T(Ke,{activator:"parent",location:"end","content-class":"xagent-rail-tooltip"},{default:oe(()=>[xe(y(l(u)("sidebar.expandSidebar")),1)]),_:1})],8,hs)):(d(),v("button",{key:2,type:"button",class:"flex h-8 w-8 items-center justify-center rounded-xl border border-transparent bg-transparent text-gray-400 transition-colors hover:bg-black/[0.03] hover:text-gray-700",onClick:ie,title:l(u)("sidebar.collapseSidebar")},[(d(),v("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",class:ee(["transition-transform",{"rotate-180":F.value}])},[...c[7]||(c[7]=[o("path",{d:"M810.666667 85.333333H213.333333C140.8 85.333333 85.333333 140.8 85.333333 213.333333v597.333334c0 72.533333 55.466667 128 128 128h597.333334c72.533333 0 128-55.466667 128-128V213.333333c0-72.533333-55.466667-128-128-128zM170.666667 810.666667V213.333333c0-25.6 17.066667-42.666667 42.666666-42.666666h128v682.666666H213.333333c-25.6 0-42.666667-17.066667-42.666666-42.666666z m682.666666 0c0 25.6-17.066667 42.666667-42.666666 42.666666h-384V170.666667h384c25.6 0 42.666667 17.066667 42.666666 42.666666v597.333334z",fill:"currentColor"},null,-1)])],2))],8,ms))],2),F.value?(d(),v("div",zs,[o("button",{class:"mx-auto flex h-10 w-10 items-center justify-center rounded-2xl text-[#0D1321] transition-colors hover:bg-black/[0.04]",onClick:Fe,"aria-label":l(u)("xAgent.newChatEntry")},[T(pe,{icon:l(st),size:"22"},null,8,["icon"]),T(Ke,{activator:"parent",location:"end","content-class":"xagent-rail-tooltip"},{default:oe(()=>[xe(y(l(u)("xAgent.newChatEntry")),1)]),_:1})],8,qs),c[10]||(c[10]=o("div",{class:"flex-1"},null,-1)),o("button",{class:"mx-auto flex h-10 w-10 items-center justify-center rounded-2xl text-[#0D1321] transition-colors hover:bg-black/[0.04]",onClick:ie,"aria-label":l(u)("sidebar.expandSidebar")},[T(pe,{icon:l(qt),size:"23"},null,8,["icon"]),T(Ke,{activator:"parent",location:"end","content-class":"xagent-rail-tooltip"},{default:oe(()=>[xe(y(l(u)("sidebar.expandSidebar")),1)]),_:1})],8,Bs)])):(d(),v(_e,{key:0},[o("div",{class:ee(["absolute right-0 top-0 z-20 h-full w-2 cursor-col-resize touch-none select-none",J.value?"bg-[#6A5CFF]/10":"bg-transparent hover:bg-[#6A5CFF]/10"]),onPointerdown:a,title:"ææ½è°æ´å®½åº¦"},[...c[8]||(c[8]=[o("div",{class:"absolute right-0 top-1/2 h-10 w-px -translate-y-1/2 bg-gray-300/80"},null,-1)])],34),c[9]||(c[9]=o("div",{class:"h-2"},null,-1)),o("div",xs,[o("div",bs,[o("button",{class:"flex w-full items-center gap-3 rounded-xl px-3 py-2 text-left text-[15px] font-normal text-[#0D1321] transition-colors hover:bg-black/[0.035]",onClick:Fe},[o("span",ys,[T(pe,{icon:l(st),size:"17"},null,8,["icon"])]),o("span",null,y(l(u)("xAgent.newChatEntry")),1)])]),o("div",ks,y(l(u)("xAgent.recentChats")),1),U.value&&!ce.value.length?(d(),v("div",ws,y(l(u)("xAgent.loadingChats")),1)):ce.value.length?(d(),v("div",_s,[(d(!0),v(_e,null,He(ce.value,x=>(d(),v("div",{key:x.chatId,class:ee(["group cursor-pointer rounded-[18px] px-3 py-2 transition-colors",_.selectedChatId===x.chatId?"bg-[#EDF9FF] text-[#0D1321]":"text-[#2D3348] hover:bg-black/[0.035]"]),onClick:S=>Je(x.chatId)},[H.value===x.chatId?(d(),v("div",{key:0,class:"flex items-center gap-2",onClick:c[3]||(c[3]=ue(()=>{},["stop"]))}
1,[rt(o("input",{ref_for:!0,ref_key:"titleInputRef",ref:ae,"onUpdate:modelValue":c[0]||(c[0]=S=>g.value=S),type:"text",class:"h-8 min-w-0 flex-1 rounded-xl border border-gray-200 bg-white px-3 text-[14px] text-[#0D1321] outline-none ring-0 focus:border-[#6A5CFF]",placeholder:l(u)("xAgent.renameTitlePlaceholder"),disabled:A.value,maxlength:"100",onKeydown:S=>Oe(S,x.chatId),onBlur:S=>Le(x.chatId)},null,40,Is),[[ut,g.value]]),o("button",{type:"button",class:"flex h-8 w-8 items-center justify-center rounded-xl text-green-600 transition-colors hover:bg-green-50 disabled:opacity-60",title:l(u)("xAgent.saveTitle"),disabled:A.value,onMousedown:c[1]||(c[1]=ue(()=>{},["prevent"])),onClick:ue(S=>Le(x.chatId),["stop"])},[T(pe,{icon:l(Bt),size:"16"},null,8,["icon"])],40,Ss),o("button",{type:"button",class:"flex h-8 w-8 items-center justify-center rounded-xl text-gray-500 transition-colors hover:bg-gray-100 disabled:opacity-60",title:l(u)("xAgent.cancelRename"),disabled:A.value,onMousedown:c[2]||(c[2]=ue(()=>{},["prevent"])),onClick:ue(he,["stop"])},[T(pe,{icon:l(Ht),size:"16"},null,8,["icon"])],40,Ts)])):(d(),v("div",Fs,[o("div",$s,[o("div",{class:"truncate text-[15px] font-normal leading-6",title:x.title},y(x.displayTitle),9,Ds),T(Wt,{location:"bottom end",origin:"top right",offset:6,"close-on-content-click":!0},{activator:oe(({props:S})=>[o("button",Ct({ref_for:!0},S,{type:"button",class:["absolute right-0 top-1/2 z-10 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-lg text-gray-500 opacity-0 transition hover:bg-[#EDF9FF] hover:text-[#6A5CFF] focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25 disabled:cursor-not-allowed disabled:opacity-60 group-hover:opacity-100",_.selectedChatId===x.chatId?"opacity-100":""],title:l(u)("xAgent.moreActions"),"aria-label":l(u)("xAgent.moreActions"),disabled:D.value===x.chatId,onClick:c[4]||(c[4]=ue(()=>{},["stop"]))}),[T(pe,{icon:l(Ot),size:"18"},null,8,["icon"])],16,Es)]),default:oe(()=>[o("div",Ms,[o("button",{type:"button",class:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[14px] text-gray-700 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",disabled:D.value===x.chatId,onClick:S=>Ve(x.chatId)},[T(pe,{icon:l(Jt),size:"16"},null,8,["icon"]),o("span",null,y(l(u)("xAgent.renameTitle")),1)],8,Ps),o("button",{type:"button",class:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[14px] text-red-600 transition-colors hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-50",disabled:D.value===x.chatId,onClick:S=>ze(x.chatId)},[T(pe,{icon:l(ot),size:"16"},null,8,["icon"]),o("span",null,y(l(u)("xAgent.deleteChat")),1)],8,Ns)])]),_:2},1024)])]))],10,As))),128))])):(d(),v("div",Cs,y(l(u)("xAgent.noChatHistory")),1))]),o("div",js,[Ie.value?(d(),v("button",{key:0,class:"flex h-8.5 w-full items-center justify-center rounded-xl bg-transparent text-sm font-normal text-gray-400 transition-colors hover:bg-black/[0.03] hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-60",disabled:h.value,onClick:z},[h.value?(d(),v("span",Rs,"å è½½ä¸...")):(d(),v("span",Us,"æ¥çæ´å¤"))],8,Ls)):(d(),v("div",Vs," æ²¡ææ´å¤ä¼è¯äº "))])],64))])],4),T(l(ct),{modelValue:R.value,"onUpdate:modelValue":c[5]||(c[5]=x=>R.value=x),title:l(u)("xAgent.deleteChat"),size:"small","show-close-button":!D.value,"close-on-backdrop-click":!D.value,onClose:$e},{default:oe(()=>[o("div",Hs,[o("div",Js,[o("div",Os,[T(pe,{icon:l(ot),size:"20"},null,8,["icon"])]),o("div",Ws,[o("p",Ks,y(l(u)("xAgent.deleteChatConfirm")),1),o("p",{class:"mt-1 truncate text-sm text-red-700",title:Se.value},y(Se.value),9,Xs)])]),o("div",Gs,[o("button",{type:"button",class:"rounded-xl border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",disabled:!!D.value,onClick:$e},y(l(u)("common.cancel")),9,Qs),o("button",{type:"button",class:"inline-flex items-center gap-2 rounded-xl border border-red-600 bg-red-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50",disabled:!!D.value,onClick:qe},[D.value?(d(),v("svg",Zs,[...c[11]||(c[11]=[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),o("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"},null,-1)])])):te("",!0),o("span",null,y(D.value?l(u)("xAgent.deletingChat"):l(u)("xAgent.deleteChat")),1)],8,Ys)])])]),_:1},8,["modelValue","title","show-close-button","close-on-backdrop-click"])],64))}}),io=Qe(lo,[["__scopeId","data-v-46380a76"]]),ro=["aria-label"],uo={class:"flex shrink-0 items-start justify-between gap-3 border-b border-gray-200/70 px-5 py-4"},co={class:"min-w-0"},fo={class:"text-[17px] font-semibold tracking-tight text-gray-900"},po={class:"mt-1 text-[12px] leading-5 text-gray-500"},vo=["aria-label"],ho={class:"flex shrink-0 items-center justify-between gap-2 px-5 py-3"},go={class:"inline-flex items-center gap-1.5 rounded-full bg-purple-50 px-2.5 py-0.5 text-[11px] font-medium text-purple-700"},mo=["disabled"],xo={class:"min-h-0 flex-1 overflow-y-auto px-5 pb-5"},bo={key:0,class:"flex h-40 items-center justify-center text-sm text-gray-400"},yo={key:1,class:"flex h-56 flex-col items-center justify-center text-center"},ko={class:"text-[14px] font-medium text-gray-700"},wo={class:"mt-1 max-w-[260px] text-[12px] leading-5 text-gray-400"},Co={key:2,class:"space-y-2.5"},_o=["onClick"],Ao={class:"min-w-0 flex-1"},Io={class:"flex items-center gap-2"},So={class:"truncate text-[14px] font-medium text-gray-900"},To=["title"],Fo={key:0,class:"border-t border-gray-100 p-4"},$o={class:"space-y-4"},Do={class:"mb-1.5 block text-[12px] font-medium text-gray-600"},Eo=["onUpdate:modelValue","placeholder"],Mo={class:"mb-1.5 block text-[12px] font-medium text-gray-600"},Po=["value","placeholder","onInput"],No={class:"flex items-center justify-between gap-2 pt-1"},jo={class:"flex items-center gap-2"},Lo=["disabled","title","onClick"],Ro={key:0,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Uo={key:1,class:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Vo=["disabled","onClick"],zo=["disabled","onClick"],qo={key:0,class:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Bo={class:"py-4 text-sm text-gray-600"},Ho={class:"flex w-full justify-end gap-3"},Jo=Pe({__name:"NotificationChannelsDrawer",props:{modelValue:{type:Boolean,default:!1},pushContent:{default:""},autoCreateOnOpen:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(W,{emit:P}){const X=/^https:\/\/open\.(feishu\.cn|larksuite\.com)\/open-apis\/bot\/v2\/hook\/.+/,u=W,G=P,{t:b}=Ue(),{showMessage:B}=Ge(),M=["AGENT_SCHEDULE"],_=k([]),$=k(null),F=k(!1),I=k(!1),U=k(null),h=k(!1),V=k(null),Q=k(!1),J=k(null),f=k({}),H=k(null),g=n=>n.id&&n.id>0?`id:${n.id}`:`draft:${n._clientId||""}`,A=n=>!n.id||n.id<=0,D=n=>{const i=new Set(n!=null&&n.length?n:M);return i.add("AGENT_SCHEDULE"),Array.from(i)},R=n=>{var a;const i=(((a=n.config)==null?void 0:a.webhookUrl)||"").trim();return i?X.test(i)?"":b("notificationChannels.fieldWebhookInvalid"):""},ne=n=>{var a;if(A(n))return!0;const i=n._original;return i?n.channelName!==i.channelName||(((a=n.config)==null?void 0:a.webhookUrl)||"")!==i.webhookUrl:!1},ae=n=>{var a,N;return I.value||h.value||!((a=n.channelName)!=null&&a.trim())||!(((N=n.config)==null?void 0:N.webhookUrl)||"").trim()||R(n)?!1:ne(n)},le=n=>{var i;n.subscriptions=D(n.subscriptions),n._original={channelName:n.channelName,webhookUrl:((i=n.config)==null?void 0:i.webhookUrl)||"",status:1,subscriptions:[...M]}},Ae=(n,i)=>{n.config?n.config.webhookUrl=i:n.config={webhookUrl:i}},Ne=n=>{const i=g(n);_.value=_.value.filter(a=>g(a)!==i),$.value===i&&($.value=_.value.length?g(_.value[0]):null)},Ie=n=>{const i=g(n);$.value=$.value===i?null:i},ce=async()=>
1{if(!F.value){F.value=!0;try{const i=((await Yt({pageNumber:1,pageSize:100})).list||[]).map(a=>{var N;return{...a,config:a.config||{webhookUrl:""},subscriptions:D(a.subscriptions),_original:{channelName:a.channelName,webhookUrl:((N=a.config)==null?void 0:N.webhookUrl)||"",status:1,subscriptions:[...M]}}});_.value=i,i.length&&!$.value&&($.value=g(i[0]))}catch(n){console.error("å è½½æ¨éæ¸ é失败:",n),B(b("notificationChannels.loadFailed"),"error")}finally{F.value=!1}}},Se=async n=>{const i=g(n);if(!(H.value||!u.pushContent)){H.value=i,delete f.value[i];try{const a=await Kt({id:n.id,content:u.pushContent});f.value={...f.value,[i]:{success:(a==null?void 0:a.success)??!0,message:(a==null?void 0:a.message)||"æ¨éæå"}},(a==null?void 0:a.success)!==!1?B("æ¨éæå","success"):B(a.message||"æ¨é失败","error")}catch(a){const N=(a==null?void 0:a.message)||"æ¨é失败";f.value={...f.value,[i]:{success:!1,message:N}},B(N,"error")}finally{H.value=null}}},ie=()=>{const n=_.value.find(N=>A(N));if(n){$.value=g(n);return}const i=`new-${Date.now()}`,a={id:0,channelName:"",channelType:"feishu_robot",config:{webhookUrl:""},status:1,createdAt:"",updatedAt:"",subscriptions:[...M],_clientId:i};_.value=[a,..._.value],$.value=g(a)},be=()=>{h.value||(Q.value=!1,J.value=null)},ye=async n=>{if(!(I.value||h.value)){if(A(n)){Ne(n);return}J.value=n,Q.value=!0}},je=async()=>{const n=J.value;if(!(!n||I.value||h.value)){h.value=!0,V.value=g(n);try{await Xt(n.id),B(b("notificationChannels.deleteSuccess"),"success");const i=g(n);Q.value=!1,J.value=null,await ce(),$.value===i&&($.value=_.value.length?g(_.value[0]):null)}catch(i){console.error("å 餿¨éæ¸ é失败:",i),B((i==null?void 0:i.message)||b("notificationChannels.deleteFailed"),"error")}finally{h.value=!1,V.value=null}}},Te=async n=>{var N;if(!ae(n)||h.value)return;const i=n.channelName.trim(),a=(((N=n.config)==null?void 0:N.webhookUrl)||"").trim();I.value=!0,U.value=g(n);try{if(A(n)){const z={channelName:i,status:1,config:{webhookUrl:a},subscriptions:[...M]};await Gt(z),B(b("notificationChannels.createSuccess"),"success")}else{const z={id:n.id,channelName:i,status:1,config:{webhookUrl:a},subscriptions:[...M]};await Qt(z),B(b("notificationChannels.saveSuccess"),"success")}const O=g(n);await ce();const Z=_.value.find(z=>g(z)===O);Z?$.value=g(Z):A(n)?_.value.length&&($.value=g(_.value[0])):$.value=null}catch(O){console.error("ä¿åæ¨éæ¸ é失败:",O),B((O==null?void 0:O.message)||b("notificationChannels.saveFailed"),"error")}finally{I.value=!1,U.value=null}},ve=()=>{I.value||h.value||(be(),G("update:modelValue",!1))};return re(Q,n=>{!n&&!h.value&&(J.value=null)}),re(()=>u.modelValue,async n=>{n?(f.value={},await ce(),u.autoCreateOnOpen&&ie()):(be(),f.value={},$.value=null,_.value=_.value.filter(i=>!A(i)),_.value.forEach(le))}),(n,i)=>(d(),lt(_t,{to:"body"},[T(tt,{name:"drawer-fade"},{default:oe(()=>[W.modelValue?(d(),v("div",{key:0,class:"drawer-mask",onClick:ve})):te("",!0)]),_:1}),T(tt,{name:"drawer-slide"},{default:oe(()=>[W.modelValue?(d(),v("aside",{key:0,class:"drawer-panel",role:"dialog","aria-label":l(b)("notificationChannels.title"),onClick:i[0]||(i[0]=ue(()=>{},["stop"]))},[o("header",uo,[o("div",co,[o("h2",fo,y(l(b)("notificationChannels.title")),1),o("p",po,y(l(b)("notificationChannels.description")),1)]),o("button",{type:"button",class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-gray-400 transition-colors hover:bg-black/[0.04] hover:text-gray-700","aria-label":l(b)("notificationChannels.close"),onClick:ve},[...i[2]||(i[2]=[o("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o("path",{d:"M18 6 6 18M6 6l12 12"})],-1)])],8,vo)]),o("div",ho,[o("span",go,[i[3]||(i[3]=o("span",{class:"h-1.5 w-1.5 rounded-full bg-purple-500"},null,-1)),xe(" "+y(l(b)("notificationChannels.typeLabel")),1)]),o("button",{type:"button",class:"inline-flex items-center gap-1.5 rounded-xl border border-purple-200 bg-purple-50 px-3 py-1.5 text-[13px] font-medium text-purple-700 transition-colors hover:border-purple-300 hover:bg-purple-100 disabled:cursor-not-allowed disabled:opacity-60",disabled:I.value||F.value,onClick:ie},[i[4]||(i[4]=o("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o("path",{d:"M12 5v14M5 12h14"})],-1)),o("span",null,y(l(b)("notificationChannels.addChannel")),1)],8,mo)]),o("div",xo,[F.value&&!_.value.length?(d(),v("div",bo,y(l(b)("notificationChannels.loading")),1)):_.value.length?(d(),v("ul",Co,[(d(!0),v(_e,null,He(_.value,a=>{var N,O,Z;return d(),v("li",{key:g(a),class:ee(["overflow-hidden rounded-2xl border bg-white transition-colors",$.value===g(a)?"border-purple-200 shadow-[0_2px_10px_rgba(106,92,255,0.06)]":"border-gray-200/80 hover:border-gray-300"])},[o("button",{type:"button",class:"flex w-full items-center justify-between gap-3 px-4 py-3 text-left",onClick:z=>Ie(a)},[o("div",Ao,[o("div",Io,[i[6]||(i[6]=o("span",{class:"h-2 w-2 shrink-0 rounded-full bg-green-500"},null,-1)),o("p",So,y(a.channelName||l(b)("notificationChannels.unnamed")),1)]),o("p",{class:"mt-1 truncate text-[12px] text-gray-400",title:((N=a.config)==null?void 0:N.webhookUrl)||""},y((O=a.config)!=null&&O.webhookUrl?a.config.webhookUrl:l(b)("notificationChannels.noWebhook")),9,To)]),(d(),v("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:ee(["shrink-0 text-gray-400 transition-transform",$.value===g(a)?"rotate-180":""]),"aria-hidden":"true"},[...i[7]||(i[7]=[o("path",{d:"m6 9 6 6 6-6"},null,-1)])],2))],8,_o),$.value===g(a)?(d(),v("div",Fo,[o("div",$o,[o("div",null,[o("label",Do,y(l(b)("notificationChannels.fieldName")),1),rt(o("input",{"onUpdate:modelValue":z=>a.channelName=z,type:"text",placeholder:l(b)("notificationChannels.fieldNamePlaceholder"),class:"w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-[13px] text-gray-900 transition-colors focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-200",maxlength:40}
1,null,8,Eo),[[ut,a.channelName]])]),o("div",null,[o("label",Mo,y(l(b)("notificationChannels.fieldWebhook")),1),o("input",{value:((Z=a.config)==null?void 0:Z.webhookUrl)||"",type:"url",placeholder:l(b)("notificationChannels.fieldWebhookPlaceholder"),class:ee(["w-full rounded-xl border px-3 py-2 font-mono text-[12px] text-gray-900 transition-colors focus:outline-none focus:ring-2",R(a)?"border-red-300 bg-red-50 focus:border-red-400 focus:ring-red-200":"border-gray-200 bg-white focus:border-purple-500 focus:ring-purple-200"]),onInput:z=>Ae(a,z.target.value)},null,42,Po),o("p",{class:ee(["mt-1.5 text-[11px] leading-4",R(a)?"text-red-500":"text-gray-400"])},y(R(a)||l(b)("notificationChannels.fieldWebhookHint")),3)]),o("div",No,[o("div",jo,[o("button",{type:"button",class:ee(["inline-flex items-center gap-1.5 rounded-xl border px-3 py-1.5 text-[12px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",W.pushContent?"border-[#6A5CFF] bg-[#6A5CFF] text-white hover:bg-[#5B4DFF]":"cursor-not-allowed border-gray-200 bg-gray-50 text-gray-400"]),disabled:!W.pushContent||H.value===g(a),title:W.pushContent?"":l(b)("notificationChannels.comingSoonHint"),onClick:ue(z=>Se(a),["stop"])},[H.value!==g(a)?(d(),v("svg",Ro,[...i[8]||(i[8]=[o("path",{d:"m5 12 5 5L20 7"},null,-1)])])):(d(),v("svg",Uo,[...i[9]||(i[9]=[o("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"3","stroke-opacity":"0.25"},null,-1),o("path",{d:"M22 12a10 10 0 0 1-10 10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"},null,-1)])])),xe(" "+y(H.value===g(a)?"æ¨éä¸â¦":l(b)("notificationChannels.testPush")),1)],10,Lo),f.value[g(a)]?(d(),v("div",{key:0,class:ee(["rounded-lg px-2.5 py-1.5 text-[12px] leading-5",f.value[g(a)].success?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-700"])},y(f.value[g(a)].message||(f.value[g(a)].success?"æ¨éæå":"æ¨é失败")),3)):te("",!0),o("button",{type:"button",class:ee(["inline-flex items-center gap-1.5 rounded-xl border px-3 py-1.5 text-[12px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",A(a)?"border-gray-200 bg-white text-gray-600 hover:bg-gray-50":"border-red-200 bg-red-50 text-red-600 hover:bg-red-100"]),disabled:I.value||h.value,onClick:ue(z=>ye(a),["stop"])},[i[10]||(i[10]=o("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M6 6l1 14a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-14"})],-1)),xe(" "+y(h.value&&V.value===g(a)?l(b)("notificationChannels.deleting"):A(a)?l(b)("notificationChannels.discardDraft"):l(b)("notificationChannels.delete")),1)],10,Vo)]),o("button",{type:"button",class:"inline-flex items-center gap-1.5 rounded-xl bg-[#6A5CFF] px-4 py-1.5 text-[13px] font-medium text-white shadow-sm transition-colors hover:bg-[#5B4DFF] disabled:cursor-not-allowed disabled:bg-purple-200",disabled:!ae(a),onClick:ue(z=>Te(a),["stop"])},[I.value&&U.value===g(a)?(d(),v("svg",qo,[...i[11]||(i[11]=[o("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"3","stroke-opacity":"0.25"},null,-1),o("path",{d:"M22 12a10 10 0 0 1-10 10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"},null,-1)])])):te("",!0),o("span",null,y(I.value&&U.value===g(a)?l(b)("notificationChannels.saving"):A(a)?l(b)("notificationChannels.create"):l(b)("notificationChannels.save")),1)],8,zo)])])])):te("",!0)],2)}),128))])):(d(),v("div",yo,[i[5]||(i[5]=o("div",{class:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-gray-100 text-gray-400"},[o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 0 1-3.46 0"})])],-1)),o("p",ko,y(l(b)("notificationChannels.emptyTitle")),1),o("p",wo,y(l(b)("notificationChannels.emptyDesc")),1)]))])],8,ro)):te("",!0)]),_:1}),T(l(ct),{modelValue:Q.value,"onUpdate:modelValue":i[1]||(i[1]=a=>Q.value=a),title:l(b)("notificationChannels.delete"),size:"small"},{footer:oe(()=>[o("div",Ho,[T(l(nt),{variant:"secondary",class:"flex-1",disabled:h.value,onClick:be},{default:oe(()=>[xe(y(l(b)("common.cancel")),1)]),_:1},8,["disabled"]),T(l(nt),{variant:"primary",class:"flex-1",disabled:h.value,onClick:je},{default:oe(()=>[xe(y(h.value?l(b)("notificationChannels.deleting"):l(b)("common.confirm")),1)]),_:1},8,["disabled"])])]),default:oe(()=>[o("div",Bo,y(l(b)("notificationChannels.deleteConfirm")),1)]),_:1},8,["modelValue","title"])]))}}),Oo=Qe(Jo,[["__scopeId","data-v-8af1a308"]]),Wo={class:"xagent-shell"},Ko={class:"xagent-main"},Xo={class:"xagent-page-wrapper"},Go={class:"relative flex min-h-0 flex-1 flex-col bg-[radial-gradient(circle_at_top,#EDF9FF_0%,#ffffff_40%,#F7F8FA_100%)]"},Qo={key:0,class:"flex flex-1 items-center justify-center overflow-y-auto px-4 py-10 md:px-6"},Yo={class:"w-full max-w-3xl text-center"},Zo={class:"mb-8 flex flex-col items-center"},en={class:"text-3xl font-semibold tracking-tight text-gray-900 md:text-4xl"},tn={key:1,class:"flex flex-1 items-center justify-center min-h-0"},sn={class:"px-4 py-8 text-center",role:"status","aria-live":"polite"},on={class:"text-sm text-gray-500"},nn={class:"mx-auto flex max-w-5xl flex-col gap-6 pb-8"},an={key:0,class:"w-full max-w-[820px] min-w-0"},ln={key:1,class:"flex max-w-[85%] min-w-0 flex-col items-end"},rn={class:"min-w-0 rounded-[24px] bg-[#F3F3F3] px-4 py-3 text-[#0D1321]"},un=["src"],cn={key:1,class:"user-content"},dn={key:0,class:"mt-2 flex items-center gap-2"},fn=["title","onClick"],pn=["title","onClick"],vn={key:0,class:"flex flex-col items-start gap-2"},hn={class:"px-1 text-[11px] font-medium text-[#6A5CFF]"},gn={key:3,class:"bg-white/70 px-4 pb-2 pt-3 supports-[backdrop-filter]:bg-white/60 md:px-6"},mn={class:"mx-auto max-w-5xl"},xn={class:"mt-2 text-center text-[11px] text-gray-400"},bn=5e3,yn=Pe({__name:"XAgent",setup(W){const P=St(),X=Xe(),{t:u}=Ue(),G=zt(),b=k(null),B=k(null),M=k(null),_=k(!1),$=k(""),F=k(""),I=k(!1);let U=null;const h={queue:"",timer:null,entry:null,fetchCompleted:!1,displayStopped:!1,onComplete:null},V=()=>
1{if(h.timer&&clearInterval(h.timer),h.timer=null,h.entry&&h.queue&&(h.entry.content+=h.queue),h.queue="",h.entry=null,h.onComplete){const e=h.onComplete;h.onComplete=null,e()}},Q=e=>typeof e=="string"?e:"",J=e=>{if(typeof e!="string")return"";try{return decodeURIComponent(e)}catch{return e}},f=k(Q(P.query.chatId)),H=k({}),g=k({}),A=k({}),D=k({}),R=Y(()=>f.value?g.value[f.value]||[]:[]),ne=Y(()=>!!f.value&&!!A.value[f.value]),ae=Y(()=>!!f.value&&!!D.value[f.value]),le=Y(()=>ne.value&&R.value.length>0),Ae=Y(()=>f.value?ne.value&&!le.value:!ae.value),Ne=Y(()=>f.value&&H.value[f.value]||"çµéAI Agent");function Ie(e){const t=e.trim();t&&F.value.trim()!==t&&(F.value=t)}const ce=()=>{X.push("/xagent")},Se=async()=>{try{await G.getUserInfo(!0)}catch(e){console.warn("å·æ°ç®åä½é¢å¤±è´¥:",e)}},ie=async(e,t="push")=>{const s={...P.query};delete s.chatId,e&&(s.chatId=e),Q(P.query.chatId)!==e&&await X[t]({path:P.path,query:s})},be=["prefillKey","content1","q","newChat","autoSend","schedulePushIntent","scheduleIntentAt"],ye=async()=>{const e={...P.query};let t=!1;for(const s of be)s in e&&(delete e[s],t=!0);t&&await X.replace({path:P.path,query:e})},je=e=>{var s;const t=(s=e.content)==null?void 0:s.trim();if(t)return t;if(e.contentJson&&Object.keys(e.contentJson).length){if("task"in e.contentJson||"taskId"in e.contentJson)return"";const m=e.contentJson.content||e.contentJson.message||e.contentJson.text;return typeof m=="string"&&m.trim()?m.trim():JSON.stringify(e.contentJson,null,2)}return""},Te=e=>{const t=e.contentJson;if(!t||typeof t!="object")return null;const s=t.task;return s&&typeof s=="object"?s:t},ve=e=>{const t=Te(e);if(!t)return null;const s=typeof t.taskId=="string"?t.taskId:"";if(!s)return null;const p=typeof t.taskType=="string"?t.taskType:void 0;return p!=="MATERIAL_ANALYSIS_TASK"?null:{taskId:s,taskType:p,taskStatus:typeof t.taskStatus=="string"?t.taskStatus:void 0}},n=e=>{const t=Te(e);if(!t)return"";const s=t.result;if(!s||typeof s!="object")return"";const p=s.text;return typeof p=="string"?p.trim():""},i=e=>e.map(t=>{const s=ve(t),p=n(t);return{role:t.role==="USER"?"user":"ai",content:je(t),contentJson:t.contentJson,messageId:t.messageId,task:s,isStreaming:!1,taskPolling:!!s&&!Z.has(s.taskStatus||"")&&!p,taskSyncedStatus:p&&(s==null?void 0:s.taskStatus)||null,taskSyncing:!1,taskDetailLoaded:!!p}}).filter(t=>t.content.length>0||!!t.task),a=()=>f.value?(g.value[f.value]||(g.value[f.value]=[]),g.value[f.value]):[],N=e=>{const t=e[e.length-1];return(t==null?void 0:t.role)==="ai"?t:null},O=new Map,Z=new Set(["COMPLETED","FAILED"]),z=e=>{var t;return((t=e.task)==null?void 0:t.taskId)||e.messageId||""},Fe=e=>{const t=O.get(e);t&&(clearTimeout(t),O.delete(e))},Je=()=>{for(const e of O.keys())Fe(e)},Ve=(e,t)=>{var p,m,E,C;return{text:(t==null?void 0:t.trim())||((m=(p=e.result)==null?void 0:p.content)==null?void 0:m.trim())||((E=e.reason)==null?void 0:E.trim())||((C=e.aiPrompts)==null?void 0:C.trim())||JSON.stringify(e.analysisResult??{},null,2),structured:e.analysisResult??{}}},he=(e,t)=>{if(!t.trim())return;if(!e.contentJson||typeof e.contentJson!="object"){e.contentJson={task:{result:{text:t,structured:{}}}};return}const s={...e.contentJson},p=s.task,m=p&&typeof p=="object"?{...p}:{},E=m.result,C=E&&typeof E=="object"?{...E}:{};C.text=t,"structured"in C||(C.structured={}),m.result=C,s.task=m,e.contentJson=s},Le=(e,t)=>{var m,E,C,q,se,De;const s=((E=(m=e.result)==null?void 0:m.content)==null?void 0:E.trim())||((C=e.aiPrompts)==null?void 0:C.trim());if(s)return s;if(t==="FAILED")return((q=e.reason)==null?void 0:q.trim())||((De=(se=e.result)==null?void 0:se.reason)==null?void 0:De.trim())||"任塿§è¡å¤±è´¥";const p=e.analysisResult??{};return Object.keys(p).length?JSON.stringify(p,null,2):""},Oe=async(e,t,s)=>{var E,C;const p=(E=e.task)==null?void 0:E.taskId,m=e.messageId;if(!(!p||!m)&&!(e.taskSyncedStatus===t&&e.taskDetailLoaded)&&!e.taskSyncing){e.taskSyncing=!0;try{const q=s?Le(s,t):"";q&&!e.content.trim()&&(e.content=q),q&&he(e,q),s&&(e.taskDetailLoaded=!0);const se=(s==null?void 0:s.reason)||((C=s==null?void 0:s.result)==null?void 0:C.reason);await jt({messageId:m,taskId:p,taskStatus:t,...t==="FAILED"&&se?{reason:se}:{},result:Ve(s||{},q||e.content)}),e.taskSyncedStatus=t}catch(q){console.error("æ´æ°æ¶æ¯ä»»å¡ç»æå¤±è´¥:",q)}finally{e.taskSyncing=!1,e.taskPolling=!1}}},ze=(e,t=bn)=>{const s=z(e);if(!s)return;Fe(s),e.taskPolling=!0;const p=setTimeout(()=>{$e(e)},t);O.set(s,p)},$e=async e=>{var p,m,E;const t=(p=e.task)==null?void 0:p.taskId;if(!t)return;const s=z(e);if(s){try{const C=await Nt(t),q=C.status||((m=e.task)==null?void 0:m.taskStatus)||"UNKNOWN";if(e.task={...e.task||{taskId:t},taskId:t,taskStatus:q,taskType:(E=e.task)==null?void 0:E.taskType},Z.has(q)){await Oe(e,q,C),Fe(s),e.taskPolling=!1;return}}catch(C){console.error("轮询任å¡è¯¦æ
失败:",C)}ze(e)}},Re=e=>{var p,m,E,C;if(!((p=e.task)==null?void 0:p.taskId))return;const s=z(e);if(!(!s||O.has(s))){if(Z.has(((m=e.task)==null?void 0:m.taskStatus)||"")){if(((E=e.task)==null?void 0:E.taskType)==="MATERIAL_ANALYSIS_TASK"&&!e.taskDetailLoa
1ded){$e(e);return}if(e.taskSyncedStatus===((C=e.task)==null?void 0:C.taskStatus))return;$e(e);return}ze(e,0)}},qe=()=>{var e;for(const t of R.value)t.role!=="ai"||!((e=t.task)!=null&&e.taskId)||Re(t)};let ke=0;const r=async e=>{if(!e)return;const t=++ke;D.value={...D.value,[e]:!0};try{const s=await Et({chatId:e,pageNumber:1,pageSize:20});if(t!==ke||f.value!==e)return;const p=i(s.list||[]);g.value={...g.value,[e]:p},A.value={...A.value,[e]:!0},qe(),p.length&&Me(()=>fe(!0))}catch(s){if(t!==ke)return;console.error("å è½½ä¼è¯æ¶æ¯å¤±è´¥:",s),me("å è½½ä¼è¯æ¶æ¯å¤±è´¥ï¼è¯·ç¨åéè¯","error"),g.value={...g.value,[e]:[]},A.value={...A.value,[e]:!0}}finally{t===ke&&(D.value={...D.value,[e]:!1})}},c=()=>{de.value=null,F.value="",we.value=[]},x=(e,t=!0)=>{if(!e)return;const s=f.value===e,p=!!f.value&&!s;if(s&&A.value[e]){fe(!0);return}f.value=e,t&&ie(e,"push"),a(),p&&(I.value&&U&&(U.abort(),I.value=!1),V(),c()),A.value[e]||r(e),fe(!0)},S=(e=!0)=>{f.value="",e&&ie("","push"),c()},K=e=>{H.value=e.reduce((t,s)=>(t[s.chatId]=s.title,t),{})},ge=e=>{H.value={...H.value,[e.chatId]:e.title}},dt=()=>{var e,t;f.value&&((t=(e=B.value)==null?void 0:e.startEditTitle)==null||t.call(e,f.value))},ft=({chatId:e})=>{const t={...g.value};delete t[e],g.value=t;const s={...A.value};delete s[e],A.value=s;const p={...D.value};delete p[e],D.value=p;const m={...H.value};delete m[e],H.value=m,f.value===e&&(I.value&&U&&(U.abort(),I.value=!1),V(),c(),S())},{showMessage:me}=Ge(),de=k(),we=k([]),pt=Y(()=>(F.value.trim().length>0||we.value.length>0)&&!ae.value);re(()=>{var e;return(e=de.value)==null?void 0:e.url},e=>{var t,s;e&&((t=de.value)==null?void 0:t.process)===void 0&&!((s=de.value)!=null&&s.error)&&!F.value.trim()&&(F.value="å¤å»ä¸ä¸è¿ä¸ªè§é¢")}),re(()=>{var e;return(e=de.value)==null?void 0:e.businessId},e=>{if(typeof e=="string"&&e){we.value=[{businessType:"FILE",businessId:e}];return}de.value||(we.value=[])});const vt=e=>/\.(jpg|jpeg|png|gif|webp)(\?|$)/i.test(e)||e.startsWith("data:image/"),ht=e=>{if(!e||typeof e!="object")return"";const t=e.task;if(!t||typeof t!="object")return"";const s=typeof t.taskStatus=="string"?t.taskStatus:"",p=t.result;if(!p||typeof p!="object")return s==="FAILED"?"任塿§è¡å¤±è´¥":"AIæ£å¨å¤çä¸â¦â¦";const m=p.text;return typeof m=="string"&&m.trim()?m.trim():s==="FAILED"?"任塿§è¡å¤±è´¥":"AIæ£å¨å¤çä¸â¦â¦"},Ye=async(e,t)=>{try{const s=ht(t),p=[e.trim(),s].filter(Boolean).join(` 2 3`);await navigator.clipboard.writeText(p||e),me("å·²å¤å¶å°åªè´´æ¿","success")}catch{me("å¤å¶å¤±è´¥","error")}},gt=e=>{const t=X.resolve({name:"XAgentMessageDetail",params:{messageId:e}});return new URL(t.href,window.location.origin).toString()},Ze=async e=>{if(e)try{await navigator.clipboard.writeText(gt(e)),me(u("xAgent.shareLinkCopied"),"success")}catch{me(u("xAgent.copyFailed"),"error")}},Be=k(!1),Ce=k(!0),mt=()=>{if(!M.value)return!0;const{scrollTop:e,scrollHeight:t,clientHeight:s}=M.value;return t-e-s<50},fe=(e=!1)=>{Me(()=>{M.value&&(e||Ce.value)&&(M.value.scrollTop=M.value.scrollHeight,Ce.value=!0,Be.value=!1)})},xt=()=>{Ce.value=mt(),I.value&&!Ce.value&&(Be.value=!0),Ce.value&&(Be.value=!1)};re(()=>R.value.length,()=>fe(!0)),re(()=>{var e;return(e=R.value[R.value.length-1])==null?void 0:e.content},()=>{!Be.value&&Ce.value&&fe()},{deep:!0}),re(f,()=>{Me(()=>fe(!0))}),re(()=>P.query.chatId,e=>{const t=Q(e);t!==f.value&&(t?x(t,!1):S(!1))});const bt=e=>{$.value=e,_.value=!0},yt=()=>{if(!I.value)return;h.displayStopped=!0,V(),I.value=!1;const e=a(),t=N(e);t&&(t.isStreaming=!1)},et=async()=>{var C,q,se,De;const e=we.value.map(w=>({...w})),t=F.value.trim()||(e.length?"å¤å»è¿ä¸ªè§é¢":"");if(!t&&e.length===0)return;let s=f.value,p=!1;if(!s)try{s=(await Mt()).chatId,p=!0,f.value=s,g.value={...g.value,[s]:[]},A.value={...A.value,[s]:!0},ie(s,"replace")}catch(w){console.error("å建ä¼è¯å¤±è´¥:",w),me("å建ä¼è¯å¤±è´¥ï¼è¯·ç¨åéè¯","error");return}const m=a();let E=!1;try{m.push({role:"user",content:t}),F.value="",de.value=null,we.value=[],(q=(C=b.value)==null?void 0:C.resetHeight)==null||q.call(C),I.value=!0,U&&U.abort(),U=new AbortController,V(),h.fetchCompleted=!1,h.displayStopped=!1,fe(),await Pt({chatId:s,message:t,attachments:e.length?e:void 0},w=>{if(h.displayStopped)return;let L=N(m);(!L||L.isError)&&(m.push({role:"ai",content:"",isStreaming:!0}),L=m[m.length-1]),L.isStreaming=!0,h.entry=L,h.queue+=w,h.timer||(h.timer=setInterval(()=>{if(!h.entry){V();return}if(h.queue.length>0){const j=h.queue.length>80?3:1;h.entry.content+=h.queue.slice(0,j),h.queue=h.queue.slice(j)}else h.fetchCompleted&&V()},50))},w=>{var Ee;if(w.type!=="TASK_STATUS"||!((Ee=w.task)!=null&&Ee.taskId))return;const L={taskId:w.task.taskId,taskType:w.task.taskType,taskStatus:w.task.taskStatus},j=N(m);if((j==null?void 0:j.role)==="ai"){j.task=L,j.messageId=w.messageId||j.messageId,j.isStreaming=!0,j.taskPolling=!0,Re(j);return}m.push({role:"ai",content:"",messageId:w.messageId||null,task:L,isStreaming:!0,taskPolling:!0}),Re(m[m.length-1])},w=>{if(console.error(w),V(),w.name==="AbortError")return;const L=(w==null?void 0:w.message)||"è°ç¨AIæ¥å£å¤±è´¥";E=!0,m.push({role:"ai",content:L,isError:!0}),me(L,"error")},()=>{h.fetchCompleted=!0,h.onComplete=()=>{const w=N(m);w&&(w.isStreaming=!1),fe()},h.queue.length===0&&V()},U.signal)}catch(w){if(console.error(w),V(),w instanceof Error&&w.name==="AbortError")return;if(!E){const L=w instanceof Error?w.message:"è°ç¨AIæ¥å£å¤±è´¥";m.push({role:"ai",content:L,isError:!0}),me(L,"error")}}finally{I.value=!1,Se();const w=N(m);w&&(w.isStreaming=!1),p&&((De=(se=B.value)==null?void 0:se.reload)==null||De.call(se))}};re(R,()=>{Me(()=>{qe()})},{deep:!0,immediate:!0});let We="";return it(()=>{We=document.title,document.title=u("app.title");let e="",t=[];const s=J(P.query.prefillKey),p=J(P.query.newChat)==="1",m=J(P.query.autoSend)==="1",E=J(P.query.schedulePushIntent)==="1",C=J(P.query.scheduleIntentAt);
3if(s)try{const L=localStorage.getItem(s)||"";if(L){try{const j=JSON.parse(L);typeof(j==null?void 0:j.message)=="string"&&(e=j.message),Array.isArray(j==null?void 0:j.attachments)&&(t=j.attachments.filter(Ee=>!!Ee&&typeof Ee.businessType=="string"&&typeof Ee.businessId=="string"))}catch{e=L}localStorage.removeItem(s)}}catch{}try{e||(e=sessionStorage.getItem("xagent_prefill_content1")||""),e&&!s&&sessionStorage.removeItem("xagent_prefill_content1")}catch{}const q=J(P.query.content1),se=J(P.query.q),w=e.trim()||q.trim()||se.trim();p&&S(!1),w&&(F.value=w),t.length&&(we.value=t),f.value&&r(f.value),Me(()=>{var L,j;if((j=(L=b.value)==null?void 0:L.focus)==null||j.call(L),m&&(w||t.length)&&!f.value){et().finally(()=>{if(E){X.replace({path:"/manage/notifications",query:{openPushConfig:"1",...C?{createdAfter:C}:{}}});return}ye()});return}(w||t.length)&&Object.keys(P.query).length&&ye()})}),At(()=>{We&&(document.title=We),Je(),U&&U.abort(),V()}),(e,t)=>(d(),v("div",Wo,[T(io,{ref_key:"asideRef",ref:B,"selected-chat-id":f.value,onSelect:x,onNewDraft:S,onTitlesChange:K,onTitleUpdated:ge,onChatDeleted:ft},null,8,["selected-chat-id"]),o("main",Ko,[o("div",Xo,[T(cs,{"selected-chat-id":f.value,"current-view-title":Ne.value,onGoHome:ce,onRenameCurrentChat:dt},null,8,["selected-chat-id","current-view-title"]),o("div",Go,[Ae.value?(d(),v("div",Qo,[o("div",Yo,[o("div",Zo,[o("h2",en,y(l(u)("xAgent.subtitle")),1)]),T(ts,{onApply:Ie})])])):ae.value?(d(),v("div",tn,[o("div",sn,[t[4]||(t[4]=o("div",{class:"mx-auto mb-4 h-10 w-10 animate-spin rounded-full border-2 border-gray-200 border-t-[#6A5CFF]"},null,-1)),o("p",on,y(l(u)("xAgent.loadingMessages")),1)])])):le.value?(d(),v(_e,{key:2},[o("div",{ref_key:"mainRef",ref:M,class:"flex-1 overflow-y-auto px-4 py-6 md:px-6",role:"log","aria-live":"polite","aria-relevant":"additions text",onScroll:xt},[o("div",nn,[(d(!0),v(_e,null,He(R.value,(s,p)=>{var m,E;return d(),v("div",{key:s.messageId||`${s.role}-${p}-${s.content.slice(0,20)}`,class:ee(["flex flex-col gap-2",s.role==="user"?"items-end":"items-start"])},[o("p",{class:ee(["px-1 text-[11px] font-medium",s.role==="user"?"text-gray-400":"text-[#6A5CFF]"])},y(s.role==="user"?l(u)("xAgent.you"):l(u)("xAgent.title")),3),s.role==="ai"?(d(),v("div",an,[T(Lt,{content:s.content,"content-json":s.contentJson||null,"is-error":!!s.isError,"task-id":((m=s.task)==null?void 0:m.taskId)||null,"task-status":((E=s.task)==null?void 0:E.taskStatus)||null,"is-streaming":!!s.isStreaming,"task-polling":!!s.taskPolling,"show-copy":(!I.value||p!==R.value.length-1)&&!s.isError,"show-share":!!s.messageId,"show-push":!!s.messageId&&s.role==="ai",onPush:C=>bt(s.content),onCopy:C=>Ye(s.content,s.contentJson||null),onShare:C=>Ze(s.messageId)},null,8,["content","content-json","is-error","task-id","task-status","is-streaming","task-polling","show-copy","show-share","show-push","onPush","onCopy","onShare"])])):(d(),v("div",ln,[o("div",rn,[vt(s.content)?(d(),v("img",{key:0,src:s.content,class:"block max-h-[220px] max-w-[280px] rounded-2xl",alt:"uploaded"},null,8,un)):(d(),v("span",cn,y(s.content),1))]),s.messageId?(d(),v("div",dn,[o("button",{type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-gray-200 bg-white text-[#687280] transition-colors hover:border-[#6A5CFF]/20 hover:bg-[#EDF9FF] hover:text-[#6A5CFF] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25",title:l(u)("common.copy"),onClick:C=>Ye(s.content,s.contentJson||null)},[...t[5]||(t[5]=[o("svg",{class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)])],8,fn),o("button",{type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-gray-200 bg-white text-[#687280] transition-colors hover:border-[#6A5CFF]/20 hover:bg-[#EDF9FF] hover:text-[#6A5CFF] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25",title:l(u)("xAgent.shareLink"),onClick:C=>Ze(s.messageId)},[...t[6]||(t[6]=[o("svg",{class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[o("path",{d:"M10 13a5 5 0 0 0 7.07 0l2.83-2.83a5 5 0 0 0-7.07-7.07L11.5 4.43"}),o("path",{d:"M14 11a5 5 0 0 0-7.07 0L4.1 13.83a5 5 0 0 0 7.07 7.07L12.5 19.57"})],-1)])],8,pn)])):te("",!0)]))],2)}),128)),I.value&&R.value.length&&R.value[R.value.length-1].role==="user"?(d(),v("div",vn,[o("p",hn,y(l(u)("xAgent.title")),1),t[7]||
3(t[7]=It('<div class="rounded-[24px] border border-gray-200 bg-white px-4 py-3" data-v-92ea5a26><div class="typing-indicator flex gap-1.5 py-1" data-v-92ea5a26><span class="h-2 w-2 rounded-full bg-[#6A5CFF]/70" data-v-92ea5a26></span><span class="h-2 w-2 rounded-full bg-[#6A5CFF]/70" data-v-92ea5a26></span><span class="h-2 w-2 rounded-full bg-[#6A5CFF]/70" data-v-92ea5a26></span></div></div>',1))])):te("",!0)])],544),Ce.value?te("",!0):(d(),v("button",{key:0,type:"button",class:"absolute bottom-[108px] right-6 z-10 inline-flex items-center rounded-full border border-gray-200 bg-white px-3 py-2 text-xs font-medium text-[#2D3348] shadow-lg transition-colors hover:border-[#6A5CFF]/20 hover:bg-[#EDF9FF] hover:text-[#6A5CFF] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6A5CFF]/25",onClick:t[0]||(t[0]=s=>fe(!0))},y(l(u)("xAgent.jumpToBottom")),1))],64)):te("",!0),Ae.value||le.value?(d(),v("div",gn,[o("div",mn,[T(Tt,{ref_key:"agentInputRef",ref:b,modelValue:F.value,"onUpdate:modelValue":t[1]||(t[1]=s=>F.value=s),file:de.value,"onUpdate:file":t[2]||(t[2]=s=>de.value=s),placeholder:l(u)("xAgent.chatPlaceholder"),"show-upload":!0,variant:"chat",disabled:!pt.value||I.value,sending:I.value,onSend:et,onStop:yt},null,8,["modelValue","file","placeholder","disabled","sending"]),o("p",xn,y(l(u)("xAgent.disclaimer"))+" AI 对è¯åä»»å¡ä¼æ¶èç®åã ",1)])])):te("",!0)])])]),T(Oo,{modelValue:_.value,"onUpdate:modelValue":t[3]||(t[3]=s=>_.value=s),"push-content":$.value},null,8,["modelValue","push-content"])]))}}),zn=Qe(yn,[["__scopeId","data-v-92ea5a26"]]);export{zn as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.