import{d as Q,r as i,c_ as X,e as P,e6 as Y,b7 as Z,b as ee,o as m,c as f,f as s,B as r,C as e,a as t,E as y,G as h,a2 as w,F as A,R as B,A as ae,av as le,a8 as te,K as se,S as re,U as ue,__tla as ne}from"./index-92ad187a.js";import{E as oe,__tla as de}from"./el-card-93209b1d.js";import{f as ce,__tla as ie}from"./formatTime-c7f253d6.js";import{g as me,__tla as pe}from"./index-343decc0.js";import{u as ve,__tla as _e}from"./useMessage-d9788660.js";let F,fe=Promise.all([(()=>{try{return ne}catch{}})(),(()=>{try{return de}catch{}})(),(()=>{try{return ie}catch{}})(),(()=>{try{return pe}catch{}})(),(()=>{try{return _e}catch{}})()]).then(async()=>{let g,b,k,V,S,U,N,O,$,I,J,R;g={class:"flex"},b=e("div",{class:"card-header"},[e("span",null,"\u8FDE\u63A5")],-1),k={class:"flex items-center"},V=e("span",{class:"mr-4 text-lg font-medium"}," \u8FDE\u63A5\u72B6\u6001: ",-1),S=e("hr",{class:"my-4"},null,-1),U={class:"flex"},N=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),O=e("hr",{class:"my-4"},null,-1),$=e("div",{class:"card-header"},[e("span",null,"\u6D88\u606F\u8BB0\u5F55")],-1),I={class:"max-h-80 overflow-auto"},J={class:"flex items-center"},R=e("span",{class:"text-primary mr-2 font-medium"},"\u6536\u5230\u6D88\u606F:",-1),F=Q({name:"InfraWebSocket",__name:"index",setup(ye){const x=ve(),p=i("https://zxpt.newfeifan.cn/infra/ws".replace("http","ws")+"?token="+X()),o=P(()=>C.value==="OPEN"),G=P(()=>o.value?"success":"red"),{status:C,data:d,send:W,close:j,open:q}=Y(p.value,{autoReconnect:!1,heartbeat:!0}),v=i([]);Z(()=>{if(d.value)try{if(d.value==="pong")return;const n=JSON.parse(d.value),l=n.type,u=JSON.parse(n.content);if(!l)return void x.error("\u672A\u77E5\u7684\u6D88\u606F\u7C7B\u578B\uFF1A"+d.value);if(l==="demo-message-receive")return void(u.single?v.value.push({text:`\u3010\u5355\u53D1\u3011\u7528\u6237\u7F16\u53F7(${u.fromUserId})\uFF1A${u.text}`,time:new Date().getTime()}):v.value.push({text:`\u3010\u7FA4\u53D1\u3011\u7528\u6237\u7F16\u53F7(${u.fromUserId})\uFF1A${u.text}`,time:new Date().getTime()}));if(l==="notice-push")return void v.value.push({text:`\u3010\u7CFB\u7EDF\u901A\u77E5\u3011\uFF1A${u.title}`,time:new Date().getTime()});x.error("\u672A\u5904\u7406\u6D88\u606F\uFF1A"+d.value)}catch(n){x.error("\u5904\u7406\u6D88\u606F\u53D1\u751F\u5F02\u5E38\uFF1A"+d.value),console.error(n)}});const c=i(""),_=i(""),H=()=>{const n=JSON.stringify({text:c.value,toUserId:_.value}),l=JSON.stringify({type:"demo-message-send",content:n});W(l),c.value=""},L=()=>{o.value?j():q()},D=i([]);return ee(async()=>{D.value=await me()}),(n,l)=>{const u=le,E=te,T=se,z=re,M=ue,K=oe;return m(),f("div",g,[s(K,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[b]),default:r(()=>[e("div",k,[V,s(u,{color:t(G)},{default:r(()=>[y(h(t(C)),1)]),_:1},8,["color"])]),S,e("div",U,[s(E,{modelValue:t(p),"onUpdate:modelValue":l[0]||(l[0]=a=>w(p)?p.value=a:null),disabled:""},{prepend:r(()=>[y("\u670D\u52A1\u5730\u5740")]),_:1},8,["modelValue"]),s(T,{type:t(o)?"danger":"primary",onClick:L},{default:r(()=>[y(h(t(o)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),N,O,s(E,{modelValue:t(c),"onUpdate:modelValue":l[1]||(l[1]=a=>w(c)?c.value=a:null),autosize:{minRows:2,maxRows:4},disabled:!t(o),clearable:"",type:"textarea",placeholder:"\u8BF7\u8F93\u5165\u4F60\u8981\u53D1\u9001\u7684\u6D88\u606F"},null,8,["modelValue","disabled"]),s(M,{modelValue:t(_),"onUpdate:modelValue":l[2]||(l[2]=a=>w(_)?_.value=a:null),class:"mt-4",placeholder:"\u8BF7\u9009\u62E9\u53D1\u9001\u4EBA"},{default:r(()=>[s(z,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(m(!0),f(A,null,B(t(D),a=>(m(),ae(z,{key:a.id,label:a.nickname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),s(T,{disabled:!t(o),block:"",class:"ml-2 mt-4",type:"primary",onClick:H},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(K,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[$]),default:r(()=>[e("div",I,[e("ul",null,[(m(!0),f(A,null,B(t(v).reverse(),a=>(m(),f("li",{key:a.time,class:"mt-2"},[e("div",J,[R,e("span",null,h(t(ce)(a.time)),1)]),e("div",null,h(a.text),1)]))),128))])])]),_:1})])}}})});export{fe as __tla,F as default};
