@zhin.js/adapter-sandbox 2.0.24 → 3.0.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @zhin.js/adapter-process
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 32049f5: fix: init publish
8
+ - Updated dependencies [32049f5]
9
+ - @zhin.js/console@3.0.1
10
+ - @zhin.js/http@1.0.75
11
+ - @zhin.js/client@1.1.1
12
+ - @zhin.js/core@1.1.24
13
+ - zhin.js@1.0.82
14
+
15
+ ## 3.0.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @zhin.js/client@1.1.0
21
+ - @zhin.js/console@3.0.0
22
+
3
23
  ## 2.0.24
4
24
 
5
25
  ### Patch Changes
@@ -53,8 +53,11 @@ export default function Sandbox() {
53
53
  useEffect(() => { fetchFaceList() }, [])
54
54
 
55
55
  useEffect(() => {
56
- const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
57
- wsRef.current = new WebSocket(`${protocol}//${window.location.host}/sandbox`)
56
+ const stored = localStorage.getItem('zhin_api_base')?.trim()
57
+ const base = (stored ? stored.replace(/\/$/, '') : null) ?? window.location.origin
58
+ const wsUrl = new URL('/sandbox', `${base}/`)
59
+ wsUrl.protocol = wsUrl.protocol === 'https:' ? 'wss:' : 'ws:'
60
+ wsRef.current = new WebSocket(wsUrl.href)
58
61
  wsRef.current.onopen = () => setConnected(true)
59
62
  wsRef.current.onmessage = (event) => {
60
63
  try {
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import Ve,{useState as C,useEffect as Ie,useRef as we}from"react";import{cn as M,resolveMediaSrc as Pe,pickMediaRawUrl as ye}from"@zhin.js/client";import{forwardRef as da,createElement as ua}from"react";var Le=(...m)=>m.filter((L,h,x)=>!!L&&L.trim()!==""&&x.indexOf(L)===h).join(" ").trim();var Te=m=>m.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var qe=m=>m.replace(/^([A-Z])|[\s-_]+(\w)/g,(L,h,x)=>x?x.toUpperCase():h.toLowerCase());var ke=m=>{let L=qe(m);return L.charAt(0).toUpperCase()+L.slice(1)};import{forwardRef as oa,createElement as Oe}from"react";var xe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Ue=m=>{for(let L in m)if(L.startsWith("aria-")||L==="role"||L==="title")return!0;return!1};import{createContext as ea,useContext as aa,useMemo as Oa,createElement as Na}from"react";var ta=ea({});var He=()=>aa(ta);var Ne=oa(({color:m,size:L,strokeWidth:h,absoluteStrokeWidth:x,className:N="",children:D,iconNode:g,...p},w)=>{let{size:F=24,strokeWidth:b=2,absoluteStrokeWidth:K=!1,color:E="currentColor",className:Z=""}=He()??{},H=x??K?Number(h??b)*24/Number(L??F):h??b;return Oe("svg",{ref:w,...xe,width:L??F??xe.width,height:L??F??xe.height,stroke:m??E,strokeWidth:H,className:Le("lucide",Z,N),...!D&&!Ue(p)&&{"aria-hidden":"true"},...p},[...g.map(([B,P])=>Oe(B,P)),...Array.isArray(D)?D:[D]])});var r=(m,L)=>{let h=da(({className:x,...N},D)=>ua(Ne,{ref:D,iconNode:L,className:Le(`lucide-${Te(ke(m))}`,`lucide-${m}`,x),...N}));return h.displayName=ke(m),h};var la=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],V=r("bell",la);var sa=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ee=r("bot",sa);var ra=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ae=r("check",ra);var fa=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],te=r("hash",fa);var ia=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],oe=r("image",ia);var ca=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],de=r("info",ca);var na=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],O=r("message-square",na);var pa=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],ue=r("music",pa);var ma=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],j=r("search",ma);var La=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],le=r("send",La);var xa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],se=r("smile",xa);var Ia=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],re=r("trash-2",Ia);var Ca=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],z=r("user-plus",Ca);var ga=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],X=r("user",ga);var ha=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],fe=r("users",ha);var Sa=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ie=r("video",Sa);var ka=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ce=r("wifi-off",ka);var wa=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],ne=r("wifi",wa);var Pa=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pe=r("x",Pa);import{useRef as Ee,forwardRef as ya,useImperativeHandle as Aa}from"react";import{jsx as Ma}from"react/jsx-runtime";var Ge=ya(({placeholder:m="\u8F93\u5165\u6D88\u606F...",onSend:L,onChange:h,onAtTrigger:x,minHeight:N="44px",maxHeight:D="200px"},g)=>{let p=Ee(null),w=Ee(null),F=()=>{if(!p.current)return{text:"",segments:[]};let d="",t=[],u=Array.from(p.current.childNodes);for(let c of u)if(c.nodeType===Node.TEXT_NODE){let l=c.textContent||"";l&&(d+=l,t.push({type:"text",data:{text:l}}))}else if(c.nodeType===Node.ELEMENT_NODE){let l=c;if(l.classList.contains("editor-face")){let n=l.dataset.id;d+=`[face:${n}]`,t.push({type:"face",data:{id:Number(n)}})}else if(l.classList.contains("editor-image")){let n=l.dataset.url;d+=`[image:${n}]`,t.push({type:"image",data:{url:n}})}else if(l.classList.contains("editor-video")){let n=l.dataset.url||"";d+=`[video:${n}]`,t.push({type:"video",data:{url:n}})}else if(l.classList.contains("editor-audio")){let n=l.dataset.url||"";d+=`[audio:${n}]`,t.push({type:"audio",data:{url:n}})}else if(l.classList.contains("editor-at")){let n=l.dataset.name,A=l.dataset.id;d+=`[@${n}]`,t.push({type:"at",data:{name:n,qq:A}})}else l.tagName==="BR"&&(d+=`
2
- `)}return{text:d,segments:t}},b=d=>{if(!p.current)return;let t=document.createElement("img");t.src=`https://face.viki.moe/apng/${d}.png`,t.alt=`[face:${d}]`,t.dataset.type="face",t.dataset.id=String(d),t.className="editor-face",B(t),v()},K=d=>{if(!p.current||!d.trim())return;let t=document.createElement("img");t.src=d.trim(),t.alt=`[image:${d.trim()}]`,t.dataset.type="image",t.dataset.url=d.trim(),t.className="editor-image",B(t),v()},E=d=>{if(!p.current||!d.trim())return;let t=d.trim(),u=document.createElement("span");u.className="editor-video",u.dataset.url=t,u.contentEditable="false",u.textContent="\u{1F4F9} \u89C6\u9891",B(u),v()},Z=d=>{if(!p.current||!d.trim())return;let t=d.trim(),u=document.createElement("span");u.className="editor-audio",u.dataset.url=t,u.contentEditable="false",u.textContent="\u{1F3B5} \u97F3\u9891",B(u),v()},H=(d,t)=>{if(!p.current||!d.trim())return;let u=document.createElement("span");u.dataset.type="at",u.dataset.name=d,t&&(u.dataset.id=t),u.className="editor-at",u.contentEditable="false";let c=document.createElement("span");c.textContent="@",c.className="editor-at-symbol";let l=document.createElement("span");l.textContent=d,l.className="editor-at-name",u.appendChild(c),u.appendChild(l),B(u),v()},B=d=>{if(!p.current)return;p.current.focus();let t=window.getSelection();if(t&&t.rangeCount>0){let u=t.getRangeAt(0);if(p.current.contains(u.commonAncestorContainer))u.deleteContents(),u.insertNode(d),u.collapse(!1),t.removeAllRanges(),t.addRange(u);else{p.current.appendChild(d);let l=document.createRange();l.setStartAfter(d),l.collapse(!0),t.removeAllRanges(),t.addRange(l)}}else{p.current.appendChild(d);let u=window.getSelection();if(u){let c=document.createRange();c.setStartAfter(d),c.collapse(!0),u.removeAllRanges(),u.addRange(c)}}},P=()=>{p.current&&(p.current.innerHTML="",v())},G=()=>{p.current?.focus()},$=()=>F(),me=()=>{if(!p.current||!x)return;let d=window.getSelection();if(!d||d.rangeCount===0){x(!1,""),w.current=null;return}let t=d.getRangeAt(0);if(!p.current.contains(t.commonAncestorContainer)){x(!1,""),w.current=null;return}let u=t.startContainer;if(u.nodeType!==Node.TEXT_NODE){x(!1,""),w.current=null;return}let c=u,l=c.textContent?.substring(0,t.startOffset)||"",n=l.lastIndexOf("@");if(n!==-1){let A=l.substring(n+1);if(A.includes(" ")||A.includes(`
3
- `)){x(!1,""),w.current=null;return}w.current=c;let W=document.createRange();W.setStart(c,n),W.setEnd(c,n+1);let T=W.getBoundingClientRect(),R=p.current.getBoundingClientRect();x(!0,A,{top:T.bottom-R.top,left:T.left-R.left})}else x(!1,""),w.current=null},v=()=>{if(me(),h){let{text:d,segments:t}=F();h(d,t)}},Ce=(d,t)=>{if(!w.current)return;let u=w.current,c=u.textContent||"",l=c.lastIndexOf("@");if(l!==-1){let n=c.substring(l+1),A=l+1+n.split(/[\s\n]/)[0].length,W=c.substring(0,l),T=c.substring(A);u.textContent=W+T;let R=window.getSelection();if(R){let q=document.createRange();q.setStart(u,l),q.collapse(!0),R.removeAllRanges(),R.addRange(q)}}w.current=null,H(d,t)},Y=d=>{d.preventDefault();let t=d.clipboardData,c=Array.from(t.items).find(n=>n.type.startsWith("image/"));if(c){let n=c.getAsFile();if(n){let A=new FileReader;A.onload=()=>{typeof A.result=="string"&&K(A.result)},A.readAsDataURL(n)}return}let l=t.getData("text/plain");l&&(document.execCommand("insertText",!1,l),v())},Q=d=>{if(d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),L)){let{text:t,segments:u}=F();L(t,u)}};return Aa(g,()=>({focus:G,clear:P,insertFace:b,insertImage:K,insertVideo:E,insertAudio:Z,insertAt:H,replaceAtTrigger:Ce,getContent:$})),Ma("div",{ref:p,contentEditable:!0,suppressContentEditableWarning:!0,onInput:v,onKeyDown:Q,onPaste:Y,"data-placeholder":m,className:"rich-text-editor",style:{width:"100%",minHeight:N,maxHeight:D,padding:"0.5rem 0.75rem",border:"1px solid var(--gray-6)",borderRadius:"6px",backgroundColor:"var(--gray-1)",fontSize:"var(--font-size-2)",outline:"none",overflowY:"auto",lineHeight:"1.5",wordWrap:"break-word",color:"var(--gray-12)"}})});Ge.displayName="RichTextEditor";var We=Ge;import{Fragment as Ba,jsx as e,jsxs as o}from"react/jsx-runtime";function Ae(){let[m,L]=C([]),[h,x]=C([{id:"user_1001",name:"\u6D4B\u8BD5\u7528\u6237",type:"private",unread:0},{id:"group_2001",name:"\u6D4B\u8BD5\u7FA4\u7EC4",type:"group",unread:0},{id:"channel_3001",name:"\u6D4B\u8BD5\u9891\u9053",type:"channel",unread:0}]),[N,D]=C([]),[g,p]=C(h[0]),[w,F]=C(""),[b,K]=C("ProcessBot"),[E,Z]=C(!1),[H,B]=C(!1),[P,G]=C(null),[$,me]=C(""),[v,Ce]=C(!1),[Y,Q]=C(null),[d,t]=C(""),[u,c]=C(""),[l,n]=C(""),[A]=C([{id:"10001",name:"\u5F20\u4E09"},{id:"10002",name:"\u674E\u56DB"},{id:"10003",name:"\u738B\u4E94"},{id:"10004",name:"\u8D75\u516D"},{id:"10005",name:"\u6D4B\u8BD5\u7528\u6237"},{id:"10086",name:"Admin"},{id:"10010",name:"Test User"}]),[W,T]=C([]),[R,q]=C(!1),[_,ge]=C("chat"),Me=we(null),J=we(null),U=we(null),ze=async()=>{try{let a=await fetch("https://face.viki.moe/metadata.json");D(await a.json())}catch(a){console.error("[Sandbox] Failed to fetch face list:",a)}};Ie(()=>{ze()},[]),Ie(()=>{let a=window.location.protocol==="https:"?"wss:":"ws:";return J.current=new WebSocket(`${a}//${window.location.host}/sandbox`),J.current.onopen=()=>Z(!0),J.current.onmessage=f=>{try{let s=JSON.parse(f.data),I=typeof s.content=="string"?he(s.content):Array.isArray(s.content)?s.content:he(String(s.content)),i=h.find(y=>y.id===s.id);if(!i){let y=s.type==="private"?`\u79C1\u804A-${s.bot||b}`:s.type==="group"?`\u7FA4\u7EC4-${s.id}`:`\u9891\u9053-${s.id}`;i={id:s.id,name:y,type:s.type,unread:0},x(k=>[...k,i]),p(i)}let S={id:`bot_${s.timestamp}`,type:"received",channelType:s.type,channelId:s.id,channelName:i.name,senderId:"bot",senderName:s.bot||b,content:I,timestamp:s.timestamp};L(y=>[...y,S])}catch(s){console.error("[Sandbox] Failed to parse message:",s)}},J.current.onclose=()=>Z(!1),()=>{J.current?.close()}},[b,h]),Ie(()=>{Me.current?.scrollIntoView({behavior:"smooth"})},[m]),Ie(()=>{T(w.trim()?he(w):[])},[w]);let he=a=>{let f=[],s=/\[@([^\]]+)\]|\[face:(\d+)\]|\[image:([^\]]+)\]|\[video:([^\]]+)\]|\[audio:([^\]]+)\]/g,I=0,i;for(;(i=s.exec(a))!==null;){if(i.index>I){let S=a.substring(I,i.index);S&&f.push({type:"text",data:{text:S}})}i[1]?f.push({type:"at",data:{qq:i[1],name:i[1]}}):i[2]?f.push({type:"face",data:{id:parseInt(i[2],10)}}):i[3]?f.push({type:"image",data:{url:i[3]}}):i[4]?f.push({type:"video",data:{url:i[4]}}):i[5]&&f.push({type:"audio",data:{url:i[5]}}),I=s.lastIndex}if(I<a.length){let S=a.substring(I);S&&f.push({type:"text",data:{text:S}})}return f.length>0?f:[{type:"text",data:{text:a}}]},Be=a=>a.length===0?!1:a.some(f=>f.type==="text"?!!String(f.data?.text??"").trim():!0),Xe=(a,f)=>{let s=f?"ring-1 ring-primary-foreground/25":"ring-1 ring-border/60";return a.map((I,i)=>{if(typeof I=="string")return e("span",{children:I.split(`
4
- `).map((y,k)=>o(Ve.Fragment,{children:[y,k<I.split(`
5
- `).length-1&&e("br",{})]},k))},i);let S=I.data;switch(I.type){case"text":return e("span",{children:String(S.text??"").split(`
6
- `).map((y,k)=>o(Ve.Fragment,{children:[y,k<String(S.text??"").split(`
7
- `).length-1&&e("br",{})]},k))},i);case"at":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-accent text-accent-foreground text-xs mx-0.5",children:["@",String(S.name??S.qq??"")]},i);case"face":return e("img",{src:`https://face.viki.moe/apng/${S.id}.png`,alt:"",className:"w-6 h-6 inline-block align-middle mx-0.5"},i);case"image":{let y=ye(S),k=Pe(y,"image");return k?e("a",{href:k,target:"_blank",rel:"noreferrer",className:"block my-1",children:e("img",{src:k,alt:"",className:M("max-w-[min(320px,88vw)] rounded-lg block",s,"ring-offset-0"),onError:Ye=>{Ye.target.style.display="none"}})},i):e("span",{className:"text-xs opacity-70",children:"[\u56FE\u7247]"},i)}case"video":{let y=ye(S),k=Pe(y,"video");return k?e("video",{src:k,controls:!0,playsInline:!0,preload:"metadata",className:M("max-w-[min(360px,92vw)] max-h-72 rounded-lg my-1 bg-black/10",s)},i):e("span",{className:"text-xs opacity-70",children:"[\u89C6\u9891\u65E0\u5730\u5740]"},i)}case"audio":case"record":{let y=ye(S),k=Pe(y,"audio");return k?e("audio",{src:k,controls:!0,preload:"metadata",className:M("w-full max-w-sm my-2 h-10",f&&"opacity-95")},i):e("span",{className:"text-xs opacity-70",children:"[\u97F3\u9891\u65E0\u5730\u5740]"},i)}case"file":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-xs mx-0.5",children:["\u{1F4CE} ",String(S.name||"\u6587\u4EF6")]},i);default:return o("span",{className:"text-xs opacity-70",children:["[",I.type,"]"]},i)}})},Fe=(a,f)=>{if(!Be(f))return;let s={id:`msg_${Date.now()}`,type:"sent",channelType:g.type,channelId:g.id,channelName:g.name,senderId:"test_user",senderName:"\u6D4B\u8BD5\u7528\u6237",content:f,timestamp:Date.now()};L(I=>[...I,s]),F(""),T([]),U.current?.clear(),J.current?.send(JSON.stringify({type:g.type,id:g.id,content:f,timestamp:Date.now()}))},Ke=()=>{confirm("\u786E\u5B9A\u6E05\u7A7A\u6240\u6709\u6D88\u606F\u8BB0\u5F55\uFF1F")&&L([])},Ze=a=>{ge("chat"),p(a),x(f=>f.map(s=>s.id===a.id?{...s,unread:0}:s)),window.innerWidth<768&&q(!1)},Qe=()=>{let a=["private","group","channel"],f=a[Math.floor(Math.random()*a.length)],s=prompt("\u8BF7\u8F93\u5165\u9891\u9053\u540D\u79F0\uFF1A");if(s){let I={id:`${f}_${Date.now()}`,name:s,type:f,unread:0};x(i=>[...i,I]),p(I)}},De=a=>{switch(a){case"private":return e(X,{size:16});case"group":return e(fe,{size:16});case"channel":return e(te,{size:16});default:return e(O,{size:16})}},_e=a=>{U.current?.insertFace(a),B(!1)},Re=()=>{let a=$.trim();!a||!P||(P==="image"?U.current?.insertImage(a):P==="video"?U.current?.insertVideo(a):U.current?.insertAudio(a),me(""),G(null))},Fa=()=>{l.trim()&&(U.current?.insertAt(l.trim()),n(""),Ce(!1))},Je=a=>{U.current?.replaceAtTrigger(a.name,a.id),Q(null),t("")},je=(a,f,s)=>{if(g.type==="private"){Q(null),t("");return}a&&s?(Q(s),t(f)):(Q(null),t(""))},be=A.filter(a=>{if(!d.trim())return!0;let f=d.toLowerCase();return a.name.toLowerCase().includes(f)||a.id.toLowerCase().includes(f)}),$e=(a,f)=>{F(a),T(f)},ve=N.filter(a=>a.name.toLowerCase().includes(u.toLowerCase())||a.describe.toLowerCase().includes(u.toLowerCase())),Se=m.filter(a=>a.channelId===g.id);return o("div",{className:"sandbox-container rounded-xl border border-border/70 bg-card/30 shadow-sm",children:[o("button",{className:"mobile-channel-toggle md:hidden",onClick:()=>q(!R),children:[e(O,{size:20})," \u9891\u9053\u5217\u8868"]}),o("div",{className:M("channel-sidebar rounded-lg border bg-card",R&&"show"),children:[e("div",{className:"p-3 border-b",children:o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2",children:[e("div",{className:"p-1 rounded-md bg-secondary",children:e(O,{size:16,className:"text-muted-foreground"})}),e("h3",{className:"font-semibold",children:"\u9891\u9053\u5217\u8868"})]}),o("span",{className:M("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border",E?"bg-emerald-100 text-emerald-800 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-400 dark:border-emerald-800":"bg-muted text-muted-foreground"),children:[E?e(ne,{size:12}):e(ce,{size:12}),E?"\u5DF2\u8FDE\u63A5":"\u672A\u8FDE\u63A5"]})]})}),o("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:[h.map(a=>{let f=_==="chat"&&g.id===a.id;return o("div",{className:M("menu-item",f&&"active"),onClick:()=>Ze(a),children:[e("span",{className:"shrink-0",children:De(a.type)}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium truncate",children:a.name}),e("div",{className:"text-xs text-muted-foreground",children:a.type==="private"?"\u79C1\u804A":a.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),a.unread>0&&e("span",{className:"inline-flex items-center justify-center h-5 min-w-5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-medium px-1",children:a.unread})]},a.id)}),o("div",{className:"pt-2 mt-2 border-t space-y-1",children:[o("div",{className:M("menu-item",_==="requests"&&"active"),onClick:()=>{ge("requests"),window.innerWidth<768&&q(!1)},children:[e(z,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium",children:"\u8BF7\u6C42"}),e("div",{className:"text-xs text-muted-foreground",children:"\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49"})]})]}),o("div",{className:M("menu-item",_==="notices"&&"active"),onClick:()=>{ge("notices"),window.innerWidth<768&&q(!1)},children:[e(V,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium",children:"\u901A\u77E5"}),e("div",{className:"text-xs text-muted-foreground",children:"\u7FA4\u7BA1/\u64A4\u56DE\u7B49"})]})]})]})]}),e("div",{className:"p-2 border-t",children:e("button",{className:"w-full py-2 px-3 rounded-md border border-dashed text-sm text-muted-foreground hover:bg-accent transition-colors",onClick:Qe,children:"+ \u6DFB\u52A0\u9891\u9053"})})]}),R&&e("div",{className:"channel-overlay md:hidden",onClick:()=>q(!1)}),o("div",{className:"chat-area",children:[_==="requests"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[e("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[e(z,{size:20})," \u8BF7\u6C42"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[e(z,{size:48,className:"opacity-30"}),e("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u8BF7\u6C42\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49\u8BF7\u6C42\u8BF7\u5230\u4FA7\u8FB9\u680F ",e("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),_==="notices"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[e("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[e(V,{size:20})," \u901A\u77E5"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[e(V,{size:48,className:"opacity-30"}),e("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u901A\u77E5\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u7FA4\u7BA1\u3001\u64A4\u56DE\u7B49\u901A\u77E5\u8BF7\u5230\u4FA7\u8FB9\u680F ",e("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),_==="chat"&&o(Ba,{children:[e("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0",children:o("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[o("div",{className:"flex items-center gap-3",children:[e("div",{className:"p-2 rounded-lg bg-secondary",children:De(g.type)}),o("div",{children:[e("h2",{className:"text-lg font-bold",children:g.name}),o("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e("span",{children:g.id}),e("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-[10px]",children:Se.length}),e("span",{children:"\u6761\u6D88\u606F"})]})]}),e("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-secondary text-secondary-foreground",children:g.type==="private"?"\u79C1\u804A":g.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),o("div",{className:"flex items-center gap-2",children:[e("input",{value:b,onChange:a=>K(a.target.value),placeholder:"\u673A\u5668\u4EBA\u540D\u79F0",className:"h-8 w-28 rounded-md border bg-transparent px-2 text-sm"}),o("button",{className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-secondary text-secondary-foreground text-sm hover:bg-secondary/80",onClick:Ke,children:[e(re,{size:14})," \u6E05\u7A7A"]})]})]})}),e("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0",children:e("div",{className:"flex-1 overflow-y-auto p-4",children:Se.length===0?o("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[e(O,{size:64,className:"text-muted-foreground/20"}),e("span",{className:"text-muted-foreground",children:"\u6682\u65E0\u6D88\u606F\uFF0C\u5F00\u59CB\u5BF9\u8BDD\u5427\uFF01"})]}):o("div",{className:"space-y-2",children:[Se.map(a=>e("div",{className:M("flex",a.type==="sent"?"justify-end":"justify-start"),children:o("div",{className:M("max-w-[70%] p-3 rounded-2xl",a.type==="sent"?"bg-primary text-primary-foreground":"bg-muted"),children:[o("div",{className:"flex items-center gap-2 mb-1",children:[a.type==="received"&&e(ee,{size:14}),a.type==="sent"&&e(X,{size:14}),e("span",{className:"text-xs font-medium opacity-90",children:a.senderName}),e("span",{className:"text-xs opacity-70",children:new Date(a.timestamp).toLocaleTimeString()})]}),e("div",{className:"text-sm space-y-1",children:Xe(a.content,a.type==="sent")})]})},a.id)),e("div",{ref:Me})]})})}),o("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0 space-y-3",children:[o("div",{className:"flex gap-2 items-center flex-wrap",children:[e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",H?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{B(!H),G(null)},title:"\u63D2\u5165\u8868\u60C5",children:e(se,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="image"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="image"?null:"image"),B(!1)},title:"\u63D2\u5165\u56FE\u7247 URL",children:e(oe,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="video"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="video"?null:"video"),B(!1)},title:"\u63D2\u5165\u89C6\u9891 URL",children:e(ie,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="audio"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="audio"?null:"audio"),B(!1)},title:"\u63D2\u5165\u97F3\u9891 URL",children:e(ue,{size:16})}),e("div",{className:"flex-1 min-w-[1rem]"}),w&&e("button",{className:"h-8 w-8 rounded-md flex items-center justify-center hover:bg-accent transition-colors",onClick:()=>{F(""),T([])},children:e(pe,{size:16})})]}),H&&o("div",{className:"p-3 rounded-md border bg-muted/30 max-h-64 overflow-y-auto space-y-2",children:[e("input",{value:u,onChange:a=>c(a.target.value),placeholder:"\u641C\u7D22\u8868\u60C5...",className:"w-full h-8 rounded-md border bg-transparent px-2 text-sm"}),e("div",{className:"grid grid-cols-8 gap-1",children:ve.slice(0,80).map(a=>e("button",{onClick:()=>_e(a.id),title:a.name,className:"w-10 h-10 rounded-md border flex items-center justify-center hover:bg-accent transition-colors",children:e("img",{src:`https://face.viki.moe/apng/${a.id}.png`,alt:a.name,className:"w-8 h-8"})},a.id))}),ve.length===0&&o("div",{className:"flex flex-col items-center gap-2 py-4",children:[e(j,{size:32,className:"text-muted-foreground/30"}),e("span",{className:"text-sm text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u8868\u60C5"})]})]}),P&&o("div",{className:"p-3 rounded-md border bg-muted/30 space-y-2",children:[o("p",{className:"text-xs text-muted-foreground",children:[P==="image"&&"\u652F\u6301 http(s) \u56FE\u7247\u94FE\u63A5\u6216 data URL",P==="video"&&"\u652F\u6301\u6D4F\u89C8\u5668\u53EF\u89E3\u7801\u7684\u89C6\u9891\u76F4\u94FE\uFF08\u5982 .mp4\u3001.webm\uFF09",P==="audio"&&"\u652F\u6301 .mp3\u3001.ogg\u3001.wav \u7B49\u97F3\u9891\u76F4\u94FE"]}),e("input",{value:$,onChange:a=>me(a.target.value),placeholder:P==="image"?"\u56FE\u7247 URL\u2026":P==="video"?"\u89C6\u9891 URL\u2026":"\u97F3\u9891 URL\u2026",className:"w-full h-8 rounded-md border border-input bg-background px-2 text-sm",onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Re())}}),o("button",{type:"button",className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-primary text-primary-foreground text-sm disabled:opacity-50",onClick:Re,disabled:!$.trim(),children:[e(ae,{size:14})," \u63D2\u5165\u5230\u8F93\u5165\u6846"]})]}),o("div",{className:"flex gap-2 items-start",children:[o("div",{className:"flex-1 relative",children:[e(We,{ref:U,placeholder:`\u5411 ${g.name} \u53D1\u9001\u6D88\u606F...`,onSend:Fe,onChange:$e,onAtTrigger:je,minHeight:"44px",maxHeight:"200px"}),Y&&e("div",{className:"absolute z-50 rounded-lg border bg-popover shadow-md min-w-60 max-h-72 overflow-y-auto p-1",style:{top:`${Y.top}px`,left:`${Y.left}px`},children:be.length>0?be.map(a=>o("div",{className:"flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-accent transition-colors",onClick:()=>Je(a),children:[e(X,{size:16,className:"text-muted-foreground"}),o("div",{className:"flex-1",children:[e("div",{className:"text-sm font-medium",children:a.name}),o("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.id]})]})]},a.id)):o("div",{className:"flex flex-col items-center gap-2 p-4",children:[e(j,{size:20,className:"text-muted-foreground/50"}),e("span",{className:"text-xs text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u7528\u6237"})]})})]}),o("button",{className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-md bg-primary text-primary-foreground text-sm font-medium disabled:opacity-50 transition-colors hover:bg-primary/90",onClick:()=>{let a=U.current?.getContent();a&&Fe(a.text,a.segments)},disabled:!Be(W),children:[e(le,{size:16})," \u53D1\u9001"]})]}),o("div",{className:"flex items-center gap-2 flex-wrap text-xs text-muted-foreground",children:[e(de,{size:12})," \u5FEB\u6377\u64CD\u4F5C:",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Enter"})," \u53D1\u9001",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Shift+Enter"})," \u6362\u884C",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[@\u540D\u79F0]"})," @\u67D0\u4EBA",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[video:URL]"}),e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[audio:URL]"})]})]})]})]})]})}function Io(m){m.addRoute({path:"/console/sandbox",name:"\u6C99\u76D2",element:m.React.createElement(Ae,{hostReact:m.React})}),m.addTool({id:"sandbox",name:"\u6C99\u76D2",path:"/console/sandbox"})}export{Io as register};
1
+ import ze,{useState as C,useEffect as Ce,useRef as Pe}from"react";import{cn as M,resolveMediaSrc as ye,pickMediaRawUrl as Ae}from"@zhin.js/client";import{forwardRef as ua,createElement as la}from"react";var xe=(...p)=>p.filter((m,h,x)=>!!m&&m.trim()!==""&&x.indexOf(m)===h).join(" ").trim();var qe=p=>p.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var Ue=p=>p.replace(/^([A-Z])|[\s-_]+(\w)/g,(m,h,x)=>x?x.toUpperCase():h.toLowerCase());var we=p=>{let m=Ue(p);return m.charAt(0).toUpperCase()+m.slice(1)};import{forwardRef as da,createElement as Ne}from"react";var Ie={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var He=p=>{for(let m in p)if(m.startsWith("aria-")||m==="role"||m==="title")return!0;return!1};import{createContext as aa,useContext as ta,useMemo as Na,createElement as Ea}from"react";var oa=aa({});var Oe=()=>ta(oa);var Ee=da(({color:p,size:m,strokeWidth:h,absoluteStrokeWidth:x,className:N="",children:D,iconNode:g,...n},w)=>{let{size:F=24,strokeWidth:b=2,absoluteStrokeWidth:Z=!1,color:E="currentColor",className:Q=""}=Oe()??{},H=x??Z?Number(h??b)*24/Number(m??F):h??b;return Ne("svg",{ref:w,...Ie,width:m??F??Ie.width,height:m??F??Ie.height,stroke:p??E,strokeWidth:H,className:xe("lucide",Q,N),...!D&&!He(n)&&{"aria-hidden":"true"},...n},[...g.map(([B,P])=>Ne(B,P)),...Array.isArray(D)?D:[D]])});var r=(p,m)=>{let h=ua(({className:x,...N},D)=>la(Ee,{ref:D,iconNode:m,className:xe(`lucide-${qe(we(p))}`,`lucide-${p}`,x),...N}));return h.displayName=we(p),h};var sa=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],z=r("bell",sa);var ra=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ae=r("bot",ra);var fa=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],te=r("check",fa);var ia=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],oe=r("hash",ia);var ca=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],de=r("image",ca);var na=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ue=r("info",na);var pa=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],O=r("message-square",pa);var ma=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],le=r("music",ma);var La=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],$=r("search",La);var xa=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],se=r("send",xa);var Ia=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],re=r("smile",Ia);var Ca=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],fe=r("trash-2",Ca);var ga=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],X=r("user-plus",ga);var ha=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],K=r("user",ha);var Sa=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ie=r("users",Sa);var ka=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ce=r("video",ka);var wa=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ne=r("wifi-off",wa);var Pa=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],pe=r("wifi",Pa);var ya=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],me=r("x",ya);import{useRef as Ge,forwardRef as Aa,useImperativeHandle as Ma}from"react";import{jsx as Ba}from"react/jsx-runtime";var We=Aa(({placeholder:p="\u8F93\u5165\u6D88\u606F...",onSend:m,onChange:h,onAtTrigger:x,minHeight:N="44px",maxHeight:D="200px"},g)=>{let n=Ge(null),w=Ge(null),F=()=>{if(!n.current)return{text:"",segments:[]};let d="",t=[],l=Array.from(n.current.childNodes);for(let i of l)if(i.nodeType===Node.TEXT_NODE){let s=i.textContent||"";s&&(d+=s,t.push({type:"text",data:{text:s}}))}else if(i.nodeType===Node.ELEMENT_NODE){let s=i;if(s.classList.contains("editor-face")){let c=s.dataset.id;d+=`[face:${c}]`,t.push({type:"face",data:{id:Number(c)}})}else if(s.classList.contains("editor-image")){let c=s.dataset.url;d+=`[image:${c}]`,t.push({type:"image",data:{url:c}})}else if(s.classList.contains("editor-video")){let c=s.dataset.url||"";d+=`[video:${c}]`,t.push({type:"video",data:{url:c}})}else if(s.classList.contains("editor-audio")){let c=s.dataset.url||"";d+=`[audio:${c}]`,t.push({type:"audio",data:{url:c}})}else if(s.classList.contains("editor-at")){let c=s.dataset.name,A=s.dataset.id;d+=`[@${c}]`,t.push({type:"at",data:{name:c,qq:A}})}else s.tagName==="BR"&&(d+=`
2
+ `)}return{text:d,segments:t}},b=d=>{if(!n.current)return;let t=document.createElement("img");t.src=`https://face.viki.moe/apng/${d}.png`,t.alt=`[face:${d}]`,t.dataset.type="face",t.dataset.id=String(d),t.className="editor-face",B(t),v()},Z=d=>{if(!n.current||!d.trim())return;let t=document.createElement("img");t.src=d.trim(),t.alt=`[image:${d.trim()}]`,t.dataset.type="image",t.dataset.url=d.trim(),t.className="editor-image",B(t),v()},E=d=>{if(!n.current||!d.trim())return;let t=d.trim(),l=document.createElement("span");l.className="editor-video",l.dataset.url=t,l.contentEditable="false",l.textContent="\u{1F4F9} \u89C6\u9891",B(l),v()},Q=d=>{if(!n.current||!d.trim())return;let t=d.trim(),l=document.createElement("span");l.className="editor-audio",l.dataset.url=t,l.contentEditable="false",l.textContent="\u{1F3B5} \u97F3\u9891",B(l),v()},H=(d,t)=>{if(!n.current||!d.trim())return;let l=document.createElement("span");l.dataset.type="at",l.dataset.name=d,t&&(l.dataset.id=t),l.className="editor-at",l.contentEditable="false";let i=document.createElement("span");i.textContent="@",i.className="editor-at-symbol";let s=document.createElement("span");s.textContent=d,s.className="editor-at-name",l.appendChild(i),l.appendChild(s),B(l),v()},B=d=>{if(!n.current)return;n.current.focus();let t=window.getSelection();if(t&&t.rangeCount>0){let l=t.getRangeAt(0);if(n.current.contains(l.commonAncestorContainer))l.deleteContents(),l.insertNode(d),l.collapse(!1),t.removeAllRanges(),t.addRange(l);else{n.current.appendChild(d);let s=document.createRange();s.setStartAfter(d),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}}else{n.current.appendChild(d);let l=window.getSelection();if(l){let i=document.createRange();i.setStartAfter(d),i.collapse(!0),l.removeAllRanges(),l.addRange(i)}}},P=()=>{n.current&&(n.current.innerHTML="",v())},G=()=>{n.current?.focus()},Y=()=>F(),Le=()=>{if(!n.current||!x)return;let d=window.getSelection();if(!d||d.rangeCount===0){x(!1,""),w.current=null;return}let t=d.getRangeAt(0);if(!n.current.contains(t.commonAncestorContainer)){x(!1,""),w.current=null;return}let l=t.startContainer;if(l.nodeType!==Node.TEXT_NODE){x(!1,""),w.current=null;return}let i=l,s=i.textContent?.substring(0,t.startOffset)||"",c=s.lastIndexOf("@");if(c!==-1){let A=s.substring(c+1);if(A.includes(" ")||A.includes(`
3
+ `)){x(!1,""),w.current=null;return}w.current=i;let W=document.createRange();W.setStart(i,c),W.setEnd(i,c+1);let T=W.getBoundingClientRect(),R=n.current.getBoundingClientRect();x(!0,A,{top:T.bottom-R.top,left:T.left-R.left})}else x(!1,""),w.current=null},v=()=>{if(Le(),h){let{text:d,segments:t}=F();h(d,t)}},ge=(d,t)=>{if(!w.current)return;let l=w.current,i=l.textContent||"",s=i.lastIndexOf("@");if(s!==-1){let c=i.substring(s+1),A=s+1+c.split(/[\s\n]/)[0].length,W=i.substring(0,s),T=i.substring(A);l.textContent=W+T;let R=window.getSelection();if(R){let q=document.createRange();q.setStart(l,s),q.collapse(!0),R.removeAllRanges(),R.addRange(q)}}w.current=null,H(d,t)},ee=d=>{d.preventDefault();let t=d.clipboardData,i=Array.from(t.items).find(c=>c.type.startsWith("image/"));if(i){let c=i.getAsFile();if(c){let A=new FileReader;A.onload=()=>{typeof A.result=="string"&&Z(A.result)},A.readAsDataURL(c)}return}let s=t.getData("text/plain");s&&(document.execCommand("insertText",!1,s),v())},_=d=>{if(d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),m)){let{text:t,segments:l}=F();m(t,l)}};return Ma(g,()=>({focus:G,clear:P,insertFace:b,insertImage:Z,insertVideo:E,insertAudio:Q,insertAt:H,replaceAtTrigger:ge,getContent:Y})),Ba("div",{ref:n,contentEditable:!0,suppressContentEditableWarning:!0,onInput:v,onKeyDown:_,onPaste:ee,"data-placeholder":p,className:"rich-text-editor",style:{width:"100%",minHeight:N,maxHeight:D,padding:"0.5rem 0.75rem",border:"1px solid var(--gray-6)",borderRadius:"6px",backgroundColor:"var(--gray-1)",fontSize:"var(--font-size-2)",outline:"none",overflowY:"auto",lineHeight:"1.5",wordWrap:"break-word",color:"var(--gray-12)"}})});We.displayName="RichTextEditor";var Ve=We;import{Fragment as Fa,jsx as a,jsxs as o}from"react/jsx-runtime";function Me(){let[p,m]=C([]),[h,x]=C([{id:"user_1001",name:"\u6D4B\u8BD5\u7528\u6237",type:"private",unread:0},{id:"group_2001",name:"\u6D4B\u8BD5\u7FA4\u7EC4",type:"group",unread:0},{id:"channel_3001",name:"\u6D4B\u8BD5\u9891\u9053",type:"channel",unread:0}]),[N,D]=C([]),[g,n]=C(h[0]),[w,F]=C(""),[b,Z]=C("ProcessBot"),[E,Q]=C(!1),[H,B]=C(!1),[P,G]=C(null),[Y,Le]=C(""),[v,ge]=C(!1),[ee,_]=C(null),[d,t]=C(""),[l,i]=C(""),[s,c]=C(""),[A]=C([{id:"10001",name:"\u5F20\u4E09"},{id:"10002",name:"\u674E\u56DB"},{id:"10003",name:"\u738B\u4E94"},{id:"10004",name:"\u8D75\u516D"},{id:"10005",name:"\u6D4B\u8BD5\u7528\u6237"},{id:"10086",name:"Admin"},{id:"10010",name:"Test User"}]),[W,T]=C([]),[R,q]=C(!1),[J,he]=C("chat"),Be=Pe(null),j=Pe(null),U=Pe(null),Xe=async()=>{try{let e=await fetch("https://face.viki.moe/metadata.json");D(await e.json())}catch(e){console.error("[Sandbox] Failed to fetch face list:",e)}};Ce(()=>{Xe()},[]),Ce(()=>{let e=localStorage.getItem("zhin_api_base")?.trim(),f=(e?e.replace(/\/$/,""):null)??window.location.origin,L=new URL("/sandbox",`${f}/`);return L.protocol=L.protocol==="https:"?"wss:":"ws:",j.current=new WebSocket(L.href),j.current.onopen=()=>Q(!0),j.current.onmessage=I=>{try{let u=JSON.parse(I.data),S=typeof u.content=="string"?Se(u.content):Array.isArray(u.content)?u.content:Se(String(u.content)),y=h.find(V=>V.id===u.id);if(!y){let V=u.type==="private"?`\u79C1\u804A-${u.bot||b}`:u.type==="group"?`\u7FA4\u7EC4-${u.id}`:`\u9891\u9053-${u.id}`;y={id:u.id,name:V,type:u.type,unread:0},x(ea=>[...ea,y]),n(y)}let k={id:`bot_${u.timestamp}`,type:"received",channelType:u.type,channelId:u.id,channelName:y.name,senderId:"bot",senderName:u.bot||b,content:S,timestamp:u.timestamp};m(V=>[...V,k])}catch(u){console.error("[Sandbox] Failed to parse message:",u)}},j.current.onclose=()=>Q(!1),()=>{j.current?.close()}},[b,h]),Ce(()=>{Be.current?.scrollIntoView({behavior:"smooth"})},[p]),Ce(()=>{T(w.trim()?Se(w):[])},[w]);let Se=e=>{let f=[],L=/\[@([^\]]+)\]|\[face:(\d+)\]|\[image:([^\]]+)\]|\[video:([^\]]+)\]|\[audio:([^\]]+)\]/g,I=0,u;for(;(u=L.exec(e))!==null;){if(u.index>I){let S=e.substring(I,u.index);S&&f.push({type:"text",data:{text:S}})}u[1]?f.push({type:"at",data:{qq:u[1],name:u[1]}}):u[2]?f.push({type:"face",data:{id:parseInt(u[2],10)}}):u[3]?f.push({type:"image",data:{url:u[3]}}):u[4]?f.push({type:"video",data:{url:u[4]}}):u[5]&&f.push({type:"audio",data:{url:u[5]}}),I=L.lastIndex}if(I<e.length){let S=e.substring(I);S&&f.push({type:"text",data:{text:S}})}return f.length>0?f:[{type:"text",data:{text:e}}]},Fe=e=>e.length===0?!1:e.some(f=>f.type==="text"?!!String(f.data?.text??"").trim():!0),Ke=(e,f)=>{let L=f?"ring-1 ring-primary-foreground/25":"ring-1 ring-border/60";return e.map((I,u)=>{if(typeof I=="string")return a("span",{children:I.split(`
4
+ `).map((y,k)=>o(ze.Fragment,{children:[y,k<I.split(`
5
+ `).length-1&&a("br",{})]},k))},u);let S=I.data;switch(I.type){case"text":return a("span",{children:String(S.text??"").split(`
6
+ `).map((y,k)=>o(ze.Fragment,{children:[y,k<String(S.text??"").split(`
7
+ `).length-1&&a("br",{})]},k))},u);case"at":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-accent text-accent-foreground text-xs mx-0.5",children:["@",String(S.name??S.qq??"")]},u);case"face":return a("img",{src:`https://face.viki.moe/apng/${S.id}.png`,alt:"",className:"w-6 h-6 inline-block align-middle mx-0.5"},u);case"image":{let y=Ae(S),k=ye(y,"image");return k?a("a",{href:k,target:"_blank",rel:"noreferrer",className:"block my-1",children:a("img",{src:k,alt:"",className:M("max-w-[min(320px,88vw)] rounded-lg block",L,"ring-offset-0"),onError:V=>{V.target.style.display="none"}})},u):a("span",{className:"text-xs opacity-70",children:"[\u56FE\u7247]"},u)}case"video":{let y=Ae(S),k=ye(y,"video");return k?a("video",{src:k,controls:!0,playsInline:!0,preload:"metadata",className:M("max-w-[min(360px,92vw)] max-h-72 rounded-lg my-1 bg-black/10",L)},u):a("span",{className:"text-xs opacity-70",children:"[\u89C6\u9891\u65E0\u5730\u5740]"},u)}case"audio":case"record":{let y=Ae(S),k=ye(y,"audio");return k?a("audio",{src:k,controls:!0,preload:"metadata",className:M("w-full max-w-sm my-2 h-10",f&&"opacity-95")},u):a("span",{className:"text-xs opacity-70",children:"[\u97F3\u9891\u65E0\u5730\u5740]"},u)}case"file":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-xs mx-0.5",children:["\u{1F4CE} ",String(S.name||"\u6587\u4EF6")]},u);default:return o("span",{className:"text-xs opacity-70",children:["[",I.type,"]"]},u)}})},De=(e,f)=>{if(!Fe(f))return;let L={id:`msg_${Date.now()}`,type:"sent",channelType:g.type,channelId:g.id,channelName:g.name,senderId:"test_user",senderName:"\u6D4B\u8BD5\u7528\u6237",content:f,timestamp:Date.now()};m(I=>[...I,L]),F(""),T([]),U.current?.clear(),j.current?.send(JSON.stringify({type:g.type,id:g.id,content:f,timestamp:Date.now()}))},Ze=()=>{confirm("\u786E\u5B9A\u6E05\u7A7A\u6240\u6709\u6D88\u606F\u8BB0\u5F55\uFF1F")&&m([])},Qe=e=>{he("chat"),n(e),x(f=>f.map(L=>L.id===e.id?{...L,unread:0}:L)),window.innerWidth<768&&q(!1)},_e=()=>{let e=["private","group","channel"],f=e[Math.floor(Math.random()*e.length)],L=prompt("\u8BF7\u8F93\u5165\u9891\u9053\u540D\u79F0\uFF1A");if(L){let I={id:`${f}_${Date.now()}`,name:L,type:f,unread:0};x(u=>[...u,I]),n(I)}},Re=e=>{switch(e){case"private":return a(K,{size:16});case"group":return a(ie,{size:16});case"channel":return a(oe,{size:16});default:return a(O,{size:16})}},Je=e=>{U.current?.insertFace(e),B(!1)},be=()=>{let e=Y.trim();!e||!P||(P==="image"?U.current?.insertImage(e):P==="video"?U.current?.insertVideo(e):U.current?.insertAudio(e),Le(""),G(null))},Da=()=>{s.trim()&&(U.current?.insertAt(s.trim()),c(""),ge(!1))},je=e=>{U.current?.replaceAtTrigger(e.name,e.id),_(null),t("")},$e=(e,f,L)=>{if(g.type==="private"){_(null),t("");return}e&&L?(_(L),t(f)):(_(null),t(""))},ve=A.filter(e=>{if(!d.trim())return!0;let f=d.toLowerCase();return e.name.toLowerCase().includes(f)||e.id.toLowerCase().includes(f)}),Ye=(e,f)=>{F(e),T(f)},Te=N.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())||e.describe.toLowerCase().includes(l.toLowerCase())),ke=p.filter(e=>e.channelId===g.id);return o("div",{className:"sandbox-container rounded-xl border border-border/70 bg-card/30 shadow-sm",children:[o("button",{className:"mobile-channel-toggle md:hidden",onClick:()=>q(!R),children:[a(O,{size:20})," \u9891\u9053\u5217\u8868"]}),o("div",{className:M("channel-sidebar rounded-lg border bg-card",R&&"show"),children:[a("div",{className:"p-3 border-b",children:o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2",children:[a("div",{className:"p-1 rounded-md bg-secondary",children:a(O,{size:16,className:"text-muted-foreground"})}),a("h3",{className:"font-semibold",children:"\u9891\u9053\u5217\u8868"})]}),o("span",{className:M("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border",E?"bg-emerald-100 text-emerald-800 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-400 dark:border-emerald-800":"bg-muted text-muted-foreground"),children:[E?a(pe,{size:12}):a(ne,{size:12}),E?"\u5DF2\u8FDE\u63A5":"\u672A\u8FDE\u63A5"]})]})}),o("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:[h.map(e=>{let f=J==="chat"&&g.id===e.id;return o("div",{className:M("menu-item",f&&"active"),onClick:()=>Qe(e),children:[a("span",{className:"shrink-0",children:Re(e.type)}),o("div",{className:"flex-1 min-w-0",children:[a("div",{className:"text-sm font-medium truncate",children:e.name}),a("div",{className:"text-xs text-muted-foreground",children:e.type==="private"?"\u79C1\u804A":e.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),e.unread>0&&a("span",{className:"inline-flex items-center justify-center h-5 min-w-5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-medium px-1",children:e.unread})]},e.id)}),o("div",{className:"pt-2 mt-2 border-t space-y-1",children:[o("div",{className:M("menu-item",J==="requests"&&"active"),onClick:()=>{he("requests"),window.innerWidth<768&&q(!1)},children:[a(X,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[a("div",{className:"text-sm font-medium",children:"\u8BF7\u6C42"}),a("div",{className:"text-xs text-muted-foreground",children:"\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49"})]})]}),o("div",{className:M("menu-item",J==="notices"&&"active"),onClick:()=>{he("notices"),window.innerWidth<768&&q(!1)},children:[a(z,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[a("div",{className:"text-sm font-medium",children:"\u901A\u77E5"}),a("div",{className:"text-xs text-muted-foreground",children:"\u7FA4\u7BA1/\u64A4\u56DE\u7B49"})]})]})]})]}),a("div",{className:"p-2 border-t",children:a("button",{className:"w-full py-2 px-3 rounded-md border border-dashed text-sm text-muted-foreground hover:bg-accent transition-colors",onClick:_e,children:"+ \u6DFB\u52A0\u9891\u9053"})})]}),R&&a("div",{className:"channel-overlay md:hidden",onClick:()=>q(!1)}),o("div",{className:"chat-area",children:[J==="requests"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[a("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[a(X,{size:20})," \u8BF7\u6C42"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[a(X,{size:48,className:"opacity-30"}),a("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u8BF7\u6C42\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49\u8BF7\u6C42\u8BF7\u5230\u4FA7\u8FB9\u680F ",a("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),J==="notices"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[a("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[a(z,{size:20})," \u901A\u77E5"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[a(z,{size:48,className:"opacity-30"}),a("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u901A\u77E5\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u7FA4\u7BA1\u3001\u64A4\u56DE\u7B49\u901A\u77E5\u8BF7\u5230\u4FA7\u8FB9\u680F ",a("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),J==="chat"&&o(Fa,{children:[a("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0",children:o("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[o("div",{className:"flex items-center gap-3",children:[a("div",{className:"p-2 rounded-lg bg-secondary",children:Re(g.type)}),o("div",{children:[a("h2",{className:"text-lg font-bold",children:g.name}),o("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[a("span",{children:g.id}),a("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-[10px]",children:ke.length}),a("span",{children:"\u6761\u6D88\u606F"})]})]}),a("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-secondary text-secondary-foreground",children:g.type==="private"?"\u79C1\u804A":g.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),o("div",{className:"flex items-center gap-2",children:[a("input",{value:b,onChange:e=>Z(e.target.value),placeholder:"\u673A\u5668\u4EBA\u540D\u79F0",className:"h-8 w-28 rounded-md border bg-transparent px-2 text-sm"}),o("button",{className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-secondary text-secondary-foreground text-sm hover:bg-secondary/80",onClick:Ze,children:[a(fe,{size:14})," \u6E05\u7A7A"]})]})]})}),a("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0",children:a("div",{className:"flex-1 overflow-y-auto p-4",children:ke.length===0?o("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[a(O,{size:64,className:"text-muted-foreground/20"}),a("span",{className:"text-muted-foreground",children:"\u6682\u65E0\u6D88\u606F\uFF0C\u5F00\u59CB\u5BF9\u8BDD\u5427\uFF01"})]}):o("div",{className:"space-y-2",children:[ke.map(e=>a("div",{className:M("flex",e.type==="sent"?"justify-end":"justify-start"),children:o("div",{className:M("max-w-[70%] p-3 rounded-2xl",e.type==="sent"?"bg-primary text-primary-foreground":"bg-muted"),children:[o("div",{className:"flex items-center gap-2 mb-1",children:[e.type==="received"&&a(ae,{size:14}),e.type==="sent"&&a(K,{size:14}),a("span",{className:"text-xs font-medium opacity-90",children:e.senderName}),a("span",{className:"text-xs opacity-70",children:new Date(e.timestamp).toLocaleTimeString()})]}),a("div",{className:"text-sm space-y-1",children:Ke(e.content,e.type==="sent")})]})},e.id)),a("div",{ref:Be})]})})}),o("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0 space-y-3",children:[o("div",{className:"flex gap-2 items-center flex-wrap",children:[a("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",H?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{B(!H),G(null)},title:"\u63D2\u5165\u8868\u60C5",children:a(re,{size:16})}),a("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="image"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(e=>e==="image"?null:"image"),B(!1)},title:"\u63D2\u5165\u56FE\u7247 URL",children:a(de,{size:16})}),a("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="video"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(e=>e==="video"?null:"video"),B(!1)},title:"\u63D2\u5165\u89C6\u9891 URL",children:a(ce,{size:16})}),a("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="audio"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(e=>e==="audio"?null:"audio"),B(!1)},title:"\u63D2\u5165\u97F3\u9891 URL",children:a(le,{size:16})}),a("div",{className:"flex-1 min-w-[1rem]"}),w&&a("button",{className:"h-8 w-8 rounded-md flex items-center justify-center hover:bg-accent transition-colors",onClick:()=>{F(""),T([])},children:a(me,{size:16})})]}),H&&o("div",{className:"p-3 rounded-md border bg-muted/30 max-h-64 overflow-y-auto space-y-2",children:[a("input",{value:l,onChange:e=>i(e.target.value),placeholder:"\u641C\u7D22\u8868\u60C5...",className:"w-full h-8 rounded-md border bg-transparent px-2 text-sm"}),a("div",{className:"grid grid-cols-8 gap-1",children:Te.slice(0,80).map(e=>a("button",{onClick:()=>Je(e.id),title:e.name,className:"w-10 h-10 rounded-md border flex items-center justify-center hover:bg-accent transition-colors",children:a("img",{src:`https://face.viki.moe/apng/${e.id}.png`,alt:e.name,className:"w-8 h-8"})},e.id))}),Te.length===0&&o("div",{className:"flex flex-col items-center gap-2 py-4",children:[a($,{size:32,className:"text-muted-foreground/30"}),a("span",{className:"text-sm text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u8868\u60C5"})]})]}),P&&o("div",{className:"p-3 rounded-md border bg-muted/30 space-y-2",children:[o("p",{className:"text-xs text-muted-foreground",children:[P==="image"&&"\u652F\u6301 http(s) \u56FE\u7247\u94FE\u63A5\u6216 data URL",P==="video"&&"\u652F\u6301\u6D4F\u89C8\u5668\u53EF\u89E3\u7801\u7684\u89C6\u9891\u76F4\u94FE\uFF08\u5982 .mp4\u3001.webm\uFF09",P==="audio"&&"\u652F\u6301 .mp3\u3001.ogg\u3001.wav \u7B49\u97F3\u9891\u76F4\u94FE"]}),a("input",{value:Y,onChange:e=>Le(e.target.value),placeholder:P==="image"?"\u56FE\u7247 URL\u2026":P==="video"?"\u89C6\u9891 URL\u2026":"\u97F3\u9891 URL\u2026",className:"w-full h-8 rounded-md border border-input bg-background px-2 text-sm",onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),be())}}),o("button",{type:"button",className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-primary text-primary-foreground text-sm disabled:opacity-50",onClick:be,disabled:!Y.trim(),children:[a(te,{size:14})," \u63D2\u5165\u5230\u8F93\u5165\u6846"]})]}),o("div",{className:"flex gap-2 items-start",children:[o("div",{className:"flex-1 relative",children:[a(Ve,{ref:U,placeholder:`\u5411 ${g.name} \u53D1\u9001\u6D88\u606F...`,onSend:De,onChange:Ye,onAtTrigger:$e,minHeight:"44px",maxHeight:"200px"}),ee&&a("div",{className:"absolute z-50 rounded-lg border bg-popover shadow-md min-w-60 max-h-72 overflow-y-auto p-1",style:{top:`${ee.top}px`,left:`${ee.left}px`},children:ve.length>0?ve.map(e=>o("div",{className:"flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-accent transition-colors",onClick:()=>je(e),children:[a(K,{size:16,className:"text-muted-foreground"}),o("div",{className:"flex-1",children:[a("div",{className:"text-sm font-medium",children:e.name}),o("div",{className:"text-xs text-muted-foreground",children:["ID: ",e.id]})]})]},e.id)):o("div",{className:"flex flex-col items-center gap-2 p-4",children:[a($,{size:20,className:"text-muted-foreground/50"}),a("span",{className:"text-xs text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u7528\u6237"})]})})]}),o("button",{className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-md bg-primary text-primary-foreground text-sm font-medium disabled:opacity-50 transition-colors hover:bg-primary/90",onClick:()=>{let e=U.current?.getContent();e&&De(e.text,e.segments)},disabled:!Fe(W),children:[a(se,{size:16})," \u53D1\u9001"]})]}),o("div",{className:"flex items-center gap-2 flex-wrap text-xs text-muted-foreground",children:[a(ue,{size:12})," \u5FEB\u6377\u64CD\u4F5C:",a("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Enter"})," \u53D1\u9001",a("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Shift+Enter"})," \u6362\u884C",a("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[@\u540D\u79F0]"})," @\u67D0\u4EBA",a("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[video:URL]"}),a("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[audio:URL]"})]})]})]})]})]})}function Co(p){p.addRoute({path:"/console/sandbox",name:"\u6C99\u76D2",element:p.React.createElement(Me,{hostReact:p.React})}),p.addTool({id:"sandbox",name:"\u6C99\u76D2",path:"/console/sandbox"})}export{Co as register};
8
8
  /*! Bundled license information:
9
9
 
10
10
  lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-sandbox",
3
- "version": "2.0.24",
3
+ "version": "3.0.1",
4
4
  "description": "Zhin.js adapter for local testing and development",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -48,15 +48,15 @@
48
48
  "radix-ui": "^1.4.3",
49
49
  "lucide-react": "^1.16.0",
50
50
  "typescript": "^6.0.3",
51
- "@zhin.js/cli": "1.0.77",
52
- "zhin.js": "1.0.81"
51
+ "@zhin.js/cli": "1.0.78",
52
+ "zhin.js": "1.0.82"
53
53
  },
54
54
  "peerDependencies": {
55
- "@zhin.js/core": "1.1.23",
56
- "@zhin.js/client": "1.0.18",
57
- "@zhin.js/http": "1.0.74",
58
- "@zhin.js/console": "2.0.24",
59
- "zhin.js": "1.0.81"
55
+ "@zhin.js/core": "1.1.24",
56
+ "@zhin.js/client": "1.1.1",
57
+ "@zhin.js/http": "1.0.75",
58
+ "@zhin.js/console": "3.0.1",
59
+ "zhin.js": "1.0.82"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@zhin.js/http": {